OKTOWRITE $SSW/radio/ovsa/idl/util/oktowrite.pro
[Previous] [Next]
 NAME:
     OKTOWRITE
 PURPOSE:
     Checks for existence of a file, and if it exists a widget is
     displayed asking if the file may be overwritten.
 CATEGORY:
     OVRO UTILITY
 CALLING SEQUENCE:
     ans = oktowrite(filename[,query])
 INPUTS:
     filename	the path and name of a file to be checked for existence
     query		an optional string to display.  If omitted, the string
   			  used is "Okay to overwrite this file?"
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
 ROUTINES CALLED:
 OUTPUTS:
     ans       a string containing either 'Yes' or 'No'.  If the
                 file does not exist, 'Yes' is returned.  If the
                 file does exist, then 'Yes' is returned if the user
                 gives overwrite permission, or 'No' otherwise.
 COMMENTS:
 CALLED BY:
	ADJUST_AMF, ADJUST_REFCAL, AMPHIT, APCAL_ADD_2MANT, APCAL_ADD_2M_RL
	CONCAT_OVSA_FILE, EXTRACT_RAW_DATA, INSERT_REC
	OVSA_EXPLORER formerly OVSA_PRESUB, OVSA_FORMAT_NEW, OVSA_PRESUB, SCHEDULE
	SPLIT_OVSA_FILE, WAMPHIT, WDIALOG_HISTORY, WDUMPREC
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
    Written 10-Apr-1997 by Dale Gary
    26-Jul-2005  DG
      Added query string option


Onedimensional files handling $SSW/radio/ethz/idl/ragview/files_1d.pro
[Previous] [Next]
 NAME:
	One-dimensional files handling.
 PURPOSE
	User Interface to read different types of files containing 
	data for one-dimensional plots.
 CALLING SEQUENCE:
	Files_1D, x, y [, qual, dx, dy, file ]
 INPUTS:
	Variables have the same meaning as for the outputs, but
	are used if a write option is selectioned.
 OUTPUTS:
	x, y: values to be plotted. 
	qualifier: the value given in the file by a number determined
		in the mdisp format description, 
		and translated for the system variable !psym.
	dx, dy: values for the length of the error bars, they are 1D
		if the bars are symmetric, otherwise 2D with
		the second dimension = 2.
	file: the name of the file read
 KEYWORDS:
	FILENAME: if the filename is given, the interactive
		part of the procedure is not used and the
		file named "filename" is read.
	FILETYPE: if the type is given, only those files are 
		selected, and the file type is not asked 
		interactively.
	LINESTYLE: the style of the line used to connect points.
		( Write default = 0 ). See !p.linestyle.
	THICK: the line thickness (Write default = 0 ).
		See !p.thick
	TITLE, SUBTITLE, XTITLE, YTITLE: For the description
		of the plot.
	STATUS: "Done" if a file has been read, "Not Done" else.
 SIDE EFFECT:
	Windows are opened, on vt300 the screen is erased.

 CALLS: ***
	Columns_Read, FILEMENU, FILES_1D, General_Menu [1], General_Menu [2]
	LOADSELECTION, MDISPREAD, MDISPWRITE
 MODIFICATION HISTORY:
	Creadted in June 1991 by A.Csillaghy
	Modified, A.Csillaghy, for Wave 4 (mdispread), Nov. 92


OPEN_NRH_CFILE $SSW/radio/nrh/idl/2dnrh/cfile/open_nrh_cfile.pro
[Previous] [Next]
 NAME:
	OPEN_NRH_CFILE

 PURPOSE:
	Cette procedure initialise les structures pour un fichier CFILE de NRH

 CATEGORY:
	Fichier CFILE

 CALLING SEQUENCE:
	OPEN_NRH_CFILE, File, Str_inf, Str_lim

 INPUTS:
	FILE	Nom du fichier

	
 KEYWORD PARAMETERS:
	Non

 OUTPUTS:
	STR_INF	Structure de type NRH_STR_INFIC
	STR_LIM	Structure de type NRH_STR_LIM

 CALLS: ***
	FXPAR [1], FXPAR [2], HEADFITS [1], HEADFITS [2], HEADFITS [3]
 CALLED BY:
	CENTER_NRH2, FLUX_NRH2
 COMMON BLOCKS:
	Non

 SIDE EFFECTS:
	Describe "side effects" here.  There aren't any?  Well, just delete
	this entry.

 RESTRICTIONS:
	Describe any "restrictions" here.  Delete this section if there are
	no important restrictions.

 PROCEDURE:
	Cette procedure remplit uniquement
		STR_INF.DATE, STR_LIM.HD, STR_LIM.HF

 EXAMPLE:
	Please provide a simple example here

 MODIFICATION HISTORY:
	Ecrit par:J Bonmartin (obspm.fr) le 15/09/98


OPENARC $SSW/radio/ovsa/idl/util/openarc.pro
[Previous] [Next]
 NAME:
     OPENARC
 PURPOSE:
     Open the archive file of a given filename, and associate
     the variable A with it, returning the logical unit number.
 CATEGORY:
     OVRO APC DATA
 CALLING SEQUENCE:
     lun = openarc(filename,a,nrec[,/update])
 INPUTS:
     filename  The fully qualified name of the file to open
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
     update    A switch to indicate that the file is to be opened
                 for writing/updating.
 ROUTINES CALLED:
     widget_message
 OUTPUTS:
     lun       The logical unit number of the open file.  To
                 close the file, use the procedure FREE_LUN,lun
     a         The ASSOC variable associated with the file.
     nrec      The number of records currently in the file (the
                 file may grow later)
 COMMENTS:
 CALLED BY:
	ACALCHEK, ANALYZE [1], APCALCHEK, ARLOCPLOT, BASFIT, CONCAT_OVSA_FILE, CTRCALCHEK
	DAILY, DLACHEK, DLASCAN, DLCALCHEK, EXTRACT_RAW_DATA, FCALCHEK, FLAREMETER, FST_MKPARM
	GCALCHEK, GET_SCANINFO, HIGHRES, INSERT_REC, LAUNCHER, LIMCHEK, MOUNTCAL
	OVSA_MAKE_INDEX, PCALCHEK, PKUPCHEK, PNTCHEK, QUICKLOOK, READ_DRIFTSCAN
	Read_DriftData, SATCALCHEK, SCREENDMP, SHOW_REGNS, SOLAID, SPLIT_OVSA_FILE, SURVANAL
	TOP20, TPANALYZE, TPCALCHEK1, TPCALCHEK2, TRUNCATE, WACAL, WANALYZE, WATCHER
	WDIALOG_HISTORY, WDUMPREC, WFSURVEY, WPOINT, WRITE_DAILY, WRITE_TPSEG, WTESTPLOT
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 11-Jan-1998 by Dale E. Gary
     23-Jul-2000  DG
       Added UPDATE switch to allow open for writing.  Also added
       error exit if file length is not a multiple of 2048.
     16-May-2002 GN
       Added AUTO switch to not display widget message when called in auto mode


OPLOT_CIRCLE $SSW/radio/nrh/idl/gen/oplot_circle.pro
[Previous] [Next]
 NAME:
	OPLOT_CIRCLE

 PURPOSE:
	Trace d'un cercle sur une image aux coordonnees 0,0

 CATEGORY:
	TRACE

 CALLING SEQUENCE:
	oplot_circle, radius

 INPUTS:
	RADIUS	Rayon du cercle

 CALLED BY:
	NRH_IMAGE, NRH_PLOT_REF, PLOT_MAXPOS, PLOT_SOURCES
 EXAMPLE:
	OPLOT_CIRCLE, 1.
 trace un cercle representant le soleil optique sur une image representee
 en coordonnees heliographiques
	Cette routine est equivalente a TVCIRCLE de IDLASTRO, mais ne deborde
 pas du cadre pour les traces de contours
	Elle ne peut etre utilisee a la suite de TV ou TVSCL, car le cercle est
 centre sur les coordonnees O,O, utiliser alors TVCIRCLE  
 MODIFICATION HISTORY:
	Ecrit par: J Bonmartin (obspm.fr)


OPTIC_CIRC $SSW/radio/nrh/idl/gen/optic_circ.pro
[Previous] [Next]
 NAME:
	OPTIC_CIRC

 PURPOSE:
	Cette procedure visualise une image et demande de definir le cercle
 optique en cliquant 3 points (CIR_3PNT)
	Ou bien demande d'entrer les cooordonnees du centre et la valeur du
 rayon solaire

 CATEGORY:
	Visualisation

 CALLING SEQUENCE:
	OPTIC_CIRC,Image,Xcen, Ycen, Ray


 INPUTS:
	Image	Image a visualiser (2 dimensions)


 OUTPUTS:
	Xcen	coordonnee X du centre du soleil optique
	Ycen	coordonnee Y du centre du soleil optique
	Ray	rayon du soleil optique

 KEYWORDS:
	DIM	Dimension de l'image affichee, 400 par defaut
	GROUP	Identification du widget appelant

 PROCEDURE;
	Cette procedure demande la confirmation de la determination du 
	soleil optique. Efface la fenetre et recommence l'affichage si 
	on le demande. Sinon elle efface la fenetre et retourne

 CALLS: ***
	CIR_3PNT, CONGRID [1], CONGRID [2], CONGRID [3], CW_FIELD, OPTIC_CIRC_EVENT
	TVCIRCLE, XMANAGER
 CALLED BY:
	FOPEN_GIF, FOPEN_PNG, FOPEN_STD_SOHO, FOPEN_YOHKOH, READ_MAP_GIF, READ_MAP_PNG
 EXAMPLE:

 MODIFICATION HISTORY:
	Ecrit par: J Bonmartin le 25/11/97
	Le 10/05/99	Widget pour la saisie des coordonnees du centre et
		la valeur du rayon (JB)


