%VERSION:2 62 526 0:ADD_HISTORY_STRING 2336:ARITHM 12978:ASCII2YAAAR 17143:AVGSIG 21827:BAND_2_DET 23117:CHK_DET 25056:CHK_TAG 26686:CUT_AAR 28251:DEFINE_YAAAR 29608:DERED 37140:DERED_CORR 38831:DERED_GETEXT 40495:DISP_AAR 54521:FLUX_CONSERV 58106:GET_HDRKEY 60845:GET_UNIT 62845:GLUE 66627:IS_STRUC 67840:MAKE52 69402:MAKE_DETMASK 71840:MAKEYAAARHEAD 73858:MASK 76317:NORMAL 80779:POINT2EXT 86296:POLYINT 88385:SAP 91008:SAP_ABS 92475:SAP_ADD 94828:SAP_DIV 96936:SAP_EXP 98403:SAP_EXP10 99906:SAP_KEYWORD_SET 101278:SAP_LOG 102782:SAP_LOG10 104329:SAP_MAX 106559:SAP_MEAN 109208:SAP_MIN 111436:SAP_MULT 113570:SAP_REBIN 125987:SAP_RFITS 129269:SAP_SHIFT 133024:SAP_SQRT 134506:SAP_SUB 136625:SAP_WFITS 137915:SCALE_DEFINE 143428:SET_USERSYM 144905:SM_AIRY 148350:SM_BOX 151791:SM_GAUSS 155231:SM_MEDIAN 158822:SPECT_FORM 163132:SQUIT 164781:SYMGEN 166175:SYN_PHOT 184309:TIPPEX 187335:UPDATE_HISTORY 193217:VEL_PROF 198634:WAV_DOP 202484:WAVE_FORM 205628:WRITE2HIST 208132:WRITE_HDRKEY 211623:ZODIACAL ;+ Identifier add_history_string Purpose Add a given string to the history string of a given structure in the format of ISAP history handling Synopsis add_history_string, struct, newstring, xx, stat Arguments Name I/O Type Description ----------------------------------------------------- struct I/O struct The structure containing the history tag to be modified newstring I string The string to be written xx I string The two character code describing the nature of the entry (see description of update_history) stat O integer error status, 0 if ok, 1 if fatal Returns --- Description If history is empty or does not contain an END line fill in the END line. Check if history containes only 80 character lines. If not, fill up with zeros. See if history string will get longer than 32767 characters. If so expand the dimension of the history tag. See if new string is longer than 64 characters and has to be broken. Add new string to history. Comment This routine will usually be called from update_history. To add a string interactively to the history use either update_history or write2hist. Example --- Dependencies CALLS: sap_error CALLED FROM: update_history.pro, write2hist.pro Category ISAP Filename add_history_string.pro Author E. Sturm (--> ES) Version 1.1 History 0.1 26-10-95 ES 1.0 30-11-95 ES V1 delivery 1.1 13-05-96 ES error status added 11-07-96 ES slight modification of stat ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier arithm Purpose Shell for the call to the subroutines which perform spectrum arithmetics or functions on the fluxes/photocurrents in ISAP (LWS/SWS) structures. Invoked by the Widget User Interface or from the ISAP command line. Synopsis struc_out=arithm( algo, in1, [in2] [,band=band] [,det=det] [,/sloppy] [,/weight] [,/stat ) Arguments Name I/O Type Description ----------------------------------------------------- algo I string Operation to be performed in1 I AAR/SPD input structure (first argument) in2 I AAR/SPD/ scalar/ array input (second argument) band I scalar/ Detetctor band(s) to which operation intarr is limited (SWS specific) det I scalar/ Detector(s) to which operation is intarr limited SWS: 1...52 LWS: 0...9 !!!!!!! sloppy I keyword if set, suppress comparison of wavelengths in in1 and in2. Operation is done blindly item by item, ignoring possible fatal consequences weight I keyword if set, mean is weighted with 1./stdev^2 stat I/O int error status, 0 if ok, 1 if fatal Returns structure of kind in1 (see comment) 0 if a fatal error occurs (currently only in GUI mode) Description Does arithmetics on either two similar ISAP structures, or on a structure and a number (applicable to all detectors) or on a structure and an array (LWS: 10 elements, SWS: 52 elements according to the number of detectors in each case). Alternatively, applies a function to an IA structure. Checks if in1 is SWS SPD or LWS/SWS AAR/YAAAR. Checks in2 as well and in addition if scalar or array. If two structures are processed they are checked for same type, same number of data points, and identical reference scale (i.e wavelengths or grating positions). "Identical" means scale1 - scale2 .lt. epsilon with epsilon=1.E-5. Checks also flux and wavelength units (which are defined in the header) and issues a warning if they do not agree. /sloppy relaxes the wavelentgh match, but should be used with care only. If the switch /weight is set "mean" is performed with the inverse of the square of the standard deviations as weights. Weighting with constants (like "(3.*arr1 + 2.*arr2)/5.") can be performed step by step - calling sap_mult, sap_add, and sap_div. After the checks the desired routines (e.g. add) are called with the appropriate parameters. Finally the output structures are constructed. - possible values for algo: 'add', 'sub', 'mult', 'div', 'mean', 'exp', 'exp10', 'log', 'log10', 'sqrt', 'abs', 'min', 'max' . Case insensitve. - possible range for band: 1...6. Vectors (e.g. [1,2,4]) are allowed - possible range for det: 1...52(SWS) or 0...9 (LWS)!!. Vectors are allowed. In case of two input structures the bad data masks (bit 2^30 of flag - set with mask.pro) are simply combined. I.e. if one or both of the two structures contains bad points the opereation is performed normally but the result is flagged as 'bad'. (At the moment only implemented for AARs, not SPDs). Comment 1)The operations are performed automatically on fluxes or photocurrents with wavelengths as reference scale. For the processing of other tags than these arithm would need some additional information. 2)If in2 is an array and you do not specify det or band, data of unused detectors should be 0 for 'add' and 'sub' and 1 for 'mult' and 'div' E.g. in2_array=fltarr(52) in2_array(0:1)=10. out=arithm('add',in1,in2_array) if you specify det or band values in in2_array may be ignorred. E.g. in2_array=fltarr(52) in2_array(0:1)=10. out=arithm('add',in1,in2_array,det=[3,4]) This will do nothing to the data, because in2_array specifies detector 1 and 2 to be modified, but this is overwritten by det=[3,4]. For these two detectors the adding constant is given as 0. 3)Weighting is only meaningful for mean. Therefore SAP_ADD, SAP_SUB, SAP_MULT etc. do not provide for weighting. 4)For SWS SPDs the flux offsets of the several parts of a ramp are currently (first version) NOT taken into account. Hence, spectrum arithmetics in case of SWS SPDs can only be used after RESUM (an SWS IA routine). 5)Rules for the output structure: - if just a constant is added, subtracted etc. then the output structure is the same as the input structure. Only the array on which the operation was performed is replaced. - if two spectra are involved (coaddition, mean etc.) then the contents of the resulting structure are taken from the first spectrum (given through struc_in). The data arrays which were changed (e.g flux and stdev) are replaced. - The processing of the structures is indicated via update_history. 6)If in1 is of type YAAAR it MUST NOT contain other tags than .wave, .flux, .stdev and .flag. In particular this routine expects no .det tags in YAAAR, because the detector counting is different for SWS and LWS. The routine can't know by itself, which kind of counting is necessary. If you want to have an AAR with .det tag, the routine can be modified: if tpye eq 'YAAAR' then type eq 'SAAR'. YAAAR can then be treated like a normal SAAR. But than the user has to make sure that the detector counting is correct! 7)If errors get very small, they are round of to zero !! It may be better in this case to set the error to a minimum value (e.g. 1e-30) and print a warning Example 1) Add the constant 5. to all fluxes of band 4 in aar1: aar1 = arithm( 'add', aar1, stat, 5., band=4, stat=stat ) 2) Addition of two spectra: coadd = arithm( 'add', aar1, aar2, stat=stat) performs addition of the fluxes of arr1 and arr2 (the result is not renormalized. This is done by 'mean'). The wavelength scales of aar1 and aar2 have to be identical. The errors are propagated. 3) outspd = arithm( 'div', spd1, spd2, /sloppy ) divides the fluxes of two spectra. The spectra are NOT checked for identical reference scales. The error is propagated. 4) average = arithm( 'mean' , aar1, aar2, /weight ) computes weighted mean of two spectra (fluxes). The weights are taken from the uncertainties (stdev^2). The spectra are checked for identical reference scale. The errors are propagated. The tags "flux" and "stdev" of the output are given by the mean of flx1 and flx2 and the propagated errors. All other entries in the output structure ("average") are taken from aar1 (see comment). 5) subtract a zodiacal light model: aar2 = zodi_spec(aar1) aar2 = arithm( 'sub', aar1, aar2) Dependencies CALLS: chk_tag, chk_det, get_unit, is_struct, make52, make_detmask, sap_error, sap_keyword_set, update_history CALLED FROM: GUI, IA Category ISAP Filename arithm.pro Author E. Sturm (--> ES) A. Fiedler (--> AF) D. Lutz Version 1.1 History def of requirements E. Sturm / D. Lutz 26.7.95 0.1 14-09-95 ES based on ia_ari (D. Lutz) 0.2 27-09-95 AF modified detector counting and call to subroutines (call_procedure) 0.3 04-10-95 AF if in2 is an array and keywords det or band not pressend, all detectors are selected. Check if selected ones pressent. tests if algo should have 2 or 1 argument 0.4 10-10-95 ES added part for SPDs. Modified call to chk_det (not applicable for SPDs). Tests. ASAP integration 1.0 15-11-95 ES check bad data masks 1.1 29-01-96 ES new call to is_sruct 29-02-96 ES stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier ascii2yaaar Purpose Create an IDL structure from an ASCII table of [wave, flux(, stdev)] of arbitrary units Synopsis YAAAR = ascii2yaaar( filename, wunit, funit[, stdev=stdev] [, skip=skip][,stat=stat]) Arguments Name I/O Type Description ---------------------------------------------------------- filename I String ASCII table filename wunit I String Wavelength unit (e.g., 'um') funit I String Flux unit (e.g., 'Jy') stdev I Switch Flux standard deviation array, assumed to be in units of funit skip I Switch To skip lines for reading stat I/O integer error status; 1 if fatal, 0 if ok Returns YAAAR IDL structure Description - Create an IDL structure from either 2 or 3 column ASCII tables of [wave, flux(, stdev)] for manipulation by IA and ISAP software. Comment - Top structure of the output consists of AAR tags [type, header, history, data]. The data record structure consists only of [wave, flux, stdev, flag], where flag (required for the GUI) has been set to 0. This record structure is defined in DEFINE_YAAAR. - Input units are required, and are entered into the header record. ANY units may be input, but only the units specified in the conversion routines WAVE_FORM and SPECT_FORM can be later read out of the header and converted. - Flux standard deviation values may be read from the ASCII table, or input as an array at the command line. - RESTRICTIONS: Wavelength standard deviations are presently not allowed. Flux standard deviation units are hard-wired to funit. No ASCII header text is read. Example YAAAR = ascii2yaaar('HD90429.SED', 'um', 'Jy', /stdev) Open the file HD90429.SED, read wave, flux, and flux standard deviation columns with units um, Jy, Jy. YAAAR = ascii2yaaar('HD5980.dat', 'A', 'erg/cm^2/s/A') Open file HR5980.dat, read wave and flux columns in units of Angstroms (A) and erg/cm^2/s/A, and set the flux standard deviations to constant value 1e-10. YAAAR = ascii2yaaar('HD50896.dat', 'um', 'Jy') sdarray = [sd1, sd2, ..., sdn] YAAAR.data.stdev = sdarray Open file HD50896.dat, read wave and flux in the specified units, and then reset the flux standard deviations = sdarray. Dependencies CALLS: define_yaaar, makeyaaarhead, sap_error, sap_keyword_set, update_history, write_hdrkey CALLED FROM: GUI, IA Category UTIL, I/O Filename ascii2yaaar.pro Author P. Morris p.morris@sron.ruu.nl Version 1.4 History 0.1 31-10-95 PM 0.2 02-11-95 ES modified read loop, minor changes 0.3 22-11-95 ES added update_history (but inactive) 0.4 24-11-95 PM modified units input to header for minimum necessary string length 0.5 04-01-96 PM redefine stdev as a switch; if not set, stdev = 1e-10; activate update_history 1.1 29-01-96 ES replaced write_fits_key with write_hdrkey 1.2 20-03-96 IRK include keyword "skip" to skip header lines (irk@ipac.caltech.edu) 1.3 09-05-96 ES added wavelength sorting 1.4 09-07-96 ES added error status 22-07-96 IRK corrected keyword "stat" into "errstat" ;- ;+ Identifier avgsig Purpose Calculate the statistcal parameter of an array (mean, sigma) Synopsis stat_struc = avgsig (xarr,[sarr],/disp) Arguments Name I/O Type Description ----------------------------------------------------- xarr I any except string input array sarr I any except string input sigma array Returns structure stat_struc with tags .mean and .sigma Description Calculate the mean and standard deviation, or uncertainty in the mean of the data points in the input array (xarr). The following statistics are computed depending on the logic of the input parameters provided: 1. Input data array without sigma array or dispersion keyword: >stat_struc = avg_sig(x) stat_struc.mean = sum(x_i)/n Unweighed sample mean of x is computed, assuming equal uncertainties in the data points. Equation (2-7) of Bevington. stat_struc.sigma = s/sqrt(n), where s=sqrt{sum(x_i-mean)^2/(n-i)} is the sample standard deviation of the data around their mean. Uncertainty in the determination of the unweighted sample mean of x is computed. Equation (5-13) of Bevington. 2. Input data array without sigma array, but with dispersion keyword: >stat_struc = avg_sig(x,/disp) stat_struc.mean = sum(x_i)/n Unweighed sample mean of x is computed, assuming equal uncertainties in the data points. Equation (2-7) of Bevington. stat_struc.sigma = s = sqrt{sum(x_i-mean)^2/(n-1)} Sample standard deviation [dispersion] of the data around their mean is computed. Equation (2-10) of Bevington. 3. Input data array and weights, without dispersion keyword: >stat_struc = avg_sig(x,sig) stat_struc.mean = sum(x_i/sig_i^2)/sum(1./sig_i^2) Weigthed mean is computed accounting for unequal uncertainties sig_i in the data points x_i. Equation (5-14) of Bevington. stat_struc.sigma = sqrt{sum(1./sig_i^2)} Uncertainty in the weighted mean is computed, ignoring the dispersion [spread] of the data points around their mean. Equation (5-15) of Bevington. 4. Input data array and weights, with dispersion keyword: >stat_struc = avg_sig(x,sig,/disp) stat_struc.mean = sum(x_i/sig_i^2)/sum(1./sig_i^2) Weigthed mean is computed accounting for unequal uncertainties sig_i in the data points x_i. Equation (5-14) of Bevington. stat_struc.sigma = sqrt{sum[(x_i-mean)^2/sig_i^2] /[(n-1)*sum(1./sig_i^2)]} Uncertainty in the weighted mean is computed, accounting for the dispersion [spread] of the data points around their mean. Last two equations on bottom of p. 73 of Bevington. Comment See Bevington, P. R., 1969, Data Propagation and Error Analysis for the Physical Sciences (McGraw-Hill). Example stat_struc = avg_sig(flux) OR stat_struc = avg_sig(flux, /disp) OR stat_struc = avg_sig(flux, stdev) OR stat_struc = avg_sig(flux, stdev, /disp) OR Dependencies CALLS: acknowledge CALLED FROM: inter_pol Category ISAP Filename avgsig.pro Author I. R. Khan Version 1.0 History Aug 25, 1995 1.0 ---> irk ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, California Institute of Technology. ; U.S. Government Sponsorship under NASA Contract NAS7-918 ; is acknowledged. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier band_2_det Purpose Convert a SWS band to the absolute detector(s) Synopsis det = band_2_det(band,stat=stat) Arguments Name I/O Type: Description: -------------------------------------------------------- band I intarr Selected detectorband(s) (0,1..6) (0=all bands) stat I /O int error status, 0 if ok, 1 if fatal Description This routine converts the SWS bandnumber to an integer array of detector numbers Defined number of det per band: [12,12,12,12,2,2] Band range: 0,1-6, Channel range: 1-52 Returns The absolute detector number(s) (1..52) Comment -- Example det= band_2_det(1) this yields an array det = [1,2,3,4,5,6,7,8,9,10,11,12] Dependencies CALLS: sap_error CALLED FROM: disp_aar, sap_rebin Category ISAP Filename band_2_det.pro Author E. Sturm (--> ES) Version 1.2 History 1.0 19-10-1995 ES first version, based on the SWS IA routine band2det (N.J.M. Sijm) 1.1 30-11-1995 ES ISAP V1 delivery 1.2 09-07-1996 ES stat added ;- ;+ Identifier chk_det Purpose Check if detectors specified in detmask are indeed present in in_det Synopsis status= chk_det(detmask, in_det, det_offset, argnam) Arguments Name I/O Type Description ----------------------------------------------------- detmask I intarr(52) detector mask for the selection of particular detectors (generated through make_detmask.pro) in_det I intarr(*) array containing the actual detectors (e.g. in1.data.det) det_offset I int offset for detector counting (LWS: 0, SWS, 1) argnam I string '1', or '2', for first or second argument Returns 0 if ok, 1 if at least one of the specified detectors is not present in in_det Description --- Comment --- Example --- Dependencies CALLS: sap_error CALLED FROM: arithm Category ISAP Filename chk_det.pro Author E. Sturm (--> ES) A. Fiedler (--> AF) Version 1.0 History 0.1 14-09-95 ES 0.2 27-09-95 AF added det_offset and argnam changed where to total 1.0 29-11-95 ES V1 delivery 1.1 29-02-96 ES changed into function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier chk_tag Purpose Check whether a given structure containes a particular tag Synopsis status = chk_tag(struc_in, tagnames) Arguments Name I/O Type Description ----------------------------------------------------- struc_in I struct The input structure to be searched for the tag tagname tagnames I string/ The tag name(s) to be searched in strarr struc_in Returns integer or intarr: 1 if struc_in contains the tag tagname, 2 if not Description --- Comment --- Example status = chk_tag(saar.data,'flux') if saar contains .flux: status = 1,else 2 status = chk_tag(saar.data,['wave','flag']) if saar.data contains .wave but not .flag this yields status = [1, 2] Dependencies CALLS: -- CALLED FROM: arithm (general auxillary routine) Category ISAP Filename chk_tag.pro Author E. Sturm (--> ES) Version 1.0 History 0.1 14-09-95 ES 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier cut_aar Purpose extract a subset of an AAR into a smaller AAR Synopsis aar_out = cut_aar( aar_in, index, stat) Arguments Name I/O Type Description ----------------------------------------------------- aar_in I AAR The input AAR to be cut index I intarr the data index array of the wanted data stat O integer the error status: 0 if ok, 1 if fatal Returns a new AAR which is a subset of aar_in, containing all data of aar_in.data(index). The header (NAXIS2) is updated. Description -- Comment -- Example find the data of band 1A of an SWS AOT01 observation and produce a new AAR with just these data in it: b1a = get_aotb_index(aar,'1A') aar_b1a = cut_aar(aar,b1a) Category ISAP Filename cut_aar.pro Dependencies CALLS: sap_error, update_history, write_hdrkey CALLED FROM: Author E. Sturm (--> ES) Version 0.1 History 0.1 01-05-96 ES first version ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1996, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier define_yaaar Purpose Define a YAAAR IDL structure Synopsis YAAAR = define_yaaar([, header=header] [, length=length] [, data=data]) Arguments Name I/O Type: Description: ------------------------------------------------- header I string Header definition length I integer Size of the structure [default=0] data I struc Data structure Returns YAAAR structure Description Definition of the YAAAR structure, following the complete AAR structure of define_yaaar.pro. This routine creates an YAAAR structure with pre-defined YAAAR header of makeyaaarhead.pro and an empty data structure of specified or default length. Comment See also define_aar.pro (IA) Dependencies CALLS: sap_keyword_set, makeyaaarhead CALLED FROM: GUI, IA, ascii2yaaar Example YAAAR = define_yaaar(header=hdr, length=200) Category ISAP Filename define_yaaar.pro Author P. Morris p.morris@sron.ruu.nl Version 1.1 History 1.0 10-25-95 PM creation of routine, only 4 data tags: wave,flux,stdev,flag 1.1 12-03-95 PM added all remaining AAR data tags ;- ;+ Identifier dered Purpose Dereddening of AAR or line lists Synopsis out = dered(in,ext,law,mode [,wext=wext] [,ownlaw=ownlaw] [,stat=stat]) Arguments Name I/O Type: Description: ---------------------------------------------------------- in I struct AAR or LLI to be dereddened ext I float Extinction in mag. By default, this is assumed to be a visual extinction A_V By specifying formal negative extinctions, DERED can also be used to 'redden' spectra law I string Designation of the reddening law to be used Currently implemented: 'RL85' Rieke+Lebofsky '85 0.3-13um 'M90' Mathis '90 0.35-250um 'DL84' Draine+Lee '84 0.5-250um (See description for details) 'OWN' Supply your own file specified by the `ownlaw' parameter. This has to be a two-column ASCII file of wavelengths (um) and extinctions (mag). The V band (0.55um) has to be in the range covered. DERED assumes that your file is sampled sufficiently dense so that it can interpolate linearly. mode I string Mode of dereddening. Possible options: 'SCREEN' simple foreground screen absorber I = I_0*exp(-tau) 'MIX' homogeneous 1-d mix of emission and absorption. Convention here is to specify the extinction through the whole region, i.e. front to back. I = I_0*(1-exp(-tau))/tau Taken from McLeod etal (1993), ApJ, 412, 111 wext I float Wavelength (micron) to which ext applies (supersedes default 'V' if set) ownlaw I string File with wavelengths (micron) and extinctions for own reddening law (applicable only if law = 'OWN') stat I/O int error status, 0 if ok, 1 if fatal Returns Dereddened AAR or LLI 0 if fatal error occured Description Currently, three different reddening laws are included: 'RL85': Rieke and Lebofsky (1985), ApJ, 288, 618. Expressed in terms of A_lambda/A_V, using R_V = 3.1, and based entirely on observations. It can be used to deredden spectra from 0.365 (the U band) to 13 microns. A spline was fit to the data in Table 3 of RL85, and then interpolated. The original data had to be converted to log_10-log_10 before fitting the spline so that it wouldn't go negative in the coarsely sampled parts of the data set. The law includes the 10 micron silicate feature. It is probably more valid for interstellar (diffuse cloud) extinction, where R_V is usually around 3.1, rather than dense or molecular clouds. 'M90': Mathis (1990), ARAA, 28, 37. Expressed in terms of A_lambda/A_J, using R_V=3.1, and based on both observations and grain models. It can be used to deredden spectra from 0.365 (the U band) to 250 microns. The 10 and 20 micron silicate feature profiles are taken from DL84 (see below), which are then added to a power law interpolation of an underlying continuum fitted between 7 and 250 microns. A spline was fit to the original data in Table 1 of M90, and then interpolated. The original data had to be converted to 1/lambda, log_10(A_lambda/A_J) before fitting the spline so that it wouldn't go negative in the coarsely sampled parts of the data set. A_lambda/A_J is independent of R_V above 1 micron. According to Mathis the extinction values for wavelengths greater than 15 microns are uncertain by at least a factor of two. 'DL84': Draine and Lee (1984), ApJ, 285, 89. Expressed in terms of A_lambda/A_V, and based on a model for dust grains. The law was digitised from figures 8 and 9 in DL84, after which some conversion was necessary from their units to A_lambda/A_V. This conversion required assuming R_V=3.1 and N_H=5.8*E21* E_(B-V) cm^-2 mag^-1. Also, a slight normalisation had to be applied to make A_V/A_V exactly equal to 1.0. The grain model consists of a mixture of graphite and 'astronomical silicate' grains, which obey an MRN size distribution. DL84 used Mie scattering theory for homogeneous spherical particles to compute the absorption and scattering cross sections. The extinction law here extends from 0.5 to 250 microns. A spline was fit to and interpolated from the digitised spectrum. Comment The speed of the routine is higher if data are sorted in wavelength, or in segments that are sorted, than for random wavelengths. The sampling of the implemented reddening laws has been adjusted to the smoothness of the curve to increase speed. Example outaar = dered(inaar,3.0,'DL84','screen',wext=2.20) deredden a spectrum that suffers a K band exinction of 3 mag. outlli = dered(inlli,-2.,'M90','screen') redden a linelist (visual extinction 2 mag) Dependencies CALLS: dered_getext, dered_corr, get_unit, is_struct, sap_error, sap_keyword_set, update_history CALLED FROM: GUI/IA Category ISAP Filename dered.pro Author D.Lutz/C.Wright Version 1.1 History 0.4 21-07-95 DL 0.5 24-07-95 CW Added description of RL85, M90 and DL84 laws. 0.6 12-10-95 DL standard laws moved from datafiles to code, sampling of laws optimized 0.7 18-10-95 DL use sap_error instead of error 0.8 16-11-95 ES update_history and unit check added 1.0 30-11-95 ES V1 delivery 1.1 29-01-96 ES new call to is_sruct 29-02-96 ES stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier dered_corr Purpose compute reddening correction factor for a single datapoint Synopsis out = dered_corr(lambda,lawlam,tau,mode,iguess,stat) Arguments Name I/O Type: Description: ---------------------------------------------------------- lambda I float wavelength for which to compute factor lawlam I fltarr array with wavelengths tau I fltarr array with optical depths for these wavelengths mode I string correction mode (see help for dered) iguess I/O int index of last hit. speeds up search if wavelengths are monotonically increasing. stat O int error stat, 0 if ok , 1 if fatal error Returns correction factor for this wavelength 0 in case of fatal error Description Comment Example corrfac = dered_corr(lambda,lawlam,tau,mode,iguess,stat) Dependencies CALLS: dered_getext, sap_error CALLED FROM: dered Category ISAP Filename dered_corr.pro Author D.Lutz Version 1.0 History 0.1 12-10-95 DL 0.2 18-10-95 DL use sap_error instead of error 1.0 30-11-95 ES V1 delivery 1.1 29-02-96 ES stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier dered_getext Purpose Function to interpolate extinction or tau for a certain lambda Synopsis out = dered_getext(lawlam,lawext,lambda,iguess,stat) Arguments Name I/O Type: Description: ---------------------------------------------------------- lawlam I fltarr array with wavelengths lawext I fltarr array with values for these wavelengths lambda I float wavelength for which to get interpolated value iguess I/O int index of last hit. speeds up search if wavelengths are monotonically increasing. is updated during execution stat O int error status, 0 if ok, 1 if fatal error Returns interpolated value 0 if fatal error occured Description Comment Example exv = dered_getext(lawlam,lawext,0.55,iguess,stat) Dependencies CALLS: sap_error CALLED FROM: dered, dered_corr Category ISAP Filename dered_getext.pro Author D.Lutz Version 1.0 History 0.1 12-10-95 DL 0.2 18-10-95 DL use sap_error instead of error 1.0 30-11-95 ES V1 delivery 1.1 29-02-96 ES stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier disp_aar Purpose Plot an Auto Analysis Structure (SAAR, LAAR, YAAR) Synopsis disp_aar, aar [, stat] [,plotmode] [,band] [,det] [,scnt] [,sdir] [,line] [,symbols] [,colors] [,xrange] [,yrange] [,psym] [,linstyle] [,plotfile] [,/errbar] [,/firstdet] [,/logflux] [,/nolegend] [,_extra=...]) Arguments Name I/O Type Description ;------------------------------------------------------- ------------ aar I AAR Input SAAR/LAAR/YAAR structure stat O int Error status : 1 for fatal, 0 otherwise plotmode I string Specify the type or mode of plotting. Options: 'stamps' (thumbnails) 'symbols' (up to 12 [user-defined]) 'colors' (up to 12) Default='colors'. band I int scalar/ Select one band (scalar) or array many (array). Example: band=[1,2]. Default is to plot all bands. Illegal option for LAAR. det I int scalar/ Select one detector (scalar) array or many (array). Example: det=[3,14,22]. NOTE: SWS detectors range 1-52; LWS detectors range 0-9. Default is to plot all detectors. scnt I int scalar/ Select one or more scan (scnt). array Range is 0 (first scan) to N. Default it to plot all scans. sdir I int scalar/ Select a scan direction. array SWS: sdir=-1 (down) sdir= 0 (TBD) sdir= 1 (up) LWS: sdir= 0 (down) sdir= 1 (up) Default it to plot all scandir's. line I int scalar/ Plot one or more specific lines. array The tag aar.data.line is used to select data for specific line(s). Default: plot all values of line. The available symbols are TBD: colors I int scalar/ 1 Scalar or array of color(s) to plot. array With plotmode='colors', this option can be used to match specific colors to data subsets specified via the det, scnt, or sdir option. This has the effect of overriding the 12 default color codes which are assigned in order as follows: 1=red 2=pink 3=white 4=cyan1 5=blue 6=grey 7=red1 8=red2 9=green1 10=green2 11=purple 12=cyan2 Default: colors=[1,2,3,4,...12]. symbols I int scalar/ Scalar or array of symbol(s) to plot. array With plotmode='symbols', this option can be used to match specific symbols to data subsets specified via the det, scnt, or sdir option. This has the effect of overriding the 12 default symbol codes which are assigned in order as follows: 1=plus 2=dot 3=square 4=diamond 5=circle 6=down-tri. 7=up-tri. 8=star 9=v-bowtie 10=h-bowtie 11=hexigon 12=hex + x Default: symbols=[1,2,3,4,...12]. xrange I fltarr(2) User defined X scale yrange I fltarr(2) User defined Y scale psym I integer User defined plotting symbol linstyle I integer User defined plotting line style plotfile I string Send the plot to a PostScript file instead of device 'x'. /errbar I switch Plot aar.data.stdev as error bars. /firstdet I switch Plot only 1st detector in each band; this is short-hand for option det=[1,13,25,37,49,51]. (SAAR only.) /logflux I switch Plot log10(flux) instead of linear scale /nolegend I switch Do not draw plot legend, and expand the plot to fill up the plot region. _extra I any Extra keywords to pass to plot/oplot (e.g., xrange,yrange, /line, etc.). Returns None Description Plot the input AAR aarture in various modes to summarize the data contents efficiently. Flux (density) versus wavelength (or frequancy or wavenumber) will be plotted depending on the units in the header keywords TUNIT1 (wave) and TUNIT2 (flux). Data subsets can be identified using different colors (plotmode='colors') [default] or symbols (plotmode='symbols'), or they can be plotted individually using plotmode='stamps' (e.g., "postage stamps", or "thumbnails"). Comments 0) This is a revised routine which combines the "best of" IA3's original PLOT_AAR (N.J.M Sijm), a preliminary plotting routine for LWS AARs (E. Sturm), and preliminary PLOT_AAR ("thumbnails") and PLOT_BAND routines for SWS AARs (Iffat Khan). 1) IDL'S "_extra" is used to pass additional plot options to plot and oplot. This allows, for example, specification of xrange,yrange, linestyle,psym, etc. User beware: This may mess up "nice" plotting otherwise done by default! The "_extra=e" keyword mechanism is used internally to pass additional options to PLOT and OPLOT from the command-line call to DISP_AAR. See the section "Keyword Inheritence" in the IDL User's Manual. 2) Autoscaling: A pass is made through the data to find the minimum and maximum X and Y values required to display all datapoints for plot modes that display all data in a single plot window (plotmode=symbols or plotmode=colors). 3) A legend/legend on the side of the plot indicates which symbol or color specifies which detector, band, or scan. Also, the name of the input AAR and the AOT is displayed. This can be omitted with option /nolegend. 4) WAVE_FORM and SPECT_FORM can convert AAR units. Therefore, there is no need for this routine to do unit conversions. Use get_fits_key to get the values of TUNIT1 (wave) and TUNIT2 (flux) and use these units strings to label the plot axes. 5) NOTE: Real data in the new SAAR aarture *will* contain valid line numbers in the saar.data.line tag, as for LWS. For testing purposes, fudge in line numbers [1,2,3,4,5,6] for regions in test file EE2_AOT2_2 (4, 8, 14, 17, 32, 41 um lines). These are easily seen using an initial call to DISP_AAR such as: idl>disp_aar,ee2_aot2_2,plotmode='stamps' Examples idl>disp_aar, saar01 For the input SWS01 AAR, plot all bands in a single plot on the X Window plot device, using a different color for each detector. Uses defaults: (plotmode='colors'; psym=3 [small dots]). idl>disp_aar, saar01, plotmode='symbols' As above, but use a different (internally defined) symbol for each of the 12 detectors. idl>disp_aar, saar01, plotmode='stamps' Plot all individual detectors for all bands and scans in separate "postage stamp", or "thumbnail" plots. Use the default symbol (psym=3) and linestyle (none). idl>disp_aar, saar01, plotmode='stamps', linsytle=0 Use linstyle=0 (solid) to connect points. idl>disp_aar, saar01, plotmode='stamps', psym=10 Use psym=10 (stair-step) to connect points. idl>disp_aar, saar01, det=[13,18], plotmode='symbols',$ symbols=[4,5] Plot only detectors 13 & 18 using symbols 4 (diamond) and 5 (triangles), without a line connecting the points. idl>disp_aar, saar01, det=[13,28], plotmode='symbols',$ symbols=[4,5], linstyle= 0 Same as above, adding a solid line to connect the points. idl>disp_aar, saar02, line=2 Plot only line 2 data (e.g., a 14 um region) from an SWS02 AAR. Each detector is plotted as a different color with psym=3, all in the same window (default mode). idl>disp_aar, saar02, line=[1,2,3,4], plotmode=stamps Make separate "postage stamp" plots for each of the four lines in an SWS02 AOT for all relevant detectors. idl>disp_aar, saar02, line=[1,2], plotmode=stamps, /firstdet Similar to above, but using only data from the first detector for each line scan. idl>disp_aar, saar02, line=3, plotmode='stamps', /errbar,psym=6 Plot only line 3 data (e.g., a 17 um region) from an SWS02 AOT. Each detector is plotted separately in its own "postage stamp = thumbnail" plot using psym=6 (square) and plotting error bars using the stdev values. idl>disp_aar, saar01, /firstdet, /errbar Plot only the first detector (1,13,25,37) in each band for an SWS02 AOT. Each detector is plotted using a different color, along with error bars. idl>disp_aar, laar02, scnt=2, plotmode='stamps' Plot only scan 2 data for an LWS02 AOT, with each detector's data in a separate "postage stamp" plot. idl>disp_aar, saar02, sdir=1 Plot only "up scans". Dependencies CALLS: band_2_det, get_hdrkey, kwd_notset, oploterr, ploterr, plot_legend, sap_error, sap_keyword_set, set_usersym, shrink_array CALLED FROM: IA, GUI Category ISAP Filename disp_aar.pro Author Iffat Khan (irk) Version 1.1 History 11-Oct-95 Definition of requirements; J. Mazz, E. Sturm, D. Lutz This is a revised routine which combines the "best of" IA3's original PLOT_AAR (N.J.M Sijm), a preliminary plotting routine for LWS AARs (E. Sturm), and preliminary PLOT_AAR (thumbnails) and PLOT_BAND routines for SWS AARs (Iffat Khan). Look in these routines for their early histories (not repeated here). 0.1 12-Oct-95 preliminary design and coding --> irk 0.2 13-Oct-95 revised code --> irk 16-Oct-95 revised/cleaned specs --> mazz (but did not touch code!) 0.3 16-Oct-95 revised code --> irk 18-Oct-95 Extensive testing of v 0.3 --> mazz@mpe via 'testplot.pro' 0.4 18-Oct-95 revised code --> irk 0.5 19-Oct-95 revised code to includ --> irk legends/legends on the plot 20-Oct-95 Extensive testing of v 0.5 --> mazz@mpe via 'testplot.pro' 0.6 25-Oct-95 revised code --> irk 0.7 26-Oct-95 revised code (use SAP-ERROR) --> irk 0.8 08-Nov-95 revised code (use KWD_NOTSET) --> irk change name newplotaar --> disp_aar 0.9 10-Nov-95 revised "Dependencies" in header --> irk 0.9 21-Nov-95 revised code after a minor correction --> irk 1.0 28-Nov-95 implement YAAAR plotting --> irk 1.0 30-Nov-95 improved plot labelling --> irk 1.1 29-Jan-96 avoid call to plot_template (added a few extra lines of code). Replaced read_fits_key with get_hdrkey --> E. Sturm (MPE) 1.1 22-Feb-96 add "comm = ' '" to declare "comm" as string 1.1 15-Aug-96 add "stat=stat" to define error status ;- ;+ Identifier flux_conserv Purpose Perform linear interpolation conserving flux Synopsis status = flux_conserv(xarr, yarr, sarr, refarr, yarr_out, sarr_out) Arguments Name I/O Type Description ----------------------------------------------------- xarr I Fltarr x-scale (e.g. wavelength array) that is to be resampled yarr I Fltarr y-scale (e.g. flux array) that is to be resampled sarr I Fltarr sigma array (stdev) for yarr refarr I Fltarr reference scale to which x-scale is to be resampled sarr_out O Fltarr the propagated errors of yarr_out yarr_out O Fltarr the rebinned yarr (interpolated flux array) Returns Error status : 1 for fatal, 0 otherwise Description xarr has to be strictly monotonically increasing . only process refarr which are within xarr limits. A middle point array is generated from the given ref scale i.e xmid(i) = (refarr(i+1) - refarr(i) )/ 2 The flux at ref(i) is then the total integral of xmid(i) <= xarr <= xmid(i+1) divided by (xmid(i) - xmid(i-1)). The integral is obtained using the formula (trapezoidal rule) sum of( (yarr(k) + yarr(k-1)) * (xarr(k) - xarr(k-1) / 2 ) for all k such that xmid(i) <= xarr(k) <= xmid(i+1) wavelength range. For the first element ref(0), use all the points in xarr within the range ref(0) to xmid(0) For mid(0) < xarr(0) set mid(0) = xarr(0) The reference scale can be locally coarser or finer than the data. Both may be unequally sampled. The error for each refmid point is computed as follows. TBD Comment Example 1) flux_conserv,lsanwav, lsanflx, lsanstdv, ref, yout, sout new grid is given by lsanwav2 (the wavelength scale of a second spectrum). By default linear interpolation is performed. Dependencies CALLS: KWD_NOTSET, POLYINT, SAP_ERROR CALLED FROM: SAP_REBIN Category ISAP Filename flux_conserv.pro Author Iffat R. Khan (irk@ipac.caltech.edu) Version 0.3 History 0.1 25-10-95 definition of requirements --> mazz@ipac 0.1 02-11-95 Design and code --> irk@ipac 0.2 22-11-95 revised code --> irk@ipac 0.3 28-11-95 revised to correct range --> irk@ipac 0.4 02-05-95 revised to terminate if --> irk@ipac ref array is too short (<= 1 point) 1.0 24-05-96 change usage to FUNCTION from PRO -->irk@ipac to handle error status flag ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, California Institute of Technology. ; U.S. Government Sponsorship under NASA Contract NAS7-918 ; is acknowledged. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier get_hdrkey Purpose Read a keyword value and optionally the corresponding comment from the header of an ISAP structure Synopsis status = get_hdrkey( header, keyword, value [,key_pos=key_pos] [,comment=comment][,stat=stat]) Arguments Name I/O Type Description ----------------------------------------------------- header I string The input header keyword I string Keyword to read from header value O varies The value of the keyword. The type of the output is determined by the type of the keyword: integers are returned as long, logicals (T or F) are returned as byte integers, i.e. 1B (true) or 0B (false). Floats and doubles are returned as double. Strings keep their type. key_pos O intarr(3) key_pos(0)=position of keyword in header string, key_pos(1) = posiion of '=', key_pos(2) = position of '/' comment O string The comment for the keyword stat I/O int error status, 0 if ok, 1 if fatal Returns return status code (0=success, 1=keyword not found) Description Read a keyword from a header Comment If the value is a string (indicated via quotation marks at the beginning and end) then this routine assumes that the string itself does not contain further quotation marks. Example 1) status = get_hdrkey( aar.header, 'object', value, key_pos) Gets the object name from the header 2) comment= '' status = get_hdrkey( aar.header, 'DATE', value, $ comment=comment) Gets the date and the corresponding comment from the header Dependencies CALLS: sap_error CALLED FROM: disp_aar, get_unit, spect_form, wave_form, wav_dop Category ISAP Filename get_hdrkey.pro Author E. Sturm (--> ES) Version 1.1 History 1.0 24-01-96 ES First version 1.1 09-07-96 ES stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier get_unit Purpose extract the unit(s) of one or several tags in the data part of a given structure (normally AAR) Synopsis unit = get_unit(strucin, tag, stat) Arguments Name I/O Type Description ----------------------------------------------------- strucin I struct (AAR) Sectrum to be checked tag I string/ name of the tag(s) for which the unit strarr shall be checked stat O int error status 0 if ok, 1 if fatal error Returns unit = lower case strarr containing the value(s) of the TUNIT keyword(s) corresponding to the given tag(s) 0 if fatal error occured Description Finds index n of tag in the data part. Reads value of corresponding TUNITn. Returns values. Comment 'microns' (LWS) is treated as 'um' Example units = get_unit(saar,'wave',stat) units = get_unit(saar,['wave', 'flux', 'stdev'],stat) Dependencies CALLS: get_hdrkey, is_struct, sap_error CALLED FROM: arithm, dered (general auxillary routine) Category ISAP Filename get_unit.pro Author E. Sturm (--> ES) Version 1.2 History 0.1 11-10-95 ES first version 1.0 30-11-95 ES V1 delivery 1.1 29-01-96 ES new call to is_struct, replace read_fits_key with get_hdrkey 29-02-96 ES error status added 1.2 26-07-96 ES treat 'microns' as 'um' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Indentifier glue Purpose To join spectra or mini-spectra into a single spectrum by averaging the overlapping portions of the spectra. Synopsis status = glue (struc_in, struc_out [, struc_in2 = struc_in2] [, epsilon = epsilon] ) Arguments Name I/O Type Description --------------------------------------------------------- struc_in I struct Input structure (AAR) struc_out O struct Output structure (AAR) (unchanged if fatal error) Data points will be sorted in wave order. Only data tags wave, flux, stdev, flag will be in the data part of struc_out. struc_in2 I struct Optional second input structure (AAR) (see struc_in for details) epsilon i float Optional epsilon to determine if two wave values are the "same" Default is 1.e-5 Returns 0 if OK 1 if fatal error Description This utility is capable of joining individual detector spectra within one AAR structure of two AAR structures. Points where wave is within epsilon will be combined with a weighted average. Stdev will be correctly propogated. See documentation for chk_multix for information about how points are combined. Comment There is no check tha the data has been rebinned. (differing wave values in the overlap areas. This program calls chk_multix which provides no mechanism for maintaining corresponding values for tags other than wave, flux, and stdev. Examples In the following examples, the output is returned in an AAR structure named AAR_GLUED. To glue all of the mini-spectra in AAR_ORIG together: stat = glue (AAR_ORIG, AAR_GLUED) To glue all of the mini-spectra in AAR_ORIG together with a tollerance of 1.0E-3 for combining points: stat = glue (AAR_ORIG, AAR_GLUED, epsilon=1.0E-3) To glue AAR_ADDON together with AAR_ORIG and produce AAR_GLUED: stat = glue (AAR_ORIG, AAR_ADDON, AAR_GLUED) Dependencies CALLS: chk_multix, kwd_notset, redo_hdr, sap_ckunits, sap_error, update_history CALLED FROM: IA, GUI Category ISAP Filename glue.pro Author R. Narron (IPAC) Version 1.6 History definition of requirements - rewrite of E. Sturm's first draft by B. Swinyard 7/8/95 0.1 950809 --> R. Narron (IPAC) Prototype 0.2 951010 --> R. Narron New AAR definition 1.0 951027 --> R. Narron New parameter checking 1.1 951106 --> R. Narron Update FITS header 1.2 951120 --> R. Narron Always set type="YAAAR" 1.3 951201 --> R. Narron Exclude all "mask" points 1.4 951206 --> R. Narron Add-in "mask" points later 1.5 951207 --> R. Narron change chk_units call to sap_ckunits 1.6 960716 --> RN added status return from chk_multix Copyright (C) 1995, California Institute of Technology. U.S. Government Sponsorship under NASA Contract NAS7-918 is acknowledged. ****************************************************************************** ;- ;+ Identifier is_struct Purpose check if a given variable is a structure of kind AAR, SPD, or LLI Synopsis status = is_struct(struct,struc_type) Arguments Name I/O Type Description ----------------------------------------------------- struct I any Input variable (the structure to be tested) struc_type I string The type for which the structure shall be tested for valid: 'AAR', 'SPD', and 'LLI' Returns 1 if the given structure is of the given type, 0 else Description -- Comment -- Example if is_struct(my_aar,'AAR') then ..... Dependencies CALLS: -- CALLED FROM: Category ISAP Filename is_struct.pro Author E. Sturm (--> ES) Version 1.0 History 0.1 19-01-96 ES first implementation 1.0 22-04-96 ES replaced "if" construction with "case"; fixed bug in return scheme ;- ;+ Identifier make52 Purpose convert in2 into 52 element array if it is not a structure Synopsis in2_array = make52(in2,stat=stat) Arguments Name I/O Type Description ----------------------------------------------------- in2 I scalar/ the second argument input of ARITHM array if it is not a structure stat I/O int error status, 0 if ok, 1 if fatal Returns A 52 elements array. Description If in2 is a number all elements are set to in2. If in2 is a 52 element array (SWS) the output is just a copy of in2. If in2 is a 10 element array (LWS) the first 10 elements of the output array are set to in2. In any other case the ASAP error handler is invoked. Comment --- Example --- Dependencies CALLS: sap_error CALLED FROM: arithm Category ISAP Filename make52.pro Author E. Sturm (--> ES) Version 1.1 History 0.1 14-09-95 ES 1.0 30-11-95 ES V1 delivery 1.1 09-07-96 ES stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier make_detmask Purpose make a detector mask out of the det and band switches Synopsis detmask = make_detmask(band, det, struc, detoffset, stat) Arguments Name I/O Type Description ----------------------------------------------------- band I scalar/ Detector band(s) to which operation intarr shall be limited (SWS specific) det I scalar/ Detector(s) to which operation intarr shall be limited struc I struct input spectrum detoffset I int offset for detector counting (LWS: 0-9, SWS: 1-52) stat O int error stat, 0 if ok, 1 if fatal error occured Returns detmask = intarr(52), a detector mask indicating the choosen detectors. 0 if fatal error occured Description If no band or det are given then all elements of detmask are set to 1. If det and/or band are given, they are checked for a valid range and the corresponding indices in detmask are set to 1. If det and band are conflicting a warning is issued. Comment detmask is intarr(52) even in case of LWS. This slight 'overkill' saves some case distinctions. Example detmask = make_detmask(band, det, in1, det1offset, stat) Dependencies CALLS: sap_error, sap_keyword_set CALLED FROM: arithm Category ISAP Filename make_detmask.pro Author E. Sturm (--> ES) A. Fiedler (--> AF) Version 1.0 History 0.1 14-09-95 ES (based on D. Lutz's routine) 0.2 27-09-95 AF modified bandind and check for valid detector range 1.0 30-11-95 ES V1 delivery 1.1 29-02-96 ES error stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier makeyaaarhead Purpose Create a real FITS header for data stored in a YAAAR (Yet Another Auto Analysis Result) IDL structure Synopsis status = makeyaaarhead( header, data ) Arguments Name I/O Type Description ----------------------------------------------------- header O String header data I any structure/array; Returns Status giving header length or fail code (-1) as integer Description - Create a header for YAAAR data, similar to makeheader.pro for ERD, SPD, AAR, etc Comment - Routine presently assumes that the YAAARs consist of wave, flux, and standard deviation arrays only. The tag "flag" is added for consistency with AAR structures. Flag values are set equal to 0. - Units are hard-wired to (um,Jy,Jy) for the input data arrays. In the future, this restriction should be removed (perhaps in MAKEYAAAR.pro) to accomodate YAAARs with other units. Example STATUS = MAKEYAAARHEAD( HEAD, DATA ) Create a header for a YAAAR Dependencies CALLS: get_date CALLED FROM: GUI, IA, ascii2yaaar Category ISAP Filename makeyaaarhead.pro Author P. Morris ---> PM p.morris@sron.ruu.nl Version 1.02 History 1.00 20-10-95 PM 02-11-95 PM Changed padding between primary and secondary headers for nearest multiple of 2880 1.01 25-11-95 HS Added new mandatory keywords 1.02 03-12-95 PM Add all SAAR/LAAR data keywords to secondary header 1.03 26-01-96 ES avoid call to cp_fits_string ;- ;+ Indentifier mask Purpose To mark specified data points as bad Synopsis status = mask, struc_in, struc_out, bad_list [, /unmask] Arguments Name I/O Type Description -------------------------------------------------------- struc_in I struct Input structure (AAR) struc_out O struct Output structure (AAR) (unchanged if fatal error) bad_list I intarr Array containing the index numbers of the points to be masked. (must be integers between 0 and N-1) unmask I int optional flag to clear the mask bits (un-setting them) Returns 0 if OK 1 if fatal error Description For every point in the bad list, the "mask" bit in the flag tag will be set to indicate that this point contains bad data. Examples In the following example, the output is returned in an AAR structure named AAR_FLAGGED. To set the mask bit on the 3rd (index 2) stat = mask (AAR_ORIG, AAR_MASKED, 2]) To CLEAR the mask bit on the 2nd and 4th (index 1 and 3) stat = mask (AAR_ORIG, AAR_MASKED, [1, 3], /unmask) This routine may also be used to add a flag tag to AAR_NOFLAG stat = mask (AAR_NOFLAG, AAR_WITHFLAG, 0, /unmask) Dependencies CALLS: kwd_notset, redo_hdr, sap_error, update_history CALLED FROM: sap_rfits, IA Category ISAP Filename mask.pro Author R. Narron (IPAC) Version 1.1 History definition of requirements - rewrite of E. Sturm's first draft by B. Swinyard 7/8/95 0.1 950905 --> R. Narron (IPAC) Prototype 0.2 951010 --> R. Narron (IPAC) New AAR definition 1.0 951027 --> R. Narron (IPAC) New parameter checking 1.1 951106 --> R. Narron (IPAC) Update FITS header if add flag tag Copyright (C) 1995, California Institute of Technology. U.S. Government Sponsorship under NASA Contract NAS7-918 is acknowledged. ****************************************************************************** ;- ;+ Indentifier normal Purpose To normalise a defined portion of an input spectrum to a constant value or to another spectrum. Synopsis status = normal (struc_in, struc_out, wave1 , wave2 [, struc_ref=struc_ref] [, n_const=n_const] [, /nowgt] [, wave1_ref=wave1_ref] [, wave2_ref=wave2_ref] ) Arguments Name I/O Type Description --------------------------------------------------------- struc_in I struct Input structure (AAR) struc_out O struct Output structure (AAR) (unchanged if fatal error) wave1 I flt Lower boundary of "defined portion" of the struc_in spectra. (same units as struc_in.wave) wave2 I flt Upper boundary of "defined portion" of the struc_in spectra. (same units as struc_in.wave) struc_ref I struct Optional spectrum to normalise to (wave, flux, and stder must be in same units as struc_in.) wave1_ref I flt Optional (defaults to wave1) Lower boundary of "defined portion" of the struc_ref spectra. (same units as struc_ref.wave) wave2_ref I flt Optional (defaults to wave2) Upper boundary of "defined portion" of the struc_ref spectra. (same units as struc_ref.wave) n_const I flt Optional normalisation constant (same units as struc_in.wave) nowgt I int When computing average value(s) don't weight by 1/(stdev^2) COMBINATIONS: - exactly ONE of struc_ref or n_const must be specified - wave1_ref and wave2_ref may only be specified if struc_ref is specified Returns 0 if OK 1 if fatal error Description A spectrum will be multiplied by a constant such that the mean within a specified wavelength range will be either (1) equal to a specified value or, (2) equal to the mean value of a wavelength range of a reference spectrum. Errors are correctly propagated (multiplied by the same scale factor). Comment This version does only multiplicative correction. Additive corrections are planned for version 2. Examples In both of the following examples, the output is returned in an AAR structure named AAR_NORM To normalize AAR_ORIG so that the portion between 10 and 20 microns (if AAR_ORIG is in microns) has an average value of 35.3, do the following: stat =normal(AAR_ORIG, AAR_NORM, 10.0, 20.0, n_const=35.3) To normalize AAR_ORIG so that the portion between 10 and 20 microns (if AAR_ORIG is in microns) has the same average value as AAR_REF has in the same range, do the following: stat=normal(AAR_ORIG, AAR_NORM, 10.0,20.0,struc_ref=AAR_REF) Dependencies CALLS: kwd_notset, sap_ckunits, sap_error, update_history CALLED FROM: IA, GUI Category ISAP Filename normal.pro Author R. Narron (IPAC) Version 1.1 History definition of requirements - rewrite of E. Sturm's first draft by B. Swinyard 7/8/95 0.1 950831 --> R. Narron (IPAC) Prototype 0.2 951010 --> R. Narron (IPAC) New AAR definition 1.0 951027 --> R. Narron (IPAC) New parameter checking 1.1 951207 --> R. Narron change chk_units call to sap_ckunits Copyright (C) 1995, California Institute of Technology. U.S. Government Sponsorship under NASA Contract NAS7-918 is acknowledged. ****************************************************************************** ;- ;+ Identifier point2ext Purpose SWS calibration conversion between point and extended sources Synopsis aar_out = point2ext(aar, dias, [/quick][,stat=stat]) Arguments Name I/O Type Description ----------------------------------------------------- aar I AAR The SWS spectrum to be converted dias I float The diameter of the source in arcsec: 0 = point source -1 = extended source ( 0 ES) L. Haser (--> LH) Version 1.1 History 1.0 26-04-96 ES/LH first version 1.1 09-07-96 ES stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1996, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier polyint Purpose Interpolate a set of N points by fitting a polynomial of degree N-1 Synopsis polyint, xp , yp , x, y Arguments Name I/O Type Description ----------------------------------------------------- xp I any except string input x array yp I any except string input y array x I any except string x value to be interpolated y O any except string y value corresponding to x Returns y - Scalar, interpolated value in (xp,yp) corresponding to x Description Interpolate a set of N points by fitting a polynomial of degree N-1. Adapted from algorithm in Numerical Recipes, Press et al. (1986) Section 3.1 (p82). Uses Neville's algorithm to iteratively build up the correct polynomial, with each iteration containing one higher order. Comment Example Find sin(2.5) by polynomial interpolation on sin(indgen(10)) IDL> xp = indgen(10) IDL> yp = sin( xp ) IDL> polyint, xp, yp, 2.5, y ,dy The above method gives y = .5988 and dy = 3.1e-4 a close approximation to the actual sin(2.5) = .5985 Dependencies CALLS: kwd_notset, sap_error CALLED FROM: flux_conserv, inter_pol Category ISAP Filename polyint.pro Author I. R. Khan Version 0.2 History 0.1 27-08-95 Design and code --> irk@ipac 0.2 01-11-95 Revised parameters --> irk@ipac checking/Error messages ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, California Institute of Technology. ; U.S. Government Sponsorship under NASA Contract NAS7-918 ; is acknowledged. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap Purpose prepare ISAP history handling Synopsis sap, logfile=logfile Arguments Name I/O Type Description ----------------------------------------------------- logfile I keyword the name of the session log file default:'sap_session.log' Returns --- Description This routine initiates the ISAP history handling. It shall be called at the beginning of an ISAP session which will be automatically done when starting IA (or the GUI). An eventual user supplied journal file is closed and the standard ISAP journal file (a temporary scratch file) is opend. A session log file for the whole IA/ISAP session is opened as well. This routine is intended to be used in combination with squit.pro at the end of the session and with a call to update_history in appropriate IA and in ISAP (shell) routines. At the end of a session the user will have 1) all informations about an IDL session up to the start of IA/ISAP in his own journal file (if such a file was provided), 2) the calls of IA/ISAP routines, i.e. the command lines, in the history tag of the output structures, and 3) a session log file of the complete IA/ISAP session in a specified file. Comment The GUI history handling will be different and will be developed later. The definition of !SAP_GUI ( set to 0) should also be added to the IA startup file. Example --- Dependencies CALLS: sap_keyword_set CALLED FROM: GUI, IA at the beginning of the session (planned) Category ISAP Filename sap.pro Author E. Sturm (--> ES) Version 1.0 History 0.1 15-10-95 ES 0.2 24-10-95 ES added keyword logfile, removed prompt for filename 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_abs Purpose Perform y = abs(x) on arrays Synopsis sap_abs, arr_in, sarr_in, arr_out, sarr_out Arguments Name I/O Type Description ----------------------------------------------------- arr_in I Float(*) input array (e.g. flux) sarr-in I Float(*) array of uncertainties for arr_in sarr_out O Float(*) array of uncertainties for arr_out (propagated errors) arr_out O Float(*) output array Returns arr_out = abs(arr_in), sarr_out= propagated error Description Comment The routine is usually called from the "shell" ARITHM Example sap_abs, aar.data.flux, aar.data.stdev, sqrt_arr, stdev Dependencies CALLS: CALLED FROM: arithm Category ISAP Filename sap_abs.pro Author A. Fiedler (--> AF) Version 1.0 History 0.1 27-09-95 AF 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_add Purpose Add either a constant or another spectrum to a spectrum (with error propagation) Synopsis sap_add, in1flux, in1err, in2flux, in2err, outflux, outerr Arguments Name I/O Type Description ----------------------------------------------------- in1flux I Float(*) array of first spectrum (flux or photocurrents) in1err I Float(*) Array of weights for in1flux in2flux I Float(*) array that is to be added (constant or fluxes of a second spectrum) in2err I Float(*) Array of weights for in2flx outflux O Float(*) array of Spectrum 1 after addition outerr O Float(*) Array of uncertainties of outflux Returns The added fluxes (or photocurrents) and their propagated errors. Description Adds either a constant or another spectrum to a spectrum. If a constant is to be added this constant has to be passed as array (from the shell arithm). The errors are propagated ( outerr = sqrt(in1err^2 + in2err^2) ). After adding two spectra together the resulting spectrum is NOT renormalized (by dividing by 2.) Comment The routine is usually called from the "shell" ARITHM which provides the appropriate arrays from the product structures. Example --- Dependencies CALLS: CALLED FROM: arithm Category ISAP Filename sap_add.pro Author E. Sturm (--> ES) A. Fiedler (--> AF) Version 1.0 History 0.1 14-09-95 ES 0.2 27-09-95 AF added check for number of arguments 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_div Purpose Divide a spectrum either by a constant or another spectrum (array) (with error propagation) Synopsis sap_div, in1flux, in1err, in2flux, in2err, outflux, outerr Arguments Name I/O Type Description ----------------------------------------------------- in1flux I Float(*) array of first spectrum (flux or photocurrents) in1err I Float(*) Array of weights for in1flux in2flux I Float(*) array by which in1flux is to be divided (constant array or fluxes) in2err I Float(*) Array of weights for in2flx outflux O Float(*) array of Spectrum 1 after division outerr O Float(*) Array of uncertainties of outflux Returns The divided fluxes (or photocurrents) and their propagated errors. Description Divides a spectrum either by a constant or another spectrum For division with a constant this constant has to be passed as array (from the shell arithm). The errors are propagated. Comment The routine is usually called from the "shell" ARITHM which provides the appropriate arrays from the product structures. Example --- Dependencies CALLS: sap_error CALLED FROM: arithm Category ISAP Filename sap_div.pro Author A. Fiedler (--> AF) Version 1.0 History 0.1 27-09-95 AF 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_exp Purpose Perform y = exp(x) on arrays (with error propagation) Synopsis sap_exp, arr_in, sarr_in, arr_out, sarr_out Arguments Name I/O Type Description ----------------------------------------------------- arr_in I Float(*) input array (e.g. flux) sarr-in I Float(*) array of uncertainties for arr_in sarr_out O Float(*) array of uncertainties for arr_out (propagated errors) arr_out O Float(*) output array Returns arr_out = exp(arr_in), sarr_out= propagated error Description Comment The routine is usually called from the "shell" ARITHM Example sap_exp, aar.data.flux, aar.data.stdev, exp_arr, exp_stdev Dependencies CALLS: -- CALLED FROM: arithm Category ISAP Filename sap_exp.pro Author A. Fiedler (--> AF) Version 1.0 History 0.1 27-09-95 AF 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_exp10 Purpose Perform y = 10^x on arrays (with error propagation) Synopsis sap_exp10, arr_in, sarr_in, arr_out, sarr_out Arguments Name I/O Type Description ----------------------------------------------------- arr_in I Float(*) input array (e.g. flux) sarr-in I Float(*) array of uncertainties for arr_in sarr_out O Float(*) array of uncertainties for arr_out (propagated errors) arr_out O Float(*) output array Returns arr_out = 10^(arr_in), sarr_out= propagated error Description Comment The routine is usually called from the "shell" ARITHM Example exp10, aar.data.flux, aar.data.stdev, exp10_arr, exp10_stdev Dependencies CALLS: -- CALLED FROM: arithm Category ISAP Filename sap_exp10.pro Author A. Fiedler (--> AF) Version 1.0 History 0.1 27-09-95 AF 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_keyword_set Purpose Check if a keyword is set. The difference to IDLs keyword_set is that a value of zero is allowed and that the string 'NONE' is interpreted as 'not set'. Synopsis set=sap_keyword_set(key) Arguments Name I/O Type Description ----------------------------------------------------- key I keyword the keyword to check Returns 0 if keyword is not set or if its value is 'NONE', 1 else Description To explicitly un-set a keyword use the string 'NONE' as value. Caution: case and blank sensitive! Comment --- Example if sap_keyword_set(det) then ..... Dependencies CALLS: -- CALLED FROM: general auxillary routine Category ISAP Filename sap_keyword_set Author E. Sturm (--> ES) Version 1.0 History 0.1 20-10-95 ES 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_log Purpose Perform y = log(x) on arrays (natural logarithm) (with error propagation) Synopsis sap_log, arr_in, sarr_in, arr_out, sarr_out Arguments Name I/O Type Description ----------------------------------------------------- arr_in I Float(*) input array (e.g. flux) sarr-in I Float(*) array of uncertainties for arr_in sarr_out O Float(*) array of uncertainties for arr_out (propagated errors) arr_out O Float(*) output array Returns arr_out = log(arr_in), sarr_out= propagated error Description Comment The routine is usually called from the "shell" ARITHM Example log, aar.data.flux, aar.data.stdev, log_arr, log_stdev Dependencies CALLS: sap_error CALLED FROM: arithm Category ISAP Filename sap_log.pro Author A. Fiedler (--> AF) Version 1.0 History 0.1 27-09-95 AF 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_log10 Purpose Perform y = log(x) on arrays (basis of log: 10) (with error propagation) Synopsis sap_log10, arr_in, sarr_in, arr_out, sarr_out Arguments Name I/O Type Description ----------------------------------------------------- arr_in I Float(*) input array (e.g. flux) sarr-in I Float(*) array of uncertainties for arr_in sarr_out O Float(*) array of uncertainties for arr_out (propagated errors) arr_out O Float(*) output array Returns arr_out = log10(arr_in), sarr_out= propagated error Description Comment The routine is usually called from the "shell" ARITHM Example sap_log10, aar.data.flux, aar.data.stdev, log10_arr, stdev Dependencies CALLS: sap_error CALLED FROM: arithm Category ISAP Filename sap_log10.pro Author A. Fiedler (--> AF) Version 1.0 History 0.1 27-09-95 AF 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_max Purpose set individual points of a spectrum to maximum value of the spectrum and either a constant or another spectrum (array) Synopsis sap_max, in1flux, in1err, in2flux, in2err, outflux, outerr Arguments Name I/O Type Description ----------------------------------------------------- in1flux I Float(*) array of first spectrum (flux or photocurrents) in1err I Float(*) Array of weights for in1flux in2flux I Float(*) array to which in1flux is compared (constant array or fluxes) in2err I Float(*) Array of weights for in2flx outflux O Float(*) array of Spectrum 1 with replaced maximum values outerr O Float(*) Array of uncertainties of outflux Returns The maximum values of the fluxes (or photocurrents) and the corresponing errors. Description The spectrum is compared with either a constant or another spectrum. The bigger value is returned. For comparison with a constant this constant has to be passed as array (from the shell arithm). The errors are taken from the bigger value. Comment The routine is usually called from the "shell" ARITHM which provides the appropriate arrays from the product structures. Example --- Dependencies CALLS: sap_error CALLED FROM: arithm Category ISAP Filename sap_max.pro Author A. Fiedler (--> AF) Version 1.0 History 0.1 02-10-95 AF 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_mean Purpose Compute the (weighted) mean of two spectra Synopsis sap_mean, in1flux, in1err, in2flux, in2err, outflux, outerr [,/weight] Arguments Name I/O Type Description ----------------------------------------------------- in1flux I Float(*) array of first spectrum (flux or photocurrents) in1err I Float(*) Array of weights for in1flux in2flux I Float(*) array of second spectrum in2err I Float(*) Array of weights for in2flx outflux O Float(*) the mean fluxes of Spectrum 1 and 2 outerr O Float(*) Array of uncertainties of outflux weight I switch if set: compute weighted mean Returns The (weighted) mean fluxes (or photocurrents) and their propagated errors. Description Adds two spectra and divides the result by 2. (unweighted mean. If weighting is desired (/weight is given) the weights are taken from the errors (stdev^2). For points where both errors are 0 the weights are set to 1 and the resulting error to 0. Comment The routine should be called from the "shell" ARITHM. If the switch /weight is set "mean" is performed with the square of the standard deviations as weights. Weighting with constants (like "(3.*arr1 + 2.*arr2)/5.") can be performed step by step - calling mult, add, and div. Weighting with artificial arrays of weights (e.g. containing zeros to mask out bad data points) is not supported in this first version (masking can be done in alternative ways). Example --- Dependencies CALLS: sap_error, sap_keyword_set CALLED FROM: arithm Category ISAP Filename sap_mean.pro Author A. Fiedler (--> AF) Version 1.0 History 0.1 27-09-95 AF 0.2 05-10-95 AF can handel zero and small errors 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_min Purpose set induvidual points of a spectrum to minimum value of spectrum and either a constant or another spectrum (array) Synopsis sap_min, in1flux, in1err, in2flux, in2err, outflux, outerr Arguments Name I/O Type Description ----------------------------------------------------- in1flux I Float(*) array of first spectrum (flux or photocurrents) in1err I Float(*) Array of weights for in1flux in2flux I Float(*) array to which in1flux is compared (constant array or fluxes) in2err I Float(*) Array of weights for in2flx outflux O Float(*) array of Spectrum 1 with replaced minimum values outerr O Float(*) Array of uncertainties of outflux Returns The minimum values of the fluxes (or photocurrents) and the corresponing errors. Description The spectrum is compared with either a constant or another spectrum. The smaller value is returned. For comparison with a constant this constant has to be passed as array (from the shell arithm). The errors are taken from the smaller value. Comment The routine is usually called from the "shell" ARITHM which provides the appropriate arrays from the product structures. Example --- Dependencies CALLS: sap_error CALLED FROM: arithm Category ISAP Filename sap_min.pro Author A. Fiedler (--> AF) Version 1.0 History 0.1 02-10-95 AF 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_mult Purpose multiplicate a spectrum either by a constant or another spectrum (array) Synopsis sap_mult, in1flux, in1err, in2flux, in2err, outflux, outerr Arguments Name I/O Type Description ----------------------------------------------------- in1flux I Float(*) array of first spectrum (flux or photocurrents) in1err I Float(*) Array of weights for in1flux in2flux I Float(*) array by which in1flux is to be multiplied (constant array or fluxes) in2err I Float(*) Array of weights for in2flx outflux O Float(*) array of Spectrum 1 after multiplication outerr O Float(*) Array of uncertainties of outflux Returns The multiplied fluxes (or photocurrents) and their propagated errors. Description Multiplies a spectrum either by a constant or another spectrum For multiplying with a constant this constant has to be passed as array (from the shell arithm). The errors are propagated. Comment The routine is usually called from the "shell" ARITHM which provides the appropriate arrays from the product structures. Example --- Dependencies CALLS: -- CALLED FROM: arithm Category ISAP Filename sap_mult.pro Author A. Fiedler (--> AF) Version 1.0 History 0.1 27-09-95 AF 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ + Identifier sap_rebin Purpose Perform resampling (=rebinning =interpolation) of an AAR Synopsis struc_out=sap_rebin(struc_in , err_stat,[,ref=ref] [,xstart=xstart][,xend=xend] [,stepwidth=stepwidth][,nstep=nstep] [,resol=resol][,/log][,algo=algo] [,/flxcons] [,band=band][,scnt = scnt] [,sdir = sdir][,det=det][,/mean] [,epsilon=epsilon]) Arguments Name I/O Type Description ----------------------------------------------------- struc_in I AAR input structure (spectrum) containing the x-scale (wavelength) and the y-scale (flux) that are to be rebinned err_stat I int Error status : 1 for fatal, 0 otherwise ref I Fltarr reference scale (wavelength) array to which x-scale is to be resampled xstart I Float start x value (start wavelength) of new x-scale xend I Float end x value (end wavelength) of new x-scale stepwidth I Float distance between two points in new x-scale (in case of equidistant rebinning) nstep I Long number of steps in the new x-scale resol I Float resolution for the new x-scale log I Integer keyword for logarithmic equidistant scale flxcons I Integer keyword for flux conserving linear interpolation algo I string indicate interpolation algorithm default = 'spline' (for cubic spline) band I intarr band #(s) whose detectors will be rebinned. band = 'none' means option is not set scnt I intarr scan #(s) whose detectors will be rebinned. scnt ='none' means option is not set sdir I intarr scan direction(s) whose detectors will be rebinned. sdir = 'none' means option is not set det I intarr individual output for each detector in this list. det = 'all' means all detectors individually rebinned. det = 'none' means option is not set (all detctors) mean I Integer keyword for computing arithmatic mean values instead of weighted mean in CHK_MULTIX epsilon I Float minimum seperation between wavelength points for multiple point processing in CHK_MULTIX struc_out O struct the rebinned structure (spectrum) Returns The rebinned AAR structure Description - This routine takes automatically Wavelength and Flux as x-scale and y-scale and the uncertainties of fluxes (stdev> for error propagation. The error for each interpolated data point (flux) is computed as follows. weighted mean of the standard deviations of the points used in interpolation (For cubic spline, 5 points are used, the closest point, and 2 additional points on each side). Weights are computed as the seperations between the reference point and the points in input xarr array. The user can specify two catagories: the character of the new x-scale (-> scale_define) and the method of interpolation (-> inter_pol). - First Call SCALE_DEFINE: The new x-scale is either 1) identical to a reference scale (i.e. the wavelength scale of another spectrum or any arbitrary scale) or 2) equidistant with - a given start and end wavelength and a given number of steps or with - a given start wavelength, a stepwidth and a number of steps or 3) consistent with a given resolution and a start wavelength and number of steps. This is equivalent to a logarithmic equidistant scale, which can have two advantages: doppler shifts are now given by addition: L = L0*(1+v/c) transforms into log(L) = log(L0) + log(1+v/c) and lineprofiles keep constant when they are shifted on logarithmic equidistant scales. - Then call CHK_MULTIX: check if xscale contains multiple points at the same value. If so, compute weighted mean of yarr and sarr at the mean xarr-points and modify xarr, yarr and sarr accordingly.(For definition of xarr, yarr and sarr see CHK_MULTIX). - Call INTER_POL: Perform the interpolation. The supported methods of interpolation are: 1) cubic spline interpolation Value of algo: 'spline' 2) polynomial interpolation Value of algo: 'polyx' where x stands for the grade of the polynomial. Example: poly3 for third order polynomial. Default value of algo used = 'poly1' (No flux conserving) - Call BIN_STRUCT: Create the output structure with meaningful tags in the data. Comment The Widget User Interface has to provide this subroutine with the necessary parameters and to make plots of the original spectrum and the result possible. It should also ask the user whether (s)he accepts the result or wants to try another interpolation. If the reference array contains multiple points at the 'same' value, the interpolation has to provide each of these points with the same value. This means that the reference array has to be monotonically but need not to be strictly monotonically increasing (or decreasing). "same value" means value1 - value2 < epsilon with epsilon = 1.E-5 as default Rebinning of SPDs is currently not included because of the complex behaviour of the wavelength scale Example 1) struc_out = sap_rebin(aar1, ref=lsanwav2) new grid is given by lsanwav2 (the wavelength scale of a second spectrum). The interpolation is linear (the default). The data tags in output AAR will be WAVE, FLUX, and STDEV. 2) struc_out = sap_rebin(aar1, xstart=3.0, xend=4.0, nstep=100, algo='spline', det='all') new scale is equidistant beginning at 3.0 um ending at at 4.0 um and with a step width of (4.-3.)/100.=0.01 um. The interpolation algorithm is a spline. The output AAR contain individual detector resampled spectrum with data tags WAVE, FLUX, STDEV, DET 3) struc_out = sap_rebin(struc_in, xstart=3.0, resol= 0.0033, nstep=100., scnt=1) new scale contains 101 points and has a constant resolution ( L(i+1) - L(i) ) / L(i) = 0.0033 ) starting at 3.0 um. (As a consequence xend = 4.1706 um). The processing arrays are the input arrays of AAR struc_in subset on scnt = 1 The output AAR contain individual detector resampled spectrum with data tags WAVE, FLUX, STDEV, SCNT 4) struc_out = sap_rebin(struc_in, xstart=3.0, xend=4.0, nstep=100, /log) new scale is logarithmic equidistant, contains 101 wavelenths and reaches from 3.0 um to 4.0 um. (e.g. the second wavelength value is given by L2=10^(log(3.0)+stepwidth) where stepwidth = (log(4.0) - log(3.0)) / 100. ) This is almost equivalent to example 3). Dependencies - CALLS: AVGSIG, BAND_2_DET, BIN_STRUCT, BINSRCH, CHK_MULTIX, FLUX_CONSERV, INTER_POL, KWD_NOTSET, POLYINT, REDO_HDR, SCALE_DEFINE, SAP_ERROR, SHRINK_ARRAY, UPDATE_HISTORY CALLED FROM: IA, GUI, SYN_PHOT Category ISAP Filename sap_rebin.pro Author Iffat Khan (irk@ipac.caltech.edu) Version 1.1 History 27. 7.95 definition of requirements E. Sturm 8. 8.95 revision of requirements E. Sturm 1. 9.95 revision of requirements J. Mazz 0.1 8. 9.95 Design and Code I.Khan 0.1 20.9.95 modified to truncate ref scale outside the data range I. Khan 0.1 21.9.95 Modifications by Sarah Unger S. Unger (replaced the functions MINMAX and UNIQ by MIN and SHRINK_ARRAY) 0.1 21.9.95 Ignore masked out data before I. Khan rebinning 0.1 27.9.95 modify to input band, scan #, I. Khan and scan direction integer arrays 0.2 29.9.95 default setting of options , I. Khan included ( -1 means option is not used) 0.3 02.10.95 default setting of options , I. Khan modified ("none" means option is not used) 0.4 17.10.95 revised code after specs revision irk Allow steps with xstart, xend; resol with xend, "linear" for algo. removed minor bugs 0.5 02-11-95 Revised parameters --> irk@ipac checking/Error messages Add /flxcons for flux conservation with linear interpolation 0.6 09-11-95 changed keyword name --> irk@ipac for BIN_STRUCT (resd ->resdet) 0.7 10-11-95 Updated "Dependencies" in --> irk@ipac the header 0.8 22-11-95 sort struc_in data over --> irk@ipac wave 0.8 28-11-95 remove a minor bug --> irk@ipac 1.0 30-11-95 version 1.0 --> irk@ipac 1.1 29-02-96 include "line" tag in --> irk@ipac rebinned structure with "scnt" option 1.1 22-04-96 removed a bug which appear --> irk@ipac when "DET" tag is missing in input struc 2.0 26-04-96 add keywords /mean and epsilon -> irk@ipac for multi points processing in CHK_MULTIX. 2.0 30-04-96 comment out sorting on "wave" -> irk@ipac ;- ;+ Indentifier sap_rfits Purpose To read a fits file into an AAR structure Synopsis status = sap_rfits (fits_file, struc_out) Arguments Name I/O Type Description -------------------------------------------------------- fits_file I string Name of fits file to read The file MUST correspond to a valid SAAR, LAAR, or YAAAR. struc_out O struct Output structure (YAAAR, SAAR, or LAAR) (unchanged if fatal error) Returns 0 = the file was read into the AAR structure 1 = could not read the file into an AAR structure (Note: A status of 0 does not guarantee that the resulting AAR structure is valid.) Description A structure (YAAAR, SAAR, LAAR) is created and the FITS file is read into it. If the FITS file has no 'flag' tag, the output AAR will automatically transforemed into a YAAAR structure *with* a 'flag' tag. Comments This program is for reading FITS files that correspond to valid YAAAR, SAAR, or LAAR structures. If you have some other kind of FITS file you will probably want to first transform it into a valid YAAAR, SAAR, or LAAR file. Alternatively, it may be easier to read the problem FITS file as is, and then fix up the resulting AAR. The FITS file must be binary table format have the TFORM names specified below. YAAAR SAAR LAAR ----- -------- -------- WAVE SWAAWAVE LSANWAV WAVEU LSANWAVU FLUX SWAAFLUX LSANFLX STDEV SWAASTDV LSANFLXU TINT SWAATINT LSANTINT DET SWAADETN LSANDET ITK SWAAITK LSANITK UTK SWAAUTK LSANUTK RPID SWAARPID LSANRPID SPARE SWAASPAR LSANFILL LINE SWAALINE LSANLINE SDIR SWAASDIR LSANSDIR SCNT SWAASCNT LSANSCNT STATUS SWAASTAT LSANSTAT FLAG SWAAFLAG LSANFLAG Example Category ISAP Filename sap_rfits.pro Author R. Narron (IPAC) Version 1.6 History 1.0 951101 --> R. Narron (IPAC) Initial version 1.1 951115 --> R. Narron Add flag tag if none in FITS file 1.2 951120 --> R. Narron Make history tag an ARRAY of one 1.3 951127 --> R. Narron change n_datas to a long (was int) 1.4 960430 --> R. Narron change STAT tag to STATUS for AAR's 1.5 960712 --> RN change datatype '2B' into '1I' (for LSAN's) 1.6 960812 --> RN for LSAN's: reorder columns, sort by WAVE Copyright (C) 1995, California Institute of Technology. U.S. Government Sponsorship under NASA Contract NAS7-918 is acknowledged. ****************************************************************************** ;- ;+ Indentifier sap_shift Purpose To normalise a single scan to a given detector by comparing overlapping wavelength regions. Synopsis status = sap_shift (struc_in, struc_out, det) Arguments Name I/O Type Description ------------------------------------------------------ struc_in I struct Input structure (AAR) Data tag "det" is requiired. struc_out O struct Output structure (AAR) (unchanged if fatal error) det I int Detector number of the "good" detector Returns status: 0 if OK 1 if fatal error Description The flux values for the "good" dector will remain unchanged. Flux values (and stdev) for the other detectors will each be multiplied by a computed constant to adjust it to the good dector. This computed constant is ratio between the weighted means in the overlap region. This process will ripple through all detectors until they have all been corrected. The standard output of the LWS OLP - and to a certain extent the SWS - is sub-divided into scans each containing the data from individual detectors which have overlapping wavelength portions when the full range of the instrument is used. Although the best effort has been made in OLP to ensure that the variation in response between detectors has been accounted for, there will inevitably be some residual discontinuity at the boundaries between detectors. This utility will allow the user to select a given detector as more trustworthy than the rest and normalise all detector data to that detector. The input spectrum may or may not have been averaged across scans and/or MASKed or TIPPEXed before this operation. Comment If any stdev values are not positive then all flux values will be weighted equally but the stdev values will be adjusted properly by the multiplication factor. If any detector has no overlap area or has a mean value of 0.0, it will not be adjusted. This version does only multiplicative correction. Additive corrections are planned for version 2. Also, aligning by scan (rather than by detector) may be added. Examples In the following example, the output is returned in an AAR structure named AAR_SHIFTED. To normalize AAR_ORIG so that all the other detectors are normalized to detector 5: stat = sap_shift (AAR_ORIG, AAR_SHIFTED, 5) Dependencies CALLS: kwd_notset, sap_error, update_history CALLED FROM: IA, GUI Category ISAP Filename sap_shift.pro Author R. Narron (IPAC) Version 1.0 History definition of requirements - rewrite of E. Sturm's first draft by B. Swinyard 7/8/95 0.1 950906 --> R. Narron (IPAC) Prototype 0.2 951010 --> R. Narron (IPAC) New AAR definition 1.0 951027 --> R. Narron (IPAC) New parameter checking Fix det 0 bug Copyright (C) 1995, California Institute of Technology. U.S. Government Sponsorship under NASA Contract NAS7-918 is acknowledged. ****************************************************************************** ;- ;+ Identifier sap_sqrt Purpose Perform y = sqrt(x) on arrays Synopsis sap_sqrt, arr_in, sarr_in, arr_out, sarr_out Arguments Name I/O Type Description ----------------------------------------------------- arr_in I Float(*) input array (e.g. flux) sarr-in I Float(*) array of uncertainties for arr_in sarr_out O Float(*) array of uncertainties for arr_out (propagated errors) arr_out O Float(*) output array Returns arr_out = sqrt(arr_in), sarr_out= propagated error Description Comment The routine is usually called from the "shell" ARITHM Example sap_sqrt, aar.data.flux, aar.data.stdev, sqrt_arr, stdev Dependencies CALLS: sap_error CALLED FROM: arithm Category ISAP Filename sap_sqrt.pro Author A. Fiedler (--> AF) Version 1.0 History 0.1 27-09-95 AF 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sap_sub Purpose Subtract either a constant or another spectrum from a spectrum Synopsis sap_sub, in1flux, in1err, in2flux, in2err, outflux, outerr Arguments Name I/O Type Description ----------------------------------------------------- in1flux I Float(*) array of first spectrum (flux or photocurrents) in1err I Float(*) Array of weights for in1flux in2flux I Float(*) array that is to be subtracted from in1flux (constant array or fluxes) in2err I Float(*) Array of weights for in2flx outflux O Float(*) array of Spectrum 1 after subtraction outerr O Float(*) Array of uncertainties of outflux Returns The subtractes fluxes (or photocurrents) and their propagated errors. Description Subtracts either a constant or another spectrum from a spectrum. If a constant is to be subtracted this constant has to be passed as array (from the shell arithm). The errors are propagated ( outerr = sqrt(in1err^2 + in2err^2) ). Comment The routine is usually called from the "shell" ARITHM which provides the appropriate arrays from the product structures. Example --- Dependencies CALLS: --- CALLED FROM: arithm Category ISAP Filename sap_sub.pro Author A. Fiedler (--> AF) Version 1.0 History 0.1 27-09-95 AF 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Indentifier sap_wfits Purpose To write a fits file from an SAAR, LAAR, or YAAAR structure Synopsis status = sap_wfits (fits_file, struc_out) Arguments Name I/O Type Description -------------------------------------------------------- fits_file I string Name of fits file to write struc_in I struct Input structure (YAAAR, SAAR, or LAAR) (AAR header must contain valid FITS) Returns 0 = file written 1 = unable to write file Description A FITS file is written from the header, history, and data tags of the input AAR structure. Comments The FITS file will only be valid if the header in the AAR is valid. Example -- Dependencies CALLS: kwd_notset, sap_error CALLED FROM: IA, GUI Category ISAP Filename sap_wfits.pro Author R. Narron (IPAC) Version 1.0 History 1.0 951101 --> R. Narron (IPAC) Initial version Copyright (C) 1995, California Institute of Technology. U.S. Government Sponsorship under NASA Contract NAS7-918 is acknowledged. ****************************************************************************** ;- ;+ Identifier scale_define Purpose compute a new x-scale (e.g. the reference wavelengths to which spectrum will be binned. Synopsis ref_arr=scale_define([refarr][,xstart=xstart][,xend=xend] [,stepwidth=stepwidth][,nstep=nstep] [,resol=resol][,/log] [,err_stat= err_stat]) Arguments Name I/O Type Description ----------------------------------------------------- refarr I Fltarr array of reference wavelengths xstart I Float start x value (e.g. start wavelength) of new x-scale xend I Float end x value (e.g. end wavelength) of new x-scale stepwidth I Float distance between two points in new x-scale (equidistant rebinning) nstep I Long number of steps in the new x-scale resol I Float resolution for the new x-scale (delta-lambda/lambda) log I Integer logarithmic equidistant scale ref_arr O Fltarr output wavelength array (to which a given spectrum is to be resampled) err_stat O Int output error status flag , 1 for fatal, 0 otherwise Returns Description Define a new x-scale for interpolation. The new x-scale is either 1) identical to a reference scale input directly as an array (i.e. the wavelength scale of another spectrum or any arbitrary scale provided by the user) or 2) equidistant with - a given start and end wavelength and a given number of steps or a stepwidth For linear scale : lam_i+1 = lam_i + step where step = (lam_end - lam_start) / nsteps For logarithmic scale (/log) : lam_i+1 = 10 ^ (log(lam_i) + log(lam_end/lam_start)/nsteps or 3) equidistant with - a given start wavelength, a stepwidth and a given number of steps Logarithmic scale (/log) is not allowd under this mode of operation. or 4) consistent with a given spectral resolution and a start wavelength , and end wavelength/or number of steps. This is equivalent to a logarithmic equidistant scale, which can have two advantages: doppler shifts are now given by addition: L = L0*(1+v/c) transforms into log(L) = log(L0) + log(1+v/c) and line profiles stay constant when they are shifted on logarithmic equidistant scales. The consecutive points are computed using the formula lam_i+1 = lam_i * (1. + resol) Dependencies KWD_NOTSET, SAP_ERROR Comment Example 1) ref_arr=scale_define(refarr) the reference wavelength scale is provided via refarr, the wavelength scale of another spectrum or any arbitrary scale provided by the user. 2) ref_arr=scale_define(xstart=3.0, xend=4.0, nstep=100) new wavelength is equidistant beginning at 3.0 um ending at at 4.0 um and with a step width of (4.-3.)/100.=0.01 um. 3) ref_arr=scale_define(xstart=3.0, stepwidth=0.03, nstep=100) new wavelength is equidistant beginning at 3.0 um and containing 101 points at a stepwidth of 0.03 um. 4) ref_arr=scale_define(xstart=3.0, resol=0.01, nstep=100) new wavelength has constant spectral resolution of (delta-lambda)/lambda = 0.01 beginning at 3.0 micron. Dependencies CALLS: kwd_notset, sap_error CALLED FROM: sap_rebin, GUI Category ISAP Filename scale_define.pro Author Iffat R. Khan Version 0.5 History 27-07-95 definition of requirements --> E. Sturm first draft 01-09-95 Review of specs and code --> mazz 0.1 07-09-95 --> irk 0.2 17-10-95 Allow step with xs, xe --> irk 0.3 02-11-95 Revised parameters --> irk@ipac checking/Error messages 0.4 10-11-95 ADD "Dependencies" in the --> irk@ipac header 0.5 22-11-95 Make starting refarr "float" --> irk@ipac 0.5 28-11-95 revised to correct data range -> irk@ipac ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, California Institute of Technology. ; U.S. Government Sponsorship under NASA Contract NAS7-918 ; is acknowledged. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier set_usersym Purpose set user defined symbols generated with symgen.pro Synopsis set_usersym, symbol [,/fill] Arguments Name I/O Type Description ----------------------------------------------------- symbol I integer The number of the symbol fill I key Set this keyword to fill the symbol Returns --- Description The SET_USERSYM procedure sets user defined symbols generated by SYMGEN: 1 = square 2 = diamond 3 = circle 4 = triangle down 5 = triangle up 6 = star 7 = "bow tie" 8 = "hour glass" 9 = hexagon 10 = hexagon with cross Comment Example To show you all of the user symbols, enter: PLOT, INDGEN(10)+1, INTARR(10), PSYM=3, XR=[0,12], $ YR=[-1,1] ;plots 10 points FOR I=1,10 DO BEGIN & SET_USERSYM,I & PLOTS,I,0,PSYM=8,SYMSIZE=7 & ENDFOR Dependencies CALLS: symgen.pro, sap_keyword_set CALLED FROM: disp_aar, (general auxillary routine) Category ISAP Filename set_usersym.pro Author A. Fiedler (--> AF) Version 1.0 History 1.0 July 1993 AF ;- ;+ Identifier sm_airy Purpose Smooth SPD or AAR using a lorentzian filter Synopsis out = sm_airy(in, width [,band] [,det] [,/sample] [,/velo] [,/sep][,stat=stat]) Arguments Name I/O Type: Description: --------------------------------------------------------------------- in I AAR/SPD spectrum to be smoothed width I float FWHM of lorentzian used for smoothing, In wavelength [um] by default. band I int scalar/ Option to select one band (scalar) or several array (array). Example: band=2, band=[1,4]. If absent all bands are selected (default). Illegal option for LAAR. det I int scalar/ Option to select one detector (scalar) or array several (array). Example: det=6, det=[3,21,30]. If absent all detectors are selected (default). /sample I switch if set, the width is interpreted in terms of samples /velo I switch if set, the width is interpreted in terms of velocity [km/s] /sep I switch if set smoothing is done separately for each detector stat I/O int error status, 0 if ok, 1 if fatal Returns Smoothed AAR/SPD Description Smooth fluxes in a SPD or AAR by convolution with a Lorentz profile cut off at 3*FWHM (on either side, 3% of peak value). At edges, signal and error are set to zero (within 3*FWHM of edges). When (2*3*FWHM + 1) is longer than the signal, this latter and the error are set to 0. The FWHM of the lorentzian can be specified in wavelength (default), velocity units or sample domain. In the first 2 cases data is unequally sampled. For AAR, smooth over all detectors combined together (default) or separately on each detector when keyword /sep is set. The errors are propagated from the original data. Comment Does not treat sdir nor scnt. Does not handle SPDs. It is too difficult to have this deal with SWS SPD offsets? How to apply to SPDs???? even after RESUM??? The program would have to know which SPD fluxes are the good ones (i.e. those with reset). Example -- Dependencies CALLS: chk_tag, is_struct, sap_error, sap_keyword_set, update_history CALLED FROM: IA, GUI Category ISAP Filename sm_airy.pro Author Laurent Verstraete (IAS) (-->LV) Version 1.3 History Draft reqs DL/ES/CW 27.7.95 revision of requirements E. Sturm 8.8.95 1.0 - 04.03.96 LV creation 1.2 - 19.03.96 LV modified to handle combined or separate sets of band/det. Treat all AARs. Make wavelengths ascendent. 1.3 - 12.3.96 ES stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sm_box Purpose Smooth SPD or AAR using a boxcar/square hat filter Synopsis out = sm_box(in, width [,band] [,det] [,/sample] [,/velo] [,/sep][,stat=stat]) Arguments Name I/O Type: Description: --------------------------------------------------------------------- in I AAR/SPD spectrum to be smoothed width I float width of boxcar used for smoothing, default is in wavelength [um]. band I int scalar/ Option to select one band (scalar) or several array (array). Example: band=2, band=[1,4]. If absent all bands are selected (default). Illegal option for LAAR. det I int scalar/ Option to select one detector (scalar) or array several (array). Example: det=6, det=[3,21,30]. If absent all detectors are selected (default). /sample I switch if set, the width is interpreted in terms of samples /velo I switch if set, the width is interpreted in terms of velocity [km/s] /sep I switch if set smoothing is done separately for each detector stat I/O int error status, 0 if ok, 1 if fatal Returns Smoothed AAR/SPD Description Smooth fluxes in an SPD or AAR by convolution with a boxcar profile. At edges, signal and error are set to zero (within 0.5*width of edges). When width is longer than the signal, this latter and the error are set to 0. The width of the boxcar can be specified in wavelength (default), velocity units or sample domain. In the first 2 cases data may is unequally sampled. For AAR, smooth over all detectors combined together (default) or separately on each detector separately when keyword /sep is set. The errors are propagated from the original data. Comment Does not treat sdir and scnt. Does not handle SPDs. It is too difficult to have this deal with SWS SPD offsets? How to apply to SPDs???? even after RESUM??? The program would have to know which SPD fluxes are the good ones (i.e. those with reset). Example -- Dependencies CALLS: chk_tag, is_struct, sap_error, sap_keyword_set, update_history CALLED FROM: IA, GUI Category ISAP Filename sm_box.pro Author Laurent Verstraete (IAS) (-->LV) Version 1.3 History Draft reqs DL/ES/CW 27.7.95 revision of requirements E. Sturm 8.8.95 1.0 - 04.03.96 LV creation 1.1 - 13.03.96 LV modified to handle combined or separate sets of band/det 1.2 - 15.03.96 LV modified to treat all AARs. Make wavelengths ascendent. 1.3 12.07.96 ES stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sm_gauss Purpose Smooth SPD or AAR using a gaussian filter Synopsis out = sm_gauss(in, width [,band] [,det] [,/sample] [,/velo] [,/sep][,stat=stat]) Arguments Name I/O Type: Description: --------------------------------------------------------------------- in I AAR/SPD spectrum to be smoothed width I float FWHM of gaussian used for smoothing, In wavelength [um] by default. band I int scalar/ Option to select one band (scalar) or several array (array). Example: band=2, band=[1,4]. If absent all bands are selected (default). Illegal option for LAAR. det I int scalar/ Option to select one detector (scalar) or array several (array). Example: det=6, det=[3,21,30]. If absent all detectors are selected (default). /sample I switch if set, the width is interpreted in terms of samples /velo I switch if set, the width is interpreted in terms of velocity [km/s] /sep I switch if set smoothing is done separately for each detector stat I/O int error status, 0 if ok, 1 if fatal Returns Smoothed AAR/SPD Description Smooth fluxes in a SPD or AAR by convolution with a gaussian profile cut off at 3*FWHM (on either side, 1% of peak value). At edges, signal and error are set to zero (within 3*FWHM of edges). When (2*3*FWHM + 1) is longer than the signal, this latter and the error set to 0. The FWHM of the gaussian can be specified in wavelength (default), velocity units or sample domain. In the first 2 cases data is unequally sampled. For AAR, smooth over all detectors combined together (default) or separately on each detector when keyword /sep is set. The errors are propagated from the original data. Comment Does not treat sdir nor scnt. Does not handle SPDs. It is too difficult to have this deal with SWS SPD offsets? How to apply to SPDs???? even after RESUM??? The program would have to know which SPD fluxes are the good ones (i.e. those with reset). Example -- Dependencies CALLS: chk_tag, is_struct, sap_error, sap_keyword_set, update_history CALLED FROM: IA, GUI Category ISAP Filename sm_gauss.pro Author Laurent Verstraete (IAS) (--> LV) Version 1.3 History Draft reqs DL/ES/CW 27.7.95 revision of requirements E. Sturm 8.8.95 1.0 - 04.03.96 LV creation 1.2 - 19.03.96 LV modified to handle combined or separate sets of band/det. Treat all AARs. Make wavelengths ascendent. 1.3 - 12.07.96 ES stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier sm_median Purpose Smooth SPD or AAR using a median filter Synopsis out = sm_median(in, width [,band] [,det] [,/sample] [,/velo] [,/sep][,stat=stat) Arguments Name I/O Type: Description: --------------------------------------------------------------------- in I AAR/SPD spectrum to be smoothed width I float width of median filter used for smoothing, default is in wavelength [um]. band I int scalar/ Option to select one band (scalar) or several array (array). Example: band=2, band=[1,4]. If absent all bands are selected (default). Illegal option for LAAR. det I int scalar/ Option to select one detector (scalar) or array several (array). Example: det=6, det=[3,21,30]. If absent all detectors are selected (default). /sample I switch if set, the width is interpreted in terms of samples /velo I switch if set, the width is interpreted in terms of velocity [km/s] /sep I switch if set smoothing is done separately for each detector stat I/O int error status, 0 if ok, 1 if fatal Returns Smoothed AAR/SPD Description Smooth fluxes in a SPD or AAR by convolution with a median filter. At edges, signal and error are set to zero (within 0.5*width of edges). When width is longer than the signal, this latter and the error are set to 0. The width of the median filter can be specified in wavelength (default), velocity units or sample domain. In the first 2 cases data may is unequally sampled. (default), velocity units or sample domain. In the first 2 cases data may is unequally sampled. For AAR, smooth over all detectors combined together (default) or separately on each detector when keyword /sep is set. The errors are propagated from the original data. Comment Does not treat sdir and scnt. Does not handle SPDs. It is too difficult to have this deal with SWS SPD offsets? How to apply to SPDs???? even after RESUM??? The program would have to know which SPD fluxes are the good ones (i.e. those with reset). Example -- Category ISAP Dependencies CALLS: chk_tag, is_struct, sap_error, sap_keyword_set, update_history CALLED FROM: IA, GUI Filename sm_median.pro Author Laurent Verstraete (IAS) (--> LV) Version 1.4 History Draft reqs DL/ES/CW 27.7.95 revision of requirements E. Sturm 8.8.95 1.0 - 04.03.96 LV creation 1.2 - 15.03.96 LV modified to handle combined or separate sets of band/det. Treat all AARs. Make wavelengths ascendent. 1.3 12.07.96 ES stat added 1.4 22.07.96 ES replaced erroneous "in1" with "aar" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier spect_form Purpose convert the flux data in an aar to new units Synopsis outaar = spect_form(inaar,unit,inunit=inunit,nostdev=nostdev [,stat=stat]) Arguments Name I/O Type: Description: ------------------------------------------------------------- inaar I AAR structure with input flux unit I string output flux unit (e.g. 'jy', 'w/cm^2/um') inunit I strarr(2) optional input units: If there is no specification of the input units in the header of inaar, the default units 'um' and 'jy' are normally assumed. Inunit will overwrite this default values. The order is (wave,flux) nostdev I switch if set, standard deviations of flux are NOT converted (e.g. if the errors are not known) stat I/O int error status, 0 if ok, 1 if fatal Returns aar with flux and (optional) stdev data converted to new units Description Routine reads the input flux density unit from inaar header. If absent from header, the default unit 'jy' (Jansky) is used. The desired output flux unit is specified by giving an ASCII string. Checks whether input/output units are one of the allowed set. The flux unit can be one of the following: ['jy', 'w/cm^2/um', 'w/m^2/um', 'w/cm^2/hz', 'erg/s/cm^2/um', 'erg/s/m^2/um', 'erg/s/cm^2/hz']. An additional '/sr' (indicating surface brightness) may be appended to all these units. The routine looks up the correct conversion from input to output units from a matrix of short conversion algorithms and converts the data to the desired units. The actual conversion may depend on the wavelength units (e.g. when going from jy to w/cm^2/um). The new units are written into the FITS header keyword of the output aar. Comment If a new flux unit is to be added, then the sections 'define valid values for flux units' and 'define the conversion factors' have to be modified. If a new wavelength unit is to be added, then the section 'prepare mixed cases' (item 1), 3) and possibly 5a)) is to be modified. 'microns' is treated as 'um' Example outarr = spect_form(saar.header,'w/cm^2/um') converts the flux scale from the input unit (e.g. Jy) to W/cm^2/um. Dependencies CALLS: get_hdrkey, sap_error, update_history, write_hdrkey CALLED FROM: GUI, IA Category ISAP Filename spect_form.pro Author E. Sturm (ES) Version 1.3 History definition of requirements - 27.7.95 D. Rigopoulou/E.Wieprecht 0.1 6-Oct-95 ES first version, based on routines from Iffat Khan (IPAC) 1.0 30-11-95 ES V1 delivery 1.1 04-01-96 ES flux unit now also written to TUNIT3 (stdev). New call to write_fits_key 29-01-96 ES replaced read_fits_key with get_hdrkey, write_fits_key with write_hdrkey 20-02-96 ES changed conversion factor for mixed cases from 10^-12 to 10^-16; added second index to convin and convout computation in 5b). 1.2 09-07-96 ES stat added 1.3 26-07-96 ES treat 'microns' (LWS) as 'um' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier squit Purpose close ISAP history handling at the end of a session Synopsis squit Arguments Name I/O Type Description ----------------------------------------------------- Returns --- Description This routine shall be called at the end of an ISAP(IA) session. It is intended to be used in combination with sap.pro at the beginning of the session and with update_history.pro in ISAP (shell) routines or in appropriate IA routines. The ISAP journal file is closed. Its contents (the commands since the last call to an ISAP routine) are appended to the session log file before the journal file is deleted. This ensures that the session log file containes the last commands of the session. Comment The GUI history handling will be different and will be developed later. Example --- Dependencies CALLS: -- CALLED FROM: general auxillary routine Category ISAP Filename squit.pro Author E. Sturm (--> ES) Version 1.0 History 0.1 15-10-95 ES 1.0 30-11-95 ES V1 delivery ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier symgen Purpose generate vectors for user defined symbols Synopsis symgen, symx, symy, syml Arguments Name I/O Type Description ----------------------------------------------------- symx O fltarr(10,17) array of 10 vectors containig the x coordinates symy O fltarr(10,17) array of 10 vectors containig the y coordinates syml O intarr(10) vector of length 10 containig the number of polygons Returns --- Description The SYMGEN procedure generates vectors for user defined symbols: - square - diamond _ circle - triangle down - triangle up - star - "bow tie" - "hour glass" - hexagon - hexagon with cross Comment --- Example SYMGEN,Symx,Symy,Syml Dependencies CALLS: -- CALLED FROM: set_usersym.pro Category UTIL Filename symgen.pro Author A.Fiedler (--> AF) Version 1.0 History 1.0 July 1993 AF ;- ;+ Identifier syn_phot Purpose To produce synthetic photometry on IS0 SWS/LWS spectra or other spectra derived within the ISAP environment. This routine will allow comparison of integrated or averaged SEDs to other measurements such as from ISOPHOT, KAO observations, ground-based telescope observations, IRAS, or theoretical predictions. Synopsis struc_out = syn_phot(struc_in, filter, faar, saar, flux_int, err_stat, mode=mode, units_out_in=units_out_in, units_out=units_out) Arguments Name 1/0 Type Description struc_in I YAAAR Input structure (spectrum) containing the x-scale (wavelength) and the y-scale (flux density in Jy, W/m^2/um, or W/cm^2/um) that is to be used for synthetic photometry. filter I Name of filter which contains transmittance vs. wavelength. This name defines either an ASCII file or else a structure. faar O Filter structure in AAR format (possibly rebinned, see Comment 3 below) saar O Source Spectrum in AAR Format (possibly rebinned, see Comment 3 below) flux_int When mode = 'ave_nufnu' this is the integrated in-band flux returned by the procedure in W/cm^2 err_stat I Error status: 1 for fatal, 0 otherwise mode I The three choices are: 1. "ave" where the filter is used as a weighting function to compute the average flux density (making no assumptions about the spectral shape of the source) 2. "ave_nufnu" where the filter is used to compute the in-band flux and a flux density is returned assuming the source shape is nu x f_nu = const , or equivalently lambda f_lambda = constant 3. "int" where where the filter is used to compute the in-band flux default mode = "ave" units_in I allowed input units_out for the Source Spectrum are: `jy', `wcm2um', `wm2um', units_out default = `jy' units_out I For the "ave" and "ave_nufnu" modes the allowed output units_out are `jy', `wcm2um', `mag'. For the "int" mode the allowed units_out are w/cm2, w/m2 if units_out = `mag' the flux density is computed. A zero point value is found in the filter function directory area. The flux density is converted to magnitudes using the zero point and mag = 2.5 * LOG (zero_point/flux_density) units_out_out default = `jy' struc_out O struct YAAAR Structure containing the single flux or flux density or mag measurements vs. the single effective wavelength Returns A valid YAAAR structure containing a single flux, flux-density or a magnitude measurement at a single wavelength that represents the filter center. It returns the filter and input spectrum, with one or these rebinned onto the x axis or the other. For the ave_nufnu mode, the in-band flux is returned. Description Performs synthetic photometry on IS0 SWS or SWS spectra. Multiplies and integrates SWS and LWS spectra with filter functions to compute simulated in-band flux, or flux density, or magnitude Comments - The routine will operate on SWS, LWS, and PHT-S AARs (once PHT-S AAR are read into the YAAAR format). - This version will not make any adjustments for beam size and Source/Beam coupling. - The user may supply their own filter or else read a filter function out of the filter library using "read filter.pro", which will also check for the presence of zero-point values. The user must set up an environment variable (this is done in the standard ISAP start-up script) "SAP_FILTERS", which points to the directory containing filter files. - The input filter y-axis values are unitless transmissions which we call T'. In the case of the four IRAS filters, T' are the "Relative System Responsivities" - See The IRAS Explanatory Suppl. Section II.C.5. The input spectrum struct_in has a y-axis flux density value called S'. The valid flux densities are Jy, W/cm2/um, and W/m2/um. Values are internally converted to W/cm2/um. The routine does not yet propagate uncertainty values in its flux determination, although this is a high priority requirement Details of processing: 1) The input SWS/LWS spectrum or modeled SED spectrum is called S' and is also a function of lambda. Its flux density units_out are converted to W/cm2/um by the routine. 2) The filter is identified by name. If the name is the name of a structure, the routine uses this structure. Otherwise, the routine looks for the filter in an ISAP directory defined by an environment variable "SAP_FILTERS" The routine uses filter.pro to locate the filter and make YAAAR which is a function of lambda and has in place of its flux values, the filter's transmission. T'. 3) The routine examines the sampling of the wavelengths in the S' and filter T' arrays. It records the maximum delta_lambda in T' and the maximum delta_lambda in the wavelenguh range of S' The array has the smaller maximum delta_lambda is defined as the reference array for rebinning the other. The rebin is done. Now either T' is rebinned to T or S' is rebinned to S. We will hereafter refer to the two arrays that are on the same wavelength scale as T and S. In the rebinning process there is no extrapolation: beyond their range, each array is assumed to have y-values equal to zero. 4) Verify each S and filter are single-valued spectra with chk_multix using epsilon of 1e-5 microns. 5) Convert the S array to W/cm2/um. If the S array does not have units_in of flux density, exit with an error message. 6) When mode = "ave", normalize the T-values of the (possibly rebinned) filter function so that summation(1 to N) ( T x delta_lambda ) = 1 (See Summation Details Below) The routine will give a warning if any T < 0 on input and will set these values to 0 7) If mode = `ave' we compute the flux density by averaging S between the start and end wavelengths of the filter, weighted by T: flux density [W/cm2/um] = summation(1 to N) ( T x delta_lambda x S The mean wavelength in this mode is mean_lambda = summation(1 to N) ( T x delta_lambda x lambda) (See Summation Details Below.) 8) If mode = `int' we compute the flux treating the filter transmission values as actual transmission (e.g. a filter with all T values equal to 1 can be used integrate with unity transmission flux density over a given wavelength range to compute total flux.) the in-band flux is: Flux = summation(1 to N) (T delta_lambda S), W cm-2 or W m-2 The routine gives a warning if T < 0 or T > 1 on input. the mean wavelength in this mode is weighted by the transmission. mean_lambda = summation(1 to N) (T x wave) / summation (1 to N) (T) 9) If mode= `ave_nufnu' follow step 8 above to arrive at the flux in W/cm2. After this, we convert the in-band flux to flux density under the assumption that the source shape is of the form nu x F_nu = constant. To do so, we handle the four IRAS filters and all other filters slightly differently. We do this in order to remain faithful to published IRAS filter effective widths: (13.48, 5.16, 2.58, 1.00) x 10^12 Hz, and effective wavelengths (12, 25, 60, 100um). For other filters we derive delta_lambda_eff and lambda_eff. 10) For the IRAF filters, eg. filter = 'iras_12.dat', our mode='ave_nufnu' procedure is to convert the flux to W/m2 and then to Jy by dividing the filter widths - the delta_nu's in Hz listed above, and finally multiplying by 10^26. By definition the effective wavelengths of the IRAS filters are lambda_eff = 12, 25, 60, or 100um If the user has requested output units_out of W/m2/um, we convert to W/m2/um by multiplying Jy by 10^-12 / lambda_eff^2 If the user has requested magnitudes, we use the flux density in Jy and mag = 2.5 log (zero_point/flux_density) where the zero_point value (in Jy) is found in the SAP_FILTERS path. 11) If the filter is not an IRAS filter, we first compute the following Two quantities: lambda_eff = summation(1 to N) (t delta_lambda] / summation(1 to N) (t delta_lambda/lambda] delta_lambda_eff= summation(1 to N) (t delta_lambda) For the relation of t to T, see the summation description below. For the derivation of these two formulae see the Derivation below. We divide the in-band flux (step 8) by delta_lambda_eff to get W/m2/um or W/cm2/um. If the user has requested Jy as the preferred output then we convert W/cm2/um to Jy by multiplying by lambda_eff^2/2.9979e-16. For output in magnitudes we again use mag = 2.5 log (zero_point/flux_density). We report the wavelength as lambda_eff as above. 12) Derivation of lambda_eff and delta_lambda_eff for Non-IRAS Filters ------------------------------------------------------------------- The idea here is that we have an arbitrary filter, and we are using it to measure the flux of an SED of arbitrary shape. Call this SED the "actual" SED. We will report a flux density at a wavelength at the filter's center (center as defined as lambda_eff). If a hypothetical source had an SED with flux density of the form: lambda f_lambda = constant and had the flux_density which we report at lambda_effective, then such a source would have the same total flux within the filter which is observed from the _actual_ SED. We first derive lambda_eff: lambda_eff = summation(1 to N) lambda weight / summation(1 to N) weight. The weight we use at each point is the product of the transmission t, the wavelength interval, delta_lambda, and a hypothetical SED with lambda f_lambda = C, or f_lambda = C/lambda. Thus, weight = delta_lambda t C/lambda. So lambda_eff = summation(1 to N) (lambda t delta_lambda C/lambda) / summation(1 to N) ( t delta_lambda C/lambda) which reduces to: lambda_eff = summation(1 to N) (t delta_lambda) / summation(1 to N) (t delta_lambda/lambda) Now, what is the effective width of the filter, delta_lambda_eff? Assume lambda_eff has been computed as above. delta_lambda_eff is defined for an SED of the form f_lambda=C/lambda, such that: f_lambda(lambda_eff)= {summation(1 to N) (t delta_lambda f_lambda)} / delta_lambda_eff Substituting in f_lambda=C/lambda, C/lambda_eff = {summation(1 to N) (t delta_lambda C/lambda)} /delta_lambda_eff and noting that lambda_eff is given by the ratio of summations above, we arrive at the simple result: delta_lambda_eff = summation(1 to N) (t delta_lambda) 13) Summation Details ----------------- There are several summations refered to above. The source and filter wavelength scale are not necessarily uniformly spaced so we have established a specification as to how the summations will be made to handle this. Filters will be assumed to end at the last specified lambda. We will take summations between the first and last lambda using mid-point lambda and Y values: S S ----s---- S S --s-- -s- S S S S ------------------------------- ----+------+-------+------ l d l d l d l If the S array (after rebinning) looks as shown above on the left, and we wish to integrate over it, we create the "s" array which is has the mean S values "s" at the midpoint (eventually weighted by errorbars), and an associated set of delta_lambdas with midpoints at locations "d". The T array is similarly prepared in t, d pairs. The sums mentioned above become as follows: (T delta_lambda S) becomes (t delta_lambda s), (T delta_lambda wave) becomes (t delta_lambda d). 14) STRUC_OUT (YAAAR) HEADER/HISTORY : The primary header of output YAAAR structure contains the following keywords. SIMPLE = T / Standard FITS format BITPIX = 8 / number of bits per data pixel NAXIS = 0 / number of data axes EXTEND = T / FITS dataset may contain extension ORIGIN = 'ISAP/IPAC' / Data written by MAKEYAAARHEAD COMMENT = 'ISO YAAAR' END The secondary header of output YAAAR structure contains the following keywords. XTENSION= 'BINTABLE' / Binary table FITS extension BITPIX = 8 / 8 BITS character format NAXIS = 2 / Tables are 2-d character array NAXIS1 = 16 / Characters in a row NAXIS2 = 1 / Number of rows in a table PCOUNT = 0 / Parameter count always 0 GCOUNT = 1 / Group count always 1 TFIELDS = 4 / No of columns in table TFORM1 = '1E ' / TTYPE1 = 'WAVE ' / wavelength of data point TUNIT1 = 'um ' / TFORM2 = '1E ' / TTYPE2 = 'FLUX ' / flux TUNIT2 = 'units_out ' / TFORM3 = '1E ' / TTYPE3 = 'STDEV ' / standard deviation TUNIT3 = 'units_out ' / TFORM4 = ''1J ' TTYPE4 = ''FLAG ' / masking flag TUNIT4 = '' ' END The history tag will contain the history from input structure struc_in, history from the filter YAAAR (read_filter.pro) , and from syn_phot itself. 15) Error (Uncertainty) propagation - TBD [We need a lot of different examples still. I would like to replace the one below because the IRAS filters will not typically be used like this.] Examples 1) out = syn_phot(sws01_aar, "IRAS_12um", units_out='jy') Multiply the IRAS 12um filter transmittance curve with an SWS01 spectrum and estimate the flux under the spectrum in this band-pass. User will get F_band in W/cm^2/um at a mean wave near 12 um. The Jy's at this wave are Jy= F_band x wave ^ 2 /2.99792E-16 Dependencies sap_rebin, read_filter, environment variable "SAP_FILTERS" pointing to filters directory. CALLED FROM: IA, GUI Category ISAP Filename syn_phot.pro Author Iffat Khan (irk@ipac.caltech.edu) Version 0.1 History 27. 7.95 requirements outline D. Lutz 16. 1.96 draft requirements J. Mazz, S. Lord 14. 2 96 more req.s (utypes) S. Lord 26. 2 96 even more req.s (units_out) S. Lord 06. 3 96 Design and Code I. Khan 06.05 96 Revision I. Khan 27.06 96 made an IRAS nufnu mode S. Lord 19.07 96 delivered code for v_2.1 irk 22.07 96 add an additinal param "stat" irk to write_hdrkey call irk ;- ;+ Indentifier tippex Purpose To replace specified fluxes with interploated values Synopsis status = tippex (struc_in, struc_out, tip_list [,all_det] [,all_scnt] [,all_sdir]) Arguments Name I/O Type Description -------------------------------------------------------- struc_in I struct Input structure (AAR) struc_out O struct Output structure (AAR) (unchanged if fatal error) tip_list I intarr Array containing the index numbers of the points to be replaced. (must be integers between 0 and N-1) all_det I int Optional keyword to include ALL detectors when updating flux. (default is to only include values from the SAME detector if there is a 'det' tag.) all_scnt I int Optional keyword to include ALL scans when updating flux. (default is to only include values from the SAME scan if there is a 'scnt' tag.) all_sdir I int Optional keyword to include BOTH scan directions when updating flux. (default is to only include values values from the SAME scan direction if there is a 'sdir' tag.) Returns status: 0 if OK 1 if fatal error Description For every point in the tip list, the "flux" value will be replaced by an interpolated value. Examples In the following example, the output is returned in an AAR structure named AAR_FLAGGED. To replace fluxes on the 2nd data point (index 1) stat = tippex (AAR_ORIG, AAR_TIP, 1) Dependencies CALLS: kwd_notset, sap_error, update_history CALLED FROM: IA, GUI Category ISAP Filename tippex.pro Author R. Narron (IPAC) Version 1.1 History definition of requirements - rewrite of E. Sturm's first draft by B. Swinyard 7/8/95 0.1 950912 --> R. Narron (IPAC) Prototype 0.2 951010 --> R. Narron (IPAC) New AAR definition 1.0 951027 --> R. Narron (IPAC) New parameter checking 1.1 960716 --> RN added check status from inter_pol Copyright (C) 1995, California Institute of Technology. U.S. Government Sponsorship under NASA Contract NAS7-918 is acknowledged. ****************************************************************************** ;- ;+ Identifier update_history Purpose write history information into the history tag of a given ISAP structure Synopsis update_history, struc [,co=co][,/no_ts][,/no_cl] [,file=file] Arguments Name I/O Type Description ----------------------------------------------------- struc I/O struct IA structure containing a history tag (e.g. AAR or Cal-G file) db I string write entries for database purposes OBSOLETE co I string write the given string as a comment into the history tag no_ts I switch don't write a time stamp no_cl I switch don't write the command line file I string The name of the journal file. Default: 'sap_default_journal.txt' Returns --- Description When an (IA/ISAP) subroutine is called update_history will write information into the history tag of the output structure. The default entry is a time stamp followed by the command line which called the subroutine. Alternatively it is possible to write comments. The time stamp (in the default IDL systime format) will always be written except if the keyword /no_ts is set. The format of the entries looks like: HISTORY = 'XX: informative string' where XX stands for a 2 character code describing the nature of the entry: TS: time stamp CL: command line ;DB: data base information (e.g. BASED_ON) OBSOLETE CO: comment (Note that the keyword is always HISTORY). As a consequence an informative string that is longer than 80-8-2-6=64 characters will be broken and continued in the next line. This continuation line will NOT contain the two character code. The supplied strings will be filled up to 64(68) characters to maintain a clean 80-character history layout. The routine first checks if the GUI variable !SAP_GUI is set. If so nothing is done (the GUI history handling will be implemented later). If not and if not keyword_set(no_cl) then the command line is extracted from the IA/ISAP journal file and added to the history tag (in the line following the time stamp). If the keyword /CO is set the corresponding entry will be added, too. The order of the entries is as follows: TS (referring to the following entry) CL ;DB OBSOLETE CO A history could hence look like HISTORY = 'TS: Fri Oct 20 12:20:32 1995' HISTORY = 'CL: outaar=aa(inspd,cal13=mycal13,cal25_1a=mycal25_' HISTORY = '1a,cal25_1b=mycal25_1b)' HISTORY = 'TS: Fri Oct 20 12:25:35 1995' HISTORY = 'CO: There seems to be a problem with band1!' When the history string gets too long (more than 32767 characters) the dimension of the history string array will be increased by one. Comment The usage of the IDL journal file requires a proper initiation of this file. This will be done automatically during the startup of IA and GUI or can be performed interactively (in IDL) calling sap.pro. The startup procedure will also close any user supplied journal file and initiate the general session log file. To add a comment manually use write2hist.pro (e.g. write2hist, out, 'Now it works!'). update_history doesn't return an error status because the only subroutine with an error status that is called is add_history_string. This subroutine, however, returns stat=1 only for a syntax error, which will not occur when called from update history. The main reason is that update_history is not used for the GUI at the moment. Example update_history, out This should be the last command before return in an ISAP subroutine that produces the output structure out. Dependencies CALLS: add_history_string, sap_error, sap_keyword_set CALLED FROM: general auxillary routine Category ISAP Filename update_history.pro Dependencies add_history_string.pro Author E. Sturm (--> ES) Version 1.2 History 20-10-95 ES+DL definition of requirements 0.1 25-10-95 ES 1.0 30-11-95 ES V1 delivery 1.1 29-02-96 ES modified action in case of struct doesn't contain history string 1.2 12-07-96 ES check, if journal file is open ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier vel_prof Purpose Convert a Spectrum (AAR) from wavelength to velocity space with respect to given (rest) wavelength(s). Synopsis aar_out = vel_prof( AAR, stat [,ref_wave=ref_wave] [,z=z] [,v=v] [,plot=plot] [stamps=stamps] [,_extra=e]) Arguments Name I/O Type Description ----------------------------------------------------- AAR I struct The input spectrum to be converted. stat O 0 or 1 error status, o=ok, 1=fatal ref_wave I int(arr) The reference wavelength (rest wavelength if z is specified). For each line in the AAR (identified by the line tag) a reference wavelength has to be given. If this keyword is not set then the routine analyses the AAR, displays which lines in which wavelength regions are present and asks the user for a ref wave for each line. z I float The redshift of the source, i.e. (lambda-lambda_0)/lambda0. If specified the program assumes ref_wave to be a rest wavelength (lambda_0). v I float c*z If specified the program assumes ref_wave to be a rest wavelength (lambda_0). plot I 0 or 1 If set, the lines are plotted in velocity space. stamps I 0 or 1 Same as /plot, but up to 6 lines are plotted into the same plot window (!p.multi = [0,2,3]). This can help to look for systematic deviations in the velocities. _extra I Any keyword(s) that is (/are) accepted by IDLs PLOT routine. Returns A copy of AAR but with wave of each line set to km/s units with respect to the given reference wavelengths. Description If not keyword_set(ref_wave) then analyse the AAR, print out the line numbers and their wavelength regions and ask the user for reference values. If keyword_set(z) then transform ref_wave according to ref_wave = ref_wave*(1+z). Compute velocities for each line: v = (wave/ref_wave - 1)*c. If keyword_set(plot or stamps) then plot immedialtely line by line in the respective plotmode. Comment Needs a properly filled line tag in the AAR. At least for SWS AOT1s this condition is currently not fulfilled. Seems to be reasonable only for AOTs in single line scan mode, i.e if there is only one spectral line per scan. If more than one line is present in a scan, you can specify a ref wave only for one of them. This is because the line numbering in the LINE tag of the AAR is associated with a scan and not with real lines (which is only reasonable). Currently, if ref_wave is not given, the user is interactively asked to enter the reference wavelengths. THIS IS NOT SUITABLE FOR THE GUI! Example IDL> aar_vel = vel_prof( AAR, stat, refwave=[17.035,28.219], z=0.01, /ynozero, xstyle=1 ) IDL> index1 = where(aar_vel.data.line eq 1) IDL> plot,aar_vel.data(index1).wave,aar_vel.data(index1).flux In this example an AAR containing two (H2) lines is converted according to the given rest wavelengths and redshift. In the subsequent plot the line profile of line 1 is plotted in velocity space, i.e. the wave unit is km/s and the line should be centered at v = 0 km/s. Dependencies CALLS: get_hdrkey, sap_error, sap_keyword_set, update_history, write_hdrkey CALLED FROM: IA, GUI Category ISAP Filename vel_prof.pro Author E. Sturm (--> ES) Version 0.2 History 0.1 15-02-96 ES first draft of requirements 0.2 19-02-96 ES first version ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier wav_dop Purpose Correct wavelengths in AAR for shifts due to radial velocity Synopsis out = wav_dop(in [,cz=cz] [,/lsr] [,/hel] [,/iso] [,stat=stat) Arguments Name I/O Type: Description: ---------------------------------------------------------- in I aar input aar cz I float radial velocity (km/s) defined as c * z, z=(lambda_obs-lambda_rest)/lambda_rest /lsr I -- correct to local standard of rest using : THis program uses : The standard solar motion relative to the majority of stars in the general catalogs of radial velocity and proper motion is : V_sun = 19.5 km/sec towards : rec_sun = 271 h , dec_sun=30.0 degree (EPOCH 2000) A scond definition is found in the literature also (but not used) : The basic solar motion relative to stars in the solar neighborhood is : V_sun = 15.4 km/sec towards rec_sun = 17.8 h , dec_sun = 25.0 degree (EPOCH 1900) /hel I -- correct to heliocentric /iso I -- correct to isocentric stat I/O int error status, 0 if ok, 1 if fatal Returns aar with modified wavelengths Description If keyword cz is set, simply correct for the given cz : out = in/(1+cz/c) SWITCHES: REQUIRE A HEADER KEYWORD TELLING WHICH SYSTEM THE INPUT DATA ARE IN (SWS DEFAULT: HELIOCENTRIC). FROM THERE, DECIDE WHETHER CONVERSION IS NECESSARY, DO IT IF YES. Data on the satellite and earth velocity components in viewing direction should be found in the FITS header. Comment If the header keyword TREFCOS is not defined the wavelength are expected to be heliocentric. If a conversion is done the keyword TREFCOS is set to 'HELIOCENTRIC', 'ISOCENTRIC' or 'LSR' The header keywords INSTRA and INSTROLL (used for LSR correction) refer to the FIRST pointing. Dependencies CALLS: get_hdrkey, is_struct, sap_error, sap_keyword_set, update_history, write_hdrkey CALLED FROM: GUI, IA Example --- Category ISAP Filename wav_dop.pro Author E.Wieprecht Version 1.2 History draft reqs DL 27.7.95 0.1 25-Sep-95 EkW first coding 0.2 20-Oct-95 EkW LSR incorporatet 1.0 30-Nov-95 ES V1 delivery 1.1 05-Jan-96 EkW correction keyword cz handling ES new call to write_fits_key 29-Jan-96 ES new call to is_struct, replaced read_fits_key with get_hdrkey, write_fits_key with write_hdrkey 1.2 10-Jul-96 ES stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier wave_form Purpose convert the wavelength data in an aar to new units Synopsis outaar = wave_form(inaar, unit [,inunit=inunit][,stat=stat]) Arguments Name I/O Type: Description: ------------------------------------------------------------- inaar I AAR structure with input wavelength unit I string output wavelength unit (e.g. 'um', 'hz', 'cm') inunit I string optional input unit: If there is no specification of the input unit in the header of inaar (i.e. no TUNIT3), the default unit 'um' is normally assumed. Inunit will overwrite this default value. stat I/O int error status, 0 if ok, 1 if fatal Returns aar with wavelength data converted to new units Description Routine reads the input wavelength unit from inaar header. If absent from header, the default unit 'um' is used (unless inunit is given). The desired output wavelength unit is specified by giving an ASCII string. Checks whether input/output units are one of the allowed set. The wavelength unit can be one of the following: ['m','cm','um','a','hz','cm^-1'] where a = Angstrom. The routine looks up the correct conversion from input to output units from a matrix of short conversion algorithms and converts the data to the desired units. The new units are written into the FITS header keyword of the output aar. Comment --- Example outarr = wave_form(saar, 'hz') converts the wavelength scale from the input unit (e.g. um) to hz Dependencies CALLS: get_hdrkey, sap_error, sap_keyword_set, update_history, write_hdrkey CALLED FROM: GUI, IA Category ISAP Filename wave_form.pro Author E. Sturm (ES) Version 1.3 History definition of requirements - 27.7.95 D. Rigopoulou/E.Wieprecht 0.1 06-10-95 ES first version, based on routines from Iffat Khan (IPAC) 0.2 24-11-95 ES corrected conversion hz <--> cm^-1 1.0 30-11-95 ES V1 delivery 1.1 04-01-96 ES New call to write_fits_key 29-01-96 ES replace read_fits_key with get_hdrkey, write_fits_key with write_hdrkey 1.2 10-07-96 ES stat added 1.3 16-07-96 ES treat 'microns' as 'um' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier write2hist Purpose write a comment into the history tag of a given IA/ISAP structure Synopsis write2hist, struc ,co [,/no_ts] [,stat=stat] Arguments Name I/O Type Description ----------------------------------------------------- struc I/O struct IA structure containing a history tag (e.g. AAR or Cal-G file) co I string string to be written as a comment into the history tag no_ts I switch don't write a time stamp stat I/O int error status, 0 if ok, 1 if fatal Returns --- Description The default entry to the history tag is a time stamp followed by the comment entry. The time stamp (in the default IDL systime format) will always be written except if the keyword /no_ts is set. The format of the entries looks like: HISTORY = 'CO: informative string' An informative string that is longer than 80-8-2-6=64 characters will be broken and continued in the next line. This continuation line will NOT contain the two character code CO. The supplied strings will be filled up to 64(68) characters to maintain a clean 80-character history layout. When the history string gets too long (more than 32767 characters) the dimension of the history string array will be increased by one. Comment see also update_history.pro Example write2hist, out, 'Now it works!',/no_ts Dependencies CALLS: add_history_string, sap_error CALLED FROM: IA Category ISAP Filename write2hist.pro Dependencies add_history_string.pro Author E. Sturm (--> ES) Version 1.1 History 0.1 2-11-95 ES 1.0 30-11-95 ES V1 delivery 1.1 10-07-96 ES stat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier write_hdrkey Purpose Write a keyword value and optionally the corresponding comment into the header of an ISAP structure Synopsis write_hdrkey, header, keyword, value, status [,comment=comment] [,pos=pos] [,second=second] [,errstat=errstat] Arguments Name I/O Type Description ----------------------------------------------------- header I string The input header keyword I string Keyword to write into header value I varies The value of the keyword. Allowed values: integer or long, float or double, string, and 0B for logical false or 1B for logical true. status O integer status code 0 keyword inserted as a new header line 1 keyword existed, overwritten 2 like 1, but old and new type differ comment I string The comment for the keyword pos The position at which the new keyword shall be inserted. Ignored if keyword already exists second If set the new keyword is written directly before the END line of the secondary header, else directly before the END line of the primary header (default). Ignored if pos is set or if keyword is found in primary header errstat I/O integer error status, 0 if ok, 1 if fatal Returns Description Writes a keyword into a header either before the end of the primary header (default) or before the end of the secondary header (if /second is set) or at the given position (if pos is given). If the keyword is already present, it is overwritten At the moment the first occurence of the keyword is taken. So the primary and secondary MUST NOT HAVE IDENTICAL KEYWORDS! Ensures that the product has correct length (blocks of 2880 characters) according to the fits standard. In case of a failure the program returns to the calling level and the header is not overwritten Comment Example 1) header = aar.header write_hdrkey, header, 'TUNIT1', 'cm', stat if stat eq 1 then aar.header = header This will overwrite the TUNIT1 value in the secondary header Dependencies CALLS: get_hdrkey, sap_error, sap_keyword_set CALLED FROM: ascii2yaaar, spect_form, wave_form, wav_dop Category ISAP Filename write_hdrkey.pro Author E. Sturm (--> ES) Version 1.1 History 1.0 25-01-96 ES First version 1.1 10-07-96 ES errstat added ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 1995, Max-Planck-Institut fuer extraterrestrische Physik (MPE); Garching, Germany ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;- ;+ Identifier zodiacal Purpose Compute zodiacal light model for an SWS AAR Synopsis out = zodiacal(in, err_stat, /iras_offset,/aperture) Arguments Name I/O Type: Description: ---------------------------------------------------------- in I AAR err_stat I Int Error status: 1 for fatal, 0 otherwise out O AAR iras_offset I int option to turn on the iras offsets aperture I int option to convert output fluxes from Jy/ster to Jy. Returns AAR with zodiacal light model Description Shell which reads ra ,dec, ut from AAR header, reads wavelength array from AAR data part, calls ZODI_MODEL, puts the result in AAR corresponding to the input AAR, and converts the surface brightness into flux densities (Jy/ster). TBD: Convert to Jy within applicable SWS aperture (using POINTTOEXT in /rev mode). Simple AAR arithmetics can then be used to subtract, add etc. the model from the original spectrum. Comment Example struc_out = zodiacal(inaar, stat) Dependencies CALLS: KWD_NOTSET, GET_HDRKEY, ZODI_MODEL CALLED FROM: IA, GUI Category ISAP Filename zodiacal.pro Author I. Khan (irk@ipac.caltech.edu) Version 0.1 History 17-07-95 Draft reqs DL S. Lord/J. Mazz 0.1 20-03-96 Design and code I. Khan ;-