;+ ; NAME: ; forecast_info ; PURPOSE: ; Use several template html files containing placeholders for several times, and ; replaces them with actual times. The resulting html pages contain information ; that goes with several of the plots used in the IPS forecast Web pages. ; CATEGORY: ; WWW: html ; CALLING SEQUENCE: PRO forecast_info, kind, dir, file, filter=filter, utnow=utnow, time=time, utnoon=utnoon, upto=upto ; INPUTS: ; kind scalar; type: string ; 'slow' or 'fast' for corotating or time-dependent tomography ; respectively. ; dir scalar; type: string ; directory where the html info files are stored. ; The procedure looks for the the templates in ./html. ; file scalar; type: string ; identifier for the html pages, e.g. 'earth_insitu_slow_v_n', ; 'synoptic_fast_v_n', etc. Note that 'kind' is a substring of 'file' ; OPTIONAL INPUT PARAMETERS: ; utnow=utnow array[1]; time structure ; the current time (usually the system time in UT) ; time=time array[1]; time structure ; last time at which tomography was run. Usually extracted ; from the 1st record of a t3d file ; utnoon=utnoon array[1]; time structure ; time when it was noon a specific location on Earth. ; Currently used in conjunction with the 'sky sweep' maps made ; by href=vu_nagoyaskymap= ; OUTPUTS: ; (updated html files are stored in 'dir') ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, who_am_i, CheckDir, txt_read, TimeOp, TimeGet, TimeUnit ; hide_env ; RESTRICTIONS: ; The template must be located in a subdirectory 'html' of the directory where ; this procedure is located. If this directory does not exist then the directory ; 'dir' specified as 1st argument is used. ; PROCEDURE: ; The template files have names 'file'.html. ; They contain placeholders of the type '(insert system time here)' corresponding ; to each of the time keywords. After being replaced by the values in the keywords ; the files are saved to disk as 'file'_info.html. ; MODIFICATION HISTORY: ; MAR-2000, Paul Hick (UCSD/CASS) ; AUG-2000, Paul Hick (UCSD/CASS) ; Move the html template files to $SSW_SMEI/sys, and modified the ; procedure to look in $SSW_SMEI/sys for the templates (if it is defined). ; JUL-2002, Paul Hick (UCSD/CASS) ; Rather then looking for whole lines to replace, the procedure now looks ; for substrings. ; SEP-2002, Paul Hick (UCSD/CASS) ; Moved templates from ./html ; Added capability to handle magnetic info files. ; APR-2004, Paul Hick (UCSD/CASS) ; Fixed bug in call to get movie_time (TimeSet instead of TimeGet was used) ;- InitVar, upto, TimeUnit(/min) ; The html template should be located in the subdirectory html ; of the directory where this procedure is located. sys = filepath(root=who_am_i(/directory), subdir='html', '') IF NOT CheckDir(sys) THEN sys = dir html_file = filepath(root=sys, file+'.html') ; Name of html template IF NOT txt_read(html_file, info) THEN RETURN ; Read the template file ; Construct name of final html file. p = strpos(file,kind) html_file = filepath(root=dir, strmid(file,0,p)+'info'+strmid(file,p+strlen(kind))+'.html') message, /info, hide_env(html_file) ; List of substrings to search for in the html template str = [ '(insert system time here)' , $ '(insert t3d_time here)' , $ '(insert ut_noon here)' , $ '(insert movie time step here)' , $ '(insert begin movie here)' , $ '(insert end movie here)' , $ '(insert fov size here)' , $ '(insert heliocentric distance here)',$ '(insert ecliptic latitude here)' ,$ '(insert delay time here)' , $ '(insert time delay here)' ] ; List of replacement substrings InitVar, utnow , !TheTime InitVar, time , !TheTime InitVar, utnoon, !TheTime time_lapsed = TimeOp(/subtract,utnow, utnoon, TimeUnit(/hour)) fovsize = forecast_cfg(/remote_fovsize, /degrees) location = forecast_cfg(utnow, /remote_location, /degrees) movie_time = abs( TimeGet( forecast_cfg(/movie_time), /day, /full) ) movie_dtime = forecast_cfg(kind, /movie_dtime, filter=filter) time_delay = forecast_cfg(/disk_dtime) delay_time = TimeOp(/add, utnow, TimeSet(day=time_delay)) time_delay = abs(time_delay) ins = [ TimeGet(utnow , /ymd, upto=upto)+' UT', $ TimeGet(time , /ymd, upto=upto)+' UT', $ TimeGet(utnoon, /ymd, upto=upto)+' UT, about '+ $ string(time_lapsed, format='(F5.1)')+' hours ago,', $ string(movie_dtime, format='(F5.1)')+'-hour' , $ string(movie_time , format='(F5.1)')+' days' , $ string(2*fovsize , format='(F5.1)')+' degrees' , $ string(location[2], format='(F5.1)')+' AU' , $ string(location[1], format='(F5.1)')+' degrees above', $ TimeGet(delay_time, /ymd, upto=upto)+' UT' , $ string(time_delay, format='(F5.1)')+' days ago'] FOR istr=0,n_elements(str)-1 DO BEGIN p = strpos(info, str[istr]) i = (where( p ne -1 ))[0] IF i NE -1 THEN BEGIN p = p[i] k = strlen(str[istr]) info[i] = strmid(info[i],0,p)+ins[istr]+strmid(info[i],p+k) ENDIF ENDFOR ; Write the html file for the web site openw, /get_lun, iu, html_file FOR i=0,n_elements(info)-1 DO printf, iu, info[i] free_lun, iu RETURN & END