;------------------------------------------------------------------------------ ;+ ; NAME: ; dust_getval ; ; PURPOSE: ; Read values from BH files or our dust maps. ; ; Either the coordinates GALL and GALB must be set, or these coordinates ; must exist in the file INFILE. Output is written to the variable VALUE ; and/or the file OUTFILE. ; ; CALLING SEQUENCE: ; value = dust_getval( [ gall, galb, infile=infile, outfile=outfile, $ ; map=map, interp=interp, noloop=noloop, verbose=verbose, $ ; ipath=ipath, bhpath=bhpath ] ) ; ; INPUTS: ; ; OPTIONAL INPUTS: ; gall: Galactic longitude(s) in degrees ; galb: Galactic latitude(s) in degrees ; map: Set to one of the following (default is 'Ebv'): ; BH : Burstein-Heiles 4*E(B-V) ; I100: 100-micron map in MJy/Sr ; X : X-map, temperature-correction factor ; T : Temperature map in degrees Kelvin for n=2 emissivity ; IX : Temperature-corrected 100-micron map in MJy/Sr ; Ebv : E(B-V) in magnitudes ; mask: 8-bit mask ; infile: If set, then read GALL and GALB from this file ; outfile: If set, then write results to this file ; interp: Set this flag to return a linearly interpolated value ; from the 4 nearest pixels. ; This is disabled if map='mask'. ; noloop: Set this flag to read all values at once without a FOR loop. ; This is a faster option for reading a large number of values, ; but requires reading an entire FITS image into memory. ; (Actually, the smallest possible sub-image is read.) ; verbose: Set this flag for verbose output, printing pixel coordinates ; and map values. Setting NOLOOP disables this option. ; ipath: Path name for dust maps ; bhpath: Path name for BH maps ; ; OUTPUTS: ; value: Value(s) from Lambert-projection maps. ; ; EXAMPLES: ; Read the reddening value E(B-V) at Galactic (l,b)=(12,+34.5), ; interpolating from the nearest 4 pixels, and return result in VALUE. ; > value = dust_getval(12, 34.5, /interp) ; ; Read the temperature map at positions listed in the file 'dave.in', ; interpolating from the nearest 4 pixels, and output to file 'dave.out'. ; The path name for the temperature maps is '/home/dave/sfd'. ; > value = dust_getval(map='T', ipath='/home/dave/sfd/', /interp, $ ; infile='dave.in', outfile='dave.out') ; ; PROCEDURES CALLED: ; bh_rdfort(), djs_int2bin(), lambert_getval() ; ; REVISION HISTORY: ; Written by D. Schlegel, 25 Sep 1997, Durham ; Modified 19 Jan 1998 for general release. ; Modified 30 Mar 1998 to read SGP mask file for b<0, since it was ; incorrectly reading the NGP mask. ; Modified 26 Jun 1998 by MD to set default path to /deep0, if visible from ; the machine running the code ;- ;------------------------------------------------------------------------------ function dust_getval, gall, galb, infile=infile, outfile=outfile, $ map=map, interp=interp, noloop=noloop, verbose=verbose, $ ipath=ipath, bhpath=bhpath if (NOT keyword_set(infile) $ AND (NOT keyword_set(gall) OR NOT keyword_set(galb)) $ ) then begin print, 'Must set either coordinates or INFILE' return, -1 endif bitnames = [ $ [ '' , '' ], $ [ '' , '' ], $ [ 'OK ' , 'asteroi' ], $ [ 'OK ' , 'glitch ' ], $ [ 'OK ' , 'source ' ], $ [ 'OK ' , 'no_list' ], $ [ 'OK ' , 'big_obj' ], $ [ 'OK ' , 'no_IRAS' ] ] if (NOT keyword_set(map)) then map = 'Ebv' if (map EQ 'mask') then interp=0 ; If INFILE is defined, then read galactic coordinates from that file if (keyword_set(infile)) then $ readcol, infile, gall, galb, format='F,F' isdeep=total(findfile('/deep0') ne '') ne 0 ;returns 1 if /deep can be seen if (NOT keyword_set(ipath)) then begin if isdeep then ipath='/deep0/ftp/pub/dust/maps/' $ else ipath = '' endif if (NOT keyword_set(bhpath)) then begin if isdeep then bhpath='/deep0/ftp/pub/dust/bh/' $ else bhpath = '' endif case map of 'BH': begin ; value = lambert_getval('bhngp.fits', 'bhsgp.fits', $ ; gall, galb, path='/mosaic/group/cmbanalysis/forecast/idl/', interp=interp, $ ; noloop=noloop, verbose=verbose) value = bh_rdfort( gall, galb, bhpath=bhpath ) end 'I100': begin value = lambert_getval( $ ; 'SFD_i100_1024_ngp.fits', 'SFD_i100_1024_sgp.fits', $ ; gall, galb, path=ipath, interp=interp, noloop=noloop, verbose=verbose) 'SFD_i100_1024_ngp.fits', 'SFD_i100_1024_sgp.fits', $ gall, galb, interp=interp, noloop=noloop, verbose=verbose) ; For reasons I don't fully understand, java version won't work unless path ; is not set. end 'X': begin value = lambert_getval( $ 'SFD_xmap_ngp.fits', 'SFD_xmap_sgp.fits', $ gall, galb, path=ipath, interp=interp, noloop=noloop, verbose=verbose) end 'T': begin value = lambert_getval( $ 'SFD_temp_ngp.fits', 'SFD_temp_sgp.fits', $ gall, galb, path=ipath, interp=interp, noloop=noloop, verbose=verbose) end 'IX': begin value = lambert_getval( $ 'SFD_dust_4096_ngp.fits', 'SFD_dust_4096_sgp.fits', $ gall, galb, path=ipath, interp=interp, noloop=noloop, verbose=verbose) value = value / 0.0184 end 'Ebv': begin value = lambert_getval( $ 'SFD_dust_4096_ngp.fits', 'SFD_dust_4096_sgp.fits', $ gall, galb, path=ipath, interp=interp, noloop=noloop, verbose=verbose) end 'mask': begin value = lambert_getval( $ 'SFD_mask_4096_ngp.fits', 'SFD_mask_4096_sgp.fits', $ gall, galb, path=ipath, interp=interp, noloop=noloop, verbose=verbose) end endcase ; If OUTFILE is defined, then write to output file if (keyword_set(outfile)) then begin get_lun, olun openw, olun, outfile if (map EQ 'mask') then begin for igal=0, N_elements(gall)-1 do begin bits = djs_int2bin(value(igal),ndigit=8) printf, olun, format='(f8.3,f8.3,7a8)', $ gall(igal), galb(igal), $ strcompress(string(2*bits(0)+bits(1))+'hcons'), $ bitnames(indgen(6)*2+4+bits(2:7)) endfor endif else begin printf, olun, format='(f8.3,f8.3,f12.5)', $ [transpose(gall), transpose(galb), transpose(value)] endelse close, olun free_lun, olun endif return, value end ;------------------------------------------------------------------------------