pro calload_lc,jday,yrss,ndays,cv,qv,pl,tl,w,cs,tm,hltprgm ;------------------------------------------------------------------------------ ; The procedure CALLOAD_LC.PRO obtains data to use in CALIBRATE_LC.PRO ; Use is as follows: ; ; calload_lc,jdays,yrls,ndays,cv,qv,pl,tl,w,cs,hltprgm ; ; Input: ; jday = integer julian date to start calibration fit ; yrss = string of the 2-digit year ; ndays = the number of days over which to do the fit ; ; Output: ; cv = CO2 voltage data (mV) ; qv = H2O voltage data (mV) ; pl = licor pressure data (hPa=mb) ; tl = licor temperature data (C) ; cs = profiler (slow) CO2 (ppm) ; w = water mixing ratio (g/kg) ; hltprgm = flags to tell program to stop,not execute ; ; Written by BWBerger 11-12/98 ; ; Modified by Dana Carrington - June 1999 - for use with Willow Creek ; data. ; ; Modified by Bruce Cook - November 2000 - for use with Lost Creek ;------------------------------------------------------------------------------ ; Initialize flag to stop program if main files are not present hltprgm = 0 ; The approximate total number of three minute intervals in ndays tot = 480*ndays ;------------------------------------------------------------------------------ ; IF ONE OR BOTH OF THE DESIRED FILES IS NOT PRESENT, THERE MUST BE AN ERROR ; STATEMENT INFORMING THE USER - NOT YET CREATED ;------------------------------------------------------------------------------ ; Load licor files - loop for number of days required. Filenames are based ; on date in yyddd format. jdays is the 3-digit string of the julian day for i = 0, (ndays-1) do begin xday = jday + i if (xday lt 10) then jdays = '00' + strtrim(string(xday),2) else $ if (xday lt 100) then jdays = '0' + strtrim(string(xday),2) else $ jdays = strtrim(string(xday),2) yyddd = yrss+jdays cmd = "load_lc,'/eddy/s4/lcreek/lic/lc"+yyddd+".lic',lictemp" r = execute(cmd) if (i eq 0) then lic = lictemp else lic = [[lic],[lictemp]] endfor ;------------------------------------------------------------------------------ ; Load slow CO2 files for i = 0, (ndays-1) do begin yday = jday + i if (yday lt 10) then jdays = '00' + strtrim(string(yday),2) else $ if (yday lt 100) then jdays = '0' + strtrim(string(yday),2) else $ jdays = strtrim(string(yday),2) yyddd = yrss+jdays cmd = "load_lc,'/eddy/s4/lcreek/ppm/lc"+yyddd+".ppm',ppmtemp" r = execute(cmd) if (i eq 0) then ppm = ppmtemp else ppm = [[ppm],[ppmtemp]] endfor ;------------------------------------------------------------------------------ ; call calload_fix_lc.pro to load files and screen/adjust CO2 data IF (yrss EQ '00') AND (jday LT 309) THEN BEGIN calload_fix_lc,jday,yrss,ndays,ppm endif ;------------------------------------------------------------------------------ ; Load water mixing files for i = 0, (ndays-1) do begin zday = jday + i if (zday lt 10) then jdays = '00' + strtrim(string(zday),2) else $ if (zday lt 100) then jdays = '0' + strtrim(string(zday),2) else $ jdays = strtrim(string(zday),2) yyddd = yrss+jdays cmd = "load_lc,'/eddy/s4/lcreek/qmix/lc"+yyddd+".qmix',qmixtemp" r = execute(cmd) if (i eq 0) then qmix = qmixtemp else qmix = [[qmix],[qmixtemp]] endfor ;------------------------------------------------------------------------------ ; Initialize necessary data tm = fltarr(1,tot)-999. cv = fltarr(1,tot)-999. qv = fltarr(1,tot)-999. pl = fltarr(1,tot)-999. tl = fltarr(1,tot)-999. ; Extract data for the chosen days tm(0,*) = lic(1,*) cv(0,*) = lic(2,*) qv(0,*) = lic(3,*) pl(0,*) = lic(4,*)*10 index=where(pl EQ -999.*10.,count) IF count NE 0 THEN pl(index)=-999. tl(0,*) = lic(5,*) r = where ((tm (0,*) eq -999) and (cv (0,*) eq -999) and (qv (0,*) eq -999) and (pl (0,*) eq -999) and (tl (0,*) eq -999), c) if (c eq 480.*ndays) then begin print,'.lic file does not have sufficient data for the selected dates.' hltprgm = 1 endif ;------------------------------------------------------------------------------ ;From the co2 array ;Initialize necessary data cs = fltarr(1,tot)-999. ; Extract data for the chosen days cs(0,*) = ppm(6,*) r = where (cs(0,*) eq -999.,c) if (c eq 480.*ndays) then begin print,'.ppm file does not have sufficient data for the selected dates.' hltprgm = 1 endif ;------------------------------------------------------------------------------ ; From the water mixing ratio ;Initialize necessary data w = fltarr(1,tot)-999. ; Extract data for the chosen days w(0,*) = qmix(3,*) r = where (w(0,*) eq -999.,c) if (c eq 480.*ndays) then begin print,'.qmix file does not have sufficient data for the selected dates.' hltprgm = 1 endif ;------------------------------------------------------------------------------ ;Convert time vector into floating minutes ;There are two things to deal with: ;1) Need to reconstruct hours and minutes because when hhmm string is read in ;above it is converted to integer (e.g., hhmm='0059' becomes hhmm=59). ;2) Need to add a day or more if number of days is more than one. minutes=tm ;Fix problem 1 for i=0,len(tm)-1 do begin if tm(i) le 59 then begin ;tm(i) is 2 or 1-digit hh=0. mm=float(tm(i)) endif else begin if tm(i) le 959 then begin ;tm(i) is 3-digits hh=float(strmid(strtrim(string(tm(i)),2),0,1)) mm=float(strmid(strtrim(string(tm(i)),2),1,2)) endif else begin hh=float(strmid(strtrim(string(tm(i)),2),0,2)) mm=float(strmid(strtrim(string(tm(i)),2),2,2)) endelse endelse minutes(i)=hh*60.+mm endfor ;Fix problem 2 if (ndays gt 1) then begin for j=1,ndays-1 do begin ;loop through ndays-1 times to fix steps for i=0,len(minutes)-1 do begin ;Look for times that are less than previous time and add 1 day if i ne 0 then begin if (minutes(i-1) gt minutes(i)) then begin minutes(i)=minutes(i)+24.*60. endif endif endfor endfor endif tm=minutes ;tm is now in continuous minutes from the start of the fit return end