PRO vu_update_marker, prefix, silent=silent, rounds=rounds, forcecd=forcecd, gzip=gzip ;+ ; NAME: ; vu_update_marker ; PURPOSE: ; Update set of 'best' tomography files at regular time intervals ; (at the same time cadence used by the Fortran tomography itself) ; by incorporating results of new tomography run. ; CATEGORY: ; Tomography I/O ; CALLING SEQUENCE: ; vu_update_marker, prefix ; INPUTS: ; prefix scalar; type: character; default: 'nv3d' ; file name prefix for data files ; (typical values are 'nv3d','nv3f','wson','nson' ; OPTIONAL INPUTS: ; /silent suppresses messages from vu_write ; /gzip compresses output files with gzip (passed to vu_write) ; OUTPUTS: ; (written to new tomography data files) ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, vu_mean, vu_select, vu_write, TimeOp, TimeGet, TimeUnit ; Carrington, forecast_cfg, vu_set, vu_prefix ; PROCEDURE: ; > Input files are picked up from directory $NAGOYA/fast/raw ; Output files are written to $NAGOYA/fast/final ; ; > The procedure is run after a new time-dependent forecast has been ; made. All output files from the last tomography (one for each time) ; are integrated with the averages from results from previous runs ; including the same times. ; ; > vu_select is called with keywords /marker and /nohdr set, i.e. ; only files with a rotation counter are picked up, and the file names ; are returned without actually reading the headers. ; MODIFICATION HISTORY: ; MAR-2001, Paul Hick (UCSD/CASS) ; NOV-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Added /gzip keyword. ;- InitVar, silent, 0 InitVar, prefix, vu_prefix(/silent,/fast) filter = prefix+'*.*' uday = TimeUnit(/day) root = filepath(root=getenv('NAGOYA'),'fast') ; Get a list of all raw tomography files. ; Get all times from the file names (don't read the headers). ; The time-dependent raw files are produced exactly at integer hours. ; This precision gets lost when writing Carrington times into the header. ; We restore the precision here by rounding times to the nearest hour ; (using the rounds keyword). The correction could be as large as 8 minutes. raw_times = vu_select(raw_files, path=filepath(root=root, 'raw'), filter=filter, $ /marker, /nohdr, imark=imark, count=raw_cnt, rounds=rounds, forcecd=forcecd) IF raw_cnt EQ 0 THEN BEGIN IF silent LE 1 THEN message, /info, 'no raw tomography files' RETURN ENDIF ; The last raw file should be the last time from the last tomography run. last_file = raw_files[raw_cnt-1] last_marker = imark[raw_cnt-1] IF silent LE 1 THEN message, /info, 'last run: '+hide_env(last_file) ; Find all files with the same marker. These are the files created during ; the last tomography run. These files need to be incorporated into the final ; averages. Get a list of times from the file names. tmp = where(imark EQ last_marker, cnt) files = raw_files[tmp] times = raw_times[tmp] ; For the time-dependent tomography final files are produced at the same ; cadence as the raw files. dest = filepath(root=root, 'final') FOR i=0,cnt-1 DO BEGIN ; Loop over all files with highest marker value time = times[i] ; Find all raw files with the same time (the markers will be ; different). These files need to be combined. raw_mark = where(TimeOp(/subtract,raw_times,time,uday) EQ 0, mark_cnt) IF mark_cnt NE 0 THEN BEGIN ; Read the files with the same time (and different markers) raw_hdr = vu_select(raw_files[raw_mark], /marker, /check, /read, $ silent=silent+1, ff=ff, /get_full, count=mark_cnt, rounds=rounds) IF silent LE 1 THEN message, /info, $ 'got '+strcompress(mark_cnt, /rem)+' files @ '+ $ TimeGet(time, /ymd, upto=TimeUnit(/minute))+ $ ' ('+string(Carrington(time),format=forecast_cfg(/crformat))+')' IF mark_cnt NE 0 THEN BEGIN ; The weights still have to be set up. For now give every file the same weight. ww = replicate(1, mark_cnt) ret_hdr = vu_mean(raw_hdr, ff, ww, /marker, ff_mean=ff_mean, userinfo=userinfo) ret_hdr = vu_set(ret_hdr, uttime=time) ; Ensure overwriting existing files ret_hdr = vu_set(ret_hdr, ntim=1) ret_hdr = vu_set(ret_hdr, time_index=1) vu_write, ret_hdr, ff_mean, userinfo=userinfo, dest=dest, silent=silent, gzip=gzip ENDIF ENDIF ENDFOR RETURN & END