----- Documentation for Util\angular_dist.pro ----- NAME: ANGULAR_DIST AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: compute angular distance between 2 targets defined by their equatorial coordinates using the haversine formula. CATEGORY: utilities CALLING SEQUENCE: ANG_DIST = ANGULAR_DIST(COORD1,COORD2) INPUTS: COORD1 = coordinates (RA/DEC, both in deg) of the first target (complex type). COORD2 = coordinates (RA/DEC, both in deg) of the second target (complex type). OUTPUTS: Function result = ANG_DIST = angular distance (in deg). OPTIONAL OUTPUT PARAMETER: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE. LOCAL FUNCTION USED: COSD HAVD LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2009/01/28 last modification by pcr 2010/02/04 ----- Documentation for Util\bisp_proj.pro ----- NAME: BISP_PROJ AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: bispectrum projection using simple baseline triplet average and trapezoidal wavelength integration with regular segments CATEGORY: utilities CALLING SEQUENCE: Y_PROJ = BISP_PROJ(N_TRI,N_VALT,N_INT,N_VALS,Y_VAL) INPUTS: N_TRI = nber of triplets. N_VALT = nber of values per triplet. N_INT = nber of spectral intervals. N_VALS = nber of values per spectral interval. Y_VAL = Row vector of N_TRI*N_VALT*N_INT*N_VALS*N_PAR function complex values OUTPUT: Function result = Y_PROJ = Array of (N_TRI*N_INT,N_PAR) projected complex values. OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: REGUTRAP LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2008/05/02 last modification by pcr 2010/05/29 ----- Documentation for Util\bprecess.pro ----- NAME: BPRECESS PURPOSE: Precess positions from J2000.0 (FK5) to B1950.0 (FK4) CATEGORY: Utilities EXPLANATION: Calculates the mean place of a star at B1950.0 on the FK4 system from the mean place at J2000.0 on the FK5 system. CALLING SEQUENCE: bprecess, ra, dec, ra_1950, dec_1950 INPUTS: RA,DEC - Input J2000 right ascension and declination in *degrees*. Scalar or N element vector OUTPUTS: RA_1950, DEC_1950 - The corresponding B1950 right ascension and declination in *degrees*. Same number of elements as RA,DEC but always double precision. OPTIONAL INPUT-OUTPUT KEYWORDS NONE NOTES: The algorithm is taken from the Explanatory Supplement to the Astronomical Almanac 1992, page 186. Also see Aoki et al (1983), A&A, 128,263 BPRECESS distinguishes between the following two cases: (1) The proper motion is known and non-zero (2) the proper motion is unknown or known to be exactly zero (i.e. extragalactic radio sources). In this case, the reverse of the algorithm in Appendix 2 of Aoki et al. (1983) is used to ensure that the output proper motion is exactly zero. Better precision can be achieved in this case by inputting the EPOCH of the original observations. The error in using the IDL procedure PRECESS for converting between B1950 and J1950 can be up to 12", mainly in right ascension. If better accuracy than this is needed then BPRECESS should be used. An unsystematic comparison of BPRECESS with the IPAC precession routine (http://nedwww.ipac.caltech.edu/forms/calculator.html) always gives differences less than 0.15". REVISION HISTORY: Written, W. Landsman October, 1992 Vectorized, W. Landsman February, 1994 Treat case where proper motion not known or exactly zero November 1994 Handling of arrays larger than 32767 Lars L. Christensen, march, 1995 Converted to IDL V5.0 W. Landsman September 1997 Fixed bug where A term not initialized for vector input W. Landsman February 2000 Adapted for SPIDAST P. Cruzalèbes March 2010 with calls to SIND & COSD ----- Documentation for Util\complex2real.pro ----- NAME: COMPLEX2REAL AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: function converting n-dim complex vector into 2n-dim real CATEGORY: utilities CALLING SEQUENCE: RY = COMPLEX2REAL(CY) INPUTS: CY = input complex vector. OUTPUT: Function result = RY = output real vector. OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2008/07/01 last modification by pcr 2010/02/04 ----- Documentation for Util\ct2lst.pro ----- NAME: CT2LST PURPOSE: Convert from Local Civil Time to Local Mean Sidereal Time. CATEGORY: Utilities CALLING SEQUENCE: CT2LST, Lng, Tme, Lst INPUTS: Lng - The longitude in degrees (east of Greenwich) of the place for which the local sidereal time is desired, scalar. The Greenwich mean sidereal time (GMST) can be found by setting Lng = 0. Tme - The Julian date of time in question, scalar OPTIONAL INPUTS: None OUTPUTS: Lst The Local Sidereal Time for the date/time specified in hours. RESTRICTIONS: None PROCEDURE: The Julian date of the day and time is question is used to determine the number of days to have passed since 0 Jan 2000. This is used in conjunction with the GST of that date to extrapolate to the current GST; this is then used to get the LST. See Astronomical Algorithms by Jean Meeus, p. 84 (Eq. 11-4) for the constants used. EXAMPLE: The Web site http://tycho.usno.navy.mil/sidereal.html contains more info on sidereal time, as well as an interactive calculator. PROCEDURES USED: none REVISION HISTORY: Adapted from the FORTRAN program GETSD by Michael R. Greason, STX, 27 October 1988. Use IAU 1984 constants Wayne Landsman, HSTX, April 1995, results differ by about 0.1 seconds Longitudes measured *east* of Greenwich W. Landsman December 1998 Time zone now measure positive East of Greenwich W. Landsman July 2008 Remove debugging print statement W. Landsman April 2009 Adapted for SPIDAST by P. Cruzalèbes March 2010 ----- Documentation for Util\date_conv.pro ----- NAME: DATE_CONV PURPOSE: Perform conversion of dates to one of six possible formats. CATEGORY: Utilities EXPLANATION: The following date formats are allowed format 1: real*8 scalar encoded as: year*1000 + day + hour/24. + min/24./60 + sec/24./60/60 where day is the day of year (1 to 366) format 2: Vector encoded as: date(0) = year (eg. 2005) date(1) = day of year (1 to 366) date(2) = hour date(3) = minute date(4) = second format 3: string (ascii text) encoded as DD-MON-YEAR HH:MM:SS.SS (eg. 14-JUL-2005 15:25:44.23) OR YYYY-MM-DD HH:MM:SS.SS (ISO standard) (eg. 1987-07-14 15:25:44.23 or 1987-07-14T15:25:44.23) format 4: three element vector giving spacecraft time words from a Hubble Space Telescope (HST) telemetry packet. Based on total number of secs since midnight, JAN. 1, 1979 format 5: Julian day. As this is also a scalar, like format 1, the distinction between the two on input is made based on their value. Numbers > 2300000 are interpreted as Julian days. CALLING SEQUENCE results = DATE_CONV( DATE, TYPE ) INPUTS: DATE - input date in one of the possible formats. Must be scalar. TYPE - type of output format desired. If not supplied then format 3 (real*8 scalar) is used. valid values: 'REAL' - format 1 'VECTOR' - format 2 'STRING' - format 3 'FITS' - YYYY-MM-DDTHH:MM:SS.SS' 'JULIAN' - Julian date 'MODIFIED' - Modified Julian date (JD-2400000.5) TYPE can be abbreviated to the single character strings 'R', 'V', 'S', 'F', 'J', and 'M'. Nobody wants to convert TO spacecraft time (I hope!) OUTPUTS: The converted date is returned as the function value. HISTORY: version 1 D. Lindler July, 1987 adapted for IDL version 2 J. Isensee May, 1990 Made year 2000 compliant; allow ISO format input jls/acc Oct 1998 DJL/ACC Jan 1998, Modified to work with dates such as 6-JAN-1996 where day of month has only one digit. DJL, Nov. 2000, Added input/output format YYYY-MM-DDTHH:MM:SS.SS Replace spaces with '0' in output FITS format W.Landsman April 2006 Added Julian date capabilities on input and output. M.Perrin, July 2007 Adapted for SPIDAST, P. Cruzalèbes March 2010 ----- Documentation for Util\daycnv.pro ----- NAME: DAYCNV PURPOSE: Converts Julian dates to Gregorian calendar dates CATEGORY: Utilities CALLING SEQUENCE: DAYCNV, XJD, YR, MN, DAY, HR INPUTS: XJD = Julian date, positive double precision scalar or vector OUTPUTS: YR = Year (Integer) MN = Month (Integer) DAY = Day (Integer) HR = Hours and fractional hours (Real). If XJD is a vector, then YR,MN,DAY and HR will be vectors of the same length. WARNING: Be sure that the Julian date is specified as double precision to maintain accuracy at the fractional hour level. METHOD: Uses the algorithm of Fliegel and Van Flandern (1968) as reported in the "Explanatory Supplement to the Astronomical Almanac" (1992), p. 604 Works for all Gregorian calendar dates with XJD > 0, i.e., dates after -4713 November 23. REVISION HISTORY: Converted to IDL from Yeoman's Comet Ephemeris Generator, B. Pfarr, STX, 6/16/88 Converted to IDL V5.0 W. Landsman September 1997 Adapted for SPIDAST, P. Cruzalèbes March 2010 ----- Documentation for Util\deg2dms.pro ----- NAME: DEG2DMS AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: convert angle in decimal degree to deg:min:sec CATEGORY: utilities INPUT KEYWORD: D = scalar value of angle to convert OUTPUT KEYWORD: DMS = string chain '+-deg:min:sec' LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2010/03/16 last modification by pcr 2010/03/17 ----- Documentation for Util\deg2hms.pro ----- NAME: DEG2HMS AUTHOR: pierre.cruzalebes@oca.eu CATEGORY: utilities PURPOSE: convert angle in decimal degree to hour:min:sec INPUT KEYWORD: D = scalar value of angle to convert OUTPUT KEYWORD: HMS = string chain '+-hour:min:sec' LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2010/03/17 ----- Documentation for Util\euler.pro ----- NAME: EULER PURPOSE: Transform between Galactic, celestial, and ecliptic coordinates. CATEGORY: Utilities EXPLANATION: CALLING SEQUENCE: EULER, AI, BI, AO, BO, SELECT INPUTS: AI - Input Longitude in DEGREES. BI - Input Latitude in DEGREES. SELECT - Integer (1-6) specifying type of coordinate transformation. SELECT From To | SELECT From To 1 RA-Dec (2000) Galactic | 4 Ecliptic RA-Dec 2 Galactic RA-DEC | 5 Ecliptic Galactic 3 RA-Dec Ecliptic | 6 Galactic Ecliptic OUTPUTS: AO - Output Longitude in DEGREES, always double precision BO - Output Latitude in DEGREES, always double precision OPTIONAL INPUT KEYWORD: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE EXAMPLE: REVISION HISTORY: Written W. Landsman, February 1987 Adapted from Fortran by Daryl Yentis NRL Made J2000 the default, added /FK4 keyword W. Landsman December 1998 Add option to specify SELECT as a keyword W. Landsman March 2003 Use less virtual memory for large input arrays W. Landsman June 2008 Added /RADIAN input keyword W. Landsman Sep 2008 Adapted by P. Cruzalèbes Mar 2010 ----- Documentation for Util\extract_proheader.pro ----- NAME: EXTRACT_PROHEADER AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: extract the content of the header of a specified procedure CATEGORY: utilities CALLING SEQUENCE: HEAD = EXTRACT_PROHEADER(PRO_NAME) INPUTS: PRO_NAME = name of the procedure OUTPUTS: Function result = HEAD = procedure header OPTIONAL OUTPUT PARAMETER: NONE COMMON BLOCKS: NONE SIDE EFFECTS: NONE REQUIREMENTS: header part must start with ';+' and end with ';-' PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: MAX_HEADER REVISION HISTORY: Written by pcr 2010/02/05 last modification by pcr 2010/03/29 ----- Documentation for Util\functproj.pro ----- NAME: FUNCTPROJ AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: function projection using simple baseline average and trapezoidal wavelength integration with regular segments CATEGORY: utilities CALLING SEQUENCE: Y_PROJ = FUNCTPROJ(N_BAS,N_VALB,N_INT,N_VALS,Y_VAL) INPUTS: N_BAS = nber of baselines. N_VALB = nber of values per baseline. N_INT = nber of spectral intervals. N_VALS = nber of values per spectral interval. Y_VAL = 2-dim array of (N_BAS*N_VALB*N_INT*NVALS,N_PAR) function values. OUTPUT: Function result = Y_PROJ = Array of (N_BAS*N_INT,N_PAR) projected values. OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: REGUTRAP LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2006/11/22 Last moddification by pcr 2010/05/29 ----- Documentation for Util\gaussian.pro ----- NAME: GAUSSIAN AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: compute three-parameter Gaussian function. CATEGORY: Utilities CALLING SEQUENCE: Y = GAUSSIAN(X,X0,GAMMA,I) INPUTS: X = row vector of values to be evaluated. X0 = location parameter, specifying location of peak of function. GAMMA = scale parameter, specifying half-width at half-maximum (HWHM). I = height of peak (amplitude). OUTPUTS: Function result = Y = Gaussian function of X (same dim as X). OPTIONAL OUTPUT PARAMETER: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: Y=I*EXP(-Z^2/2), where Z=(X-X0)/GAMMA LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: EPSILON REVISION HISTORY: Written by pcr 2009/01/28 last modification by pcr 2010/07/23 ----- Documentation for Util\get_syn_ref.pro ----- NAME: GET_SYN_REF AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: GET WAVELENGTH AND FLUX FROM A SYNTHETIC EXITANCE FILE TO RETURN THE REFERENCE EXITANCE (INTEGRATED OVER GIVEN SPECTRAL BANDWITHS) AND OPTIONALLY GET WAVELENGTH, IMPACT PARAMETER, AND INTENSITY FROM A CONVERTED SYNTHETIC RADIANCE FILE TO RETURN THE REFERENCE RADIANCE (INTEGRATED OVER THE SAME BANDWITHS). PROCEDURE USED BY FIT_MODEL, FIT_SED, CREATE_DATA, AND TEST_MODEL WITH SYNTHETIC MODEL (E.G. MARCS) CATEGORY: UTILITIES CALLING SEQUENCE: GET_SYN_REF,NAME_EM,WVL,WVL_MIN,WVL_MAX,EM0,REF_FLUX,NAME_LU,WVL_MEAS, RIP,REF_INT,ROSS2LD INPUTS: NAME_EM = SYNTHETIC EXITANCE FILE NAME. WVL = ROW VECTOR OF WAVELENGTHS. WVL_MIN = ROW VECTOR OF BANDWIDTH LOWER LIMITS, SAME SIZE AS WVL. WVL_MAX = ROW VECTOR OF BANDWIDTH UPPER LIMITS, SAME SIZE AS WVL. EM0 = ROW VECTOR OF THEORETICAL EXITANCE (USED WHEN NO SYNTHETIC FLUX IN BANDWIDTH), SAME SIZE AS WVL. OUTPUTS: REF_FLUX = ROW VECTOR OF REFERENCE FLUX, SAME SIZE AS WVL. OPTIONAL INPUT PARAMETERS: NAME_LU = SYNTHETIC RADIANCE FILE NAME (STRING). WVL_MEAS = ROW VECTOR OF MEASURED WAVELENGTHS. OPTIONAL OUTPUT PARAMETERS: RIP = ROW VECTOR OF ROSSELAND TO LIMB-DARKENED PHOTETER CONVERSION FACTOR + IMPACT PARAMETERS. REF_INT = (LENGTH(WVL),LENGTH(RIP)) ARRAY OF REFERENCE RADIANCES. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: SEE CODE. LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: TRAP LOCAL SYSTEM VARIABLE USED: LUMIN_STEP NB_RES_STEP REVISION HISTORY: Written by pcr 2007/10/09 last modification by pcr 2011/01/13 ----- Documentation for Util\get_wave_list.pro ----- NAME: GET_WAVE_LIST AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: extract wavelength lists from closure phase or AMBER input data CATEGORY: utilities INPUTS: needs text input file (in OBS_PATH/INP/ directory) with : - nber of data file(s) containing wavelength information (1 data file = 1 band) - input data file name(s) (1 file per row) - output wavelength file name(s) (in same row) - if needed: closure phase format ('clos') REQUIREMENTS: for closure phase data: data read in calibrator closure phase data file(s) (in subdirectory of OBS_PATH/) must be in ASCII format and contain : - wavelength [nm], closure phase and err. [deg] for AMBER data (default): data read in calibrator bispectral data file(s) (in subdirectory of OBS_PATH/) must be in ASCII format and contain : - wavelength [nm], nber of sel. fr. or weight, Re(bisp) and err., Im(bisp) and err. [photoel^3] OUTPUTS: data written in output wavelength file(s) (in the same subdirectory of OBS_PATH/) are (in this order, one row per spectral channel) : - wavelength and bandwidth [m] for each band LOCAL PROCEDURE CALLED: RESET_PLOT LOCAL FUNCTION USED: EXTRACT_PROHEADER LOCAL SYSTEM VARIABLE USED: NB_LAMBDA_MAX OBS_PATH SPEC_RES SPIDAST_PATH REVISION HISTORY: Written by pcr 2010/02/07 last modification by pcr 2010/04/01 ----- Documentation for Util\heliocor.pro ----- NAME: HELIOCOR PURPOSE: compute heliocentric velocity correction CATEGORY: utilities CALLING SEQUENCE HELIOCOR,obslong,obslat,ra,dec,pmra,pmdec,rjd,vhel,vlsr INPUTS: vhel: heliocentric velocity correction [km/s] vlsr: velocity correction to local standard of rest [km/s] KEYWORDS: OBSLON: observatory longitude [deg] OBSLAT: observatory latitude [deg] RA: right ascension J2000 [deg] DEC: declination J2000 [deg] PMRA: proper motion in RA [deg] PMDEC: proper motion in DEC [deg] RJD: reduced Julian date (= JD - 2400000) LOCAL PROCEDURE CALLED: CT2LST DEG2DMS DEG2HMS EULER PRECESS SUNPOS LOCAL FUNCTION USED: ANGULAR_DIST COSD DATE_CONV SIND LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Adapted to SPIDAST by pcr 2010/03/12 from http://www.astro.washington.edu/docs/idl/cgi-bin/getpro/library31.html?HELIOCOR last modification by pcr 2010/03/17 ----- Documentation for Util\helio_jd.pro ----- NAME: HELIO_JD PURPOSE: Convert geocentric (reduced) Julian date to heliocentric Julian date CATEGORY: Utilities EXPLANATION: This procedure correct for the extra light travel time between the Earth and the Sun. An online calculator for this quantity is available at http://www.physics.sfasu.edu/astro/javascript/hjd.html CALLING SEQUENCE: jdhelio = HELIO_JD( date, ra, dec) INPUTS date - reduced Julian date (= JD - 2400000), scalar or vector, MUST be double precision ra,dec - scalars giving right ascension and declination in DEGREES Equinox is J2000 OUTPUTS: jdhelio - heliocentric reduced Julian date. OPTIONAL INPUT KEYWORDS NONE Wayne Warren (Raytheon ITSS) has compared the results of HELIO_JD with the FORTRAN subroutines in the STARLINK SLALIB library (see http://star-www.rl.ac.uk/). Time Diff (sec) Date RA(2000) Dec(2000) STARLINK IDL 1999-10-29T00:00:00.0 21 08 25. -67 22 00. -59.0 -59.0 1999-10-29T00:00:00.0 02 56 33.4 +00 26 55. 474.1 474.1 1940-12-11T06:55:00.0 07 34 41.9 -00 30 42. 366.3 370.2 1992-02-29T03:15:56.2 12 56 27.4 +42 10 17. 350.8 350.9 2000-03-01T10:26:31.8 14 28 36.7 -20 42 11. 243.7 243.7 2100-02-26T09:18:24.2 08 26 51.7 +85 47 28. 104.0 108.8 PROCEDURES CALLED: bprecess, xyz, zparcheck, sind, cosd, tand REVISION HISTORY: Algorithm from the book Astronomical Photometry by Henden, p. 114 Written, W. Landsman STX June, 1989 Make J2000 default equinox, add B1950, /TIME_DIFF keywords, compute variation of the obliquity W. Landsman November 1999 Adapted for SPIDAST, P. Cruzalèbes March 2010 ----- Documentation for Util\juldate.pro ----- NAME: JULDATE PURPOSE: Convert from calendar to Reduced Julian Date CATEGORY: Utilities EXPLANATION: Julian Day Number is a count of days elapsed since Greenwich mean noon on 1 January 4713 B.C. The Julian Date is the Julian day number followed by the fraction of the day elapsed since the preceding noon. This procedure duplicates the functionality of the JULDAY() function in in the standard IDL distribution, but also allows interactive input and gives output as Reduced Julian date (=JD - 2400000.5) (Also note that prior to V5.1 there was a bug in JULDAY() that gave answers offset by 0.5 days.) CALLING SEQUENCE: JULDATE, date, jd INPUT: DATE - 3 to 6-element vector containing year,month (1-12),day, and optionally hour, minute, and second all specified as numbers (Universal Time). Year should be supplied with all digits. Years B.C should be entered as negative numbers (and note that Year 0 did not exist). If Hour, minute or seconds are not supplied, they will default to 0. OUTPUT: JD - Reduced Julian date, double precision scalar. To convert to Julian Date, add 2400000.5 OPTIONAL INPUT KEYWORD: NONE RESTRICTIONS: The procedure HELIO_JD can be used after JULDATE, if a heliocentric Julian date is required. PROCEDURE USED: NONE REVISION HISTORY Adapted from IUE RDAF (S. Parsons) 8-31-87 Algorithm from Sky and Telescope April 1981 Added /PROMPT keyword, W. Landsman September 1992 Converted to IDL V5.0 W. Landsman September 1997 Make negative years correspond to B.C. (no year 0), work for year 1582 Disallow 2 digit years. W. Landsman March 2000 Adapted for SPIDAST, P. Cruzalèbes March 2010 ----- Documentation for Util\lorentzian.pro ----- NAME: LORENTZIAN AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: compute three-parameter Lorentzian function. CATEGORY: utilities CALLING SEQUENCE: Y = LORENTZIAN(X,X0,GAMMA,I) INPUTS: X = row vector of values to be evaluated. X0 = location parameter, specifying location of peak of function. GAMMA = scale parameter, specifying half-width at half-maximum (HWHM). I = height of peak (amplitude). OUTPUTS: Function result = Y = Lorentzian function of X (same dim as X). OPTIONAL OUTPUT PARAMETER: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE MODIFICATION HISTORY: Written by pcr 2009/01/28 last modification by pcr 2009/02/01 ----- Documentation for Util\make_tab3.pro ----- NAME: MAKE_TAB3 AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: create triple index table CATEGORY: utilities CALLING SEQUENCE: TAB = MAKE_TAB3(N_TRI) INPUTS: N_TRI = nber of baseline triplets. OUTPUT: Function result = TAB = Array of ((N_TRI+1)*3) baseline indexes (first column = N_OUV, N_PAIR, N_TRI). OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2008/05/04 Last modification by pcr 2008/12/22 ----- Documentation for Util\min_pdr_radius.pro ----- NAME: MIN_PDR_RADIUS AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: MEASURE LOCATION DEFINED BY MINIMUM OF FIRST PARTIAL DERIVATIVE (INFLEXION POINT) OF NORMALIZED RADIAL RADIANCE DISTRIBUTION (MUST BE DECREASING). FUNCTION USED BY CONVERT_LIMB_DATA, FIT_MODEL, CREATE_DATA, AND TEST_MODEL WITH SYNTHETIC MODEL (E.G. MARCS) CATEGORY: UTILITIES CALLING SEQUENCE: RADIUS = MIN_PDR_RADIUS(RIP,REF_INT) INPUTS: RIP = ROW VECTOR OF IMPACT PARAMETERS (OF LENGTH NB_RIP). REF_INT = 2-DIM ARRAY OF NORMALIZED REFERENCE INTENSITIES (OF SIZE NB_LAMBDA*NB_RIP). OUTPUTS: RADIUS = ROW VECTOR OF RADIUS (OF LENGTH NB_LAMBDA). OPTIONAL INPUT PARAMETERS: NONE. OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: MAX_LONG REVISION HISTORY: Written by pcr 2008/12/07 Last modification by pcr 2010/03/25 ----- Documentation for Util\plot_spectra.pro ----- NAME: plot_spectra AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: plot synthetic spectral radiant exitance files CATEGORY: utility INPUTS: need text input file with: - nber of files to plot - names of the exitance files to plot LOCAL PROCEDURE CALLED: RESET_PLOT LOCAL FUNCTION USED: none LOCAL SYSTEM VARIABLE USED: OBS_PATH SYNTHE_PATH REVISION HISTORY: Written by pcr 2008/04/27 ----- Documentation for Util\precess.pro ----- NAME: PRECESS PURPOSE: Precess coordinates from J2000.0 to EQUINOX. CATEGORY: Utilities EXPLANATION: The (RA,DEC) system is FK5 based on epoch J2000.0 CALLING SEQUENCE: PRECESS, ra, dec, equinox INPUTS: RA - Input right ascension (scalar or vector) in DEGREES DEC - Input declination in DEGREES (scalar or vector) EQUINOX - Equinox of precessed coordinates. OUTPUTS: The input RA and DEC are modified by PRECESS to give the values after precession. OPTIONAL INPUTS: NONE OPTIONAL INPUT KEYWORDS: NONE RESTRICTIONS: Accuracy of precession decreases for declination values near 90 degrees. PRECESS should not be used more than 2.5 centuries from 2000 on the FK5 system PROCEDURE: Algorithm from Computational Spherical Astronomy by Taff (1983), p. 24. (FK4). FK5 constants from "Astronomical Almanac Explanatory Supplement 1992, page 104 Table 3.211.1. PROCEDURE CALLED: Function PREMAT - computes precession matrix REVISION HISTORY Written, Wayne Landsman, STI Corporation August 1986 Correct negative output RA values February 1989 Added /PRINT keyword W. Landsman November, 1991 Provided FK5 (J2000.0) I. Freedman January 1994 Precession Matrix computation now in PREMAT W. Landsman June 1994 Added /RADIAN keyword W. Landsman June 1997 Converted to IDL V5.0 W. Landsman September 1997 Correct negative output RA values when /RADIAN used March 1999 Work for arrays, not just vectors W. Landsman September 2003 Adapted for SPIDAST P. Cruzalèbes March 2010 ----- Documentation for Util\premat.pro ----- NAME: PREMAT PURPOSE: Return the precession matrix needed to go from J2000. to EQUINOX. CATEGORY: Utilities EXPLANATION: This matrix is used by the procedures PRECESS to precess astronomical coordinates using FK5 (J2000.0) precession angles CALLING SEQUENCE: matrix = PREMAT( equinox ) INPUTS: EQUINOX - Equinox of precessed coordinates. OUTPUT: matrix - double precision 3 x 3 precession matrix, used to precess equatorial rectangular coordinates OPTIONAL INPUT KEYWORDS: NONE PROCEDURE: FK5 constants from "Astronomical Almanac Explanatory Supplement 1992, page 104 Table 3.211.1. REVISION HISTORY Written, Wayne Landsman, HSTX Corporation, June 1994 Converted to IDL V5.0 W. Landsman September 1997 Adapted for SPIDAST P. Cruzalèbes March 2010 ----- Documentation for Util\regutrap.pro ----- NAME: REGUTRAP AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: function average using composite trapezoidal 1D rule with uniform grid (if input function = 2D array => integration on second dim only) CATEGORY: utilities CALLING SEQUENCE: Y_TRAP = REGUTRAP(Y) INPUTS: Y = Row vector or 2D array of function values (can be complex). OUTPUTS: Function result = Y_TRAP = averaged value or vector (can be complex). OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2007/01/07 last modification by pcr 2011/01/15 ----- Documentation for Util\regutrap2.pro ----- NAME: REGUTRAP AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: function average using composite trapezoidal 2D rule with uniform grid (if input function = 3D array => integration on second and third dim only) CATEGORY: utilities CALLING SEQUENCE: Z_TRAP = REGUTRAP2(Z) INPUTS: Z = 2D or 3D array of function values (can be complex). OUTPUTS: Function result = Z_TRAP = averaged value or vector (can be complex). OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2011/01/15 last modification by pcr 2011/01/15 ----- Documentation for Util\reset_plot.pro ----- NAME: RESET_PLOT AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: RESET VARIABLES USED FOR PLOT CATEGORY: UTILITY CALLING SEQUENCE: RESET_PLOT INPUTS: NONE OUTPUTS: NONE COMMON BLOCKS: NONE SIDE EFFECTS: NONE RESTRICTIONS: NONE PROCEDURE: SEE CODE LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2007/10/19 last modification by pcr 2009/03/15 ----- Documentation for Util\sunpos.pro ----- NAME: SUNPOS PURPOSE: Compute RA and Dec of Sun at given date. CATEGORY: Utilities CALLING SEQUENCE: SUNPOS, jd, ra, dec, elong, obliquity INPUTS: jd - The Julian date of the day (and time), scalar or vector usually double precision OUTPUTS: ra - The right ascension of the sun at that date in DEGREES double precision, same number of elements as jd dec - The declination of the sun at that date in DEGREES elong - Ecliptic longitude of the sun at that date in DEGREES. obliquity - the obliquity of the ecliptic, in DEGREES OPTIONAL INPUT KEYWORD: NONE NOTES: Patrick Wallace (Rutherford Appleton Laboratory, UK) has tested the accuracy of a C adaptation of the sunpos.pro code and found the following results. From 1900-2100 SUNPOS gave 7.3 arcsec maximum error, 2.6 arcsec RMS. Over the shorter interval 1950-2050 the figures were 6.4 arcsec max, 2.2 arcsec RMS. The returned RA and Dec are in the given date's equinox. Procedure was extensively revised in May 1996, and the new calling sequence is incompatible with the old one. METHOD: Uses a truncated version of Newcomb's Sun. Adapted from the IDL routine SUN_POS by CD Pike, which was adapted from a FORTRAN routine by B. Emerson (RGO). MODIFICATION HISTORY: Written by Michael R. Greason, STX, 28 October 1988. Accept vector arguments, W. Landsman April,1989 Eliminated negative right ascensions. MRG, Hughes STX, 6 May 1992. Rewritten using the 1993 Almanac. Keywords added. MRG, HSTX, 10 February 1994. Major rewrite, improved accuracy, always return values in degrees W. Landsman May, 1996 Added /RADIAN keyword, W. Landsman August, 1997 Converted to IDL V5.0 W. Landsman September 1997 Adapted for SPIDAST P. Cruzalèbes March 2010 with calls to SIND & COSD ----- Documentation for Util\sym.pro ----- NAME: SYM AUTHOR: Martin Schultz PURPOSE: define a standard sequence of plotting symbols CATEGORY: utilities CALLING SEQUENCE: PLOT,X,Y,PSYM=SYM(NUMBER) INPUTS: NUMBER -> symbol number 0 : dot 1 : filled circle 2 : filled upward triangle 3 : filled downward triangle 4 : filled diamond 5 : filled square 6 : open circle 7 : open upward triangle 8 : open downward triangle 9 : open diamond 10 : open square 11 : plus 12 : X 13 : star 14 : filled rightfacing triangle 15 : filled leftfacing triangle 16 : open rightfacing triangle 17 : open leftfacing triangle KEYWORD PARAMETERS: none OUTPUTS: function returns the symbol number to be used with PSYM= in the PLOT command REQUIREMENTS: none NOTES: This function produces a side effect in that the USERSYM procedure is used to create a symbol definition. It's meant for usage within the PLOT, OPLOT, etc. command EXAMPLE: PLOT,X,Y,PSYM=SYM(0),SYMSIZE=3 produces a plot with dots (standard symbol 3) FOR I=0,17 DO OPLOT,X+1,Y,PSYM=SYM(I),COLOR=I overplots 17 curves each with its own symbol REVISION HISTORY: mgs, 22 Aug 1997: VERSION 1.00 mgs, 10 Sep 1999: - added SHOWSYM procedure Copyright (C) 1997, Martin Schultz, Harvard University This software is provided as is without any warranty whatsoever. It may be freely used, copied or distributed for non-commercial purposes. This copyright notice must be kept with any copy of this software. If this software shall be used commercially or sold as part of a larger package, please contact the author to arrange payment. Bugs and comments should be directed to mgs@io.harvard.edu with subject "IDL routine sym" ----- Documentation for Util\trap.pro ----- NAME: TRAP AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: function average using composite trapezoidal 1D rule with non-uniform grid (if input function = 2D array => integration on second dim only) CATEGORY: utilities. CALLING SEQUENCE: Y_TRAP = TRAP(X,Y) INPUTS: X = Row vector of independent variables. Y = Row vector (same dimension as X) or 2D array (second dim same as X) of function values (can be complex). OUTPUTS: Function result = Y_TRAP = averaged value or vector (can be complex). OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: EPSILON REVISION HISTORY: Written by pcr 2007/01/07 Last modification by pcr 2011/01/15 ----- Documentation for Util\trap2.pro ----- NAME: TRAP2 AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: function average using composite trapezoidal 2D rule with non-uniform grid (if input function = 3D array => integration on second and third dim only) CATEGORY: utilities. CALLING SEQUENCE: Z_TRAP = TRAP2(X,Y,Z) INPUTS: X = Row vector of (N_VALX) independent variables in x-direction. Y = Row vector of (N_VALY) independent variables in y-direction. Z = 2D (N_VALX,N_VALY) or 3D (second dim=N_VALX, third dim=N_VALY) array of function values (can be complex). OUTPUTS: Function result = Z_TRAP = averaged value or vector (can be complex). OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: EPSILON REVISION HISTORY: Written by pcr 2011/01/15 Last modification by pcr 2011/01/19 ----- Documentation for Util\trapez_fourier.pro ----- NAME: TRAPEZ_FOURIER AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: EVALUATE THE 2D TRAPEZOIDAL DISCRETE FOURIER TRANSFORM ON THE SECOND AND THIRD DIMENSIONS OF A 3D FUNCTION AND OPTIONALLY RETURN THE VALUES OF ITS PARTIAL DERIVATIVES VS FUNCTION PARAMETER(S) (INCLUDING ANGULAR DIAM). CATEGORY: UTILITIES. CALLING SEQUENCE: TRAPEZ_FOURIER,FREQ,PARAM,IDIM,RIP_X,RIP_Y,FUNCT,TF,PDER_FUNCT,PDER_TF INPUTS: FREQ = VECTOR OF (NB_LAMBDA) COMPLEX SPATIAL FREQUENCIES (REAL PART => X-DIRECTION, IMAGINARY PART => Y-DIRECTION) . PARAM = ROW VECTOR OF (NB_PAR) MODEL PARAMETERS. IDIM = INDEX OF FUNCTION PARAMETER USED AS ANGULAR DIAMETER. RIP_X = VECTOR OF (NB_X) RELATIVE IMPACT PARAMETERS IN X-DIRECTION. RIP_Y = VECTOR OF (NB_Y) RELATIVE IMPACT PARAMETERS IN Y-DIRECTION. FUNCT = 3-DIM ARRAY OF (NB_LAMBDA*NB_X*NB_Y) VALUES OF FUNCTION TO TRANSFORM (2D TRANSFORMATION DONE ON SECOND AND THIRD DIM ONLY). OUTPUTS: TF = COMPLEX VALUE OF THE TRAPEZOIDAL FOURIER TRANSFORM AT EACH WAVELENGTH. OPTIONAL INPUT: PDER_FUNCT = 4D ARRAY OF (NB_LAMBDA*NB_X*NB_Y*NB_PAR) COMPLEX VALUES OF PARTIAL DERIVATIVES OF FUNCTION. PDER_FUNCT(I,J,JJ,K) = DERIVATIVE AT ITH WAVELENGTH AND 2D IMPACT PARAMETER(J,JJ) W/RESPECT TO KTH FUNCTION PARAMETER. OPTIONAL OUTPUT PARAMETERS: PDER_TF = 2D ARRAY OF (NB_LAMBDA*NP_PAR) COMPLEX VALUES OF PARTIAL DERIVATIVES OF FOURIER TRANSFORM. PDER_TF(I,K) = DERIVATIVE AT ITH WAVELENGTH W/RESPECT TO KTH FUNCTION PARAMETER. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: TF(LAMBDA) = TRAP2(RIP_X,RIP_Y,FUNCT(LAMBDA,RIP_X,RIP_Y)*EXP(-iZ)) *DRIP_X*DRIP_Y*DIAM^2/4/PI WHERE: Z=(RIP_X*DOUBLE(FREQ(LAMBDA))+RIP_Y*IMAGINARY(FREQ(LAMBDA)))*DIAM*PI DIAM=PARAM(IDIM) DRIP_X=RIP_X(NB_RIP_X-1)-RIP_X(0) DRIP_Y=RIP_Y(NB_RIP_Y-1)-RIP_Y(0) IF PARAM NE DIAM : PDER_TF(LAMBDA,PARAM) = TRAP2(RIP_X,RIP_Y,PDER_FUNCT(LAMBDA,RIP_X,RIP_Y,PARAM)*EXP(-iZ)) *DRIP_X*DRIP_Y*DIAM^2/4/PI IF PARAM EQ DIAM : PDER_TF(LAMBDA,DIAM) =( TRAP2(RIP_X,RIP_Y,PDER_FUNCT(LAMBDA,RIP_X,RIP_Y,DIAM)*EXP(-iZ)) -i*TRAP2(RIP_X,RIP_Y,Z*FUNCT(LAMBDA,RIP_X,RIP_Y)*EXP(-iZ))/DIAM ) *DRIP_X*DRIP_Y*DIAM^2/4/PI LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: TRAP2 LOCAL SYSTEM VARIABLE USED: EPSILON MAS2RADIAN REVISION HISTORY: Written by pcr 2011/01/14 Last modification by pcr 2011/01/17 ----- Documentation for Util\trapez_hankel.pro ----- NAME: TRAPEZ_HANKEL AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: EVALUATE THE 1D TRAPEZOIDAL DISCRETE HANKEL (FOURIER-BESSEL) TRANSFORM ON THE SECOND DIMENSION OF A 2D FUNCTION AND OPTIONALLY RETURN THE VALUES OF ITS PARTIAL DERIVATIVES VS FUNCTION PARAMETER(S) (INCLUDING ANGULAR DIAM). CATEGORY: UTILITIES. CALLING SEQUENCE: TRAPEZ_HANKEL,FREQ,PARAM,IDIM,RIP,FUNCT,TH,PDER_FUNCT,PDER_TH INPUTS: FREQ = SPATIAL FREQUENCY VECTOR (OF LENGTH NB_LAMBDA). PARAM = ROW VECTOR OF MODEL PARAMETERS (OF LENGTH NB_PAR). IDIM = INDEX OF FUNCTION PARAMETER USED AS ANGULAR DIAMETER. RIP = RELATIVE IMPACT PARAMETER VECTOR (OF LENGTH NB_RIP). FUNCT = ARRAY OF (NB_LAMBDA*NB_RIP) VALUES OF FUNCTION TO TRANSFORM (1D TRANSFORMATION DONE ON SECOND DIM ONLY). OUTPUTS: TH = VALUE OF TRAPEZOIDAL HANKEL TRANSFORM AT EACH WAVELENGTH. OPTIONAL INPUT: PDER_FUNCT = 3D ARRAY CONTAINING THE PARTIAL DERIVATIVES OF FUNCTION. PDER_FUNCT(I,J,K) = DERIVATIVE AT ITH WAVELENGTH AND JTH IMPACT PARAM W/RESPECT TO KTH FUNCT PARAM. OPTIONAL OUTPUT PARAMETERS: PDER_TH = 2D ARRAY CONTAINING THE PARTIAL DERIVATIVES OF TRANSFORM. PDER_H(I,K) = DERIVATIVE AT ITH WAVELENGTH W/RESPECT TO KTH FUNCT PARAM. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: TH(LAMBDA) = TRAP(RIP,RIP*J0(Z)*FUNCT(LAMBDA,RIP))*DRIP*DIAM^2/2 WHERE: Z=RIP*FREQ(LAMBDA)*DIAM*PI J0=BESSEL FUNCTION ORDER 0 FIRST KIND DIAM=PARAM(IDIM) DRIP=RIP(NB_RIP-1)-RIP(0) IF PARAM NE DIAM : PDER_TH(LAMBDA,PARAM) = TRAP(RIP,RIP*J0*PDER_FUNCT(LAMBDA,RIP,PARAM))*DIAM^2/2*DRIP IF PARAM EQ DIAM : PDER_TH(LAMBDA,DIAM) = ( TRAP(RIP,RIP*J0(Z)*PDER_FUNCT(LAMBDA,RIP,DIAM)) +TRAP(RIP,RIP*JJ(Z)*FUNCT(LAMBDA,RIP))*2/DIAM )*DRIP*DIAM^2/2 WHERE: JJ(Z)=J0(Z)-Z*J1(Z)/2 , J1=BESSEL FUNCTION ORDER 1 FIRST KIND LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: TRAP LOCAL SYSTEM VARIABLE USED: EPSILON MAS2RADIAN REVISION HISTORY: Written by pcr 2007/09/03 Last modification by pcr 2011/01/17 ----- Documentation for Util\trigo_deg_lib.pro ----- NAME: TRIGO_DEG_LIB CATEGORY: utilities AUTHOR: pierre.cruzalebes@oca.eu REVISION HISTORY: Written by pcr 2010/10/04 ----- Documentation for Util\value_locate.pro ----- NAME: VALUE_LOCATE AUTHOR: Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770 craigm@lheamail.gsfc.nasa.gov PURPOSE: Locate one or more values in a reference array (IDL LE 5.2 compatibility) CATEGORY: Utilities CALLING SEQUENCE: INDICES = VALUE_LOCATE(REF, VALUES) DESCRIPTION: VALUE_LOCATE locates the positions of given values within a reference array. The reference array need not be regularly spaced. This is useful for various searching, sorting and interpolation algorithms. The reference array should be a monotonically increasing or decreasing list of values which partition the real numbers. A reference array of NBINS numbers partitions the real number line into NBINS+1 regions, like so: REF: X[0] X[1] X[2] X[3] X[NBINS-1] <----------|-------------|------|---|----...---|---------------> INDICES: -1 0 1 2 3 NBINS-1 VALUE_LOCATE returns which partition each of the VALUES falls into, according to the figure above. For example, a value between X[1] and X[2] would return a value of 1. Values below X[0] return -1, and above X[NBINS-1] return NBINS-1. Thus, besides the value of -1, the returned INDICES refer to the nearest reference value to the left of the requested value. If the reference array is monotonically decreasing then the partitions are numbered starting at -1 from the right instead (and the returned INDICES refer to the nearest reference value to the *right* of the requested value). If the reference array is neither monotonically increasing or decreasing the results of VALUE_LOCATE are undefined. VALUE_LOCATE appears as a built-in function in IDL v5.3 and later. This version of VALUE_LOCATE should work under IDL v4 and later, and is intended to provide a portable solution for users who do not have the latest version of IDL. The algrorithm in this file is slower but not terribly so, than the built-in version. Users should be able to place this file in their IDL path safely: under IDL 5.3 and later, the built-in function will take precedence; under IDL 5.2 and earlier, this function will be used. INPUTS: REF - the reference array of monotonically increasing or decreasing values. VALUES - a scalar value or array of values to be located in the reference array. KEYWORDS: NONE RETURNS: An array of indices between -1L and NBINS-1. If VALUES is an array then the returned array will have the same dimensions. SEE ALSO: VALUE_LOCATE (IDL 5.3 and later) REVISION HISTORY: Written and documented, 21 Jan 2001 Case of XBINS having only one element, CM, 29 Apr 2001 Handle case of VALUES exactly hitting REF points, CM, 13 Oct 2001 $Id: value_locate.pro,v 1.5 2001/10/13 17:59:34 craigm Exp $ Copyright (C) 2001, Craig Markwardt This software is provided as is without any warranty whatsoever. Permission to use, copy, modify, and distribute modified or unmodified copies is granted, provided this copyright and disclaimer are included unchanged. Adapted for SPIDAST, P. Cruzalèbes March 2010 ----- Documentation for Util\xyz.pro ----- NAME: XYZ PURPOSE: Calculate geocentric X,Y, and Z and velocity coordinates of the Sun CATEGORY: Utilities EXPLANATION: Calculates geocentric X,Y, and Z vectors and velocity coordinates (dx, dy and dz) of the Sun. (The positive X axis is directed towards the equinox, the y-axis, towards the point on the equator at right ascension 6h, and the z axis toward the north pole of the equator). Typical position accuracy is <1e-4 AU (15000 km). CALLING SEQUENCE: XYZ, date, x, y, z INPUT: date: reduced julian date (=JD - 2400000), scalar or vector OUTPUT: x,y,z: scalars or vectors giving heliocentric rectangular coordinates (in A.U) for each date supplied. Note that sqrt(x^2 + y^2 + z^2) gives the Earth-Sun distance for the given date. equinox of output is 1950. OPTIONAL KEYWORD INPUT: NONE PROCEDURE CALLS: COSD, SIND REVISION HISTORY Original algorithm from Almanac for Computers, Doggett et al. USNO 1978 Adapted from the book Astronomical Photometry by A. Henden Written W. Landsman STX June 1989 Correct error in X coefficient W. Landsman HSTX January 1995 Added velocities, more terms to positions and EQUINOX keyword, some minor adjustments to calculations P. Plait/ACC March 24, 1999 Adapted for SPIDAST, P. Cruzalèbes March 2010 ----- Documentation for Util\ydn2md.pro ----- NAME: YDN2MD PURPOSE: Convert from year and day number of year to month and day of month. CATEGORY: Utilities CALLING SEQUENCE: YDN2MD,yr,dy,m,d INPUTS: yr = 4 digit year (like 1988), integer scalar dy = day number in year (like 310), integer scalar or vector OUTPUTS: m = month number (1-12, e.g. 11 = Nov) d = day of month (like 5). Note: On error returns m = d = -1. REVISION HISTORY: Adapted from Johns Hopkins University/Applied Physics Laboratory Update to use VALUE_LOCATE, W. Landsman January 2001 Adapted for SPIDAST, P. Cruzalèbes March 2010 ----- Documentation for Util\zparcheck.pro ----- NAME: ZPARCHECK PURPOSE: Routine to check user parameters to a procedure CATEGORY: Utilities CALLING SEQUENCE: zparcheck, progname, parameter, parnum, types, dimens, [ message ] INPUTS: progname - scalar string name of calling procedure parameter - parameter passed to the routine parnum - integer parameter number types - integer scalar or vector of valid types 1 - byte 2 - integer 3 - int*4 4 - real*4 5 - real*8 6 - complex 7 - string 8 - structure 9 - double complex 10 - pointer 11 - object ref 12 - Unsigned integer 13 - unsigned int*4 14 - int*8 15 - Unsigned int*8 dimens - integer scalar or vector giving number of allowed dimensions. OPTIONAL INPUT: message - string message describing the parameter to be printed if an error is found OUTPUTS: none SIDE EFFECTS: If an error in the parameter is a message is printed a RETALL issued REVISION HISTORY version 1 D. Lindler Dec. 86 documentation updated. M. Greason, May 1990. Recognize double complex datatype W. Landsman September 1995 Converted to IDL V5.0 W. Landsman September 1997 Check for new data types (e.g. unsigned) W. Landsman February 2000 Adapted for SPIDAST P. Cruzalèbes March 2010 with calls to SIND & COSD