diff options
Diffstat (limited to 'noao/imred/src/doecslit')
-rw-r--r-- | noao/imred/src/doecslit/Revisions | 93 | ||||
-rw-r--r-- | noao/imred/src/doecslit/apslitproc.par | 145 | ||||
-rw-r--r-- | noao/imred/src/doecslit/doecslit.cl | 106 | ||||
-rw-r--r-- | noao/imred/src/doecslit/doecslit.par | 28 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sarcrefs.cl | 77 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sarcrefs.par | 6 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sbatch.cl | 216 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sbatch.par | 24 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sdoarcs.cl | 102 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sdoarcs.par | 8 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sfluxcal.cl | 214 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sfluxcal.par | 16 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sgetspec.cl | 177 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sgetspec.par | 11 | ||||
-rw-r--r-- | noao/imred/src/doecslit/slistonly.cl | 241 | ||||
-rw-r--r-- | noao/imred/src/doecslit/slistonly.par | 13 | ||||
-rw-r--r-- | noao/imred/src/doecslit/slittasks.cl | 19 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sparams.par | 65 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sproc.cl | 490 | ||||
-rw-r--r-- | noao/imred/src/doecslit/sproc.par | 35 |
20 files changed, 2086 insertions, 0 deletions
diff --git a/noao/imred/src/doecslit/Revisions b/noao/imred/src/doecslit/Revisions new file mode 100644 index 00000000..c4e6ee16 --- /dev/null +++ b/noao/imred/src/doecslit/Revisions @@ -0,0 +1,93 @@ +.help revisions Dec94 noao.imred.src.doecslit +.nf + +======= +V2.12.3 +======= + +doecslit$sdoarcs.cl + The sparams.refit parameter was being ignored and the ecreidentify + step has refit=yes hardwired. The parameter reference is now used. + (11/14/05, Valdes) + +doecslit$sbatch.cl +doecslit$sproc.cl +doecslit$fibresponse.cl + Error messages now hint to check imtype setting. + (4/15/05, Valdes) + +======== +V2.12.2b +======== + +doecslit$sproc.cl + Modified code to eliminate goto. This is for use with pyraf. + (11/21/00, Valdes) + +======== +V2.11.3a +======== + +doecslit$sproc.cl + The arcref and arcrefs variables were not initialized if dispcor=no + and if the user goes directly to batch mode there is an undefined + local variable error. Added initialization. (1/27/98, Valdes) + +======= +V2.11.1 +======= + +doecslit$sarcrefs.cl +doecslit$sbatch.cl +doecslit$sfluxcal.cl +doecslit$sgetspec.cl +doecslit$slistonly.cl +doecslit$sproc.cl +doecslit$sdoarcs.cl + Any additional qualifiers in the imtype string are stripped. + (8/14/97, Valdes) + +doecslit$sgetspec.cl + Added the field parameter to the RENAME call. (8/12/97, Valdes) + +========= +V2.11Beta +========= + +doecslit$sbatch.cl + Fixed typo bugs in this script. (10/3/96, Valdes) + +doecslit$apslitproc.par + Made changes for the new aperture selection option. (9/5/96, Valdes) + +======= +V2.10.4 +======= + +doecslit$sgetspec.cl +doecslit$doecslit.cl + The arc table will now be checked for arc spectra. (5/1/95, Valdes) + +doecslit$sparams.par +doecslit$sdoarcs.cl +doecslit$sarcrefs.cl + Added "threshold" as a user parameter. (1/16/95, Valdes) + +doecslit$sproc.cl +doecslit$sbatch.cl +doecslit$sfluxcal.cl +doecslit$sproc.par +doecslit$sbatch.par +doecslit$sfluxcal.par + SETAIRMASS and SETJD are only called if the required keywords are + present. Errors from missing airmass or JD are then reported from + the task that actually uses them. (12/31/94, Valdes) + +doecslit$sgetspec.cl +doecslit$sgetspec.par + Added warning and query for missing CCDPROC keyword. (12/31/94, Valdes) + +======= +V2.10.3 +======= +.endhelp diff --git a/noao/imred/src/doecslit/apslitproc.par b/noao/imred/src/doecslit/apslitproc.par new file mode 100644 index 00000000..3233960a --- /dev/null +++ b/noao/imred/src/doecslit/apslitproc.par @@ -0,0 +1,145 @@ +# APSCRIPT + +input,s,a,,,,List of input images +output,s,h,"",,,List of output spectra +apertures,s,h,"",,,Apertures +scatter,s,h,"",,,List of scattered light images (optional) +references,s,h,"",,,List of aperture reference images +profiles,s,h,"",,,"List of aperture profile images +" +interactive,b,h,yes,,,Run task interactively? +find,b,h,yes,,,Find apertures? +recenter,b,h,yes,,,Recenter apertures? +resize,b,h,yes,,,Resize apertures? +edit,b,h,yes,,,Edit apertures? +trace,b,h,yes,,,Trace apertures? +fittrace,b,h,yes,,,Fit the traced points interactively? +extract,b,h,yes,,,Extract spectra? +review,b,h,yes,,,Review extractions? +subtract,b,h,yes,,,Subtract scattered light? +smooth,b,h,yes,,,Smooth scattered light along the dispersion? +fitscatter,b,h,yes,,,Fit scattered light interactively? +fitsmooth,b,h,yes,,,"Smooth the scattered light interactively? +" +line,i,h,)sparams.line,,,>sparams.line +nsum,i,h,)sparams.nsum,,,>sparams.nsum +buffer,r,h,)sparams.buffer,,,">sparams.buffer + +# OUTPUT PARAMETERS +" +format,s,h,"echelle",,,Extracted spectra format +extras,b,h,)sparams.extras,,,"Extract sky, sigma, etc.?" +dbwrite,s,h,"YES",,,Write to database? +initialize,b,h,no,,,Initialize answers? +verbose,b,h,)_.verbose,,,"Verbose output? + +# DEFAULT APERTURE PARAMETERS +" +lower,r,h,,,,Lower aperture limit relative to center +upper,r,h,,,,Upper aperture limit relative to center +apidtable,s,h,"",,,"Aperture ID table (optional) + +# DEFAULT BACKGROUND PARAMETERS +" +b_function,s,h,)sparams.b_function,,,>sparams.b_function +b_order,i,h,)sparams.b_order,,,>sparams.b_order +b_sample,s,h,)sparams.b_sample,,,>sparams.b_sample +b_naverage,i,h,)sparams.b_naverage,,,>sparams.b_naverage +b_niterate,i,h,)sparams.b_niterate,,,>sparams.b_niterate +b_low_reject,r,h,)sparams.b_low,,,>sparams.b_low +b_high_reject,r,h,)sparams.b_high,,,>sparams.b_high +b_grow,r,h,0.,0.,,"Background rejection growing radius + +# APERTURE CENTERING PARAMETERS +" +width,r,h,,,,Profile centering width +radius,r,h,,,,Profile centering radius +threshold,r,h,10.,0.,,"Detection threshold for profile centering + +# AUTOMATIC FINDING AND ORDERING PARAMETERS +" +nfind,i,h,,,,Number of apertures to be found automatically +minsep,r,h,,,,Minimum separation between spectra +maxsep,r,h,100000.,,,Maximum separation between spectra +order,s,h,"increasing",,,"Order of apertures + +# RECENTERING PARAMETERS +" +aprecenter,s,h,"",,,Apertures for recentering calculation +npeaks,r,h,INDEF,,,Select brightest peaks +shift,b,h,yes,,,"Use average shift instead of recentering? + +# RESIZING PARAMETERS +" +llimit,r,h,INDEF,,,Lower aperture limit relative to center +ulimit,r,h,INDEF,,,Upper aperture limit relative to center +ylevel,r,h,)sparams.ylevel,,,>sparams.ylevel +peak,b,h,yes,,,Is ylevel a fraction of the peak? +bkg,b,h,yes,,,Subtract background in automatic width? +r_grow,r,h,0.,,,Grow limits by this factor +avglimits,b,h,no,,,"Average limits over all apertures? + +# EDITING PARAMETERS +" +e_output,s,q,,,,Output spectra rootname +e_profiles,s,q,,,,"Profile reference image + +# TRACING PARAMETERS +" +t_nsum,i,h,)sparams.nsum,,,>sparams.nsum +t_step,i,h,)sparams.t_step,,,>sparams.t_step +t_nlost,i,h,3,1,,Number of consecutive times profile is lost before quitting +t_width,r,h,)sparams.width,,,>sparams.width +t_function,s,h,)sparams.t_function,,,>sparams.t_function +t_sample,s,h,"*",,,Trace sample regions +t_order,i,h,)sparams.t_order,,,>sparams.t_order +t_naverage,i,h,1,,,Trace average or median +t_niterate,i,h,)sparams.t_niterate,,,>sparams.t_niterate +t_low_reject,r,h,)sparams.t_low,,,>sparams.t_low +t_high_reject,r,h,)sparams.t_high,,,>sparams.t_high +t_grow,r,h,0.,0.,,"Trace rejection growing radius + +# EXTRACTION PARAMETERS +" +background,s,h,,,,Background to subtract +skybox,i,h,1,,,Box car smoothing length for sky +weights,s,h,)sparams.weights,,,>sparams.weights +pfit,s,h,)sparams.pfit,,,>sparams.pfit +clean,b,h,no,,,Detect and replace bad pixels? +nclean,r,h,0.5,,,Maximum number of pixels to clean +niterate,i,h,5,0,,Number of profile fitting iterations +saturation,r,h,INDEF,,,Saturation level +readnoise,s,h,,,,Read out noise sigma (photons) +gain,s,h,,,,Photon gain (photons/data number) +lsigma,r,h,)sparams.lsigma,,,>sparams.lsigma +usigma,r,h,)sparams.usigma,,,>sparams.usigma +polysep,r,h,0.95,0.1,0.95,Marsh algorithm polynomial spacing +polyorder,i,h,10,1,,Marsh algorithm polynomial order +nsubaps,i,h,1,1,,"Number of subapertures per aperture + +# ANSWER PARAMETERS +" +ansclobber,s,h,"NO",,," " +ansclobber1,s,h,"NO",,," " +ansdbwrite,s,h,"YES",,," " +ansdbwrite1,s,h,"NO",,," " +ansedit,s,h,"NO",,," " +ansextract,s,h,"NO",,," " +ansfind,s,h,"NO",,," " +ansfit,s,h,"NO",,," " +ansfitscatter,s,h,"NO",,," " +ansfitsmooth,s,h,"NO",,," " +ansfitspec,s,h,"NO",,," " +ansfitspec1,s,h,"NO",,," " +ansfittrace,s,h,"NO",,," " +ansfittrace1,s,h,"NO",,," " +ansflat,s,h,"NO",,," " +ansnorm,s,h,"NO",,," " +ansrecenter,s,h,"NO",,," " +ansresize,s,h,"NO",,," " +ansreview,s,h,"NO",,," " +ansreview1,s,h,"NO",,," " +ansscat,s,h,"NO",,," " +ansskyextract,s,h,"NO",,," " +anssmooth,s,h,"NO",,," " +anstrace,s,h,"NO",,," " diff --git a/noao/imred/src/doecslit/doecslit.cl b/noao/imred/src/doecslit/doecslit.cl new file mode 100644 index 00000000..a3675416 --- /dev/null +++ b/noao/imred/src/doecslit/doecslit.cl @@ -0,0 +1,106 @@ +# DOECSLIT -- Process Echelle slit spectra from 2D to wavelength calibrated +# and flux calibrated 1D spectra. +# +# The task PROC does all of the interactive work and BATCH does the +# background work. This procedure is organized this way to minimize the +# dictionary space when the background task is submitted. + +procedure doecslit (objects) + +string objects = "" {prompt="List of object spectra"} + +file apref = "" {prompt="Aperture reference spectrum"} +string arcs = "" {prompt="List of arc spectra"} +file arctable = "" {prompt="Arc assignment table (optional)"} +string standards = "" {prompt="List of standard star spectra\n"} + +string readnoise = "0." {prompt="Read out noise sigma (photons)"} +string gain = "1." {prompt="Photon gain (photons/data number)"} +real datamax = INDEF {prompt="Max data value / cosmic ray threshold"} +int norders = 10 {prompt="Number of orders"} +real width = 5. {prompt="Width of profiles (pixels)\n"} + +bool dispcor = yes {prompt="Dispersion correct spectra?"} +bool extcor = no {prompt="Extinction correct spectra?"} +bool fluxcal = no {prompt="Flux calibrate spectra?"} +bool resize = no {prompt="Resize object apertures?"} +bool clean = no {prompt="Detect and replace bad pixels?"} +bool trace = yes {prompt="Trace object spectra?"} +string background = "none" {prompt="Background to subtract", + enum="none|scattered|average|median|minimum|fit"} +bool splot = no {prompt="Plot the final spectra?"} +bool redo = no {prompt="Redo operations if previously done?"} +bool update = no {prompt="Update spectra if cal data changes?"} +bool quicklook = no {prompt="Approximate quicklook reductions?"} +bool batch = no {prompt="Extract objects in batch?"} +bool listonly = no {prompt="List steps but don't process?\n"} + +pset sparams = "" {prompt="Algorithm parameters"} + +begin + bool recenter, arcap, tr, scat + + int i, j + file obj, arc, std + + # Expand image lists + obj = mktemp ("tmp$iraf") + arc = mktemp ("tmp$iraf") + std = mktemp ("tmp$iraf") + sgetspec (objects, arcs, arctable, standards, obj, arc, std) + + # Remove any leading whitespace from parameters that might be null. + if (logfile != "") { + j = strlen (logfile) + for (i=1; i<=j && substr(logfile,i,i)==" "; i+=1); + logfile = substr (logfile, i, j) + } + if (arctable != "") { + j = strlen (arctable) + for (i=1; i<=j && substr(arctable,i,i)==" "; i+=1); + arctable = substr (arctable, i, j) + } + + apslitproc.readnoise = readnoise + apslitproc.gain = gain + apslitproc.nfind = norders + apslitproc.width = width + apslitproc.lower = -width / 2. + apslitproc.upper = width / 2. + apslitproc.b_sample = \ + str(-2*width)//":"//str(-width)//","//str(width)//":"//str(2*width) + apslitproc.t_width = width + apslitproc.radius = width + apslitproc.minsep = width + apslitproc.clean = clean + if (background == "scattered") { + scat = yes + apslitproc.background = "none" + } else { + scat = no + apslitproc.background = background + } + sproc.datamax = datamax + + recenter = yes + tr = trace + arcap = yes + if (quicklook) { + tr = no + scat = no + arcap = no + } + + sproc (obj, apref, arc, arctable, std, recenter, + resize, quicklook, tr, scat, arcap, dispcor, + extcor, fluxcal, splot, redo, update, batch, listonly) + delete (std, verify=no) + + if (sproc.dobatch) { + print ("-- Do remaining spectra as a batch job --") + print ("sbatch&batch") | cl + } else { + delete (obj, verify=no) + delete (arc, verify=no) + } +end diff --git a/noao/imred/src/doecslit/doecslit.par b/noao/imred/src/doecslit/doecslit.par new file mode 100644 index 00000000..1d68f729 --- /dev/null +++ b/noao/imred/src/doecslit/doecslit.par @@ -0,0 +1,28 @@ +objects,s,a,"",,,"List of object spectra" +apref,f,h,"",,,"Aperture reference spectrum" +arcs,s,h,"",,,"List of arc spectra" +arctable,f,h,"",,,"Arc assignment table (optional)" +standards,s,h,"",,,"List of standard star spectra +" +readnoise,s,h,"0.",,,"Read out noise sigma (photons)" +gain,s,h,"1.",,,"Photon gain (photons/data number)" +datamax,r,h,INDEF,,,"Max data value / cosmic ray threshold" +norders,i,h,10,,,"Number of orders" +width,r,h,5.,,,"Width of profiles (pixels) +" +dispcor,b,h,yes,,,"Dispersion correct spectra?" +extcor,b,h,no,,,"Extinction correct spectra?" +fluxcal,b,h,no,,,"Flux calibrate spectra?" +resize,b,h,no,,,"Resize object apertures?" +clean,b,h,no,,,"Detect and replace bad pixels?" +trace,b,h,yes,,,"Trace object spectra?" +background,s,h,"none",none|scattered|average|median|minimum|fit,,"Background to subtract" +splot,b,h,no,,,"Plot the final spectra?" +redo,b,h,no,,,"Redo operations if previously done?" +update,b,h,no,,,"Update spectra if cal data changes?" +quicklook,b,h,no,,,"Approximate quicklook reductions?" +batch,b,h,no,,,"Extract objects in batch?" +listonly,b,h,no,,,"List steps but don\'t process? +" +sparams,pset,h,"",,,"Algorithm parameters" +mode,s,h,"ql",,, diff --git a/noao/imred/src/doecslit/sarcrefs.cl b/noao/imred/src/doecslit/sarcrefs.cl new file mode 100644 index 00000000..907b446f --- /dev/null +++ b/noao/imred/src/doecslit/sarcrefs.cl @@ -0,0 +1,77 @@ +# SARCREFS -- Determine dispersion relation for reference arc. + +procedure sarcrefs (arcref, done, log1, log2) + +file arcref +file done +file log1 +file log2 + +struct *fd + +begin + string arcrefec, arcec, temp + int i, dc + bool log + + temp = mktemp ("tmp$iraf") + + # Extract the primary arc reference spectrum. Determine the + # dispersion function with IDENTIFY/REIDENTIFY. Set the wavelength + # parameters with ECDISPCOR. + + arcrefec = arcref // ".ec." // envget ("imtype") + i = stridx (",", arcrefec) + if (i > 0) + arcrefec = substr (arcrefec, 1, i-1) + if (!access (arcrefec)) { + print ("Extract arc reference image ", arcref) | tee (log1) + apslitproc (arcref, background="none", clean=no, weights="none") + } + + # Get the dispersion parameters from the header. These are + # used for all further spectra and also flag whether this + # spectrum has been processed. If the parameters are missing + # the spectrum needs to have the dispersion function and + # wavelength scale determined. The HEDIT is needed because + # in some cases the user may exit ECIDENTIFY without updating + # the database (if the image was deleted but the database + # entry was not). + + hselect (arcrefec, "dc-flag", yes, > temp) + fd = temp + dc = -1 + i = fscan (fd, dc) + fd = ""; delete (temp, verify=no) + if (i < 1) { + print ("Determine dispersion solution for ", arcref) | tee (log1) + #delete (database//"/ec"//arcref//".ec*", verify=no) + ecidentify (arcrefec, database=database, + coordlist=sparams.coordlist, match=sparams.match, + maxfeatures=100, zwidth=10., ftype="emission", + fwidth=sparams.fwidth, cradius=sparams.cradius, + threshold=sparams.threshold, minsep=2., + function=sparams.i_function, xorder=sparams.i_xorder, + yorder=sparams.i_yorder, niterate=sparams.i_niterate, + lowreject=sparams.i_low, highreject=sparams.i_high, + autowrite=yes) + hedit (arcrefec, "refspec1", arcref // ".ec", add=yes, + show=no, verify=no, update=yes) + } + + # Dispersion correct the reference arc. This step is required to + # to set the wavelength scale for all further spectra. + + if (i < 1) { + dispcor (arcrefec, "", linearize=sparams.linearize, + database=database, table="", w1=INDEF, w2=INDEF, dw=INDEF, + nw=INDEF, log=sparams.log, flux=sparams.flux, samedisp=no, + global=no, ignoreaps=no, confirm=no, listonly=no, verbose=yes, + logfile=log1, > log2) + hedit (arcrefec, "dc-flag", 0, add=yes, show=no, + verify=no, update=yes) + sproc.newdisp = yes + } + + print (arcref, >> done) +end diff --git a/noao/imred/src/doecslit/sarcrefs.par b/noao/imred/src/doecslit/sarcrefs.par new file mode 100644 index 00000000..38b81646 --- /dev/null +++ b/noao/imred/src/doecslit/sarcrefs.par @@ -0,0 +1,6 @@ +arcref,f,a,"",,, +done,f,a,"",,, +log1,f,a,"",,, +log2,f,a,"",,, +fd,*struct,h,"",,, +mode,s,h,"q",,, diff --git a/noao/imred/src/doecslit/sbatch.cl b/noao/imred/src/doecslit/sbatch.cl new file mode 100644 index 00000000..062ac3e5 --- /dev/null +++ b/noao/imred/src/doecslit/sbatch.cl @@ -0,0 +1,216 @@ +# SBATCH -- Process spectra in batch. +# This task is called in batch mode. It only processes objects +# not previously processed unless the update or redo flags are set. + +procedure sbatch () + +file objects {prompt="Object spectra"} +real datamax {prompt="Max data value / cosmic ray threshold"} + +file arcs {prompt="List of arc spectra"} +file arcref {prompt="Arc reference for dispersion solution"} +string arcrefs {prompt="Arc references\n"} + +file done {prompt="File of spectra already done"} +file logfile {prompt="Logfile"} +bool redo {prompt="Redo operations?"} +bool update {prompt="Update spectra?\n"} + +bool scattered {prompt="Subtract scattered light?"} +bool arcap {prompt="Use object apertures for arcs?"} +bool dispcor {prompt="Dispersion correct spectra?"} +bool extcor {prompt="Extinction correct spectra?"} +bool fluxcal1 {prompt="Flux calibrate spectra?"} + +bool newaps, newdisp, newsens, newarcs + +struct *fd1, *fd2, *fd3 + +begin + file temp, spec, specec, arc + bool reextract, extract, scat, disp, ext, flux, log, disperr + string imtype, ectype, str1, str2, str3, str4 + int i + str1 = "" + + imtype = "." // envget ("imtype") + i = stridx (",", imtype) + if (i > 0) + imtype = substr (imtype, 1, i-1) + ectype = ".ec" // imtype + + temp = mktemp ("tmp$iraf") + + reextract = redo || (update && (newaps || newdisp)) + + fd1 = objects + while (fscan (fd1, spec) != EOF) { + if (access (done)) { + fd2 = done + while (fscan (fd2, specec) != EOF) + if (spec == specec) + break + if (spec == specec) + next + fd2 = "" + } + if (!access (spec // imtype)) { + print ("Object spectrum not found - " // spec // imtype, + >> logfile) + print ("Check setting of imtype", >> logfile) + next + } + specec = spec // ectype + + scat = no + extract = no + disp = no + ext = no + flux = no + if (scattered) { + hselect (spec, "apscatte", yes, > temp) + fd2 = temp + if (fscan (fd2, str1) < 1) + scat = yes + fd2 = ""; delete (temp, verify=no) + } + if (reextract || !access (specec) || (update && scat)) + extract = yes + else { + hselect (specec, "dc-flag", yes, > temp) + hselect (specec, "ex-flag", yes, >> temp) + hselect (specec, "ca-flag", yes, >> temp) + fd2 = temp + if (fscan (fd2, str1) == 1) { + extract = update && newdisp + if (update && !newdisp) + # We really should check if REFSPEC will assign + # different reference spectra. + ; + } else + disp = dispcor + if (fscan (fd2, str1) == 1) + extract = update && !extcor + else + ext = extcor + if (fscan (fd2, str1) == 1) + extract = update && (!fluxcal1 || newsens) + else + flux = fluxcal1 + fd2 = ""; delete (temp, verify=no) + } + + if (extract) { + disp = dispcor + ext = extcor + flux = fluxcal1 + } + + if (extract) { + if (access (specec)) + imdelete (specec, verify=no) + + if (scat) { + print ("Subtract scattered light in ", spec, >> logfile) + apslitproc (spec, ansextract="NO", ansscat="YES") + } + + print ("Extract object spectrum ", spec, >> logfile) + hselect (spec, "date-obs,ut,exptime", yes, > temp) + hselect (spec, "ra,dec,epoch,st", yes, >> temp) + fd3 = temp + if (fscan (fd3, str1, str2, str3) == 3) { + setjd (spec, observatory=observatory, date="date-obs", + time="ut", exposure="exptime", jd="jd", hjd="", + ljd="ljd", utdate=yes, uttime=yes, listonly=no, + >> logfile) + if (fscan (fd3, str1, str2, str3, str4) == 4) + setairmass (spec, intype="beginning", + outtype="effective", exposure="exptime", + observatory=observatory, show=no, update=yes, + override=yes, >> logfile) + } + fd3 = ""; delete (temp, verify=no) + apslitproc (spec, saturation=datamax, verbose=no) + } + + disperr = no + if (disp) { + # Fix arc headers if necessary. + if (newarcs) { + fd2 = arcs + while (fscan (fd2, arc) != EOF) { + hselect (arc, "date-obs,ut,exptime", yes, > temp) + hselect (arc, "ra,dec,epoch,st", yes, >> temp) + fd3 = temp + if (fscan (fd3, str1, str2, str3) == 3) { + setjd (arc, observatory=observatory, + date="date-obs", time="ut", exposure="exptime", + jd="jd", hjd="", ljd="ljd", utdate=yes, + uttime=yes, listonly=no, >> logfile) + if (fscan (fd3, str1, str2, str3, str4) == 4) + setairmass (arc, intype="beginning", + outtype="effective", exposure="exptime", + observatory=observatory, show=no, + update=yes, override=yes, >> logfile) + } + fd3 = ""; delete (temp, verify=no) + hedit (arc, "refspec1", arc, add=yes, verify=no, + show=no, update=yes) + } + fd2 = "" + newarcs = no + } + + print ("Assign arc spectra for ", spec, >> logfile) + refspectra (spec, references=arcrefs, + apertures="", refaps="", ignoreaps=no, + select=sparams.select, sort=sparams.sort, + group=sparams.group, time=sparams.time, + timewrap=sparams.timewrap, override=yes, confirm=no, + assign=yes, logfiles="STDOUT", verbose=no, + >> logfile) + + sdoarcs (spec, arcref, reextract, arcap, logfile, yes) + + hselect (specec, "refspec1", yes, > temp) + fd2 = temp + i = fscan (fd2, arc) + fd2 = ""; delete (temp, verify=no) + if (i < 1) { + print ("No arc reference assigned for ", spec, >> logfile) + disperr = yes + } else { + print ("Dispersion correct ", spec, >> logfile) + dispcor (specec, "", linearize=sparams.linearize, + database=database, table=arcref//ectype, + w1=INDEF, w2=INDEF, dw=INDEF, nw=INDEF, + log=sparams.log, flux=sparams.flux, samedisp=no, + global=no, ignoreaps=no, confirm=no, listonly=no, + logfile=logfile, > "dev$null") + hedit (specec, "dc-flag", 0, add=yes, show=no, + verify=no, update=yes) + } + } + + if (!disperr && (extract || disp)) { + if (ext) + print ("Extinction correct ", spec, >> logfile) + if (flux) + print ("Flux calibrate ", spec, >> logfile) + if (flux || ext) + calibrate (specec, "", extinct=extcor, flux=fluxcal1, + extinction=extinction, observatory=observatory, + ignoreaps=no, sensitivity="sens", fnu=sparams.fnu, + >> logfile) + } + } + fd1 = "" + delete (objects, verify=no) + delete (arcs, verify=no) + + if (access (done)) + delete (done, verify=no) + + flprcache (0) +end diff --git a/noao/imred/src/doecslit/sbatch.par b/noao/imred/src/doecslit/sbatch.par new file mode 100644 index 00000000..9bb5239d --- /dev/null +++ b/noao/imred/src/doecslit/sbatch.par @@ -0,0 +1,24 @@ +objects,f,h,"",,,"Object spectra" +datamax,r,h,,,,"Max data value / cosmic ray threshold" +arcs,f,h,"",,,"List of arc spectra" +arcref,f,h,"",,,"Arc reference for dispersion solution" +arcrefs,s,h,,,,"Arc references +" +done,f,h,"",,,"File of spectra already done" +logfile,f,h,"",,,"Logfile" +redo,b,h,,,,"Redo operations?" +update,b,h,,,,"Update spectra? +" +scattered,b,h,,,,"Subtract scattered light?" +arcap,b,h,,,,"Use object apertures for arcs?" +dispcor,b,h,,,,"Dispersion correct spectra?" +extcor,b,h,,,,"Extinction correct spectra?" +fluxcal1,b,h,,,,"Flux calibrate spectra?" +newaps,b,h,,,, +newdisp,b,h,,,, +newsens,b,h,,,, +newarcs,b,h,,,, +fd1,*struct,h,"",,, +fd2,*struct,h,"",,, +fd3,*struct,h,"",,, +mode,s,h,"ql",,, diff --git a/noao/imred/src/doecslit/sdoarcs.cl b/noao/imred/src/doecslit/sdoarcs.cl new file mode 100644 index 00000000..76ccaab8 --- /dev/null +++ b/noao/imred/src/doecslit/sdoarcs.cl @@ -0,0 +1,102 @@ +# SDOARCS -- Determine dispersion relation for spectrum based on reference arcs. + +procedure sdoarcs (spec, arcref, reextract, arcap, logfile, batch) + +file spec +file arcref +bool reextract +bool arcap +file logfile +bool batch + +struct *fd + +begin + string imtype, ectype + int i, j, k, n + file temp, arc1, arc2, str1, str2, arctype, apref, arc, arcec, logs + file specec, specarc + bool verbose1 + + imtype = "." // envget ("imtype") + i = stridx (",", imtype) + if (i > 0) + imtype = substr (imtype, 1, i-1) + ectype = ".ec" // imtype + n = strlen (imtype) + + temp = mktemp ("tmp$iraf") + + if (batch) + verbose1 = no + else + verbose1 = verbose + if (verbose1) + logs = logfile//",STDOUT" + else + logs = logfile + + for (j=1; j<=2; j+=1) { + # The reference spectra refer initially to the 2D image. At the + # end we will reset them to refer to the 1D spectra. + + hselect (spec, "refspec"//j, yes, > temp) + fd = temp + k = fscan (fd, arc1, str1) + fd = ""; delete (temp, verify=no) + if (k < 1) + break + + # Strip possible image extension. + i = strlen (arc1) + if (i > n && substr (arc1, i-n+1, i) == imtype) + arc1 = substr (arc1, 1, i-n) + + # Set extraction output and aperture reference depending on whether + # the arcs are to be rextracted using recentered or retraced object + # apertures. + + if (arcap) { + arc2 = spec // arc1 + apref = spec + if (access (arc2//ectype)) + imdelete (arc2//ectype, verify=no) + delete (database//"/ec"//arc2//".ec*", verify = no) + } else { + arc2 = arc1 + apref = apslitproc.references + if (reextract && access (arc2//ectype)) { + if (arc2 != arcref) + imdelete (arc2//ectype, verify=no) + } + } + + # Extract and determine dispersion function if necessary. + if (!access (arc2//ectype)) { + delete (database//"/ec"//arc2//".ec*", verify = no) + if (!batch) + print ("Extract and reidentify arc spectrum ", arc1) + print ("Extract and reidentify arc spectrum ", arc1, >> logfile) + apslitproc (arc1, output=arc2//".ec", references=apref, + background="none", clean=no, weights="none", + verbose=verbose1) + ecreidentify (arc2//".ec", arcref//".ec", shift=0., + cradius=sparams.cradius, threshold=sparams.threshold, + refit=sparams.refit, database=database, logfiles=logs) + + # If not reextracting arcs based on object apertures + # then save the extracted arc to avoid doing it again. + + if (arc1 != arc2) + imdelete (arc2//".ec", verify=no) + } + + # Set the REFSPEC parameters for echelle spectrum. + if (k == 1) + hedit (spec//".ec", "refspec"//j, arc2//".ec", add=yes, + verify=no, show=no, update=yes) + else + hedit (spec//".ec", "refspec"//j, arc2//".ec "//str1, add=yes, + verify=no, show=no, update=yes) + } +end diff --git a/noao/imred/src/doecslit/sdoarcs.par b/noao/imred/src/doecslit/sdoarcs.par new file mode 100644 index 00000000..648bacaf --- /dev/null +++ b/noao/imred/src/doecslit/sdoarcs.par @@ -0,0 +1,8 @@ +spec,f,a,"",,, +arcref,f,a,"",,, +reextract,b,a,,,, +arcap,b,a,,,, +logfile,f,a,"",,, +batch,b,a,,,, +fd,*struct,h,"",,, +mode,s,h,"q",,, diff --git a/noao/imred/src/doecslit/sfluxcal.cl b/noao/imred/src/doecslit/sfluxcal.cl new file mode 100644 index 00000000..b8b7fd80 --- /dev/null +++ b/noao/imred/src/doecslit/sfluxcal.cl @@ -0,0 +1,214 @@ +# SFLUXCAL -- Extract standard stars and determine sensitivity function. +# If flux calibrating, extract and dispersion correct the standard star +# spectra. Compile the standard star fluxes from the calibration +# directory. The user is queried for the star name but the band passes +# are not allow to change interactively. Next compute the sensitivity +# function using SENSFUNC. This is interactive. Once the sensitivity +# function images are created, flux and extinction calibrate the standard +# stars. This is done in such a way that if new standard stars are added +# in a later execution only the new stars are added and then a new +# sensitivity function is computed. If the update flag is set all +# spectra which are specified are reprocessed if they were previously +# processed. In a redo the "std" file is deleted, otherwise additions +# are appended to this file. + +procedure sfluxcal (stds, arcs, arcref, arcrefs, redo, update, + scattered, arcap, extcor, done, log1, log2) + +file stds +file arcs +file arcref +string arcrefs +bool redo +bool update +bool scattered +bool arcap +bool extcor +file done +file log1 +file log2 + +struct *fd1, *fd2, *fd3 + +begin + string imtype, ectype + string spec, specec, arc, str1, str2, str3, str4 + file temp1, temp2 + int i, j + bool reextract, log, scat + str1 = "" + str2 = "" + + imtype = "." // envget ("imtype") + i = stridx (",", imtype) + if (i > 0) + imtype = substr (imtype, 1, i-1) + ectype = ".ec" // imtype + + temp1 = mktemp ("tmp$iraf") + temp2 = mktemp ("tmp$iraf") + + reextract = redo || (update && (sproc.newaps || sproc.newdisp)) + sproc.newsens = no + + if (redo && access ("std")) + delete ("std", verify=no) + + fd1 = stds + while (fscan (fd1, spec) != EOF) { + specec = spec // ectype + + scat = no + if (scattered) { + hselect (spec, "apscatte", yes, > temp1) + fd2 = temp1 + if (fscan (fd2, str1) < 1) + scat = yes + fd2 = ""; delete (temp1, verify=no) + } + if (reextract || !access (specec) || (update && scat)) { + if (access (specec)) + imdelete (specec, verify=no) + + if (scat) { + print ("Subtract scattered light in ", spec) | tee (log1) + apslitproc (spec, ansextract="NO", ansscat="YES") + } + + print ("Extract standard star spectrum ", spec) | tee (log1) + hselect (spec, "date-obs,ut,exptime", yes, > temp1) + hselect (spec, "ra,dec,epoch,st", yes, >> temp1) + fd2 = temp1 + if (fscan (fd2, str1, str2, str3) == 3) { + setjd (spec, observatory=observatory, date="date-obs", + time="ut", exposure="exptime", jd="jd", hjd="", + ljd="ljd", utdate=yes, uttime=yes, listonly=no, + >> log1) + if (fscan (fd2, str1, str2, str3, str4) == 4) + setairmass (spec, intype="beginning", + outtype="effective", exposure="exptime", + observatory=observatory, show=no, update=yes, + override=yes, >> log1) + } + fd2 = ""; delete (temp1, verify=no) + apslitproc (spec) + } + + hselect (specec, "dc-flag,std-flag", yes, > temp1) + fd2 = temp1 + j = fscan (fd2, str1, str2) + fd2 = ""; delete (temp1, verify=no) + if (j < 1) { + # Fix arc headers if necessary. + if (sproc.newarcs) { + fd2 = arcs + while (fscan (fd2, arc) != EOF) { + hselect (arc, "date-obs,ut,exptime", yes, > temp1) + hselect (arc, "ra,dec,epoch,st", yes, >> temp1) + fd3 = temp1 + if (fscan (fd3, str1, str2, str3) == 3) { + setjd (arc, observatory=observatory, + date="date-obs", time="ut", exposure="exptime", + jd="jd", hjd="", ljd="ljd", utdate=yes, + uttime=yes, listonly=no, >> log1) + if (fscan (fd3, str1, str2, str3, str4) == 4) + setairmass (arc, intype="beginning", + outtype="effective", exposure="exptime", + observatory=observatory, show=no, + update=yes, override=yes, >> log1) + } + fd3 = ""; delete (temp1, verify=no) + hedit (arc, "refspec1", arc, add=yes, verify=no, + show=no, update=yes) + } + fd2 = "" + sproc.newarcs = no + } + + print ("Assign arc spectra for ", spec) | tee (log1) + refspectra (spec, references=arcrefs, + apertures="", refaps="", ignoreaps=no, + select=sparams.select, sort=sparams.sort, + group=sparams.group, time=sparams.time, + timewrap=sparams.timewrap, override=yes, confirm=no, + assign=yes, logfiles="STDOUT", verbose=no) | + tee (log1, > log2) + + sdoarcs (spec, arcref, reextract, arcap, log1, no) + + hselect (specec, "refspec1", yes, > temp1) + fd2 = temp1 + i = fscan (fd2, arc) + fd2 = ""; delete (temp1, verify=no) + if (i < 1) { + print ("No arc reference assigned for ", spec) | tee (log1) + next + } else { + print ("Dispersion correct ", spec) | tee (log1) + dispcor (specec, "", linearize=sparams.linearize, + database=database, table=arcref//ectype, + w1=INDEF, w2=INDEF, dw=INDEF, nw=INDEF, log=sparams.log, + flux=sparams.flux, global=no, ignoreaps=no, confirm=no, + listonly=no, logfile=logfile) + hedit (specec, "dc-flag", 0, add=yes, show=no, + verify=no, update=yes) + } + } + + if (j < 2 || !access ("std")) { + print ("Compile standard star fluxes for ", spec) | tee (log1) + standard (specec, output="std", samestar=yes, beam_switch=no, + apertures="", bandwidth=sparams.bandwidth, + bandsep=sparams.bandsep, fnuzero=3.68E-20, + extinction=extinction, caldir=caldir, + observatory=observatory, interact=sparams.s_interact) + hedit (specec, "std-flag", "yes", add=yes, verify=no, + show=no, update=yes) + print (specec, >> temp2) + sproc.newsens = yes + } + } + fd1 = "" + + sections ("sens.????"//imtype, option="nolist") + if (sproc.newsens || sections.nimages == 0) { + if (!access ("std")) { + print ("No standard star data") | tee (log1) + sproc.fluxcal1 = no + } else { + imdelete ("sens.????"//imtype, verify=no) + print ("Compute sensitivity function") | tee (log1) + sensfunc ("std", "sens", apertures="", ignoreaps=no, + logfile=logfile, extinction=extinction, + newextinction="extinct.dat", observatory=observatory, + function=sparams.s_function, order=sparams.s_order, + interactive=yes, graphs="sr", marks="plus cross box") + sproc.newsens = yes + } + } + + # Note that if new standard stars are added the old standard + # stars are not recalibrated unless the redo flag is used. + + if (sproc.fluxcal1 && sproc.newsens) { + print ("Flux and/or extinction calibrate standard stars") | + tee (log1) + calibrate ("@"//temp2, "", extinct=extcor, flux=sproc.fluxcal1, + extinction=extinction, observatory=observatory, ignoreaps=no, + sensitivity="sens", fnu=sparams.fnu) | tee (log1, > log2) + if (sproc.splot1) { + print ("Standard stars:") + str1 = sproc.anssplot + if (str1 == "NO" || str1 == "YES") + sproc.splot1 = no + if (str1 == "no" || str1 == "NO") + sproc.splot2 = no + else + sproc.splot2 = yes + } + if (sproc.splot2) + splot ("@"//temp2) + sections (temp2, option="fullname", >> done) + delete (temp2, verify=no) + } +end diff --git a/noao/imred/src/doecslit/sfluxcal.par b/noao/imred/src/doecslit/sfluxcal.par new file mode 100644 index 00000000..b750d265 --- /dev/null +++ b/noao/imred/src/doecslit/sfluxcal.par @@ -0,0 +1,16 @@ +stds,s,a,,,, +arcs,s,a,,,, +arcref,f,a,"",,, +arcrefs,s,a,,,, +redo,b,a,,,, +update,b,a,,,, +scattered,b,a,,,, +arcap,b,a,,,, +extcor,b,a,,,, +done,f,a,"",,, +log1,f,a,"",,, +log2,f,a,"",,, +fd1,*struct,h,"",,, +fd2,*struct,h,"",,, +fd3,*struct,h,"",,, +mode,s,h,"q",,, diff --git a/noao/imred/src/doecslit/sgetspec.cl b/noao/imred/src/doecslit/sgetspec.cl new file mode 100644 index 00000000..7038dcb2 --- /dev/null +++ b/noao/imred/src/doecslit/sgetspec.cl @@ -0,0 +1,177 @@ +# SGETSPEC -- Get spectra which are CCD processed and not extracted. +# This task also recognizes the arc spectra in the object list and arc table. +# This task also strips the image type extension. + +procedure sgetspec (objects, arcs, arctable, standards, obj, arc, std) + +string objects {prompt="List of object images"} +string arcs {prompt="List of arc images"} +file arctable {prompt="Arc table"} +string standards {prompt="List of standard images"} +file obj {prompt="File of object images"} +file arc {prompt="File of arc images"} +file std {prompt="File of standard images"} +bool ccdproc {prompt="Add CCDPROC keyword and continue?", + mode="q"} +struct *fd1, *fd2 + +begin + string imtype, temp, image, itype + int n, n1, narcs + + imtype = "." // envget ("imtype") + n = stridx (",", imtype) + if (n > 0) + imtype = substr (imtype, 1, n-1) + n1 = strlen (imtype) + + temp = mktemp ("tmp$iraf") + + # Initialize files + set clobber=yes + sleep (> obj) + sleep (> arc) + sleep (> std) + set clobber=no + + # Do arcs + narcs = 0 + sections (arcs, option="fullname", > temp) + fd1 = temp + while (fscan (fd1, image) != EOF) { + hselect (image, "ccdproc", yes) | scan (itype) + if (nscan() == 0) { + printf ("%s: CCDPROC keyword not found.\n", image) + printf (" Either run CCDPROC or add CCDPROC keyword with HEDIT.\n") + if (!ccdproc) + error (1, "Exit") + hedit (image, "ccdproc", "DOSLIT", add=yes, update=yes, + verify=no, show=no) + } + hselect (image, "wat0_001", yes) | scanf ("system=%s", itype) + if (itype == "equispec" || itype == "multispec") + next + hselect (image, "imagetyp", yes) | scan (itype) + if (nscan() == 0) + itype = "comp" + if (itype != "comp" && itype != "COMPARISON" && + itype != "comparison" && itype != "COMP") + next + n = strlen (image) + if (n > n1 && substr (image, n-n1+1, n) == imtype) + image = substr (image, 1, n-n1) + narcs = narcs + 1 + printf ("%s %02d\n", image, narcs, >> arc) + } + fd1 = ""; delete (temp, verify=no) + + # Do arc table. + if (arctable != "") { + fd2 = arctable + while (fscan (fd2, image, image) != EOF) { + if (nscan() != 2) + next + sections (image, option="fullname", > temp) + fd1 = temp + while (fscan (fd1, image) != EOF) { + hselect (image, "ccdproc", yes) | scan (itype) + if (nscan() == 0) { + printf ("%s: CCDPROC keyword not found.\n", image) + printf (" Either run CCDPROC or add CCDPROC keyword with HEDIT.\n") + if (!ccdproc) + error (1, "Exit") + hedit (image, "ccdproc", "DOSLIT", add=yes, update=yes, + verify=no, show=no) + } + hselect (image, "wat0_001", yes) | scanf ("system=%s", itype) + if (itype == "equispec" || itype == "multispec") + next + hselect (image, "imagetyp", yes) | scan (itype) + if (nscan() == 0) + itype = "comp" + if (itype != "comp" && itype != "COMPARISON" && + itype != "comparison" && itype != "COMP") + next + n = strlen (image) + if (n > n1 && substr (image, n-n1+1, n) == imtype) + image = substr (image, 1, n-n1) + narcs = narcs + 1 + printf ("%s %02d\n", image, narcs, >> arc) + } + fd1 = ""; delete (temp, verify=no) + } + } + + # Do standards + sections (standards, option="fullname", > temp) + fd1 = temp + while (fscan (fd1, image) != EOF) { + hselect (image, "ccdproc", yes) | scan (itype) + if (nscan() == 0) { + printf ("%s: CCDPROC keyword not found.\n", image) + printf (" Either run CCDPROC or add CCDPROC keyword with HEDIT.\n") + if (!ccdproc) + error (1, "Exit") + hedit (image, "ccdproc", "DOSLIT", add=yes, update=yes, + verify=no, show=no) + } + hselect (image, "wat0_001", yes) | scanf ("system=%s", itype) + if (itype == "equispec" || itype == "multispec") + next + n = strlen (image) + if (n > n1 && substr (image, n-n1+1, n) == imtype) + image = substr (image, 1, n-n1) + print (image, >> std) + } + fd1 = ""; delete (temp, verify=no) + + # Do objects + sections (objects, option="fullname", > temp) + fd1 = temp + while (fscan (fd1, image) != EOF) { + hselect (image, "ccdproc", yes) | scan (itype) + if (nscan() == 0) { + printf ("%s: CCDPROC keyword not found.\n", image) + printf (" Either run CCDPROC or add CCDPROC keyword with HEDIT.\n") + if (!ccdproc) + error (1, "Exit") + hedit (image, "ccdproc", "DOSLIT", add=yes, update=yes, + verify=no, show=no) + } + hselect (image, "wat0_001", yes) | scanf ("system=%s", itype) + if (itype == "equispec" || itype == "multispec") + next + hselect (image, "imagetyp", yes) | scan (itype) + if (nscan() == 0) + itype = "object" + + n = strlen (image) + if (n > n1 && substr (image, n-n1+1, n) == imtype) + image = substr (image, 1, n-n1) + if (itype == "object" || itype == "OBJECT") + print (image, >> obj) + else if (itype == "comp" || itype == "COMPARISON" || + itype == "comparison" || itype == "COMP") { + narcs = narcs + 1 + printf ("%s %02d\n", image, narcs, >> arc) + } + } + fd1 = ""; delete (temp, verify=no) + + if (narcs > 0) { + sort (arc, column=0, ignore=yes, numeric=no, reverse=no, > temp) + delete (arc, verify=no) + rename (temp, arc, field="all") + itype = "" + fd1 = arc + while (fscan (fd1, image, narcs) != EOF) { + if (image != itype) + printf ("%s %02d\n", image, narcs, >> temp) + itype = image + } + delete (arc, verify=no) + sort (temp, column=2, ignore=yes, numeric=yes, reverse=no) | + fields ("STDIN", "1", lines="1-99", > arc) + delete (temp, verify=no) + } +end diff --git a/noao/imred/src/doecslit/sgetspec.par b/noao/imred/src/doecslit/sgetspec.par new file mode 100644 index 00000000..1f5387cc --- /dev/null +++ b/noao/imred/src/doecslit/sgetspec.par @@ -0,0 +1,11 @@ +objects,s,a,,,,"List of object images" +arcs,s,a,,,,"List of arc images" +arctable,f,a,"",,,"Arc table" +standards,s,a,,,,"List of standard images" +obj,f,a,"",,,"File of object images" +arc,f,a,"",,,"File of arc images" +std,f,a,"",,,"File of standard images" +ccdproc,b,q,,,,"Add CCDPROC keyword and continue?" +fd1,*struct,h,"",,, +fd2,*struct,h,"",,, +mode,s,h,"ql",,, diff --git a/noao/imred/src/doecslit/slistonly.cl b/noao/imred/src/doecslit/slistonly.cl new file mode 100644 index 00000000..f765af36 --- /dev/null +++ b/noao/imred/src/doecslit/slistonly.cl @@ -0,0 +1,241 @@ +# SLISTONLY -- List processing to be done. +# +# This follows pretty much the same logic as the full procedure but doesn't +# do anything but list the operations. + +procedure slistonly (objects, apref, arcs, standards, scattered, dispcor, + extcor, fluxcal, redo, update) + +string objects +file apref +string arcs +string standards + +bool scattered +bool dispcor +bool extcor +bool fluxcal +bool redo +bool update + +struct *fd1 +struct *fd2 + +begin + string imtype, ectype + string spec, arcref + string specec, arcrefec + string temp1, temp2, done, str + bool newaps, newdisp, newsens + bool extract, disp, ext, flux, scat, reextract, fluxcal1, stdfile + int i, j, n + + imtype = "." // envget ("imtype") + i = stridx (",", imtype) + if (i > 0) + imtype = substr (imtype, 1, i-1) + ectype = ".ec" // imtype + n = strlen (imtype) + + temp1 = mktemp ("tmp$iraf") + temp2 = mktemp ("tmp$iraf") + done = mktemp ("tmp$iraf") + + newaps = no + newdisp = no + newsens = no + fluxcal1 = fluxcal + + i = strlen (apref) + if (i > n && substr (apref, i-n+1, i) == imtype) + apref = substr (apref, 1, i-n) + + reextract = redo + if (reextract || !access (database // "/ap" // apref)) { + print ("Set reference aperture for ", apref) + newaps = yes + } + + scat = no + if (scattered) { + hselect (apref, "apscatte", yes, > temp1) + fd1 = temp1 + if (fscan (fd1, str1) < 1) + scat = yes + fd1 = ""; delete (temp1, verify=no) + } + if (scat) + print ("Subtract scattered light in ", apref) | tee (log1) + + if (dispcor) { + hselect (arcs, "$I,wat0_001", yes, > temp1) + fd1 = temp1; s1 = "" + i = fscanf (fd1, "%s\tsystem=%s", arcref, s1) + if (i < 1 || (i == 2 && (s1 == "equispec" || s1 == "multispec"))) + error (1, "No reference arcs") + fd1 = ""; delete (temp1, verify=no) + i = strlen (arcref) + if (i > n && substr (arcref, i-n+1, i) == imtype) + arcref = substr (arcref, 1, i-n) + arcrefec = arcref // ectype + + reextract = redo || (update && newaps) + if (reextract || !access (arcrefec)) { + print ("Extract arc reference image ", arcref) + print ("Determine dispersion solution for ", arcref) + newdisp = yes + } else { + hselect (arcrefec, "refspec1,dc-flag", yes, > temp1) + fd1 = temp1 + i = fscan (fd1, str, j) + fd1 = ""; delete (temp1, verify=no) + if (i < 1) { + print ("Determine dispersion solution for ", arcref) + newdisp = yes + } + } + print (arcref, > done) + + if (fluxcal1) { + stdfile = access ("std") + if (redo && stdfile) + stdfile = no + + reextract = redo || (update && (newaps || newdisp)) + hselect (standards, "$I,ctype1", yes, >temp1) + fd1 = temp1 + while (fscan (fd1, spec, s1) != EOF) { + if (nscan() == 2 && s1 == "MULTISPE") + next + i = strlen (spec) + if (i > n && substr (spec, i-n+1, i) == imtype) + spec = substr (spec, 1, i-n) + specec = spec // ectype + + scat = no + if (scattered) { + hselect (spec, "apscatte", yes, > temp2) + fd2 = temp2 + if (fscan (fd2, str) < 1) + scat = yes + fd2 = ""; delete (temp2, verify=no) + } + if (reextract || !access (specec) || (update && scat)) { + if (scat) + print ("Subtract scattered light from ", spec) + print ("Extract standard star spectrum ", spec) + print ("Dispersion correct ", spec) + print ("Compile standard star fluxes for ", spec) + stdfile = yes + newsens = yes + } else { + hselect (specec, "dc-flag,std-flag", yes, > temp2) + fd2 = temp2 + i = fscan (fd2, str1, str2) + fd2 = ""; delete (temp2, verify=no) + if (i < 1) + print ("Dispersion correct ", spec) + if (i < 2) { + print ("Compile standard star fluxes for ", spec) + stdfile = yes + newsens = yes + } + } + print (spec, >> done) + } + fd1 = ""; delete (temp1, verify=no) + + sections ("sens.????"//imtype, option="nolist") + if (newsens || sections.nimages == 0) { + if (!stdfile) { + print ("No standard stars") + fluxcal1 = no + } else { + print ("Compute sensitivity function") + newsens = yes + } + } + + if (fluxcal1 && newsens) + print ("Flux and/or extinction calibrate standard stars") + } + } + + reextract = redo || (update && (newaps || newdisp)) + hselect (objects, "$I,ctype1", yes, > temp1) + fd1 = temp1 + while (fscan (fd1, spec, s1) != EOF) { + if (nscan() == 2 && s1 == "MULTISPE") + next + if (i > n && substr (spec, i-n+1, i) == imtype) + spec = substr (spec, 1, i-n) + + if (access (done)) { + fd2 = done + while (fscan (fd2, specec) != EOF) + if (spec == specec) + break + if (spec == specec) + next + fd2 = "" + } + + specec = spec // ectype + + scat = no + extract = no + disp = no + ext = no + flux = no + if (scattered) { + hselect (spec, "apscatte", yes, > temp2) + fd2 = temp2 + if (fscan (fd2, str) < 1) + scat = yes + fd2 = ""; delete (temp2, verify=no) + } + if (reextract || !access (specec) || (update && scat)) { + extract = yes + } else { + hselect (specec, "dc-flag", yes, > temp2) + hselect (specec, "ex-flag", yes, >> temp2) + hselect (specec, "ca-flag", yes, >> temp2) + fd2 = temp2 + extract = update && newaps + if (fscan (fd2, str1) == 1) + extract = update && newdisp + else + disp = yes + if (fscan (fd2, str1) == 1) + extract = update && !extcor + else + ext = extcor + if (fscan (fd2, str1) == 1) + extract = update && (!fluxcal1 || newsens) + else + flux = fluxcal1 + fd2 = ""; delete (temp2, verify=no) + } + + if (extract) { + disp = dispcor + ext = extcor + flux = fluxcal1 + } + + if (scat) + print ("Subtract scattered light from ", spec) + if (extract) + print ("Extract object spectrum ", spec) + if (disp) + print ("Dispersion correct ", spec) + if (ext) + print ("Extinction correct ", spec) + if (flux) + print ("Flux calibrate ", spec) + } + fd1 = ""; delete (temp1, verify=no) + + if (access (done)) + delete (done, verify=no) +end diff --git a/noao/imred/src/doecslit/slistonly.par b/noao/imred/src/doecslit/slistonly.par new file mode 100644 index 00000000..f0986d61 --- /dev/null +++ b/noao/imred/src/doecslit/slistonly.par @@ -0,0 +1,13 @@ +objects,s,a,,,, +apref,f,a,"",,, +arcs,s,a,,,, +standards,s,a,,,, +scattered,b,a,,,, +dispcor,b,a,,,, +extcor,b,a,,,, +fluxcal,b,a,,,, +redo,b,a,,,, +update,b,a,,,, +fd1,*struct,h,"",,, +fd2,*struct,h,"",,, +mode,s,h,"q",,, diff --git a/noao/imred/src/doecslit/slittasks.cl b/noao/imred/src/doecslit/slittasks.cl new file mode 100644 index 00000000..ada92452 --- /dev/null +++ b/noao/imred/src/doecslit/slittasks.cl @@ -0,0 +1,19 @@ +#{ ECSLITPROC tasks + +task doecslit = "doecslit$doecslit.cl" +task sproc = "doecslit$sproc.cl" +task sarcrefs = "doecslit$sarcrefs.cl" +task sdoarcs = "doecslit$sdoarcs.cl" +task sfluxcal = "doecslit$sfluxcal.cl" +task sbatch = "doecslit$sbatch.cl" +task slistonly = "doecslit$slistonly.cl" +task sgetspec = "doecslit$sgetspec.cl" + +task sparams = "doecslit$sparams.par" + +task apslitproc = "doecslit$x_apextract.e" + +hidetask sproc, sbatch, sarcrefs, sdoarcs, sfluxcal, slistonly, sgetspec +hidetask sparams, apslitproc + +keep diff --git a/noao/imred/src/doecslit/sparams.par b/noao/imred/src/doecslit/sparams.par new file mode 100644 index 00000000..62868ed8 --- /dev/null +++ b/noao/imred/src/doecslit/sparams.par @@ -0,0 +1,65 @@ +line,i,h,INDEF,,,"Default dispersion line" +nsum,i,h,10,,,"Number of dispersion lines to sum or median" +extras,b,h,no,,,"Extract sky, sigma, etc.? + +-- AUTOMATIC APERTURE RESIZING PARAMETERS --" +ylevel,r,h,0.05,,,"Fraction of peak or intensity for resizing + +-- TRACE PARAMETERS --" +t_step,i,h,10,,,"Tracing step" +t_function,s,h,"spline3","chebyshev|legendre|spline1|spline3",,"Trace fitting function" +t_order,i,h,2,,,"Trace fitting function order" +t_niterate,i,h,1,0,,"Trace rejection iterations" +t_low,r,h,3.,0.,,"Trace lower rejection sigma" +t_high,r,h,3.,0.,,"Trace upper rejection sigma + +-- BACKGROUND AND SCATTERED LIGHT PARAMETERS --" +b_function,s,h,"legendre","chebyshev|legendre|spline1|spline3",,Background function +b_order,i,h,1,,,Background function order +b_naverage,i,h,-100,,,Background average or median +b_niterate,i,h,0,0,,Background rejection iterations +b_low,r,h,3.,0.,,Background lower rejection sigma +b_high,r,h,3.,0.,,Background upper rejection sigma +buffer,r,h,1.,0.,,Buffer distance from apertures +apscat1,pset,h,"",,,Fitting parameters across the dispersion +apscat2,pset,h,"",,,"Fitting parameters along the dispersion + +-- APERTURE EXTRACTION PARAMETERS --" +weights,s,h,"none","none|variance",,Extraction weights (none|variance) +pfit,s,h,"fit1d","fit1d|fit2d",,Profile fitting algorithm (fit1d|fit2d) +lsigma,r,h,3.,,,Lower rejection threshold +usigma,r,h,3.,,,"Upper rejection threshold + +-- ARC DISPERSION FUNCTION PARAMETERS --" +threshold,r,h,10.,0.,,"Minimum line contrast threshold" +coordlist,f,h,linelists$thar.dat,,,"Line list" +match,r,h,1.,,,"Line list matching limit in Angstroms" +fwidth,r,h,4,,,"Arc line widths in pixels" +cradius,r,h,10.,,,"Centering radius in pixels" +i_function,s,h,"legendre","legendre|chebyshev",,"Echelle coordinate function" +i_xorder,i,h,3,1,,Order of coordinate function along dispersion +i_yorder,i,h,3,1,,Order of coordinate function across dispersion +i_niterate,i,h,3,0,,"Rejection iterations" +i_low,r,h,3.,0.,,"Lower rejection sigma" +i_high,r,h,3.,0.,,"Upper rejection sigma" +refit,b,h,yes,,,"Refit coordinate function when reidentifying + +-- AUTOMATIC ARC ASSIGNMENT PARAMETERS --" +select,s,h,"interp",,,"Selection method for reference spectra" +sort,s,h,"jd",,,"Sort key" +group,s,h,"ljd",,,"Group key" +time,b,h,no,,,"Is sort key a time?" +timewrap,r,h,17.,0.,24.,"Time wrap point for time sorting + +-- DISPERSION CORRECTION PARAMETERS --" +linearize,b,h,yes,,,Linearize (interpolate) spectra? +log,b,h,no,,,"Logarithmic wavelength scale?" +flux,b,h,yes,,,"Conserve flux? + +-- SENSITIVITY CALIBRATION PARAMETERS --" +bandwidth,r,h,10.,,,Bandpass widths +bandsep,r,h,10.,,,Bandpass separation +s_interact,b,h,yes,,,Graphic interaction to examine/define bandpasses +s_function,s,h,"spline3","chebyshev|legendre|spline3|spline1",,"Fitting function" +s_order,i,h,1,1,,"Order of sensitivity function" +fnu,b,h,no,,,"Create spectra having units of FNU?" diff --git a/noao/imred/src/doecslit/sproc.cl b/noao/imred/src/doecslit/sproc.cl new file mode 100644 index 00000000..8caeadd9 --- /dev/null +++ b/noao/imred/src/doecslit/sproc.cl @@ -0,0 +1,490 @@ +# SPROC -- Process echelle slit spectra +# This program combines all the operations of scattered light +# subtraction, extraction, dispersion correction, extinction correction, +# and flux calibration in as simple and noninteractive manner as +# possible. The data must all share the same position on the 2D image +# and the same dispersion solution apart from small instrumental changes +# which can be followed automatically. + +procedure sproc (objects, apref, arcs, arctable, standards, recenter, + resize, quicklook, trace, scattered, arcap, dispcor, extcor, + fluxcal, splot, redo, update, batch, listonly) + +file objects {prompt="List of object spectra"} + +file apref {prompt="Aperture reference spectrum"} +file arcs {prompt="List of arc spectra"} +file arctable {prompt="Arc assignment table (optional)"} +file standards {prompt="List of standard star spectra\n"} + +bool recenter {prompt="Recenter object apertures?"} +bool resize {prompt="Resize object apertures?"} +bool quicklook {prompt="Edit/review object apertures?"} +bool trace {prompt="Trace object spectra?"} +bool scattered {prompt="Subtract scattered light?"} +bool arcap {prompt="Use object apertures for arcs?"} +bool dispcor {prompt="Dispersion correct spectra?"} +bool extcor {prompt="Extinction correct spectra?"} +bool fluxcal {prompt="Flux calibrate spectra?"} +bool splot {prompt="Plot the final spectrum?"} +bool redo {prompt="Redo operations if previously done?"} +bool update {prompt="Update spectra if cal data changes?"} +bool batch {prompt="Extract objects in batch?"} +bool listonly {prompt="List steps but don't process?\n"} + +real datamax = INDEF {prompt="Max data value / cosmic ray threshold"} + +string anssplot = "yes" {prompt="Splot spectrum?", mode="q", + enum="no|yes|NO|YES"} +bool newaps, newdisp, newsens, newarcs +bool fluxcal1, splot1, splot2 +bool dobatch + +struct *fd1, *fd2, *fd3 + +begin + string imtype, ectype + string arcref, spec, arc + string arcrefec, specec, arcec + string temp, done + string str1, str2, str3, str4, arcrefs, log1, log2 + bool reextract, extract, scat, disp, ext, flux, log, disperr + int i, j, n + struct err + str1 = "" + + # Call a separate task to do the listing to minimize the size of + # this script and improve it's readability. + + dobatch = no + if (listonly) { + slistonly (objects, apref, arcs, standards, scattered, + dispcor, extcor, fluxcal, redo, update) + bye + } + + imtype = "." // envget ("imtype") + i = stridx (",", imtype) + if (i > 0) + imtype = substr (imtype, 1, i-1) + ectype = ".ec" // imtype + n = strlen (imtype) + + # Temporary files used repeatedly in this script. Under some + # abort circumstances these files may be left behind. + + temp = mktemp ("tmp$iraf") + done = mktemp ("tmp$iraf") + + # Rather than always have switches on the logfile and verbose flags + # we use TEE and set a file to "dev$null" if output is not desired. + # We must check for the null string to signify no logfile. + + tee.append = yes + if (logfile == "") + log1 = "dev$null" + else + log1 = logfile + if (verbose) + log2 = "STDOUT" + else + log2 = "dev$null" + + # If the update switch is used changes in the calibration data + # can cause images to be reprocessed (if they are in the object + # list). Possible changes are in the aperture definitions, + # dispersion solution, and sensitivity function. The newarcs + # flag is used to only go through the arc image headers once + # setting the reference spectrum, airmass, and UT. + + newaps = no + newdisp = no + newsens = no + newarcs = yes + fluxcal1 = fluxcal + + # Check if there are aperture definitions in the database and + # define them if needed. This is usually somewhat interactive. + # Set the newaps flag in case an update is desired. + + # Initialize APSCRIPT for aperture reference. + apslitproc.saturation = INDEF + apslitproc.references = "" + apslitproc.ansfind = "YES" + if (recenter) + apslitproc.ansrecenter = "YES" + else + apslitproc.ansrecenter = "NO" + if (resize) + apslitproc.ansresize = "YES" + else + apslitproc.ansresize = "NO" + apslitproc.ansedit = "yes" + apslitproc.anstrace = "YES" + apslitproc.ansfittrace = "yes" + apslitproc.ansextract = "NO" + + i = strlen (apref) + if (i > n && substr (apref, i-n+1, i) == imtype) + apref = substr (apref, 1, i-n) + + reextract = redo + if (reextract || !access (database // "/ap" // apref)) { + if (!access (apref // imtype)) { + printf ("Aperture reference spectrum not found - %s%s\n", + apref, imtype) | scan (err) + error (1, err // "\nCheck setting of imtype") + } + scat = no + if (scattered) { + hselect (apref, "apscatte", yes, > temp) + fd1 = temp + if (fscan (fd1, str1) < 1) + scat = yes + fd1 = ""; delete (temp, verify=no) + } + + print ("Set reference aperture for ", apref) | tee (log1) + delete (database//"/ap"//apref, verify=no, >& "dev$null") + apslitproc (apref) + newaps = yes + } + + # Initialize APSCRIPT for aperture definitions. + if (quicklook) { + apslitproc.ansedit = "NO" + apslitproc.ansfittrace = "NO" + } + if (trace) { + apslitproc.anstrace = "yes" + } else { + apslitproc.anstrace = "NO" + } + apslitproc.ansextract = "NO" + apslitproc.ansscat = "NO" + + print ("Define object apertures", >> log1) + if (redo) + apslitproc ("@"//objects, references=apref) + else + apslitproc ("@"//objects, references="NEW"//apref) + if (dispcor && fluxcal1) { + if (redo) + apslitproc ("@"//standards, references=apref) + else + apslitproc ("@"//standards, references="NEW"//apref) + } + + # Initialize APSCRIPT for extraction and SPLOT. + apslitproc.ansrecenter = "NO" + apslitproc.ansresize = "NO" + apslitproc.ansedit = "NO" + apslitproc.anstrace = "NO" + apslitproc.ansextract = "YES" + apslitproc.ansreview = "NO" + apslitproc.ansscat = "NO" + apslitproc.anssmooth = "YES" + + if (splot && !quicklook) { + splot1 = yes + splot2 = yes + } else { + splot1 = no + splot2 = no + } + + # The next step is to setup the scattered light correction if needed. + # We use the aperture reference image for the interactive setting. + # If this image has been scattered light corrected we assume the + # scattered light functions parameters are correctly set. + + scat = no + if (scattered) { + hselect (apref, "apscatte", yes, > temp) + fd1 = temp + if (fscan (fd1, str1) < 1) + scat = yes + fd1 = ""; delete (temp, verify=no) + } + if (scat) { + print ("Setup and do scattered light subtraction in ", apref) | + tee (log1) + apslitproc.ansfitscatter = "yes" + apslitproc.ansfitsmooth = "yes" + apslitproc (apref, ansextract="NO", ansscat="YES") + apslitproc.ansfitscatter = "NO" + apslitproc.ansfitsmooth = "NO" + } + + # If not dispersion correcting we can go directly to extracting + # the object spectra. The reference arcs are the first on + # the arc lists. The processing of the reference arcs is done + # by the task ARCREFS. + + arcref = "" + arcrefs = "" + if (dispcor) { + if (arctable == "") + arcrefs = "@"//arcs + else + arcrefs = arctable + + fd1 = arcs + if (fscan (fd1, arcref) == EOF) + error (1, "No reference arcs") + fd1 = "" + if (!access (arcref // imtype)) { + printf ("Arc reference spectrum not found - %s%s\n", + arcref, imtype) | scan (err) + error (1, err // "\nCheck setting of imtype") + } + arcrefec = arcref // ectype + reextract = redo || (update && newaps) + if (reextract && access (arcrefec)) + imdelete (arcrefec, verify=no) + + apslitproc.references = apref + sarcrefs (arcref, done, log1, log2) + apslitproc.references = "" + + if (fluxcal1) + sfluxcal (standards, arcs, arcref, arcrefs, redo, update, + scattered, arcap, extcor, done, log1, log2) + } + + # Now we are ready to process the object spectra. + + reextract = redo || (update && (newaps || newdisp)) + fd1 = objects + while (fscan (fd1, spec) != EOF) { + # Check if previously done; i.e. arc. + if (access (done)) { + fd2 = done + while (fscan (fd2, specec) != EOF) + if (spec == specec) + break + if (spec == specec) + next + fd2 = "" + } + if (!access (spec // imtype)) { + printf ("Object spectrum not found - %s%s\n", + spec, imtype) | scan (err) + print (err) | tee (log1) + print ("Check setting of imtype") + next + } + specec = spec // ectype + + # Determine required operations from the flags and image header. + scat = no + extract = no + disp = no + ext = no + flux = no + if (scattered) { + hselect (spec, "apscatte", yes, > temp) + fd2 = temp + if (fscan (fd2, str1) < 1) + scat = yes + fd2 = ""; delete (temp, verify=no) + } + if (reextract || !access (specec) || (update && scat)) + extract = yes + else { + hselect (specec, "dc-flag", yes, > temp) + hselect (specec, "ex-flag", yes, >> temp) + hselect (specec, "ca-flag", yes, >> temp) + fd2 = temp + if (fscan (fd2, str1) == 1) { + extract = update && newdisp + if (update && !newdisp) + # We really should check if REFSPEC will assign + # different reference spectra. + ; + } else + disp = dispcor + if (fscan (fd2, str1) == 1) + extract = update && !extcor + else + ext = extcor + if (fscan (fd2, str1) == 1) + extract = update && (!fluxcal1 || newsens) + else + flux = fluxcal1 + fd2 = ""; delete (temp, verify=no) + } + + if (extract) { + disp = dispcor + ext = extcor + flux = fluxcal1 + } + + # If fully processed go to the next object. + if (!extract && !disp && !extcor && !flux) + next + + # If not interactive and the batch flag is set submit rest to batch. + if (batch && !splot1 && !splot2) { + fd1 = "" + flprcache + sbatch.objects = objects + sbatch.datamax = datamax + sbatch.arcs = arcs + sbatch.arcref = arcref + sbatch.arcrefs = arcrefs + sbatch.done = done + sbatch.logfile = log1 + sbatch.redo = reextract + sbatch.update = update + sbatch.scattered = scattered + sbatch.arcap = arcap + sbatch.dispcor = dispcor + sbatch.fluxcal1 = fluxcal1 + sbatch.extcor = extcor + sbatch.newaps = newaps + sbatch.newdisp = newdisp + sbatch.newsens = newsens + sbatch.newarcs = newarcs + dobatch = yes + return + } + + # Process the spectrum in foreground. + if (extract) { + if (access (specec)) + imdelete (specec, verify=no) + + if (scat) { + print ("Subtract scattered light in ", spec) | tee (log1) + apslitproc (spec, ansextract="NO", ansscat="YES") + } + + print ("Extract object spectrum ", spec) | tee (log1) + hselect (spec, "date-obs,ut,exptime", yes, > temp) + hselect (spec, "ra,dec,epoch,st", yes, >> temp) + fd2 = temp + if (fscan (fd2, str1, str2, str3) == 3) { + setjd (spec, observatory=observatory, date="date-obs", + time="ut", exposure="exptime", jd="jd", hjd="", + ljd="ljd", utdate=yes, uttime=yes, listonly=no, + >> log1) + if (fscan (fd2, str1, str2, str3, str4) == 4) + setairmass (spec, intype="beginning", + outtype="effective", exposure="exptime", + observatory=observatory, show=no, update=yes, + override=yes, >> log1) + } + fd2 = ""; delete (temp, verify=no) + apslitproc (spec, saturation=datamax) + } + + disperr = no + if (disp) { + # Fix arc headers if necessary. + if (newarcs) { + fd2 = arcs + while (fscan (fd2, arc) != EOF) { + hselect (arc, "date-obs,ut,exptime", yes, > temp) + hselect (arc, "ra,dec,epoch,st", yes, >> temp) + fd3 = temp + if (fscan (fd3, str1, str2, str3) == 3) { + setjd (arc, observatory=observatory, + date="date-obs", time="ut", exposure="exptime", + jd="jd", hjd="", ljd="ljd", utdate=yes, + uttime=yes, listonly=no, >> log1) + if (fscan (fd3, str1, str2, str3, str4) == 4) + setairmass (arc, intype="beginning", + outtype="effective", exposure="exptime", + observatory=observatory, show=no, + update=yes, override=yes, >> log1) + } + fd3 = ""; delete (temp, verify=no) + hedit (arc, "refspec1", arc, add=yes, verify=no, + show=no, update=yes) + } + fd2 = "" + newarcs = no + } + + print ("Assign arc spectra for ", spec) | tee (log1) + refspectra (spec, references=arcrefs, + apertures="", refaps="", ignoreaps=no, + select=sparams.select, sort=sparams.sort, + group=sparams.group, time=sparams.time, + timewrap=sparams.timewrap, override=yes, confirm=no, + assign=yes, logfiles="STDOUT", verbose=no) | + tee (log1, > log2) + + sdoarcs (spec, arcref, reextract, arcap, log1, no) + + hselect (specec, "refspec1", yes, > temp) + fd2 = temp + i = fscan (fd2, arc) + fd2 = ""; delete (temp, verify=no) + if (i < 1) { + print ("No arc reference assigned for ", spec) | tee (log1) + disperr = yes + } else { + print ("Dispersion correct ", spec) | tee (log1) + dispcor (specec, "", linearize=sparams.linearize, + database=database, table=arcref//ectype, + w1=INDEF, w2=INDEF, dw=INDEF, nw=INDEF, + log=sparams.log, flux=sparams.flux, samedisp=no, + global=no, confirm=no, ignoreaps=no, listonly=no, + logfile=logfile) + hedit (specec, "dc-flag", 0, add=yes, show=no, + verify=no, update=yes) + } + } + + if (!disperr && (extract || disp)) { + if (ext) + print ("Extinction correct ", spec) | tee (log1) + if (flux) + print ("Flux calibrate ", spec) | tee (log1) + if (flux || ext) + calibrate (specec, "", extinct=extcor, flux=fluxcal1, + extinction=extinction, observatory=observatory, + ignoreaps=no, sensitivity="sens", fnu=sparams.fnu) | + tee (log1, > log2) + } + if (extract || disp || ext || flux) { + if (splot1) { + print (specec, ":") + str1 = anssplot + if (str1 == "NO" || str1 == "YES") + splot1 = no + if (str1 == "no" || str1 == "NO") + splot2 = no + else + splot2 = yes + } + if (splot2) + splot (specec) + else if (splot && quicklook) { + if (disp) { + print ("q") | + specplot (specec, apertures="", autolayout=no, + scale=1., offset=0., step=0., sysid=yes, + yscale=yes, xmin=INDEF, xmax=INDEF, ymin=INDEF, + ymax=INDEF, logfile="", graphics="stdgraph", + cursor="STDIN") + } else { + print ("q") | + specplot (specec, apertures="", autolayout=yes, + autoscale=no, scale=1., offset=0., step=0., + sysid=yes, yscale=no, xmin=INDEF, xmax=INDEF, + ymin=INDEF, ymax=INDEF, logfile="", + graphics="stdgraph", cursor="STDIN") + } + } + } + print (spec, >> done) + } + fd1 = "" + + if (access (done)) + delete (done, verify=no) +end diff --git a/noao/imred/src/doecslit/sproc.par b/noao/imred/src/doecslit/sproc.par new file mode 100644 index 00000000..a0ecbd0c --- /dev/null +++ b/noao/imred/src/doecslit/sproc.par @@ -0,0 +1,35 @@ +objects,f,a,"",,,"List of object spectra" +apref,f,a,"",,,"Aperture reference spectrum" +arcs,f,a,"",,,"List of arc spectra" +arctable,f,a,"",,,"Arc assignment table (optional)" +standards,f,a,"",,,"List of standard star spectra +" +recenter,b,a,,,,"Recenter object apertures?" +resize,b,a,,,,"Resize object apertures?" +quicklook,b,a,,,,"Edit/review object apertures?" +trace,b,a,,,,"Trace object spectra?" +scattered,b,a,,,,"Subtract scattered light?" +arcap,b,a,,,,"Use object apertures for arcs?" +dispcor,b,a,,,,"Dispersion correct spectra?" +extcor,b,a,,,,"Extinction correct spectra?" +fluxcal,b,a,,,,"Flux calibrate spectra?" +splot,b,a,,,,"Plot the final spectrum?" +redo,b,a,,,,"Redo operations if previously done?" +update,b,a,,,,"Update spectra if cal data changes?" +batch,b,a,,,,"Extract objects in batch?" +listonly,b,a,,,,"List steps but don\'t process? +" +datamax,r,h,INDEF,,,"Max data value / cosmic ray threshold" +anssplot,s,q,"yes",no|yes|NO|YES,,"Splot spectrum?" +newaps,b,h,,,, +newdisp,b,h,,,, +newsens,b,h,,,, +newarcs,b,h,,,, +fluxcal1,b,h,,,, +splot1,b,h,,,, +splot2,b,h,,,, +dobatch,b,h,,,, +fd1,*struct,h,"",,, +fd2,*struct,h,"",,, +fd3,*struct,h,"",,, +mode,s,h,"ql",,, |