OSCSLOPE $SSW/radio/ovsa/idl/support/oscslope.pro
[Previous] [Next]
 NAME:
     OSCSLOPE
 PURPOSE:
     Routine, called from TCFIT, to find the slope DIDH
     of tuning currents as a function of frequency for a given
     oscillator.  Also returns an array of possible tuning
     current offsets.  TCFIT will evaluate which offset is
     correct.
 CATEGORY:
     OVRO APC INSTRUMENT CALIBRATION
 CALLING SEQUENCE:
     oscslope,data,iant,iosc,didh,tcoff,rbox,debug=debug
 INPUTS:
     data       the raw array of FCAL data as read from the data
                  file by FCALCHEK.
     iant       the antenna number (0-4) specifying which antenna
                  to use the data from.
     iosc       the oscillator number (0-2) specifying which oscillator
                  to use.
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
     debug      a switch that activates some debugging statements
                  for getting an indication of intermediate steps.
                  This switch is not compatible with /CMDFILE switch.
 ROUTINES CALLED:
 OUTPUTS:
     didh       the slope of tuning current vs harmonic that best
                  fits the data.  This is a coarse estimate that
                  will be refined in the calling routine, TCFIT.
     tcoff      an array of possible offsets to the function of
                  tuning current vs. harmonic number.  A choice is
                  made among them by the calling routine, TCFIT.
     rbox       a 2-d array representing a "stack" of phase locks (or
                  a lock map) with the x-dimension proportional to
                  DIDH (but scaled in length for greater accuracy)
                  and the y-dimension representing the stack of
                  harmonics.  This is an interim product returned
                  to, but not used by TCFIT--for debugging purposes.
 COMMENTS:
 CALLS: ***
	CONGRID [1], CONGRID [2], CONGRID [3], GAUSS_FIT
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 29-Jul-1998  DG
     26-Sep-1998  DG
       Changed determination of TCOFF, to return an array of possible
       offsets rather than just one or two.


Overplot Texts $SSW/radio/ethz/idl/ragview/custom/overplot_texts.pro
[Previous] [Next]
 NAME:
	Overplot Texts
 PURPOSE: 
	Allows creation of texts which will be overplotted in 
	the plot window, when "Data_Display"
	is used for plotting.
 CALLING SEQUENCE:
	Overplot_Texts
 SIDE EFFECTS
	The texts and their position in the plot window
	are kept in a special data structure.
 CALLS: ***
	ADD_TEXT, DATA_DISPLAY, General_Menu [1], General_Menu [2], MOVE_TEXT, N_Texts
	OVERPLOT_TEXTS, REMOVE_TEXT, Read_Test, Store_Text, WMESG, get_text, take_away
 MODIFICATION HISTORY:
	Created by A.Csillaghy in June 1991
		Inst. of Astronomy, ETH Zurich
       Modified for IDL5/SSW/Ragview in March 98 -- ACs


OVIEW2WEB $SSW/radio/ovsa/idl/web/oview2web.pro
[Previous] [Next]
 NAME:
     OVIEW2WEB
 PURPOSE:
     Creates an FTP batch file that is used to transfer files for
     a given day to the OVRO Solar Array web server.  Also initiates
     the sending of the files by spawning a batch job.
 CATEGORY:
     OVRO APC WEB
 CALLING SEQUENCE:
     oview2web,filename
 INPUTS:
     filename   the name of the OVRO data file (.ARC) for which to
                  create an overview web page.
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
 ROUTINES CALLED:
     break_file
 OUTPUTS:
 COMMENTS:
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], FILENAME2DATE, STR_SEP
	break_file [4]
 CALLED BY:
	TRUNCATE
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 27-Oct-1999 by Dale E. Gary
       Replacement for a much more involved routine of the same name
     31-Oct-1999  DG
       Slight change to reflect new location for files on bbsoweb.
     06-Nov-1999  DG
       Updates to send snapshot files from SOLAID.
     11-Jan-2000  DG
       Eliminated hardwired directory locations.
     29-Jan-2000 DG
       Fixed bug that caused spawn not to work because we were in the
       wrong disk.
     19-Apr-2000  DG
       Added handling of FITS files via a small change to add different
       relative path to FITS directory.  Assumes FITS is parallel to DATA.
     15-Dec-2000  DG
       Changed the root directory of web server to reflect change to
       web server file structure, after adding 20 GB disk.


OVSA2MAP $SSW/radio/ovsa/idl/mapping/ovsa2map.pro
[Previous] [Next]
 NAME:
     OVSA2MAP
 PURPOSE:
     Routine to read an OVSA FITS image file and return a
     MAP object with correct rotation for solar P angle.
 CATEGORY:
     OVRO MAPPING
 CALLING SEQUENCE:
     map = ovsa2map(filename[,header])
 INPUTS:
     filename  A string containing path and name of .FTS
                 file containing the OVSA image.
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
 ROUTINES CALLED:
     sxpar, fits2map, rot_map
 OUTPUTS:
     map       The map object containing the image and
                 associated information about it.
     header    Optional output containing a verbatim copy
                 of the FITS file header
 COMMENTS:
 CALLS: ***
	FITS2MAP [1], FITS2MAP [2], ROT_MAP, SXPAR [1], SXPAR [2], SXPAR [3]
 CALLED BY:
	display_ovsamap
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 28-Feb-2003 by Dale E. Gary


OVSA__DEFINE $SSW/radio/ovsa/idl/objects/ovsa__define.pro
[Previous] [Next]
 Project     : ovsa

 Name        : OVSA__DEFINE

 Purpose     : Define an ovsa object

 Category    : OVSA analysis

 Explanation : READ,  PLOT and HELP methods for OVSA FITS

 Syntax      : This procedure is invoked when a new ovsa object is
               created

 CALLS: ***
	ARR2STR [1], Arr2Str [2], CIRCLE_SYM, HMS2SEC, IPRINT, OBJ_METHODS, OVSA::HELP
	OVSA::PLOT, OVSA::READ, OVSA_BG, OVSA_FIT, OVSA_MESH, OVSA_MOVIE, PLOT_IMAGE, REVERSE
	UTPLOT [1], UTPLOT [2], UTPLOT [3], UTPLOT [4], UTPLOT [5], UTPLOT [6]
	ovsa_interact, read_ovsa_fits
 Examples    : Plot a total power light curve at 5.8 GHz from antenna 1 
               IDL> a = OBJ_NEW( 'ovsa' )
               IDL> a->READ, 'ovsa.fits', data
               IDL> a->PLOT, 1, 5.8, /lightcurve

 Inputs      : 'ovsa' = object classname
              
 Outputs     : Object with methods: READ,  PLOT and HELP

 Keywords    : None
                   
 History     : Written 8-Dec-1999 ptg
               Added movie keyword 4-April-2000 ptg 
               Added fit keyword 22-May-2000 ptg
               Added MESH keyword and checked code 21-Nov-2000 ptg

 Contact     : ptg@bbso.njit.edu (Peter Gallagher,  NJIT)


OVSA_BASELINE_SELECTOR $SSW/radio/ovsa/idl/widgets/ovsa_baseline_selector.pro
[Previous] [Next]
 NAME:
     OVSA_BASELINE_SELECTOR
 PURPOSE:
     To create an interface for selecting desired ovsa baselines
 CATEGORY:
     OVSA APC CALIBRATION ANALYSIS
 CALLING SEQUENCE:
     BASELINE_SELECTOR =OVSA_BASELINE_SELECTOR(Base,aatab=aatab,select=select)
 INPUTS:
     BASE  A widget base in which the baseline selector has to be inserted
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
     AATAB Set this keyword to an 8-element numerical array
           holding in the lowest positions the active antenna labels,
           and 255 after that. (For compatibility with the header.aatab tag in a given SAV file)
     SELECT Set this keyword to an 7 x 7 array in which for the off-diagonal elements
            0 means baseline disabled, while for the digonal elements means antenna (and all its associated baselines) disabled
 ROUTINES CALLED:
 OUTPUTS:
 COMMENTS:
 CALLS: ***
	CONCAT_DIR [1], CONCAT_DIR [2], CONCAT_DIR [3], OVSA_BASELINE_SELECTOR_EVENT
	concat_dir [4]
 CALLED BY:
	OVSA_EXPLORER formerly OVSA_PRESUB
 SIDE EFFECTS:
            Disabling an antenna takes precedence over the off diagonal elements in the SELECT array.
 RESTRICTIONS:
     This is not a stand-alone widget. A BASE widget must be provided
 MODIFICATION HISTORY:
     Written 20-Nov-2005 by Gelu M. Nita


OVSA_BG $SSW/radio/ovsa/idl/objects/ovsa_bg.pro
[Previous] [Next]
 Project     : ovsa

 Name        : OVSA_BG

 Purpose     : Subtract OVSA microwave background spectrum

 Category    : OVSA analysis

 Syntax      : result = ovsa_bg( dynamic )

 CALLS: ***
	AVERAGE, PLOT_IMAGE
 CALLED BY:
	OVSA__DEFINE
 Examples    : 

 Inputs      : dynamic = 2D dynamic spectrum
              
 Outputs     : result = the background subtracted array

 Keywords    : 
                   
 History     : Written 20-Nov-2000 ptg

 Contact     : ptg@bbso.njit.edu (Peter Gallagher,  NJIT)


ovsa_calib $SSW/radio/ovsa/idl/analysis/ovsa_calib.pro
[Previous] [Next]
 Project     : OVSA calibration

 Name        : ovsa_calib

 Purpose     : Apply phase and gain corrections using the 
               routine analyze.pro
               
 Syntax      : ovsa_calib, filename , [ r_start , r_end ] 

 Inputs      : filename  = And OVSA .ARC file

 Optional
 Input       : r_start = Record start number for a given solar scan 
               from launcher.pro or get_rec_no
               r_end = Record end number

 Outputs     : IDL save files 'filename[r,l,i].sav'

 Keywords    : None

 CALLS: ***
	ANALYZE [1], ANALYZE [2], ANALYZE [3], ARR2STR [1], Arr2Str [2], GET_REC_NO
 History     : Written 2-Nov-2000 Peter Gallagher

 Contact     : ptg@bbso.njit.edu (Peter Gallagher, BBSO)


