;+ ; NAME: ; vu_get_page ; PURPOSE: ; Save the zbuffer into image files to be used for the IPS forecast Web page ; CATEGORY: ; I/O ; CALLING SEQUENCE: PRO vu_get_page, hdr, module, $ destination = destination , $ device = device , $ use_image = use_image , $ png = png , $ gif = gif , $ bmp = bmp , $ title = title , $ ut = ut , $ upto = upto , $ silent = silent , $ new = new , $ logo = logo , $ notwin = notwin ; INPUTS: ; hdr array[1]; type: structure ; scalar; type: string ; header structure or name of tomography file used ; to generate the plot ; module scalar; type: string ; module name describing the plot in the z-buffer ; e.g. 'earth_insitu_v', etc. ; OPTIONAL INPUTS: ; destination=destination ; scalar or array[2]; type: string ; If the first element is a valid directory then an ; image file is created in that directory with a name ; based on the module name. ; If a 2nd directory is specified a backup copy is written ; to subdirectory 'module' of this 2nd directory. ; If this keyword is not specified then the image is ; displayed on the terminal. ; ; The first element can also be a valid file name to ; be used to name the output image file ; ; gif=gif if set then images are saved as gif files ; png=png if set then images are saved as png files ; ; ut=ut scalar or array[1]; time; default: none ; time used in title for IDL window, or used in ; construction of image file name. Usually this is the ; forecast time. ; device=device scalar; type: string; default: none ; graphics device to switch to after the z-buffer has ; been read. ; use_image=use_image ; scalar; type: string ; If keyword 'destination' is specified, then the image ; file (and optional backup copy) is by default created ; by reading the Z-buffer. ; If an image file is already created then its ; fully-qualified name can be specified in keyword ; 'use_image', bypassing reading the Z-buffer. The ; use_image file will be moved to 'destination[0]' ; and, optionally, a copy is placed in a subdirectory ; of 'destination[1]'. ; OUTPUTS: ; (Two image files) ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; CheckDir, IsType, SetFileSpec, GetFileSpec, do_file, reset_colors ; IsDisplay, SuperArray, Carrington, get_page, TimeGet, TimeUnit, hide_env ; InitVar, boost ; PROCEDURE: ; The current graphics device should be the z-buffer. The z-buffer is read ; by a simple tvrd(), and is then either displayed on the screen, or written ; to an image file. ; ; Two identical image files are created in subdirectories, 'www' and ; 'images/module' of the root directory $dat/nagoya. ; ; The file in 'www' is named 'module#.gif' where # is an integer digit, ; equal to the number of elements in nv3d_file. This file is used directly ; in the Web page. ; ; The file in 'images' is named 'nv3d_file[0]_#####.module#.gif. Here the ; 5-digit integer is the time differences in minutes between the system ; time and the time that file nv3d_file[0] was created. This file serves ; as a backup copy and can also be used to make movies from sequences of ; GIF files. ; MODIFICATION HISTORY: ; MAR-2000, Paul Hick (UCSD/CASS) ; MAY-2000, Paul Hick (UCSD/CASS) ; The skysweep map is now written only once for each tomography run ; (instead of each hour). ; AUG-2000, Paul Hick (UCSD/CASS) ; Added /speed and /density keywords. If one of these is set then '_v' ; or '_n' is added to the name of the gif files. ; Added 'destination' keyword to control destination of gif files. ; FEB-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Added the postfix _v or _n to the subdirectory in $dat/nagoya/image ; where the backup copy of the gif file is stored, i.e. density and ; velocity images are now stored in separate directories). ; APR-2003, Paul Hick (UCSD/CASS) ; Removed check for modules skysweep, fore/aftcast (used to avoid ; unnecessarily writing files). Changed file name convention for the ; backup image file. The title keyword explicitly allows specification ; of a prefix, replacing the default name of the nv3d file name ; specified in 'hdr'. The forecast time is now encoded as a UT time ; string instead of a Carrington rotation. ; APR-2003, Paul Hick (UCSD/CASS) ; Introduce hide_env calls in messages. ; AUG-2004, Paul Hick (UCSD/CASS) ; Added option to allow destination[0] to be a valid filename. ; OCT-2006, Paul Hick (UCSD/CASS) ; Added logo keyword ;- InitVar, silent, 0 InitVar, gif, /key InitVar, png, /key InitVar, bmp, /key IF NOT gif+bmp THEN png = 1 ; If keyword use_image is used, then the order of the following two statements ; filling imgtype is important. E.g. for remote views the order must be the ; same as in remoteview_display3d (first png, then gif) IF png THEN boost, imgtype, '.png' IF gif THEN boost, imgtype, '.gif' IF bmp THEN boost, imgtype, '.bmp' dump_image = IsType(destination,/defined) IF dump_image THEN BEGIN is_dir = CheckDir(destination[0],/silent) CASE is_dir OF 1: is_file = 0 0: BEGIN i = strpos(destination[0],'') IF i NE -1 THEN destination[0] = strmid(destination[0],0,i)+module+strmid(destination[0],i+strlen('')) SetFileSpec, destination[0], /parse, status=is_file END ENDCASE dump_image = is_dir OR is_file ENDIF IF IsType(title, /undefined) THEN BEGIN CASE IsType(hdr, /structure) OF 0: SetFileSpec, hdr[0] ; hdr is file name 1: SetFileSpec, hdr[0].file ; hdr is header structure ENDCASE title = GetFileSpec(from='name', upto='type') ENDIF IF strlen(title) NE 0 THEN title = title+'_' IF IsType(ut, /defined) THEN BEGIN InitVar, upto, TimeUnit(/second) title = title+TimeGet(Carrington(ut[0],/get_time),ymd=1-dump_image,_ydoy=dump_image,upto=upto)+'_' ENDIF title = title+module IF dump_image THEN BEGIN ; If one directory is specified a single file is written to this directory. ; If a second directory is specified an additional backup copy is written ; to subdirectory 'module' of the 2nd directory. ; The first directory receives the file for the web page. The image file ; is created by reading/writing the content of the Z-buffer, or by moving ; an existing image file (specified in 'use_image'). FOR i=0,n_elements(imgtype)-1 DO BEGIN CASE 1 OF is_dir : img = filepath(root=destination[0], module+imgtype[i]) is_file: img = GetFileSpec(destination[0],upto='name')+imgtype[i] ENDCASE CASE IsType(use_image, /defined) OF 0: BEGIN catch, ierr CASE ierr OF 0 : get_page, img, /zbuffer, /freeze, silent=silent, logo=logo ELSE: IF silent LE 0 THEN message, /info, 'error writing '+hide_env(img) ENDCASE catch, /cancel END 1: ok = do_file(/move, use_image[i], img, silent=silent) ENDCASE ; The second directory is the backup directory (e.g ; $dat/nagoya/slow/image). Unless 'title' is set, the name of the ; backup image starts with 'file' (the name of the nv3d file used ; to create the plot). An identifier is appended for the time 'ut' ; at which the plot was created. IF n_elements(destination) EQ 2 THEN $ ok = do_file(/copy, silent=silent, img, $ filepath(root=destination[1], subdir=module, title+imgtype[i])) ENDFOR stretch IF IsType(device,/defined) THEN set_plot, device ENDIF ELSE IF IsType(device,/defined) THEN BEGIN get_page, silent=silent, new=new, logo=logo, notwin=notwin ENDIF reset_colors RETURN & END