; ---------------------------------------------------------------------- ; Read NIRES object image file into structure. ; pro nsx_read_image, IMG, echo common nsx if not isfile(IMG.file) then return status=0 if (echo) then begin print, IMG.file, format='("Open and read FITS file ",A,".")' printf, logfu, IMG.file, format='("Open and read FITS file ",A,".")' endif fits_read, IMG.file, image, fptr, message=message status = (message ne '') if (status ne 0) then begin print,IMG.file, format='("***error: problem reading ",A,".")' retall ;> exit(1) endif IMG.nc = long(sxpar(fptr,"NAXIS1")) IMG.nr = long(sxpar(fptr,"NAXIS2")) if ((IMG.nc lt 1800L)||(IMG.nr lt 900L)) then begin print,IMG.file, format='("===NOTE: ",A," is not a valid spectral image.")' retall ;> exit(1) endif jd = 2086303.d ; /* 1000-01-01T12:00:00.000 */ mjd= sxpar(fptr,"MJD-OBS") if (mjd gt 0.) then jd = mjd + 2400000.5 jdstr,jd,3, utshut IMG.utshut = utshut IMG.jd = jd IMG.object = sxpar(fptr,"OBJECT") ra = sxpar(fptr,"RA") if size(ra, /tname) eq 'STRING' then IMG.ra = raparse(ra, /degrees)$ else IMG.ra = ra dec = sxpar(fptr,"DEC") if size(dec, /tname) eq 'STRING' then IMG.dec = decparse(dec, /degrees)$ else IMG.dec = dec IMG.airmass = sxpar(fptr,"AIRMASS") if (IMG.airmass lt 0.) then IMG.airmass=0. IMG.ha = sxpar(fptr,"HA" ) if (IMG.ha lt -400.) then IMG.az =0. IMG.az = sxpar(fptr,"AZ" ) if (IMG.az lt -400.) then IMG.az =0. IMG.parang = sxpar(fptr,"PARANG" ) if (IMG.parang lt -400.) then IMG.parang =0. IMG.rotposn = sxpar(fptr,"ROTPOSN") if (IMG.rotposn lt -400.) then IMG.rotposn=0. IMG.el = sxpar(fptr,"EL" ) if ((IMG.el lt 0.)||(IMG.el gt 90.01)) then IMG.el=0. IMG.exptime = sxpar(fptr,"EXPTIME") if (IMG.exptime lt 0.) then begin IMG.exptime = sxpar(fptr,"ITIME") if (IMG.exptime lt 0.) then IMG.exptime = 0. endif if (IMG.exptime lt 1.) then IMG.exptime = 1. if (echo) then begin printf,logfu,$ IMG.ra,IMG.dec,IMG.exptime,IMG.airmass,IMG.utshut, $ format='("RA=",F9.5," DEC=",F9.5," Exp=",F8.2," Air=",F6.3," ",A," ")' endif nbuffer = IMG.nc * IMG.nr ; IMG.image = PTR_NEW( fltarr(IMG.nc, IMG.nr) ) IMG.varimg= PTR_NEW( fltarr(IMG.nc, IMG.nr) ) IMG.clnimg= PTR_NEW( fltarr(IMG.nc, IMG.nr) ) IMG.corimg= PTR_NEW( fltarr(IMG.nc, IMG.nr) ) IMG.corimgNFD= PTR_NEW( fltarr(IMG.nc, IMG.nr) ) IMG.bckimg= PTR_NEW( fltarr(IMG.nc, IMG.nr) ) (*IMG.image)[*,*] = image ; IMG.image = (float *)calloc((nbuffer+1000),sizeof(float)); end