OVSA_EXPLORER formerly OVSA_PRESUB $SSW/radio/ovsa/idl/widgets/ovsa_explorer.pro
[Previous] [Next]
 NAME:
     OVSA_EXPLORER (formerly OVSA_PRESUB )
 PURPOSE:
     User-friendly interface to explore, subtract background and fit OVSA data output from ANALYZE.
 CATEGORY:
     OVSA APC CALIBRATION ANALYSIS
 CALLING SEQUENCE:
     OVSA_EXPLORER[filename=filename,,group=group]
 INPUTS:
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
     filename  the name of an Analyze output (usually a SAV file) to be open
     group     Optional widget ID for a widget that, if closed, will
                 force closure of this widget heirarchy.
 ROUTINES CALLED:
 tp_fit, range_detector, profile_display, wcalibrate

 OUTPUTS:
 COMMENTS:
 CALLS: ***
	APPLY_CAL_ALL, APPLY_CAL_ALL_2M, ARR2STR [1], Arr2Str [2], BGND_INTERP
	BGND_INTVAL, BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], CONGRID [1]
	CONGRID [2], CONGRID [3], CW_PDMENU, DECREASE_RESOLUTION, DEFPARMS, DIALOG_MESSAGE
	FILE_EXIST [2], FIND_FILE, GET_FIXED_RANGE, GET_MENU, INCREASE_RESOLUTION, LOADCT
	MPFIT, MS2STR, MSEC2STR, NINT [1], NINT [2], OKTOWRITE, OUTPLOT [1], OUTPLOT [2]
	OUTPLOT [3], OVSA_BASELINE_SELECTOR, OVSA_EXPLORER, OVSA_EXPLORER_EVENT
	OVSA_FREQUENCY_SELECTOR, PROFILE_DISPLAY, READ_MED, SET_CURSOR, TP_FIT, UTPLOT [1]
	UTPLOT [2], UTPLOT [3], UTPLOT [4], UTPLOT [5], UTPLOT [6], WCALIBRATE, WPREFERENCES
	WQUERY, XMANAGER, XSURFACE, break_file [4], file_exist [1], file_exist [3]
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 08-Dec-2001 by Dale E. Gary
     21-Dec-2001  DG
       This program is becoming complete and useful.  Still many
       features left to put in.  Fixed bug in channel assignments.
       Also added plot labels.
     22-Dec-2001  DG
       Added spectral plot.  Cleaned up some small bugs.
     27-Dec-2001  DG
       Added a movie mode, started by clicking in the spectral plot
       window.
     27-Aug-2002 GN
       Changed the name from OVSA_PRESUB to OVSA_EXPLORER
       Added new features to allow spectral fitting, displaying and saving the results.
     19-Sept-2002 GN
       Added new features to allow calibration of an ARC file and open the result in
       OVSA_EXPLORER
     22-Sept-2002 GN
       Fixed bug in the save_it section
       Introduced "Open Next Sav" submenu item in "Tools"
       Changed the default path for opening a new file from !defaults.workdir to !defaults.datadir
     08-March-2003 GN
       Added code to overplot each antenna on median spectral plot
       Introduced "Show FLAREMETER scan" submenu item in "Tools"
       to display in a separate window the associated PNG file
       produced by FLAREMETER (assumed to be in !defaults.webdir folder).
     11-April-2003 GN
       Added code o allow flaging bad fraquencies
     12-April-2003 GN
       Added code to beter handle the fit intervals
     16-April-2003 GN
       Added code to remeber the last file open and display it when ovsa_explorer is launched
     1-Nov-2003 GN
       Changed the code o allow stopping the fitting process
       Added code to automatically load the movie from the med file if it exists at the time of oppening the sav file
     5-Jan-2004 GN
       Added the Help menu item to open the ovsa_explorer.htm help file.
     6-Jan-2004 GN
       Modified code to properly handle the cancellation of the open dialog when the application is launched.
     27-Aug-2005 GN
       Replaced old menu item "Save TP and Movie' by "Save Median Data",
       adding the functionality of saving RCP (rdata) and LCP (ldata) median data in the "*.med" files,
       regardless of the currently selected polarization, but still removing from median the discarded antennas.
     29-Nov-2005 GN
       Added phase display for the baseline channels
       Added baseline and frequency selector tabs for immaging purposes.


OVSA_FINTERP $SSW/radio/ovsa/idl/support/ovsa_finterp.pro
[Previous] [Next]
 NAME:
     OVSA_FINTERP
 PURPOSE:
     Simple routine to convert the non-uniform sampling of
     frequencies to a uniform log sampling, repeating frequencies
     where necessary so that a dynamic spectrum appears as
     close to uniformly distributed as possible.
 CATEGORY:
     OVSA APC SUPPORT
 CALLING SEQUENCE:
     ovsa_finterp,f,data,fout,out
 INPUTS:
     f         The original array of (non-uniformly spaced) frequencies.
     data      The original array of data, as output by ANALYZE (perhaps
                 after calibration and/or preflare subtraction).
     fout      The new frequency array, with repeated entries where
                 necessary to make the dynamic spectrum uniformly spaced
                 in log frequency.
     out       The output array of data--the same as DATA, except with
                 some frequencies repeated as necessary to make the
                 dynamic spectrum appear uniformly spaced in log frequency.
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
 ROUTINES CALLED:
 OUTPUTS:
 COMMENTS:
 CALLS: ***
	NINT [1], NINT [2]
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 27-Dec-2001 by Dale E. Gary
     21-Apr-2002  DG
       Fixed to work with any number of channels and polarizations


OVSA_FIT $SSW/radio/ovsa/idl/objects/ovsa_fit.pro
[Previous] [Next]
 Project     : ovsa

 Name        : OVSA_FIT

 Purpose     : Fit OVSA 1-18 GHz microwave spectrum with
               function of the form I = A nu^alpha (1 - exp(-B nu^-beta))

 Category    : OVSA analysis

 Syntax      : fit = ovsa_fit( freq, flux [, fmin, fmax, param=param, 
                                           /inter, /print , yrange=yrange ])

 CALLS: ***
	ARR2STR [1], Arr2Str [2], CIRCLE_SYM, MPFITEXPR
 CALLED BY:
	OVSA__DEFINE
 Examples    : 

 Inputs      : freq = the frequency array (best results if
                      use freqs between ~2 and ~17 GHz).
               flux = the corresponding flux array

 Optional    : fmin = the min frequency to fit from
 Inputs        fmax = the max freq to fit to
              
 Outputs     : fit = the 1D fit array

 Keywords    : param = array of fit parameters 
                      [ A, B, alpha, beta, alpha-beta ] 
               inter = 'interactive' mode - the function 
                        plots the spectrum and allows the user 
                        to select the region to be fitted 
               print = print the fit parameters
               yrange = set the yrange of plot eg, yrange = [10.0,1000.0]
                   
 History     : Written 20-Jan-2000 ptg
               Added interactive feature 20-Nov-2000 ptg

 Contact     : ptg@bbso.njit.edu (Peter Gallagher,  NJIT)


OVSA_FORMAT_NEW $SSW/radio/ovsa/idl/file/ovsa_format_new.pro
[Previous] [Next]
 NAME:
     OVSA_FORMAT_NEW
 PURPOSE:
     Converts older data without INDEX records and other problems to
     the format as of 2001.  This creates the INDEX records, repairs
     the incorrect calibrator coordinates in the EPHEM records, and
     creates proper GAINPARM, TPCAL, and other records in a HOUSEKEEPING
     segment.
 CATEGORY:
     OVRO APC FILE
 CALLING SEQUENCE:
     ovsa_format_new,filelist=filelist,outdir=outdir
 INPUTS:
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
     filelist  a list of files to convert to the new format.  If
                 omitted, the user is asked to choose the files.
     outdir    a directory in which to deposit the new files.  This
                 MUST NOT be the same directory as the original files,
                 since the new files have the same name.  If omitted,
                 the user is asked to supply the output directory.
 ROUTINES CALLED:
     ovsa_make_index, make_housekeeping
 OUTPUTS:
 COMMENTS:
 CALLS: ***
	BREAK_FILE [1], BREAK_FILE [2], BREAK_FILE [3], MAKE_HOUSEKEEPING, OKTOWRITE
	OVSA_MAKE_INDEX, break_file [4]
 SIDE EFFECTS:
     New files are written to the OUTDIR
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 03-Mar-2001 by Dale E. Gary
     23-Jul-2003  DG
       Changed name of MAKE_INDEX to OVSA_MAKE_INDEX to avoid conflict with
       LASCO routine of the same name.


OVSA_FREQUENCY_SELECTOR $SSW/radio/ovsa/idl/widgets/ovsa_frequency_selector.pro
[Previous] [Next]
 NAME:
     OVSA_FREQUENCY_SELECTOR
 PURPOSE:
     To create an interface for selecting desired ovsa baselines
 CATEGORY:
     OVSA APC CALIBRATION ANALYSIS
 CALLING SEQUENCE:
     FREQUENCY_SELECTOR =OVSA_FREQUENCY_SELECTOR(Base, f=f, selected=selected)
 INPUTS:
     BASE  A widget base in which the frequency selector has to be inserted
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
     F Use this keyword to provide the OVSA frequency array.
     SELECTED Set this keyword to an array containing 0/1 for unselected/selected frequencies.
 ROUTINES CALLED:
 OUTPUTS:
 COMMENTS:
 CALLS: ***
	OVSA_FREQUENCY_SELECTOR_EVENT
 CALLED BY:
	OVSA_EXPLORER formerly OVSA_PRESUB
 SIDE EFFECTS:
 RESTRICTIONS:
     This is not a stand-alone widget. A BASE widget must be provided
 MODIFICATION HISTORY:
     Written 29-Nov-2005 by Gelu M. Nita


OVSA_GET_COLOR $SSW/radio/ovsa/idl/util/ovsa_get_color.pro
[Previous] [Next]
 NAME:
     OVSA_GET_COLOR
 PURPOSE:
     Return the color code corresponding to a specified color table index,
     suitable for setting plot or !p.background color.
 CATEGORY:
     OVRO GENERAL SUPPORT ROUTINE
 CALLING SEQUENCE:
     color = ovsa_get_color(i)
 INPUTS:
     i        The index into the color table, for which to return the color
               code.
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
 ROUTINES CALLED:
 OUTPUTS:
     color    The color code corresponding to color table entry i
 COMMENTS:
 CALLED BY:
	DLASCAN, PLOT_ASC, SOLAID
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 17-May-1998 by Dale Gary
     23-Jul-2003  DG
       Changed GET_COLOR to OVSA_GET_COLOR to avoid conflict
       with routine of the same name in SMM tree.


