I am trying to write a loop to process daily data for a whole month. My code works when manually doing 1 day at a time, but something about my loop is failing when i try to loop through every day of the month.
Basically I'm looping through n = 1,30 days to read in files, clip data to my study area, and add data from each additional day to my array of data. I want one array containing data for the whole month.
These are functions in my loop:
@mls_choosefile_co.pro
--> this just gives me the 'ToOpen' file path+name
@mls_readin_co.pro
--> this uses the file_id to read in the CO data and clip it to my study area. Output is 'co_sa_100', for CO in study area at 100 hpa, a 1x700 array (length varies by day, may be 706, 720, 680...)
^^ Both of these work fine on their own.
; make array of data for the whole month - CO at 100hpa
; to append each additional day to this on each loop iteration
co_100_all = [ ]
; make array to save how many data points per day. use -9 as a fill value to tell me when the loop has not gone over that day.
len = MAKE_ARRAY(1,ndays, VALUE = -9)
; the loop in question:
FOR n = 0,ndays DO BEGIN &$
@mls_choosefile_co.pro &$
file_id = H5F_OPEN(ToOpen) &$
@mls_readin_co.pro &$
len[n-1] = N_ELEMENTS(co_sa_100) &$
co_100_all = [[co_100_all], [co_sa_100]] &$
END
I set up the 'len' variable as a test. This will tell me how many data points have been read in per day, with a value per day (usually around 700). I've set -9 as a fill value for where the loop is not operating. It should read something like: len = [702, 716, 706]. but it only ever saves the last index in the loop and I get: len = [-9, -9, 706].
Thanks in advance!