;+ ; NAME: ; smei_mkglare ; PURPOSE: ; Converts glare related grd files to Fits files ; CATEGORY: ; camera/idl/toolbox ; CALLING SEQUENCE: PRO smei_mkglare ; INPUTS: ; From $SSWDB_SMEI/glare ; OUTPUTS: ; To $SSWDB_SMEI ; OPTIONAL OUTPUT PARAMETERS: ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; grd_read, do_file, IsType ; PROCEDURE: ; MODIFICATION HISTORY: ; JUL-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- ; The glare maps are stored in glaredb. ; The indexing program picks up files from smeidb. smeidb = getenv('SSWDB_SMEI') glaredb = filepath(root=smeidb,'glare') ; glare_map contains a 318x64 map of the glare as a mode 2 CCD frame. ff = [ '2_2003_151_1_el_ccd_smoo_eng' ,$ ; Glare map for cam 2, mode 0 '2_2003_151_1_el' ,$ ; Glare map for cam 2, mode 2 from eclipse data '2_2003_151_1_el_ccd_model' ,$ ; Glare map model for cam 2, mode 2 '3_2004_288_ccd_modeleng' ,$ ; Glare map model for cam 3, mode 0 '3_2004_288_ccd_model' ,$ ; Glare map model for cam 3, mode 1 '3_2004_288_ccd_model4x4' ] ; Glare map model for cam 3, mode 2 dot = '.' c2m0 = (where( strpos(ff+dot,'2_2003_151_1_el_ccd_smoo_eng' +dot) NE -1 ))[0] c2m2 = (where( strpos(ff+dot,'2_2003_151_1_el' +dot) NE -1 ))[0] c3m0 = (where( strpos(ff+dot,'3_2004_288_ccd_modeleng' +dot) NE -1 ))[0] c3m1 = (where( strpos(ff+dot,'3_2004_288_ccd_model' +dot) NE -1 ))[0] c3m2 = (where( strpos(ff+dot,'3_2004_288_ccd_model4x4' +dot) NE -1 ))[0] glare_maps = ['c2m0','c2m2','c3m0','c3m1','c3m2'] glare_nums = [ c2m0 , c2m2 , c3m0 , c3m1 , c3m2 ] ff = 'glare'+ff ; Convert all .grd files to .fts.gz FOR i=0,n_elements(ff)-1 DO $ IF grd_read(filepath(root=glaredb,ff[i]+'.grd.gz'), map, /norow,/silent) THEN $ writefits,filepath(root=glaredb,ff[i]+'.fts'),map,/compress ; Rename and move glare maps from smeidb to glaredb FOR i=0,n_elements(glare_maps)-1 DO $ j = do_file(/move, $ filepath(root=glaredb, ff[glare_nums[i]]+'.fts.gz'), $ filepath(root=smeidb , glare_maps[i]+'_glare_map.fts.gz') $ ) ff = 'glare_multiplier_model' ; 90 x 180 IF grd_read(filepath(root=glaredb,ff+'.grd.gz'),/silent, map) THEN BEGIN ;whatis, map ; smei_sky wants a 90 x 180 array covering Rx from 0 to -90 and ; Ry from -90 to +90. dim = size(map,/dim) IF dim[0] EQ 30 AND dim[1] EQ 90 THEN BEGIN tmp = fltarr(90,180) tmp[60:89,90:179] = map ; Insert 30 x 90 into 90 x 180 at topright corner map = tmp ENDIF ; Make a basic fits header based on the data mkhdr, hdr, IsType(map), size(map,/dim) ; Add keyword to map from Rx, Ry to array index. ; Rx covers ( 0,-90) on an open grid in 90 steps ; Ry covers (-90, 90) on an open grid in 180 steps ; Rx : i = 1 -> Rx = - 0.5; i = 90 -> Rx = -89.5 : cx = 0.5, dx = -1.0 ; Ry : j = 1 -> Ry = -89.5; j =180 -> Ry = 89.5 : cy = 90.5, dy = 1.0 fxaddpar, hdr, 'CRPIX1', 0.5, ' i (1-based) = CRPIX1+(Rx-CRVAL1)/CDELT1', format='(F7.2)' fxaddpar, hdr, 'CRPIX2', 90.5, ' j (1-based) = CRPIX2+(Ry-CRVAL2)/CDELT2', format='(F7.2)' fxaddpar, hdr, 'CDELT1', -1.0, ' Degrees per bin' , format='(F7.2)' fxaddpar, hdr, 'CDELT2', 1.0, ' Degrees per bin' , format='(F7.2)' fxaddpar, hdr, 'CRVAL1', 0.0, ' Thetax=0.0' , format='(F7.2)' fxaddpar, hdr, 'CRVAL2', 0.0, ' Thetay=0.0' , format='(F7.2)' fxaddpar, hdr, 'CUNIT1', 'deg',' Angles in degrees' fxaddpar, hdr, 'CUNIT2', 'deg',' Angles in degrees' writefits, filepath(root=glaredb, ff+'.fts'), map, hdr, /compress ; Put copy of glare multiplier file in smeidb i = do_file(/copy, $ filepath(root=glaredb, ff+'.fts.gz'), $ filepath(root=smeidb , 'glare_multiplier.fts.gz') $ ) ENDIF RETURN & END