OVSA_GET_INDEX $SSW/radio/ovsa/idl/index/ovsa_get_index.pro
[Previous] [Next]
 NAME:
     OVSA_GET_INDEX
 PURPOSE:
     Reads an INDEX segment from a .ARC file and returns a structure containing
     the information contained in therein.
 CATEGORY:
     OVRO APC UTIL
 CALLING SEQUENCE:
     idx = ovsa_get_index(a,nrec[,/create])
 INPUTS:
     a       The ASSOC variable associated with the .ARC file (as returned
                from a call to OPENARC()
     nrec    The total number of records in the file (as returned from a call
                to OPENARC()
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
     create  An optional switch to specify whether to allow the user to
                create a new INDEX record if none exists.
 ROUTINES CALLED:
     find_index, create_index, get_index_struct, getdata, decode
 OUTPUTS:
     idx     An INDEX structure containing the information from the INDEX
               segment (as defined in GET_INDEX_STRUCT()).
 COMMENTS:
 CALLS: ***
	CREATE_INDEX, DECODE, FIND_INDEX, GETDATA, GET_INDEX_STRUCT
 CALLED BY:
	ARLOCPLOT, CTRCALCHEK, DAILY, GET_SCANINFO, INSERT_REC, MOUNTCAL, NEWSCAN
	READ_DRIFTSCAN, SHOW_REGNS, SURVANAL, TPCALCHEK2, UPDATE_TPRECS, WDIALOG_HISTORY
	WDUMPREC, WFSURVEY, WRITE_TPSEG
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 03-Feb-2000 by Dale E. Gary
     18-Jul-2001 GN
       Replaced get_index by ovsa_get_index to avoid conflict with Yohkoh


ovsa_interact $SSW/radio/ovsa/idl/objects/ovsa_interact.pro
[Previous] [Next]
 Project     : ovsa

 Name        : ovsa_interact.pro

 Purpose     : All user to click on the dynamic spectrum and 
               view either a light curve or spectrum

 Category    : OVSA analysis

 Explanation :

 Syntax      : ovsa_interact,fold,iold,inew,tnew,fnew,ant,t_start,$
               spectrum=spectrum,lightcurve=lightcurve

 CALLS: ***
	ARR2STR [1], Arr2Str [2], CIRCLE_SYM, CLEAR_UTPLOT [1], CLEAR_UTPLOT [2], HMS2SEC
	LOADCT, PLOT_IMAGE, REVERSE, SEC2HMS, UTPLOT [1], UTPLOT [2], UTPLOT [3], UTPLOT [4]
	UTPLOT [5], UTPLOT [6]
 CALLED BY:
	OVSA__DEFINE
 Examples    :

 Inputs      : 

 Outputs     : 

 Keywords    : 

 History     : Written 09 December 1999, P. T. Gallagher, NJIT

 Contact     : ptg@penumbra.njit.edu


OVSA_LFIT $SSW/radio/ovsa/idl/fitting/ovsa_lfit.pro
[Previous] [Next]
 NAME:
     OVSA_LFIT
 PURPOSE:
     Does a linear fit to values at an array of times , giving the slope,
     offset, and sigma of the fit.
 CATEGORY:
     OVRO APC UTILITY
 CALLING SEQUENCE:
     errflg = ovsa_lfit(t,v,tref,vref,dvdt,sigv)
 INPUTS:
     t      Array of times corresponding to the data
     v      Array of values to which to fit the linear function
     tref   The reference time at which VREF is to be given
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
 ROUTINES CALLED:
 OUTPUTS:
     vref   The value of the fit at time TREF.
     dvdt   The slope of the fit.
     sigv   The standard error in the mean of the values V.
 COMMENTS:
 CALLED BY:
	RVAV
 SIDE EFFECTS:
 RESTRICTIONS:
     Assumes only data of finite values are supplied.
 MODIFICATION HISTORY:
     Written 04-Dec-1998 by Dale E. Gary
     23-Jul-2003  DG
       Changed the generic name LFIT to OVSA_LFIT to avoid conflict
       with McTiernan routine of the same name.


OVSA_LST $SSW/radio/ovsa/idl/time/ovsa_lst.pro
[Previous] [Next]
 NAME:
     OVSA_LST
 PURPOSE:
     Calculate the Local Sidereal Time for the Solar Array at the
     Owens Valley Radio Observatory, given a date and time as Modified
     Julian Day number.
 CATEGORY:
     OVRO APC TIME
 CALLING SEQUENCE:
     LST = OVSA_LST(MJD)
 INPUTS:
     MJD       the date and time given as a Modified Julian Day number,
                 which is JD-2400000.5
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
 ROUTINES CALLED:
 OUTPUTS:
 COMMENTS:
       OVSA_LST is based on slalib routine GMST, by Patrick Wallace.
 CALLED BY:
	ARLOCPLOT, DELAY, MAKE_SOLCALTRAJ, Read_DriftData
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 28-Mar-2000 by Dale E. Gary


OVSA_LUN_ASSOC $SSW/radio/ovsa/idl/file/ovsa_lun_assoc.pro
[Previous] [Next]
 NAME:
     OVSA_LUN_ASSOC
 PURPOSE:
     Obtain the logical unit number corresponding to an ASSOCIATED
     variable.
 CATEGORY:
     OVRO APC FILE
 CALLING SEQUENCE:
     lun = ovsa_lun_assoc(a,filename=filename)
 INPUTS:
     a         The ASSOCIATED variable corresponding to an open file
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
 ROUTINES CALLED:
 OUTPUTS:
     lun       The logical unit number (LUN) of the open file, or -1
                 if the file is not open.
     filename  The filename corresponding to the open file.
 COMMENTS:
     This is likely a very dangerous thing to do, since if RSI
     changes the format of the output of HELP, it will break.
 CALLED BY:
	NEWSCAN
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 04-Aug-2003 by Dale E. Gary


OVSA_MAKE_INDEX $SSW/radio/ovsa/idl/index/ovsa_make_index.pro
[Previous] [Next]
 NAME:
     OVSA_MAKE_INDEX
 PURPOSE:
     Interface to CREATE_INDEX, to make or update an INDEX segment in
     a data file.
 CATEGORY:
     OVRO APC DATA ANALYSIS
 CALLING SEQUENCE:
     ovsa_make_index,filename[,/update | ,outfile=outfile]
 INPUTS:
     filename  The name of the file in which to create or update the INDEX
                 segment.
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
     update    Switch to invoke updating of an existing INDEX segment.  If
                 set, and an INDEX segment already exists, the INDEX segment
                 will be overwritten in place.  If an INDEX segment does not
                 already exist, a new INDEX segment is written at the end of
                 the file, as usual.  If unset, and an INDEX segment already
                 exists, nothing is written.
     outfile   The full path name of a file to write the INDEX to.  This is
                 just passed on to CREATE_INDEX.  If omitted, the new INDEX
                 segment is written to the file named by FILENAME.  OUTFILE
                 keyword is not compatible with UPDATE keyword.
 ROUTINES CALLED:
     create_index
 OUTPUTS:
 COMMENTS:
 CALLS: ***
	CREATE_INDEX, OPENARC
 CALLED BY:
	CONCAT_OVSA_FILE, OVSA_FORMAT_NEW, SPLIT_OVSA_FILE
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 27-Nov-1999 by Dale E. Gary
     29-Dec-1999  DG
       Added UPDATE keyword to allow updating an existing INDEX segment.
     03-Mar-2001  DG
       Added OUTFILE keyword to allow writing INDEX to a new file.
     23-Jul-2003  DG
       Changed name of MAKE_INDEX to OVSA_MAKE_INDEX to avoid conflict with
       LASCO routine of the same name.


OVSA_MESH $SSW/radio/ovsa/idl/objects/ovsa_mesh.pro
[Previous] [Next]
 Project     : OVSA

 Name        : OVSA_MESH

 Purpose     : Regrid OVSA dynamic spectrum.

 Category    : OVSAQL (quicklook) analysis

 Explanation :

 Syntax      : OVSA_MESH, D_SPEC_OLD, FOLD, TOLD, D_SPEC_NEW, FNEW, TNEW

 CALLED BY:
	OVSA__DEFINE
 Examples    : 

 Inputs      : D_SPEC_OLD = Dynamic spectrum array to be corrected
               FOLD = Original frequency array
               TOLD = Original time array

 Outputs     : Same as inputs but corrected

 Keywords    : None
                                  
 History     : Written 09 December 1999, P. T. Gallagher, NJIT

 Contact     : ptg@penumbra.njit.edu


OVSA_MPFIT $SSW/radio/ovsa/idl/fitting/ovsa_mpfit.pro
[Previous] [Next]
 NAME:
   OVSA_MPFIT

 AUTHOR:
   Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770
   craigm@lheamail.gsfc.nasa.gov
   UPDATED VERSIONs can be found on my WEB PAGE:
      http://cow.physics.wisc.edu/~craigm/idl/idl.html
   Renamed to OVSA_MPFIT and changed to use [] on limited
      and limits arrays to avoid conflicts (with limits() function)

 PURPOSE:
   Perform Levenberg-Marquardt least-squares minimization (MINPACK-1)

 MAJOR TOPICS:
   Curve and Surface Fitting

 CALLING SEQUENCE:
   parms = OVSA_MPFIT(MYFUNCT, start_parms, FUNCTARGS=fcnargs, NFEV=nfev,
                 MAXITER=maxiter, ERRMSG=errmsg, NPRINT=nprint, QUIET=quiet,
                 FTOL=ftol, XTOL=xtol, GTOL=gtol, NITER=niter,
                 STATUS=status, ITERPROC=iterproc, ITERARGS=iterargs,
                 COVAR=covar, PERROR=perror, BESTNORM=bestnorm,
                 PARINFO=parinfo)

 DESCRIPTION:

  MPFIT uses the Levenberg-Marquardt technique to solve the
  least-squares problem.  In its typical use, MPFIT will be used to
  fit a user-supplied function (the "model") to user-supplied data
  points (the "data") by adjusting a set of parameters.  MPFIT is
  based upon MINPACK-1 (LMDIF.F) by More' and collaborators.

  For example, a researcher may think that a set of observed data
  points is best modelled with a Gaussian curve.  A Gaussian curve is
  parameterized by its mean, standard deviation and normalization.
  MPFIT will, within certain constraints, find the set of parameters
  which best fits the data.  The fit is "best" in the least-squares
  sense; that is, the sum of the weighted squared differences between
  the model and data is minimized.

  The Levenberg-Marquardt technique is a particular strategy for
  iteratively searching for the best fit.  This particular
  implementation is drawn from MINPACK-1 (see NETLIB), and seems to
  be more robust than routines provided with IDL.  This version
  allows upper and lower bounding constraints to be placed on each
  parameter, or the parameter can be held fixed.

  The IDL user-supplied function should return an array of weighted
  deviations between model and data.  In a typical scientific problem
  the residuals should be weighted so that each deviate has a
  gaussian sigma of 1.0.  If X represents values of the independent
  variable, Y represents a measurement for each value of X, and ERR
  represents the error in the measurements, then the deviates could
  be calculated as follows:

    DEVIATES = (Y - F(X)) / ERR

  where F is the analytical function representing the model.  You are
  recommended to use the convenience functions MPFITFUN and
  MPFITEXPR, which are driver functions that calculate the deviates
  for you.  If ERR are the 1-sigma uncertainties in Y, then

    TOTAL( DEVIATES^2 )

  will be the total chi-squared value.  MPFIT will minimize the
  chi-square value.  The values of X, Y and ERR are passed through
  MPFIT to the user-supplied function via the FUNCTARGS keyword.

  Simple constraints can be placed on parameter values by using the
  PARINFO keyword to MPFIT.  See below for a description of this
  keyword.

  MPFIT does not perform more general optimization tasks.  See TNMIN
  instead.  MPFIT is customized, based on MINPACK-1, to the
  least-squares minimization problem.

 USER FUNCTION

  The user must define a function which returns the appropriate
  values as specified above.  The function should return the weighted
  deviations between the model and the data.  For applications which
  use finite-difference derivatives -- the default -- the user
  function should be declared in the following way:

    FUNCTION MYFUNCT, p, X=x, Y=y, ERR=err
     ; Parameter values are passed in "p"
     model = F(x, p)
     return, (y-model)/err
    END

  See below for applications with analytical derivatives.

  The keyword parameters X, Y, and ERR in the example above are
  suggestive but not required.  Any parameters can be passed to
  MYFUNCT by using the FUNCTARGS keyword to MPFIT.  Use MPFITFUN and
  MPFITEXPR if you need ideas on how to do that.  The function *must*
  accept a parameter list, P.

  In general there are no restrictions on the number of dimensions in
  X, Y or ERR.  However the deviates *must* be returned in a
  one-dimensional array, and must have the same type (float or
  double) as the input arrays.

  User functions may also indicate a fatal error condition using the
  ERROR_CODE common block variable, as described below under the
  MPFIT_ERROR common block definition (by setting ERROR_CODE to a
  number between -15 and -1).

 ANALYTIC DERIVATIVES

  In the search for the best-fit solution, MPFIT by default
  calculates derivatives numerically via a finite difference
  approximation.  The user-supplied function need not calculate the
  derivatives explicitly.  However, if you desire to compute them
  analytically, then the AUTODERIVATIVE=0 keyword must be passed.  As
  a practical matter, it is often sufficient and even faster to allow
  MPFIT to calculate the derivatives numerically, and so
  AUTODERIVATIVE=0 is not necessary.

  Also, the user function must be declared with one additional
  parameter, as follows:

    FUNCTION MYFUNCT, p, dp, X=x, Y=y, ERR=err
     model = F(x, p)

     if n_params() GT 1 then begin
       ; Compute derivatives
       dp = make_array(n_elements(x), n_elements(p), value=x(0)*0)
       for i = 0, n_elements(p)-1 do $
         dp(*,i) = FGRAD(x, p, i)
     endif

     return, (y-model)/err
    END

  where FGRAD(x, p, i) is a user function which must compute the
  derivative of the model with respect to parameter P(i) at X.  When
  finite differencing is used for computing derivatives (ie, when
  AUTODERIVATIVE=1), the parameter DP is not passed.  Therefore
  functions can use N_PARAMS() to indicate whether they must compute
  the derivatives or not.

  Derivatives should be returned in the DP array. DP should be an m x
  n array, where m is the number of data points and n is the number
  of parameters.  dp(i,j) is the derivative at the ith point with
  respect to the jth parameter.

  The derivatives with respect to fixed parameters are ignored; zero
  is an appropriate value to insert for those derivatives.  Upon
  input to the user function, DP is set to a vector with the same
  length as P, with a value of 1 for a parameter which is free, and a
  value of zero for a parameter which is fixed (and hence no
  derivative needs to be calculated).  This input vector may be
  overwritten as needed.

  If the data is higher than one dimensional, then the *last*
  dimension should be the parameter dimension.  Example: fitting a
  50x50 image, "dp" should be 50x50xNPAR.

 CONSTRAINING PARAMETER VALUES WITH THE PARINFO KEYWORD

  The behavior of MPFIT can be modified with respect to each
  parameter to be fitted.  A parameter value can be fixed; simple
  boundary constraints can be imposed; limitations on the parameter
  changes can be imposed; properties of the automatic derivative can
  be modified; and parameters can be tied to one another.

  These properties are governed by the PARINFO structure, which is
  passed as a keyword parameter to MPFIT.

  PARINFO should be an array of structures, one for each parameter.
  Each parameter is associated with one element of the array, in
  numerical order.  The structure can have the following entries
  (none are required):

     .VALUE - the starting parameter value (but see the START_PARAMS
              parameter for more information).

     .FIXED - a boolean value, whether the parameter is to be held
              fixed or not.  Fixed parameters are not varied by
              MPFIT, but are passed on to MYFUNCT for evaluation.

     .LIMITED - a two-element boolean array.  If the first/second
                element is set, then the parameter is bounded on the
                lower/upper side.  A parameter can be bounded on both
                sides.  Both LIMITED and LIMITS must be given
                together.

     .LIMITS - a two-element float or double array.  Gives the
               parameter limits on the lower and upper sides,
               respectively.  Zero, one or two of these values can be
               set, depending on the values of LIMITED.  Both LIMITED
               and LIMITS must be given together.

     .PARNAME - a string, giving the name of the parameter.  The
                fitting code of MPFIT does not use this tag in any
                way.  However, the default ITERPROC will print the
                parameter name if available.

     .STEP - the step size to be used in calculating the numerical
             derivatives.  If set to zero, then the step size is
             computed automatically.  Ignored when AUTODERIVATIVE=0.
             This value is superceded by the RELSTEP value.

     .RELSTEP - the *relative* step size to be used in calculating
                the numerical derivatives.  This number is the
                fractional size of the step, compared to the
                parameter value.  This value supercedes the STEP
                setting.  If the parameter is zero, then a default
                step size is chosen.

     .MPSIDE - the sidedness of the finite difference when computing
               numerical derivatives.  This field can take four
               values:

                  0 - one-sided derivative computed automatically
                  1 - one-sided derivative (f(x+h) - f(x)  )/h
                 -1 - one-sided derivative (f(x)   - f(x-h))/h
                  2 - two-sided derivative (f(x+h) - f(x-h))/(2*h)

              Where H is the STEP parameter described above.  The
              "automatic" one-sided derivative method will chose a
              direction for the finite difference which does not
              violate any constraints.  The other methods do not
              perform this check.  The two-sided method is in
              principle more precise, but requires twice as many
              function evaluations.  Default: 0.

     .MPMAXSTEP - the maximum change to be made in the parameter
                  value.  During the fitting process, the parameter
                  will never be changed by more than this value in
                  one iteration.

                  A value of 0 indicates no maximum.  Default: 0.

     .TIED - a string expression which "ties" the parameter to other
             free or fixed parameters.  Any expression involving
             constants and the parameter array P are permitted.
             Example: if parameter 2 is always to be twice parameter
             1 then use the following: parinfo(2).tied = '2 * P(1)'.
             Since they are totally constrained, tied parameters are
             considered to be fixed; no errors are computed for them.
             [ NOTE: the PARNAME can't be used in expressions. ]

     .MPPRINT - if set to 1, then the default ITERPROC will print the
                parameter value.  If set to 0, the parameter value
                will not be printed.  This tag can be used to
                selectively print only a few parameter values out of
                many.  Default: 1 (all parameters printed)


  Future modifications to the PARINFO structure, if any, will involve
  adding structure tags beginning with the two letters "MP".
  Therefore programmers are urged to avoid using tags starting with
  the same letters; otherwise they are free to include their own
  fields within the PARINFO structure, and they will be ignored.

  PARINFO Example:
  parinfo = replicate({value:0.D, fixed:0, limited:[0,0], $
                       limits:[0.D,0]}, 5)
  parinfo(0).fixed = 1
  parinfo(4).limited(0) = 1
  parinfo(4).limits(0)  = 50.D
  parinfo(*).value = [5.7D, 2.2, 500., 1.5, 2000.]

  A total of 5 parameters, with starting values of 5.7,
  2.2, 500, 1.5, and 2000 are given.  The first parameter
  is fixed at a value of 5.7, and the last parameter is
  constrained to be above 50.


 HARD-TO-COMPUTE FUNCTIONS: "EXTERNAL" EVALUATION

  The normal mode of operation for MPFIT is for the user to pass a
  function name, and MPFIT will call the user function multiple times
  as it iterates toward a solution.

  Some user functions are particularly hard to compute using the
  standard model of MPFIT.  Usually these are functions that depend
  on a large amount of external data, and so it is not feasible, or
  at least highly impractical, to have MPFIT call it.  In those cases
  it may be possible to use the "(EXTERNAL)" evaluation option.

  In this case the user is responsible for making all function *and
  derivative* evaluations.  The function and Jacobian data are passed
  in through the EXTERNAL_FVEC and EXTERNAL_FJAC keywords,
  respectively.  The user indicates the selection of this option by
  specifying a function name (MYFUNCT) of "(EXTERNAL)".  No
  user-function calls are made when EXTERNAL evaluation is being
  used.

  At the end of each iteration, control returns to the user, who must
  reevaluate the function at its new parameter values.  Users should
  check the return value of the STATUS keyword, where a value of 9
  indicates the user should supply more data for the next iteration,
  and re-call MPFIT.  The user may refrain from calling MPFIT
  further; as usual, STATUS will indicate when the solution has
  converged and no more iterations are required.

  Because MPFIT must maintain its own data structures between calls,
  the user must also pass a named variable to the EXTERNAL_STATE
  keyword.  This variable must be maintained by the user, but not
  changed, throughout the fitting process.  When no more iterations
  are desired, the named variable may be discarded.


 INPUTS:
   MYFUNCT - a string variable containing the name of the function to
             be minimized.  The function should return the weighted
             deviations between the model and the data, as described
             above.

             For EXTERNAL evaluation of functions, this parameter
             should be set to a value of "(EXTERNAL)".

   START_PARAMS - An array of starting values for each of the
                  parameters of the model.  The number of parameters
                  should be fewer than the number of measurements.
                  Also, the parameters should have the same data type
                  as the measurements (double is preferred).

                  This parameter is optional if the PARINFO keyword
                  is used (but see PARINFO).  The PARINFO keyword
                  provides a mechanism to fix or constrain individual
                  parameters.  If both START_PARAMS and PARINFO are
                  passed, then the starting *value* is taken from
                  START_PARAMS, but the *constraints* are taken from
                  PARINFO.

 RETURNS:

   Returns the array of best-fit parameters.


 KEYWORD PARAMETERS:

   AUTODERIVATIVE - If this is set, derivatives of the function will
                    be computed automatically via a finite
                    differencing procedure.  If not set, then MYFUNCT
                    must provide the (analytical) derivatives.
                    Default: set (=1)
                    NOTE: to supply your own analytical derivatives,
                      explicitly pass AUTODERIVATIVE=0

   BESTNORM - the value of the summed squared residuals for the
              returned parameter values.

   COVAR - the covariance matrix for the set of parameters returned
           by MPFIT.  The matrix is NxN where N is the number of
           parameters.  The square root of the diagonal elements
           gives the formal 1-sigma statistical errors on the
           parameters IF errors were treated "properly" in MYFUNC.
           Parameter errors are also returned in PERROR.

           To compute the correlation matrix, PCOR, use this example:
           IDL> PCOR = COV * 0
           IDL> FOR i = 0, n-1 DO FOR j = 0, n-1 DO $
                PCOR(i,j) = COV(i,j)/sqrt(COV(i,i)*COV(j,j))

           If NOCOVAR is set or MPFIT terminated abnormally, then
           COVAR is set to a scalar with value !VALUES.D_NAN.

   DOF - number of degrees of freedom, computed as
             DOF = N_ELEMENTS(DEVIATES) - NFREE
         Note that this doesn't account for pegged parameters (see
         NPEGGED).

   ERRMSG - a string error or warning message is returned.

   EXTERNAL_FVEC - upon input, the function values, evaluated at
                   START_PARAMS.  This should be an M-vector, where M
                   is the number of data points.

   EXTERNAL_FJAC - upon input, the Jacobian array of partial
                   derivative values.  This should be a M x N array,
                   where M is the number of data points and N is the
                   number of parameters.  NOTE: that all FIXED or
                   TIED parameters must *not* be included in this
                   array.

   EXTERNAL_STATE - a named variable to store MPFIT-related state
                    information between iterations (used in input and
                    output to MPFIT).  The user must not manipulate
                    or discard this data until the final iteration is
                    performed.

   FASTNORM - set this keyword to select a faster algorithm to
              compute sum-of-square values internally.  For systems
              with large numbers of data points, the standard
              algorithm can become prohibitively slow because it
              cannot be vectorized well.  By setting this keyword,
              MPFIT will run faster, but it will be more prone to
              floating point overflows and underflows.  Thus, setting
              this keyword may sacrifice some stability in the
              fitting process.

   FTOL - a nonnegative input variable. Termination occurs when both
          the actual and predicted relative reductions in the sum of
          squares are at most FTOL (and STATUS is accordingly set to
          1 or 3).  Therefore, FTOL measures the relative error
          desired in the sum of squares.  Default: 1D-10

   FUNCTARGS - A structure which contains the parameters to be passed
               to the user-supplied function specified by MYFUNCT via
               the _EXTRA mechanism.  This is the way you can pass
               additional data to your user-supplied function without
               using common blocks.

               Consider the following example:
                if FUNCTARGS = { XVAL:[1.D,2,3], YVAL:[1.D,4,9],
                                 ERRVAL:[1.D,1,1] }
                then the user supplied function should be declared
                like this:
                FUNCTION MYFUNCT, P, XVAL=x, YVAL=y, ERRVAL=err

               By default, no extra parameters are passed to the
               user-supplied function, but your function should
               accept *at least* one keyword parameter.  [ This is to
               accomodate a limitation in IDL's _EXTRA
               parameter-passing mechanism. ]

   GTOL - a nonnegative input variable. Termination occurs when the
          cosine of the angle between fvec and any column of the
          jacobian is at most GTOL in absolute value (and STATUS is
          accordingly set to 4). Therefore, GTOL measures the
          orthogonality desired between the function vector and the
          columns of the jacobian.  Default: 1D-10

   ITERARGS - The keyword arguments to be passed to ITERPROC via the
              _EXTRA mechanism.  This should be a structure, and is
              similar in operation to FUNCTARGS.
              Default: no arguments are passed.

   ITERPROC - The name of a procedure to be called upon each NPRINT
              iteration of the MPFIT routine.  ITERPROC is always
              called in the final iteration.  It should be declared
              in the following way:

              PRO ITERPROC, MYFUNCT, p, iter, fnorm, FUNCTARGS=fcnargs, $
                PARINFO=parinfo, QUIET=quiet, DOF=dof, ...
                ; perform custom iteration update
              END

              ITERPROC must either accept all three keyword
              parameters (FUNCTARGS, PARINFO and QUIET), or at least
              accept them via the _EXTRA keyword.

              MYFUNCT is the user-supplied function to be minimized,
              P is the current set of model parameters, ITER is the
              iteration number, and FUNCTARGS are the arguments to be
              passed to MYFUNCT.  FNORM should be the chi-squared
              value.  QUIET is set when no textual output should be
              printed.  DOF is the number of degrees of freedom,
              normally the number of points less the number of free
              parameters.  See below for documentation of PARINFO.

              In implementation, ITERPROC can perform updates to the
              terminal or graphical user interface, to provide
              feedback while the fit proceeds.  If the fit is to be
              stopped for any reason, then ITERPROC should set the
              common block variable ERROR_CODE to negative value
              between -15 and -1 (see MPFIT_ERROR common block
              below).  In principle, ITERPROC should probably not
              modify the parameter values, because it may interfere
              with the algorithm's stability.  In practice it is
              allowed.

              Default: an internal routine is used to print the
                       parameter values.

   ITERSTOP - Set this keyword if you wish to be able to stop the
              fitting by hitting the predefined ITERKEYSTOP key on
              the keyboard.  This only works if you use the default
              ITERPROC.

   ITERKEYSTOP - A keyboard key which will halt the fit (and if
                 ITERSTOP is set and the default ITERPROC is used).
                 ITERSTOPKEY may either be a one-character string
                 with the desired key, or a scalar integer giving the
                 ASCII code of the desired key.
                 Default: 7b (control-g)

                 NOTE: the default value of ASCI 7 (control-G) cannot
                 be read in some windowing environments, so you must
                 change to a printable character like 'q'.

   MAXITER - The maximum number of iterations to perform.  If the
             number is exceeded, then the STATUS value is set to 5
             and MPFIT returns.
             Default: 200 iterations

   NFEV - the number of MYFUNCT function evaluations performed.

   NFREE - the number of free parameters in the fit.  This includes
           parameters which are not FIXED and not TIED, but it does
           include parameters which are pegged at LIMITS.

   NITER - the number of iterations completed.

   NOCOVAR - set this keyword to prevent the calculation of the
             covariance matrix before returning (see COVAR)

   NPEGGED - the number of free parameters which are pegged at a
             LIMIT.

   NPRINT - The frequency with which ITERPROC is called.  A value of
            1 indicates that ITERPROC is called with every iteration,
            while 2 indicates every other iteration, etc.  Be aware
            that several Levenberg-Marquardt attempts can be made in
            a single iteration.  Also, the ITERPROC is *always*
            called for the final iteration, regardless of the
            iteration number.
            Default value: 1

   PARINFO - Provides a mechanism for more sophisticated constraints
             to be placed on parameter values.  When PARINFO is not
             passed, then it is assumed that all parameters are free
             and unconstrained.  Values in PARINFO are never
             modified during a call to MPFIT.

             See description above for the structure of PARINFO.

             Default value:  all parameters are free and unconstrained.

   PERROR - The formal 1-sigma errors in each parameter, computed
            from the covariance matrix.  If a parameter is held
            fixed, or if it touches a boundary, then the error is
            reported as zero.

            If the fit is unweighted (i.e. no errors were given, or
            the weights were uniformly set to unity), then PERROR
            will probably not represent the true parameter
            uncertainties.

            *If* you can assume that the true reduced chi-squared
            value is unity -- meaning that the fit is implicitly
            assumed to be of good quality -- then the estimated
            parameter uncertainties can be computed by scaling PERROR
            by the measured chi-squared value.

              DOF     = N_ELEMENTS(X) - N_ELEMENTS(PARMS) ; deg of freedom
              PCERROR = PERROR * SQRT(BESTNORM / DOF)   ; scaled uncertainties

   QUIET - set this keyword when no textual output should be printed
           by MPFIT

   RESDAMP - a scalar number, indicating the cut-off value of
             residuals where "damping" will occur.  Residuals with
             magnitudes greater than this number will be replaced by
             their logarithm.  This partially mitigates the so-called
             large residual problem inherent in least-squares solvers
             (as for the test problem CURVI, http://www.maxthis.com/-
             curviex.htm).  A value of 0 indicates no damping.
             Default: 0

             Note: RESDAMP doesn't work with AUTODERIV=0

   STATUS - an integer status code is returned.  All values greater
            than zero can represent success (however STATUS EQ 5 may
            indicate failure to converge).  It can have one of the
            following values:

        -16  a parameter or function value has become infinite or an
             undefined number.  This is usually a consequence of
             numerical overflow in the user's model function, which
             must be avoided.

        -15 to -1
             these are error codes that either MYFUNCT or ITERPROC
             may return to terminate the fitting process (see
             description of MPFIT_ERROR common below).  If either
             MYFUNCT or ITERPROC set ERROR_CODE to a negative number,
             then that number is returned in STATUS.  Values from -15
             to -1 are reserved for the user functions and will not
             clash with MPFIT.

	   0  improper input parameters.

	   1  both actual and predicted relative reductions
	      in the sum of squares are at most FTOL.

	   2  relative error between two consecutive iterates
	      is at most XTOL

	   3  conditions for STATUS = 1 and STATUS = 2 both hold.

	   4  the cosine of the angle between fvec and any
	      column of the jacobian is at most GTOL in
	      absolute value.

	   5  the maximum number of iterations has been reached

	   6  FTOL is too small. no further reduction in
	      the sum of squares is possible.

	   7  XTOL is too small. no further improvement in
	      the approximate solution x is possible.

	   8  GTOL is too small. fvec is orthogonal to the
	      columns of the jacobian to machine precision.

          9  A successful single iteration has been completed, and
             the user must supply another "EXTERNAL" evaluation of
             the function and its derivatives.  This status indicator
             is neither an error nor a convergence indicator.

   XTOL - a nonnegative input variable. Termination occurs when the
          relative error between two consecutive iterates is at most
          XTOL (and STATUS is accordingly set to 2 or 3).  Therefore,
          XTOL measures the relative error desired in the approximate
          solution.  Default: 1D-10


 EXAMPLE:

   p0 = [5.7D, 2.2, 500., 1.5, 2000.]
   fa = {X:x, Y:y, ERR:err}
   p = mpfit('MYFUNCT', p0, functargs=fa)

   Minimizes sum of squares of MYFUNCT.  MYFUNCT is called with the X,
   Y, and ERR keyword parameters that are given by FUNCTARGS.  The
   resulting parameter values are returned in p.


 CALLS: ***
	MPFIT, MPFIT_CALL, MPFIT_COVAR, MPFIT_DEFITER, MPFIT_DUMMY, MPFIT_ENORM
	MPFIT_FDJAC2, MPFIT_LMPAR, MPFIT_PARINFO, MPFIT_QRFAC, MPFIT_QRSOLV
	MPFIT_RESETPROF, MPFIT_SETMACHAR, MPFIT_TIE
 COMMON BLOCKS:

   COMMON MPFIT_ERROR, ERROR_CODE

     User routines may stop the fitting process at any time by
     setting an error condition.  This condition may be set in either
     the user's model computation routine (MYFUNCT), or in the
     iteration procedure (ITERPROC).

     To stop the fitting, the above common block must be declared,
     and ERROR_CODE must be set to a negative number.  After the user
     procedure or function returns, MPFIT checks the value of this
     common block variable and exits immediately if the error
     condition has been set.  This value is also returned in the
     STATUS keyword: values of -1 through -15 are reserved error
     codes for the user routines.  By default the value of ERROR_CODE
     is zero, indicating a successful function/procedure call.

   COMMON MPFIT_PROFILE
   COMMON MPFIT_MACHAR
   COMMON MPFIT_CONFIG

     These are undocumented common blocks are used internally by
     MPFIT and may change in future implementations.

 THEORY OF OPERATION:

   There are many specific strategies for function minimization.  One
   very popular technique is to use function gradient information to
   realize the local structure of the function.  Near a local minimum
   the function value can be taylor expanded about x0 as follows:

      f(x) = f(x0) + f'(x0) . (x-x0) + (1/2) (x-x0) . f''(x0) . (x-x0)
             -----   ---------------   -------------------------------  (1)
     Order    0th          1st                      2nd

   Here f'(x) is the gradient vector of f at x, and f''(x) is the
   Hessian matrix of second derivatives of f at x.  The vector x is
   the set of function parameters, not the measured data vector.  One
   can find the minimum of f, f(xm) using Newton's method, and
   arrives at the following linear equation:

      f''(x0) . (xm-x0) = - f'(x0)                            (2)

   If an inverse can be found for f''(x0) then one can solve for
   (xm-x0), the step vector from the current position x0 to the new
   projected minimum.  Here the problem has been linearized (ie, the
   gradient information is known to first order).  f''(x0) is
   symmetric n x n matrix, and should be positive definite.

   The Levenberg - Marquardt technique is a variation on this theme.
   It adds an additional diagonal term to the equation which may aid the
   convergence properties:

      (f''(x0) + nu I) . (xm-x0) = -f'(x0)                  (2a)

   where I is the identity matrix.  When nu is large, the overall
   matrix is diagonally dominant, and the iterations follow steepest
   descent.  When nu is small, the iterations are quadratically
   convergent.

   In principle, if f''(x0) and f'(x0) are known then xm-x0 can be
   determined.  However the Hessian matrix is often difficult or
   impossible to compute.  The gradient f'(x0) may be easier to
   compute, if even by finite difference techniques.  So-called
   quasi-Newton techniques attempt to successively estimate f''(x0)
   by building up gradient information as the iterations proceed.

   In the least squares problem there are further simplifications
   which assist in solving eqn (2).  The function to be minimized is
   a sum of squares:

       f = Sum(hi^2)                                         (3)

   where hi is the ith residual out of m residuals as described
   above.  This can be substituted back into eqn (2) after computing
   the derivatives:

       f'  = 2 Sum(hi  hi')
       f'' = 2 Sum(hi' hj') + 2 Sum(hi hi'')                (4)

   If one assumes that the parameters are already close enough to a
   minimum, then one typically finds that the second term in f'' is
   negligible [or, in any case, is too difficult to compute].  Thus,
   equation (2) can be solved, at least approximately, using only
   gradient information.

   In matrix notation, the combination of eqns (2) and (4) becomes:

        hT' . h' . dx = - hT' . h                          (5)

   Where h is the residual vector (length m), hT is its transpose, h'
   is the Jacobian matrix (dimensions n x m), and dx is (xm-x0).  The
   user function supplies the residual vector h, and in some cases h'
   when it is not found by finite differences (see MPFIT_FDJAC2,
   which finds h and hT').  Even if dx is not the best absolute step
   to take, it does provide a good estimate of the best *direction*,
   so often a line minimization will occur along the dx vector
   direction.

   The method of solution employed by MINPACK is to form the Q . R
   factorization of h', where Q is an orthogonal matrix such that QT .
   Q = I, and R is upper right triangular.  Using h' = Q . R and the
   ortogonality of Q, eqn (5) becomes

        (RT . QT) . (Q . R) . dx = - (RT . QT) . h
                     RT . R . dx = - RT . QT . h         (6)
                          R . dx = - QT . h

   where the last statement follows because R is upper triangular.
   Here, R, QT and h are known so this is a matter of solving for dx.
   The routine MPFIT_QRFAC provides the QR factorization of h, with
   pivoting, and MPFIT_QRSOLV provides the solution for dx.

 REFERENCES:

   MINPACK-1, Jorge More', available from netlib (www.netlib.org).
   "Optimization Software Guide," Jorge More' and Stephen Wright,
     SIAM, *Frontiers in Applied Mathematics*, Number 14.
   More', Jorge J., "The Levenberg-Marquardt Algorithm:
     Implementation and Theory," in *Numerical Analysis*, ed. Watson,
     G. A., Lecture Notes in Mathematics 630, Springer-Verlag, 1977.

 MODIFICATION HISTORY:
   Translated from MINPACK-1 in FORTRAN, Apr-Jul 1998, CM
   Fixed bug in parameter limits (x vs xnew), 04 Aug 1998, CM
   Added PERROR keyword, 04 Aug 1998, CM
   Added COVAR keyword, 20 Aug 1998, CM
   Added NITER output keyword, 05 Oct 1998
      D.L Windt, Bell Labs, windt@bell-labs.com;
   Made each PARINFO component optional, 05 Oct 1998 CM
   Analytical derivatives allowed via AUTODERIVATIVE keyword, 09 Nov 1998
   Parameter values can be tied to others, 09 Nov 1998
   Fixed small bugs (Wayne Landsman), 24 Nov 1998
   Added better exception error reporting, 24 Nov 1998 CM
   Cosmetic documentation changes, 02 Jan 1999 CM
   Changed definition of ITERPROC to be consistent with TNMIN, 19 Jan 1999 CM
   Fixed bug when AUTDERIVATIVE=0.  Incorrect sign, 02 Feb 1999 CM
   Added keyboard stop to MPFIT_DEFITER, 28 Feb 1999 CM
   Cosmetic documentation changes, 14 May 1999 CM
   IDL optimizations for speed & FASTNORM keyword, 15 May 1999 CM
   Tried a faster version of mpfit_enorm, 30 May 1999 CM
   Changed web address to cow.physics.wisc.edu, 14 Jun 1999 CM
   Found malformation of FDJAC in MPFIT for 1 parm, 03 Aug 1999 CM
   Factored out user-function call into MPFIT_CALL.  It is possible,
     but currently disabled, to call procedures.  The calling format
     is similar to CURVEFIT, 25 Sep 1999, CM
   Slightly changed mpfit_tie to be less intrusive, 25 Sep 1999, CM
   Fixed some bugs associated with tied parameters in mpfit_fdjac, 25
     Sep 1999, CM
   Reordered documentation; now alphabetical, 02 Oct 1999, CM
   Added QUERY keyword for more robust error detection in drivers, 29
     Oct 1999, CM
   Documented PERROR for unweighted fits, 03 Nov 1999, CM
   Split out MPFIT_RESETPROF to aid in profiling, 03 Nov 1999, CM
   Some profiling and speed optimization, 03 Nov 1999, CM
     Worst offenders, in order: fdjac2, qrfac, qrsolv, enorm.
     fdjac2 depends on user function, qrfac and enorm seem to be
     fully optimized.  qrsolv probably could be tweaked a little, but
     is still <10% of total compute time.
   Made sure that !err was set to 0 in MPFIT_DEFITER, 10 Jan 2000, CM
   Fixed small inconsistency in setting of QANYLIM, 28 Jan 2000, CM
   Added PARINFO field RELSTEP, 28 Jan 2000, CM
   Converted to MPFIT_ERROR common block for indicating error
     conditions, 28 Jan 2000, CM
   Corrected scope of MPFIT_ERROR common block, CM, 07 Mar 2000
   Minor speed improvement in MPFIT_ENORM, CM 26 Mar 2000
   Corrected case where ITERPROC changed parameter values and
     parameter values were TIED, CM 26 Mar 2000
   Changed MPFIT_CALL to modify NFEV automatically, and to support
     user procedures more, CM 26 Mar 2000
   Copying permission terms have been liberalized, 26 Mar 2000, CM
   Catch zero value of zero a(j,lj) in MPFIT_QRFAC, 20 Jul 2000, CM
      (thanks to David Schlegel <schlegel@astro.princeton.edu>)
   MPFIT_SETMACHAR is called only once at init; only one common block
     is created (MPFIT_MACHAR); it is now a structure; removed almost
     all CHECK_MATH calls for compatibility with IDL5 and !EXCEPT;
     profiling data is now in a structure too; noted some
     mathematical discrepancies in Linux IDL5.0, 17 Nov 2000, CM
   Some significant changes.  New PARINFO fields: MPSIDE, MPMINSTEP,
     MPMAXSTEP.  Improved documentation.  Now PTIED constraints are
     maintained in the MPCONFIG common block.  A new procedure to
     parse PARINFO fields.  FDJAC2 now computes a larger variety of
     one-sided and two-sided finite difference derivatives.  NFEV is
     stored in the MPCONFIG common now.  17 Dec 2000, CM
   Added check that PARINFO and XALL have same size, 29 Dec 2000 CM
   Don't call function in TERMINATE when there is an error, 05 Jan
     2000
   Check for float vs. double discrepancies; corrected implementation
     of MIN/MAXSTEP, which I still am not sure of, but now at least
     the correct behavior occurs *without* it, CM 08 Jan 2001
   Added SCALE_FCN keyword, to allow for scaling, as for the CASH
     statistic; added documentation about the theory of operation,
     and under the QR factorization; slowly I'm beginning to
     understand the bowels of this algorithm, CM 10 Jan 2001
   Remove MPMINSTEP field of PARINFO, for now at least, CM 11 Jan
     2001
   Added RESDAMP keyword, CM, 14 Jan 2001
   Tried to improve the DAMP handling a little, CM, 13 Mar 2001
   Corrected .PARNAME behavior in _DEFITER, CM, 19 Mar 2001
   Added checks for parameter and function overflow; a new STATUS
     value to reflect this; STATUS values of -15 to -1 are reserved
     for user function errors, CM, 03 Apr 2001
   DAMP keyword is now a TANH, CM, 03 Apr 2001
   Added more error checking of float vs. double, CM, 07 Apr 2001
   Fixed bug in handling of parameter lower limits; moved overflow
     checking to end of loop, CM, 20 Apr 2001
   Failure using GOTO, TERMINATE more graceful if FNORM1 not defined,
     CM, 13 Aug 2001
   Add MPPRINT tag to PARINFO, CM, 19 Nov 2001
   Add DOF keyword to DEFITER procedure, and print degrees of
     freedom, CM, 28 Nov 2001
   Add check to be sure MYFUNCT is a scalar string, CM, 14 Jan 2002
   Addition of EXTERNAL_FJAC, EXTERNAL_FVEC keywords; ability to save
     fitter's state from one call to the next; allow '(EXTERNAL)'
     function name, which implies that user will supply function and
     Jacobian at each iteration, CM, 10 Mar 2002
   Documented EXTERNAL evaluation code, CM, 10 Mar 2002
   Corrected signficant bug in the way that the STEP parameter, and
     FIXED parameters interacted (Thanks Andrew Steffl), CM, 02 Apr
     2002
   Allow COVAR and PERROR keywords to be computed, even in case of
     '(EXTERNAL)' function, 26 May 2002
   Add NFREE and NPEGGED keywords; compute NPEGGED; compute DOF using
     NFREE instead of n_elements(X), thanks to Kristian Kjaer, CM 11
     Sep 2002
   Hopefully PERROR is all positive now, CM 13 Sep 2002
   Documented RELSTEP field of PARINFO (!!), CM, 25 Oct 2002
   Error checking to detect missing start pars, CM 12 Apr 2003
   Add DOF keyword to return degrees of freedom, CM, 30 June 2003
   Always call ITERPROC in the final iteration; add ITERKEYSTOP
     keyword, CM, 30 June 2003
   Correct bug in MPFIT_LMPAR of singularity handling, which might
     likely be fatal for one-parameter fits, CM, 21 Nov 2003
     (with thanks to Peter Tuthill for the proper test case)

  $Id: mpfit.pro,v 1.30 2003/11/24 01:51:13 craigm Exp $


OVSA_PKFIT $SSW/radio/ovsa/idl/fitting/ovsa_pkfit.pro
[Previous] [Next]
 NAME:
     OVSA_PKFIT
 PURPOSE:
     PKUPCHEK support routine.  Fits PEAKUP data to find the
     pointing offset of an active region from the current pointing
     position for the 27 antennas.
 CATEGORY:
     OVRO APC PKUPCHEK SUPPORT ROUTINE
 CALLING SEQUENCE:
     ovsa_pkfit,avdat,obseq,traj,pk,po,rmserr[,/debug]
 INPUTS:
     avdat   the PEAKUP data array, of size (nant,nf,nblk), where
                the first index is the number of antennas (5--only
                the first two [27 m] are used), second index is the
                number of frequencies (8), and the third index is
                the number of "blocks" (pointings--8)
                in the PEAKUP Trajectory.
     obseq   the observing sequence structure associated with the
                PEAKUP data.
     traj    the trajectory segment structure associated with the
                PEAKUP data.
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
     debug    a switch to enable plotting of some intermediate
                results.
 ROUTINES CALLED:
 OUTPUTS:
     pk      an array of size (nant,nf,2) containing the percent
                peak level above the minimum data value at each frequency
                for each of the two axes (0 = HO, 1 = DO).
     po      an array of size (nant,nf,2) containing the pointing
                offsets in degrees for each of the two axes, HO and DO.
     rmserr  an array of size (nant,nf,2) containing the rms error of the
                fit for the two axes, HO and DO.
 COMMENTS:
 CALLS: ***
	CURVEFIT, GFUNCT, MOMENT
 CALLED BY:
	PKUPCHEK
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 20-Dec-1998 by Dale E. Gary
     23-Dec-1998  DG
       Some cleanup, including placing GFUNCT function within this file.
     11-Dec-1999  DG
       Fixed problem with fitting negative "peaks" and cleaned up the
       /debug plotting.
     15-Jan-2000  DG
       Fixed bug that swapped HO and DO values!
     23-Jul-2003  DG
       Changed name of PKFIT to OVSA_PKFIT to avoid conflict with
       ASTRON routine of the same name.


OVSA_POLN $SSW/radio/ovsa/idl/analysis/ovsa_poln.pro
[Previous] [Next]
 NAME:
     OVSA_POLN
 PURPOSE:
     Converts calibrated data (returned from ANALYZE and calibrated with
     APPLY_CAL_ALL) into R and L polarization, eliminating the need to
     keep three polarization states.  Note that the total power channels
     will not be valid unless the background is subtracted first.
 CATEGORY:
     OVRO APC ANALYSIS
 CALLING SEQUENCE:
     ovsa_poln,avg,nant,nbl,npol,R_,L_,TP_R,TP_L
 INPUTS:
     avg       the calibrated output data from ANALYZE, with the Total
                 Power channels background subtracted, if applicable.
     nant      the number of antennas used in the data
     nbl       the number of baselines used in the data
     npol      the number of polarizations in the data
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
 ROUTINES CALLED:
 OUTPUTS:
     R_        the RCP baseline data, in the form of a complex array of
                 size (NBL,NF,NTIMES).  The real part gives the cos channel
                 amplitudes, while the imaginary part gives the sin channel
                 amplitudes
     L_        the LCP baseline data, exactly parallel to R_
     TP_R      the RCP total power data, in the form of a real array of
                 size (NANT,NF,NTIMES).
     TP_L      the LCP total power data, exactly parallel to TP_R
 COMMENTS:
 CALLED BY:
	calib_rate
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 04-Aug-2001 by Dale E. Gary
     23-Jul-2003  DG
       Change name to OVSA_POLN and call it from CALIB_RATE
     31-May-2006  SDT
       Change to work with new R/L polarization scheme


OVSA_PRESUB $SSW/radio/ovsa/idl/widgets/ovsa_presub.pro
[Previous] [Next]
 NAME:
     OVSA_PRESUB
 PURPOSE:
     User-friendly interface for selecting and applying background
     subtraction to OVSA data output from ANALYZE.
 CATEGORY:
     OVSA APC CALIBRATION ANALYSIS
 CALLING SEQUENCE:
     ovsa_presub[,group=group]
 INPUTS:
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
     group     Optional widget ID for a widget that, if closed, will
                 force closure of this widget heirarchy.
 ROUTINES CALLED:

 OUTPUTS:
 COMMENTS:
 CALLS: ***
	APPLY_CAL_ALL, BGND_INTERP, BGND_INTVAL, CONGRID [1], CONGRID [2], CONGRID [3]
	CW_PDMENU, LOADCT, MSEC2STR, NINT [1], NINT [2], OKTOWRITE, OUTPLOT [1], OUTPLOT [2]
	OUTPLOT [3], OVSA_PRESUB_EVENT, UTPLOT [1], UTPLOT [2], UTPLOT [3], UTPLOT [4]
	UTPLOT [5], UTPLOT [6], XMANAGER
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 08-Dec-2001 by Dale E. Gary
     21-Dec-2001  DG
       This program is becoming complete and useful.  Still many
       features left to put in.  Fixed bug in channel assignments.
       Also added plot labels.
     22-Dec-2001  DG
       Added spectral plot.  Cleaned up some small bugs.
     27-Dec-2001  DG
       Added a movie mode, started by clicking in the spectral plot
       window.


OVSA_UV $SSW/radio/ovsa/idl/misc/ovsa_uv.pro
[Previous] [Next]
 NAME:
     OVSA_UV
 PURPOSE:
     Returns OVSA UV coverage for given HA range, Dec, and antennas
 CATEGORY:
     OVSA MISC
 CALLING SEQUENCE:
     uvt = ovsa_uv(harange,hstep,dec,antlist[,halist])
 INPUTS:
     harange   a 2-element array giving the start and end hour-angle, [h].
                 Valid OVSA coverage is limited to the range [-4.0,4.0]
     hstep     a float giving the step size in hour angle [h]
     dec       the source declination (assumed constant) [deg]
     antlist   an integer array specifying the OVSA antennas for which to
                 return coverage, e.g. [1,2,4,5,6,7] for all antennas of
                 current array.  The 7th antenna's approximate location
                 can be specified by antenna number 3.
 OPTIONAL (KEYWORD) INPUT PARAMETERS:
 ROUTINES CALLED:
     uvt       a float array of size [NANT,NANT,NSTEPS], where NANT is
                 n_elements(antlist), and NSTEPS is derived from the HA
                 range and step size.  The upper non-diagonal elements
                 for each step contain the U values, while the lower
                 non-diagonal elements contain the V values.  The units
                 can be thought of as nsec, or wavelengths at 1 GHz.
                 A convenient method for plotting the values for all
                 returned antennas is:
                    plot,[-2000,2000]*2,[-2000,2000]*2,/nodata
                    for i = 0, nant-1 do for j = i+1,nant-1 do $
                           oplot, uvt[j,i,*], uvt[i,j,*],psym=3
                    for i = 0, nant-1 do for j = i+1,nant-1 do $
                           oplot,-uvt[j,i,*],-uvt[i,j,*],psym=3
     halist    a float array giving the list of hour angles at which the
                 UV points are determined.  Optional.
 OUTPUTS:
 COMMENTS:
 CALLS: ***
	BDOTS, GET_BLCOR
 SIDE EFFECTS:
 RESTRICTIONS:
 MODIFICATION HISTORY:
     Written 29-Mar-2001 by Dale Gary