;create_annual_wc.pro concatenates the daily output data files produced ;by dayflux_wc.pro into one large file. ;Use is as follows: ; create_annual ;The operator will be prompted for information such as date, and file ;type (ie rot, lag, flx, sflx, spec or stats files). ;--- ;To set input and output file paths you should copy this code into a file ; called something like: create_annual_yourname.pro ; Then change the input and output file paths and the name on the first ; line of code (to match the new program name). ; ;Output will have filenames based on the file type and level. ;For example: ; wc1997.rot ; wc1999.sflx etc. ; ;Output file format is as follows: ;For all files the first six columns are: ;yyyy mm dd fhour jday fjday ; ;The following columns are the same as in the corresponding daily files except ;the first column containing the date and time is excluded since it would be ;redundant. The columns depend on file type as follows: ; ;************************************ ;rot files: ; ;theta phi theta_medianfiltered phi_medianfiltered (all in radians) ;************************************ ;lag files: ; ;ww_lag wt_lag wc_lag wq_lag (all in seconds) ;************************************ ;flx and sflx files: ; ;wc wq wt wm theta phi lag_c lag_q mc bc mq bq ; ;Where the only difference between the flx and sflx files are the units which ;are as follows: ; quantity desc flx sflx ;---------------------------------------------------------------------------- ; wc co2 flux ppm*m/s umol/(m^2*s) ; wq h2o flux g*m/(s*kg) W/m^2 ; wt sensible heat flux K*m/s W/m^2 ; wm momentum flux m^2/s^2 Pa ;theta & phi rotations used rad rad ;lag_c & lag_q co2 & h2o lags sec sec ; mc co2 calibration slope ppm/mV ppm/mV ; bc co2 calibration intercept ppm ppm ; mq h2o calibration slope (g/kg)/mV (g/kg)/mV ; bq h2o calibration intercept g/kg g/kg ;************************************** ;spec files: ; ;c_cfactor cflag q_cfactor qflag ; ;Where ;c_cfactor & q_cfactor are spectral correction factors for co2 and h2o, resp. ;cflag and qflag are flags giving info about the correction factors ;All are dimensionless. ;************************************** ;stats files: ; ;ur_mean ur_var vr_mean vr_var wr_mean wr_var wr_skew wr_kurt t_virt_mean ;t_virt_var c_mean c_var q_mean q_var pl_mean pl_var ; ;Where ur,vr,wr (m/s); t_virt (C); c (ppm); q (g/kg); pl (hPa=mb) ;************************************** ; ;Written by weiguowang 10/4/99 based on create_annual.pro for wlef ;Modified by BWBerger 3/3/00 to use yyddd as input date format. pro create_annual_lc_cherrey ;(change above to create_annual_wc_yourname if you are setting this up ; to run in specific directories) print,'ENTER STARTING DATE IN YYDDD FORMAT:' startyyddd='' read,startyyddd ;extract date elements out of start date startyyddd=strtrim(startyyddd,2) ;clean-up start date string startyy = strmid(startyyddd,0,2) ;string of 2-digit year if (fix(startyy) le 99) and (fix(startyy) ge 50) then begin startyyyy='19'+startyy ;string of 4-digit year endif else begin startyyyy='20'+startyy ;string of 4-digit year endelse startjday=fix(strmid(startyyddd,2,3)) ;integer of starting jdate ;get month and day from jday startyyyymmdd=jdatetodate(startjday,fix(startyyyy)) ;integer startyyyymmdd startmm = strmid(strtrim(string(startyyyymmdd),2),4,2) ;string of 2-digit month startdd = strmid(strtrim(string(startyyyymmdd),2),6,2) ;string of 2-digit day ;get integers of date elements based on start date ;month and day get incremented as necessary if number of days ndays > 1 dd = fix(startdd)-1 ;integer day gets incremented in loop below to correct day ;day=0 is ok for getnextdaydate.pro below. mm = fix(startmm) ;integer month yyyy = fix(startyyyy);integer 4-digit year print,'ENTER THE TOTAL NUMBER OF DAYS TO BE ANALYZED:' print,'(Do not overlap Jan. 1)' days=1 read,days ;the number of days of data to be analysed print,'ENTER NUMBER FOR TYPE OF FILE TO BE PROCESSED:' print,'Choices: 1= .rot, 2= .lag, 3= .flx, 4= .sflx, 5= .spec, 6= .stats' filetype=0 read,filetype ;get first part of the extension for file name if filetype eq 1 then begin exten1='rot' ;exten1 for input and output file names exten2='rot' ;exten 2 for input and output directory path ;(necessary since flx & sflx files are in same directory) header=1 ;need to know if file has an alpha header or not endif if filetype eq 2 then begin exten1='lag' exten2='lag' header=1 endif if filetype eq 3 then begin exten1='flx' exten2='flx' header=0 endif if filetype eq 4 then begin exten1='sflx' exten2='flx' header=0 endif if filetype eq 5 then begin exten1='spec' exten2='spec' header=1 endif if filetype eq 6 then begin exten1='stats' exten2='stats' header=1 endif ;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ;**************************************************************************** ;INPUT AND OUTPUT DIRECTORY PATHS - MODIFY AS NECESSARY ;---------------------------------------------------------------------------- ;output directory path ;outdir = '/data/eddy2/bruce/wcreek/output/'+exten2+'/' ;outdir = '/data/eddy2/wwg/wcreek/output/'+exten2+'/' ;outdir = '/eddy/s1/wang/d2wwg/lcreek/output/'+exten2+'/' outdir = '/abl/s0/users/kcherrey/lcreek/output/'+exten2+'/' ;input directory path ;indir = '/data/eddy2/bruce/wcreek/output/'+exten2+'/' ;indir = '/data/eddy2/wwg/wcreek/output/'+exten2+'/' ;indir = '/eddy/s1/wang/d2wwg/lcreek/output/'+exten2+'/' indir = '/abl/s0/users/kcherrey/lcreek/output/'+exten2+'/' ;get output file name outfile= outdir + 'lc' + startyyyy +'.'+ exten1 ;open output file openw,fout,outfile,/get_lun ;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ;Iterate until the required number of day's data are processed ;ie until numofdays=compareday numofdays=0 compareday = fix(days) repeat begin ;repeat until all requested days are processed getnextdaydate,yyyy,mm,dd ;get next day's date (first time looping is ok ;because dd is initially set to day before start day ;dd=0 is ok, mm is not incremented to dd=1 jday=jdate2(yyyy,mm,dd) ;integer julian day numofdays=numofdays+1 ;************* ;initialize input data array and data arrays used to create output ;nin is number of colums in input file row1=dblarr(6) ;output always starts with year mo day hour jday fjday if (filetype eq 1) or (filetype eq 2) or (filetype eq 5) then begin ;rot, lag or spec file nin=5 ;number of columns in input file endif if (filetype eq 3) or (filetype eq 4) then begin ;flx or sflx file nin=13 endif if (filetype eq 6) then begin ;stats file nin=17 endif datain=dblarr(nin) nout=6+nin-1 dataout=dblarr(nout) ;nout=columns in row1 + (nin-1) ;nin-1 because first column in input not used ;************ ;build up input filename to read if jday lt 10 then begin sjday='00'+strtrim(string(jday),2) ;3-digit string jday endif else begin if jday lt 100 then begin sjday='0'+strtrim(string(jday),2);3-digit string jday endif else begin sjday=strtrim(string(jday),2) ;3-digit string jday endelse endelse infile=indir+startyy+sjday+'.'+exten1 print,'Opening input file:',infile ;open input file. openr,fin,infile,Error = err,/get_lun ;********************* ;read input file and fill output file ; if input is bad, fill output with badvals for the day if (err ne 0)then begin ;File doesn't exist. Need to add missing data print,'Error reading: '+infile print,'File missing or corrupt - filling date with badvals.' print,'' for i=0,47 do begin hour=i/2. fjday=jday+hour/24. data=fltarr(nin-1)-999. row1 = [yyyy,mm,dd,hour,jday,fjday] dataout=[row1,data] cmd="printf,fout,dataout,format='(I4,1x,I2,1x,I2,1x,f4.1,1x,I3,1x,e15.7,1x,"+strtrim(string(nin-1),2)+"(e15.7,1x))'" r=execute(cmd) endfor endif else begin ;File was found so load up data arrays. if header ne 0 then begin firstline='' readf,fin,firstline ;read header line first endif ;********************************************************************* ;Read in the data from daily input files ;loops through 24 hours of one day's sonic statistics ;******************************************************************** while (not eof(fin)) do begin readf,fin,datain ;get fractional hour and fjday from info in 1st column yydddhhmm=strtrim(string(long(datain(0))),2) slen=strlen(yydddhhmm) hh=float(strmid(yydddhhmm,slen-4,2)) min=float(strmid(yydddhhmm,slen-2,2)) hour=hh+min/60. fjday=jday+float(hour)/24. row1 = [yyyy,mm,dd,hour,jday,fjday] dataout=[row1,datain(1:len(datain)-1)] cmd="printf,fout,dataout,format='(I4,1x,I2,1x,I2,1x,f4.1,1x,I3,1x,e15.7,1x,"+strtrim(string(nin-1),2)+"(e15.7,1x))'" ;format based on input file used r=execute(cmd) end close,fin free_lun,fin endelse endrep until(numofdays ge days) close,fout free_lun,fout print,'saving '+outfile return end