Trouble referencing folder from textwave (quotations around string problem)
Hello all,
Brief background - I have a mobile dataset (latitude, longitude, time, wave1, wave2) that involves repeat drives of some areas over two years. During these drives, I pass points of interest (POIs) sometimes, multiple times, or never.
I would like to collect and plot data associated with specific POIs. I have already found the blocks of data I'm interested in (index_start, index_stop), and the data folder those blocs are associated with (DateofMeasurement) but when I want to operate on all the data associated with a single POI I'm running into a problem.
My experiment file has many folders, each named by the date my data was collected (20180118, 2018071, etc.). During each collection day, I have latitude, longitude, time, wave0, wave1, wave2, etc.
I would like to access segments of data from different days. Currently, my code looks something like this:
A_Code= {1,1,9,1,1,1,6,1}
DateofMeasurement= {"'20180118'","'20180118'","'20180118'","'20180710'","'20180710'","20180713'","'20180713_14_Drive2'","'20180713_14_Drive2'"}
index_start= {22673,22943,23147,6866,7037,28912,2822,2902}
index_stop= {22847,23127,23559,6930,7128,28963,2908,2945}
function calculate_correlation() //I execute this function from a specific POI folder
wave A_Code, Index_Start, Index_Stop, Wave1, Wave2
wave/T DateofMeasurement
//A_Code, Index_Start, Index_Stop and DateofMeasurement all reside in a specific POI folder
//wave1 and Wave2 are in every measurement day folder
variable i, looplength
looplength = numpnts(A_Code)
string folder //This is where I need to get rid of the extra "" on either side of my folder name
Duplicate /o A_code, Wave1_Intercept, Wave1_Int_sig, Wave1_Slope, Wave1_Slope_sig, Wave1_Rsq
Wave1_Intercept =nan
Wave1_Int_sig =nan
Wave1_Slope = nan
Wave1_Slope_sig = nan
Wave1_Rsq = nan
Wave W_coef, W_sigma
for (i=0; i<=looplength; i+=1)
if (A_Code[i] == 1)
folder = DateofMeasurement[i]
CurveFit/M=2/W=0/Q line, Root:$(folder):Wave1[Index_Start[i], Index_stop[i]]/X=Root:$(folder):Wave2[Index_Start[i], Index_stop[i]]/D
//hopefully CurveFit works in this context. I haven't debugged this far yet.
Wave1_Intercept[i] = W_coef[0] //store variables from linear fit for comparison
Wave1_Int_sig[i] = W_sigma[0]
Wave1_Slope[i] = W_coef[1]
Wave1_Slope[i] = W_sigma[1]
Wave1_Rsq[i] = V_r2
elseif (A_Code[i] > 1)
endif
endfor
end
Basically, I have extra " " around my folder name that invalidates the path name. Any suggestions would be much appreciated.
Thank you for your time,
Edie
I'm not sure I understand but, if what you want to do is remove the single quotes from the value stored in the folder string variable, here is an example:
String folder = "'20180118'"
folder = ReplaceString("'", folder, "") // Remove single quotes
Print folder
End
May 7, 2019 at 04:51 pm - Permalink
In reply to I'm not sure I understand… by hrodstein
Thank you for your help!
May 9, 2019 at 06:39 am - Permalink