;+ ; NAME: ; mk_celias ; PURPOSE: ; Update celias hourly averages ; CATEGORY: ; CALLING SEQUENCE: PRO mk_celias, update=update, nowget=nowget ; INPUTS: ; OPTIONAL INPUT PARAMETERS: ; /update only update the current yearly file ; /nowget skip wget to download new data ; OUTPUTS: ; OPTIONAL OUTPUT PARAMETERS: ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, TimeGet, TimeSystem, TimeUnit, TimeSet ; Carrington, boost, txt_red, IsType ; PROCEDURE: ; MODIFICATION HISTORY: ; OCT-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- InitVar, update, /key InitVar, nowget, /key insitu_dir = filepath(root=getenv('DAT'),'insitu') celias_dir = filepath(root=insitu_dir,'celias') last_yr = TimeGet(TimeSystem(),TimeUnit(/year),/scalar) frst_yr = ([1996,last_yr])[update] crn = Carrington( TimeSet(yr=[frst_yr,last_yr+1], doy=1) ) frst_crn = floor( crn[0] ) last_crn = ceil ( crn[1] ) ; Loop over all candidate Carrington rotations ; The files are organized per CR with filename CRN_####.1HR FOR i=frst_crn,last_crn DO BEGIN f = 'CRN_'+string(i,format='(I4.4)')+'.1HR' ; Update rotation using wget IF NOT nowget THEN $ spawn, 'cd '+celias_dir+'; wget -N http://umtof.umd.edu/pm/crn/archive/'+f ; Read file and append the data to the 'all' array f = filepath(root=celias_dir,f) IF (file_search(f))[0] NE '' THEN BEGIN IF txt_read(f,one) THEN BEGIN j = (where(strpos(one,'YR') NE -1))[0] boost, all, one[j+1:*] ENDIF ENDIF ENDFOR IF IsType(all,/defined) THEN BEGIN ; Split up the data by year all = all[uniq(all,sort(all))] FOR yr=frst_yr, last_yr DO BEGIN one = where( strmid(all,0,2) EQ string(yr mod 100,format='(I2.2)') ) IF one[0] NE -1 THEN BEGIN one = all[one] file = filepath(root=insitu_dir,'celias_'+string(yr,format='(I4.4)')+'.hravg') message, /info, 'writing '+file openw, /get_lun, iu, file FOR i=0L,n_elements(one)-1 DO printf, iu, one[i] free_lun, iu ENDIF ENDFOR ENDIF RETURN & END