IDL Help for the RADTRANS Library

This page was created by the IDL library routine mk_html_help. For more information on this routine, refer to the IDL Online Help Navigator or type:

     ? mk_html_help

at the IDL command line prompt.

Last modified: Fri May 28 14:35:17 2010.


List of Routines


Routine Descriptions

CHECKPARM

[Next Routine] [List of Routines]
 CHECKPARM  --  Don Banfield  --  ???

 PURPOSE:
    This procedure will check that the given set of parameters is valid.
    It will adjust those that are allowed to vary to make them return
    to a valid state.

 SYNTAX:
    checkparm, a [, MAXPI0= , /no_vary , usevarylist= ]

 INPUT:
    a = parameters that are varying

 OPTIONAL KEYWORDS:
    maxpi0 = maximum value for pi0 parameters
    no_vary = check all parameters for valid values whether or not they
              are being varied
    usevarylist = vector containing the indices of the varying parameters
                  (default is the current common variable "varylist")

 REQUIRED COMMON VARIABLES:
    afull, varyflag, varylist, npi0

 REVISION HISTORY:
    22 June 2009 - added the case of a higher pressure varying
                   with a lower layer at the max
    03 March 2010 - added the case of a middle layer varying
                    with the layers above and below at equal values
    02 April 2010 - vary flag can equal 3 to denote pi0 fixed at the
                    pi0 value immediately redward

(See checkparm.pro)


CHISQD

[Previous Routine] [Next Routine] [List of Routines]
 CHISQD  --  Don Banfield  --  ???

 PURPOSE:
    This function will compute the model and chisquared for a given set of data
    and parameters for the model.

 SYNTAX:
    result = chisqd(f,y,sigma,m,n,allchi)

 INPUTS:
    y is the observations vector (n)
    f is the model evaluation (n) given the parameters and independent variables
    sigma is the standard deviation vector (n)
    m is the number of varying paramaters
    n is the number of observations

 OPTIONAL OUTPUT:
    allchi = named variable to hold the vector (n) with chi^2 for all observations

 OUTPUT:
    result = reduced chi^2 value

(See chisqd.pro)


CUTTER_GEN

[Previous Routine] [Next Routine] [List of Routines]
 CUTTER_GEN  --  Paul Strycker  --  21 May 2009
                                    25 March 2010

 PURPOSE:
    Makes data cuts from a list of FITS data cubes
    for Don Banfield's radiative transfer code (in FORTRAN).
    The user selects fiducial points to create regions to add to the data cut.
    The pixels included in each region are based on a Pricipal Component Analysis.

 SYNTAX:
    cutter = cutter_gen( cubelist [, maskname= , specdelta= ,
                         pixdelta= , /zr_include , cutnumber= ,
                         mu_max= , /no_spec_check] )

 INPUT:
    cubelist = A file containing a list of FITS file names.

 OPTIONAL KEYWORDS:
    MASKNAME = FITS file name containing a pixel mask array
    specdelta = threshold for spectral similarity
    pixdelta = max height/width in pixels for a single region
    /zr_include = include the regional cut in the output
                  (I/F, mu, mu_0, and phase for all fiducial pixels)
    cutnumber = internal counter used for recursive calls (not applicable to user)
    mu_max = range (+- this value) for mu and mu_0 allowed in a single region
    /no_spec_check = do not require spectral similarity between regions

 OUTPUT:
    cutter={  
             id = CUBELIST
             utcdate = UTC date of the creation of this structure
             nfilter = number of filters in the data set
             filterid = vector of wavelengths of the filters
             filter_images = vector [nfilter] with the number of images per filter
             image_name = vector [total(filter_images)] with each image file name
             pixdelta = threshold for +- mu and mu_0 (keyword pixdelta)
             mu_max = threshold for +- mu and mu_0 (keyword mu_max)
             npix = number of fiducial pixels
             nregion = number of averaged regions from the fiducial points for each filter
             len = vector [nregion] with the number of pixels per region
             regpix = the indices of the region's points in FIDPTS
             fidpts = the (x,y) locations of the fiducial points
             latlon = [avg(latitude),avg(longitude)] for all fiducial points
             z = the data cut by averaged regions [4,nregion]
             zr = the entire data cut by pixel [4,n_fidpts*nfilter]
                  (must have set keyword /zr_include for this to be returned)
           }

 CALLS:
    READCOL, READHEADLIST, FITS_READ, PVIEW, SEL_BOX, UNDEFINE, PCA_EXE,
    PCACUBEPARMS, PCA_BADPIX, RGBIMG, SEL_PCA, SEL_DIM_PAIRS, SEL_DIST,
    READYESNO, CUT_COMBINE, WRITE_GIF, WRITE_BMP

(See cutter_gen.pro)


CUTTER_LON

[Previous Routine] [Next Routine] [List of Routines]
 CUTTER_LON  --  Paul Strycker  --  12 May 2010

 PURPOSE:
    Makes data cuts from a list of FITS data cubes
    for Don Banfield's radiative transfer code (in FORTRAN).
    The user selects an area, in which fiducial points
    are automatically selected at the central longitude across all latitudes
    to create a series data cuts with one region each.
    The pixels included in each region are based on a Pricipal Component Analysis.

 SYNTAX:
    cutter_lon, cubelist, ncuts [, maskname= , specdelta= ,
                pixdelta= , /zr_include , savepath= , mu_max= , startnum= ]

 INPUT:
    cubelist = A file containing a list of FITS file names.
    ncuts = total number of cuts to create across the selected latitudes

 OPTIONAL KEYWORDS:
    MASKNAME = FITS file name containing a pixel mask array
    specdelta = threshold for spectral similarity
    pixdelta = max height/width in pixels for a single region
    /zr_include = include the regional cut in the output
                  (I/F, mu, mu_0, and phase for all fiducial pixels)
    savepath = full path to the directory in which to save output files
    mu_max = range (+- this value) for mu and mu_0 allowed in a single region
    startnum = the ID number (###) of the first cut: lon_cut###.dat
               default = 0

 OUTPUT:
    A data file for each cut created with the file name convention:
      savepath+"lon_cut###.dat".
    Each file contains a structure variable named "z", where
      z = {  
             id = CUBELIST
             utcdate = UTC date of the creation of this structure
             nfilter = number of filters in the data set
             filterid = vector of wavelengths of the filters
             filter_images = vector [nfilter] with the number of images per filter
             image_name = vector [total(filter_images)] with each image file name
             pixdelta = threshold for +- mu and mu_0 (keyword pixdelta)
             mu_max = threshold for +- mu and mu_0 (keyword mu_max)
             npix = number of fiducial pixels
             nregion = number of averaged regions from the fiducial points for each filter
             len = vector [nregion] with the number of pixels per region
             regpix = the indices of the region's points in FIDPTS
             fidpts = the (x,y) locations of the fiducial points
             latlon = [avg(latitude),avg(longitude)] for all fiducial points
             z = the data cut by averaged regions [4,nregion]
             zr = the entire data cut by pixel [4,n_fidpts*nfilter]
                  (must have set keyword /zr_include for this to be returned)
          }

 CALLS:
    READCOL, READHEADLIST, FITS_READ, PVIEW, SEL_BOX, UNDEFINE, PCA_EXE,
    PCACUBEPARMS, PCA_BADPIX, RGBIMG, SEL_PCA, SEL_DIM_PAIRS, SEL_DIST,
    WRITE_GIF, WRITE_BMP

(See cutter_lon.pro)


CUT_COMBINE

[Previous Routine] [Next Routine] [List of Routines]
 CUT_COMBINE  --  Paul Strycker  --  11 March 2010
                                     25 March 2010
                                     31 March 2010

 PURPOSE:
    Combines two data cut structure variables from CUTTER_GEN into one.

 SYNTAX:
    result = cut_combine( z1, z2 [, /show, /verbose, /allow_different])

 INPUTS:
    z1 = structure variable containing the first of two cuts to combine
    z2 = structure variable containing the second of two cuts to combine

 OPTIONAL KEYWORDS:
    /show = Display the data values from the selected regions with CUT_VIEW.
    /verbose = Report statistics on the pixels included in z1 and z2.
    /allow_different = Allow z1 and z2 to be cuts from different image cubes.

 OUTPUT:
    result = structure variable with the properly concatenated data from z1 and z2

(See cut_combine.pro)


CUT_SPECTRA

[Previous Routine] [Next Routine] [List of Routines]
 CUT_SPECTRA  --  Paul Strycker  --  11 March 2010
                                     25 March 2010
                                     31 March 2010

 PURPOSE:
    Returns the I/F spectrum of a data cut created by CUTTER_GEN or CUTTER_LON.

 SYNTAX:
    result = cut_spectra( cutter [, savefile, /show, /verbose , /overwrite])

 INPUT:
    cutter = Structure variable containing a data cut from CUTTER_GEN or CUTTER_LON.

 OPTIONAL INPUT:
    savefile = Full path to a FITS file name in which to save the spectra.

 OPTIONAL KEYWORDS:
    /show = Plot the spectra.
    /verbose = Print update messages to screen.
    /overwrite = Overwrite "savefile" if it already exists.

 OUTPUT:
    result = two spectra in the format: fltarr(number of filters,2),
             where [*,0] is the average I/F spectrum for the cut
               and [*,1] is the average (I/F)/(mu_0) spectrum for the cut.

 CALLS:
    FITS_READ, SEL_DIM_PAIRS, FITS_WRITE, PERCENTCOMPLETE

(See cut_spectra.pro)


CUT_VIEW

[Previous Routine] [Next Routine] [List of Routines]
 CUT_VIEW  --  Paul Strycker  --  26 March 2010

 PURPOSE:
     Views values with the data cuts made by CUTTER_GEN.

 SYNTAX:
    cut_view, cutter [, /drawarea]

 INPUT:
    cutter = structure variable produced by function CUTTER_GEN.

 OPTIONAL KEYWORD:
    /drawarea = draw a line around the area

 CALLS:
    SEL_DIM_PAIRS, SEL_INVERT, PERCENTCOMPLETE, PVIEW

(See cut_view.pro)


DERIVATIVE

[Previous Routine] [Next Routine] [List of Routines]
 DERIVATIVE  --  Don Banfield  --  ???

 PURPOSE:
    This function will compute the derivatives of the linearized model about
    a given fiducial point with respect to the parameters of the model.

 SYNTAX:
    deriv = derivative( a0, f0, nvarying, n [, MAXPI0= , usevarylist= ] )

 INPUTS:
    a0 = the fiducial parameter set (nvarying)
    f0 = the fiducial model evaluation (n)
    nvarying = number of varying parameters
    n = number of observations being modeled

 OPTIONAL KEYWORDS:
    maxpi0 = maximum value for pi0 parameters
    usevarylist = vector containing the indices of the varying parameters

 OUTPUT:
    deriv = the returned derivative matrix (n x nvarying)

 REQUIRED COMMON VARIABLES:
    workpath, fortrancode

 CALLS:
    PUTMODEL, fortrancode (location set in common variable)

 REVISION HISTORY (Paul Strycker):
    08 February 2010 - NOSHELL keyword added to spawn command; use FILE_DELETE
    03 March 2010 - modified the "endrep until" conditions (line 48)

(See derivative.pro)


DUBGEOM

[Previous Routine] [Next Routine] [List of Routines]
 DUBGEOM  --  Don Banfield  --  ???

 PURPOSE:
    This procedure will take the data cube cuts (which have the form
    of Z(nelements,data_type)) and translate these into the form of
    input that the fortran doubling program is expecting.

 SYNTAX:
    dubgeom, z, nregion, nfilter

 REQUIRES COMMON VARIABLE:
    workpath

(See dubgeom.pro)


EVALMODELS

[Previous Routine] [Next Routine] [List of Routines]
 EVALMODELS  --  Paul Strycker  --  16 June 2009

 Evaluates the chi^2 error given a set of observations
 and a list of models (already with results).

 CALLS:
    ORGDAT, GETRESULT, CHISQD

(See evalmodels.pro)


GETMODEL

[Previous Routine] [Next Routine] [List of Routines]
 GETMODEL  --  Don Banfield  --  ???

 PURPOSE:
    This procedure will read from a given file the model parameters.  It
    will also read from another file to determine which of these parameters
    are to be varied and which are to be fixed.  The parameters pi0,tau and p
    and rp are included in the parameter list, and allowed to vary. 
    The organization of the model parameter vector is 
    p,p,p..., tau,tau,tau..., rp,rp,rp...,
    pi0(filter1),pi0(filter1),pi0(filter1)...,
    pi0(filter2),pi0(filter2),pi0(filter2)..., etc.
    The list array is organized the same way,
    and should hold 1's for those that vary and 0's for those that are fixed,
    and 2's for pressures that are linked to the pressure above them (i.e. sheets),
    and 3's for pi0s that are linked to the pi0 immediately redward of them.
    This procedure also returns the number of varying parameters (nvarying).

 SYNTAX:
    getmodel, num [, a , nvarying , prefix= , varyfile= ]

 INPUT:
    num = Model number to be read: "rawmodel###" OR prefix+"###".

 OPTIONAL OUTPUT:
    a = Named variable in which to store the values of the
        varying parameters (a vector with length "nvarying").
    nvarying = Named variable in which to store the number of varying parameters.

 OPTIONAL KEYWORDS:
    prefix = String containing the full directory path and the characters
             preceeding "###" in the model to be read.
             EXAMPLE: prefix = '/home/user/radtrans/model/mymodel'
               GETMODEL will look for '/home/user/radtrans/model/mymodel###',
               where ### is the input "num".
    varyfile = Full path to the file containing the parameter-varying flags.

 REQUIRES COMMON VARIABLE:
    workpath

 CREATES/MODIFIES COMMON VARIABLES:
    afull, varyflag, varylist, npi0

 CALLS:
    READCOL_N, READCOL

 REVISION HISTORY:
    02 April 2010 - vary can EQ 3 for pi0s

(See getmodel.pro)


GETRESULT

[Previous Routine] [Next Routine] [List of Routines]
 GETRESULT  --  Don Banfield  --  ???

 PURPOSE:
    This function will read the result file and pull the computed dependant
    variables (akin to the observations) into a vector.


 REQUIRES COMMON VARIABLE:
    workpath

 CALLS:
    READCOL

(See getresult.pro)


GRIDFIT

[Previous Routine] [Next Routine] [List of Routines]
 GRIDFIT  --  Paul Strycker  --  18 June 2009
                                 18 May 2010 (last modified)

 PURPOSE:
    Beginning with data and an initial model, this fitting algorithm
    iteratively searches the grid of parameters produced by separately
    allowing every permutation of pairs of parameters to vary. Then it
    converges on a non-quantized solution.

 SYNTAX:
    gridfit, z, initialmodel [, last_iter= , savepath= , rawpath= ,
             maxiter= , parmvaryfile= , fortrancode= , workpath= ,
             /no_pressure , /no_radius , no_lev= , /no_pi0 , /no_tau]

 INPUTS:
    z = Structure created by CUTTER_GEN containing a data cut from the
        input images of location(s) with a single vertical structure.
    initialmodel = Number corresponding to the model parameter file
                  (rawpath+"rawmodel###") to be used as the initial model.

 OPTIONAL KEYWORDS:
    last_iter = Starting iteration number, if previous results exist. (Default = 0)
    savepath = Full path to the directory in which results are saved.
    rawpath = Full path to the directory containing the initial model "rawmodel###".
    maxiter = Maximum number of iterations allowed. (Default = 4)
    parmvaryfile = Full path to the file containing the parameters to vary.
    fortrancode = Full path to the executable FORTRAN code. (Default = workpath+"fitmodl*")
    workpath = Full path to the working directory.
    /no_pressure = Do not set any pressure variables free to vary.
    /no_radius = Do not set any radii variables free to vary.
    no_lev = Vector containing the levels to ignore.
            (Do not set any variables free to vary in these aerosol layers.)
    /no_pi0 = Do not set any pi0 variables free to vary.
    /no_tau = Do not set any optical depth variables free to vary.

 CREATES COMMON VARIABLES:
    workpath, fortrancode

 CALLS:
    CHANGENAME, WORKSCAT, VARYMODEL, PATCHMODELS, EVALMODELS

 EXAMPLES:
    gridfit,z,4,savepath='results2/',raw='savedmodels/',$
            parmvaryfile='savedmodels/toplev.vary',last_iter=2
    gridfit,z,4,savepath='results2/',raw='savedmodels/',$
            /no_rad,/no_pres,/no_tau,no_lev=[1,3]

(See gridfit.pro)


ORGDAT

[Previous Routine] [Next Routine] [List of Routines]
 ORGDAT  --  Don Banfield  --  ???

 PURPOSE:
    This procedure will take a data cut (z) as input and return as output the
    same information re-organized into independant variables (x) and
    observations (y).  It will also define the standard deviations (sigma)
    for each observation, and return the number of observations (nobs).

(See orgdat.pro)


PARMFIT

[Previous Routine] [Next Routine] [List of Routines]
 PARMFIT  --  Don Banfield  --  ???

 PURPOSE:
    This is the main program that will do the SVD parameter fitting.

 SYNTAX:
    parmfit, zstruc, nmodel [, Xcutoff , Ncutoff , damping , /verbose ,
             /WIDGFIT , MAXPI0= , savebest= , /noshow , /varymodel ,
             /converge]

 INPUTS:
    zstruc = Structure created by CUTTER_GEN containing a data cut from the
             input images of location(s) with a single vertical structure.
    nmodel = Number corresponding to the model parameter file
             (workpath+"rawmodel###") to be used as the initial model.
    
 OPTIONAL INPUTS:
    Xcutoff = Convergence threshold value for delta Chi^2.
    Ncutoff = Maximum number of iterations.
    damping = Fraction of the estimated-parameter-change to use for the
              next iteration.

 OPTIONAL KEYWORDS:
    /verbose = Display fitting information.
    /WIDGFIT = Indicates that PARMFIT was called by WIDGFIT.
    maxpi0 = Maximum value for pi0 parameters.
    savebest = Integer (###), where the minimum Chi^2 model and result files
               ("workmodlXXX" and "workrslt.XXX") are copied to
               "tempmodl###" and "temprslt.###". (If not set, then the
               minimum Chi^2 model and result files are not copied.)
    /noshow = Do not plot the data and model results.
    /varymodel = Indicates that PARMFIT was called by VARYMODEL in the
                 vary-parameter-pairs mode (Phase A of GRIDFIT).
    /converge = Indicates that PARMFIT was called by VARYMODEL in the
                convergence mode (Phase C of GRIDFIT).

 NOTES:
    The following common variables must already be set:
    workpath = Full path to the desired working directory.
    fortrancode = Full path to the FORTRAN code for the 
                  radiative-transfer modeling. This MUST be in the
                  "workpath" directory!

 REQUIRED COMMON VARIABLES:
    workpath, fortrancode, afull, varyflag, varylist, npi0

 CALLS:
    DUBGEOM, ORGDAT, GETMODEL, CHECKPARM, PUTMODEL, FORPRINT, GETRESULT, 
    fortrancode (location set in common variable), CHISQD, DERIVATIVE,
    WORKSCAT

 REVISION HISTORY (Paul Strycker):
    08 February 2010 - NOSHELL keyword added to SPAWN commands; use FILE_xxxxx
    26 February 2010 - Copy model result files in addition to model structures.

(See parmfit.pro)


PATCHMODELS

[Previous Routine] [Next Routine] [List of Routines]
 PATCHMODELS  --  Paul Strycker  --  16 June 2009

 PURPOSE:
    This procedure will take a set of models (vector MODELNUM) derived from
    an initial model (RAWNUM) and build a grid of model files
    that covers the range of each parameter's values (Phase B of GRIDFIT).
    These are input to the FORTRAN program (fortrancode).

 SYNTAX:
    patchmodels, rawnum, modelnum [, ngrid , nvary , parmvarypath= ,
                 gridparms= , gridflag= , parmstats= , modelpath= ,
                 savepath= , maxsamp= , /verbose]

 INPUTS:
    rawnum = Model number of the inital model: "rawmodel###".
    modelnum = Vector of model numbers from which to make the grid: "tempmodl*".

 OPTIONAL OUTPUTS:
    ngrid = Named variable to return the number of models in the grid.
    nvary = Named variable to return the number of parameters that vary > 1%.

 OPTIONAL KEYWORDS:
    parmvarypath = Full path to the directory in which to save/find the
                   "tempvary###" files, which contain the individual permutations.
    gridparms = Named variable to return the grid of model parameters.
    gridflag = Named variable to return the vector of flags denoting
               which parameters vary > 1% in the provided set of models.
    parmstats = Named variable to return the parameter array sent to MAKEGRID.
    modelpath = Full path to the directory containing the models:
                "rawmodel###" and "tempmodl*". (Default = '')
    savepath = Full path to the directory in which to save grid models and results.
    maxsamp = Maximum number of samples per parameter in the grid.
    /verbose = Display fitting information.

 CALLS:
    GETMODEL, CHECKPARM, MAKEGRID, fortrancode (location set in common variable),
    PERCENTCOMPLETE

 REVISION HISTORY:
    08 February 2010 - NOSHELL keyword added to SPAWN commands; use FILE_xxxxx
    02 April 2010 - vary can EQ 3
    04 May 2010 - clean working directory before modeling the grid

(See patchmodels.pro)


PREPARE_Z

[Previous Routine] [Next Routine] [List of Routines]
 PREPARE_Z  --  Paul Strycker  --  25 March 2010

 Prepares the structure (Z) saved in DATAFILE (an IDL format save file)
 to be sent to the radiative transfer modeling programs (GRIDFIT, etc.).
 Essentially, this removes unnecessary data from Z so that it is not
 passed from program to program.

 INPUT:
    datafile = string containing the full path to the IDL save file
               that contains the structure Z
         NOTE: The structure variable must be named "z" in the save file!

 OPTIONAL KEYWORD:
    /zr_include = includes the structure tag "zr" if it exists in Z

 OUTPUT:
    z = structure with the minimum necessary data
        for use in the radiative transfer modeling code GRIDFIT

 CALLS:
    EXIST_TAG

(See prepare_z.pro)


PUTMODEL

[Previous Routine] [Next Routine] [List of Routines]
 PUTMODEL  --  Don Banfield  --  ???

 PURPOSE:
    This procedure will take a parameter vector
    and build a model parameter file for input to the doubling program.

 SYNTAX:
    putmodel, num, a [, /no_vary , usevarylist=]

 INPUTS:
    num = Model number to be saved: workpath+"workmodl###".
    a = Vector containing values of the varying parameters.

 OPTIONAL KEYWORDS:
    /no_vary = Do not use the input vector "a", but only use the
               common variable "afull" to make the model.
    usevarylist = Vector containing the indices of the varying parameters.
                  If not set, the indices are set by the common variable "varylist".

 REQUIRES COMMON VARIABLES:
    workpath, afull, varyflag, varylist, npi0

(See putmodel.pro)


READMODEL

[Previous Routine] [Next Routine] [List of Routines]
This procedure will read from a given file the model parameters.  It
will also read from another file to determine which of these parameters
are to be varied and which are to be fixed.  The parameters pi0,tau and p
and rp are included in the parameter list, and allowed to vary. 
The organization of the model parameter vector is pi0,pi0,pi0... tau,tau,
tau..., p,p,p..., rp,rp,rp...  The list array is organized the same way,
and should hold 1's for those that vary and 0's for those that are fixed,
and 2's for pressures that are linked to the pressure above them (i.e. sheets).
This procedure also returns the number of varying parameters (nvarying).

 CALLS:
    READCOL_N

(See readmodel.pro)


SEL_PCA

[Previous Routine] [Next Routine] [List of Routines]
 SEL_PCA  --  Paul Strycker  --  21 May 2009
                                 14 May 2010

 PURPOSE:
    Select pixels with spectra similar to the fiducial point (or bins all
    pixels by spectra) based on a previously run principal component analysis (PCA)
    using the procedure PCA_EXE on a spectral image cube.
    PCs containing a specified amount of the total variance (keyword "minvar")
    are used to reconstruct the image cube (thereby reducing noise),
    and the spectral-similarity test is conducted on this cube.

 SYNTAX:
    result = sel_pca ( coeff, eigenvectors, coeffheader, maskmap
                       [, pixselmap, npix= , minvar= , nbins= ,
                       fidx= , fidy= , delta= , /verbose ] )

 INPUTS:
    coeff = PCA coefficients (amplitude maps)
    eigenvectors = PCA eigen vectors (the principal components [PCs])
    coeffheader = The header from the FITS file containing the coefficients.
    maskmap = Bad pixel map in either of two formats:
              (1) 2-D array ([naxis1,naxis2] of the image cube), with
                  bad pixels set to 0 and good pixels set to 1.
              (2) Vector containing the indices of the good pixels.

 OPTIONAL OUTPUT:
    pixselmap = Named variable for a pixel map containing either of two results:
                If NOT using the keyword "nbins":
                  2-D array [naxis1,naxis2], with the selected pixels set to 1.
                If using the keyword "nbins":
                  2-D array [naxis1,naxis2] containing the ID number of the
                  spectral bin for each pixel. (This is redundant with the
                  returned result of the function in this case.)

 OPTIONAL KEYWORDS:
    npix = Named variable for the number of pixels selected.
           (Undefined if keyword "nbins" is set.)
    minvar = The minimum percentage of the total variance in the original
             image cube to be included when reconstructing the image cube
             from the supplied PCs (eigenvectors). Default = 95%.
             Example: minvar=98, variance in PCs (taken from coeffheader)
                      for 5 PCs = [83,10,4,2,1].
                      The first three sum to 97%, and the first four sum to 99%.
                      Then SEL_PCA will use PCs 1-4 (but not 5) to
                      reconstruct the spectral image cube before searching
                      for spectrally similar pixels to the fiducial pixel.
    nbins = The number of bins into which the spectra should be divided.
            Setting this sends the coefficients of the appropriate PCs 
            (based on keyword "minvar") to the function BINSPEC, bins all pixels
            accordingly, and returns the result. This completely ignores
            keywords npix, fidx, fidy, and delta.
    fidx = The x-value of the fiducial pixel.
           (If not supplied, the user is prompted for this value.)
    fidy = The y-value of the fiducial pixel.
           (If not supplied, the user is prompted for this value.)
    delta = The spectral tolerance in units of standard deviations
            to be applied (separately) to each wavelength. Only pixels 
            with an RMS difference from the fiducial point that is less than
            delta*stddev for all wavelengths in the reconstructed spectral cube
            (see keyword "minvar") will be included in the final selection.
    /verbose = Print information messages.

 OUTPUT:
    result = Either of two results:
             If NOT using the keyword "nbins":
               Vector with the indices of the selected pixels.
             If using the keyword "nbins":
               2-D array [naxis1,naxis2] containing the ID number of the
               spectral bin for each pixel. (This is redundant with the
               returned result of the function in this case.)

 CALLS:
    PCACUBEPARMS, PCA_RECON, RMSDIFFMAP, BINSPEC

(See ../utils/sel_pca.pro)


VARYMODEL

[Previous Routine] [Next Routine] [List of Routines]
 VARYMODEL  --  Paul Strycker  --  17 June 2009
                                   05 May 2010 (last modified)

 PURPOSE:
    Takes data and an initial model and runs PARMFIT on
    every permutation of varying pairs of model parameters.

 SYNTAX:
    varymodel, z, modelnum [, dim, prefix= , savepath= , modelpath= ,
              parmvarypath= , parmvaryfile= , 
              /no_pressure , /no_radius , no_lev= ,
              /no_pi0 , /no_tau , /converge , /verbose , /disp_all]

 INPUTS:
    z = Structure created by CUTTER_GEN containing a data cut from the
        input images of location(s) with a single vertical structure.
    modelnum = Number corresponding to the model parameter file
               (modelpath+"rawmodel###" OR modelpath+prefix+"###").

 OPTIONAL INPUT:
    dim = Named variable to hold the number of permutations explored.

 OPTIONAL KEYWORDS:
    prefix = String to preceed "###" in the model name. (Default = "rawmodel")
    savepath = Full path to the directory in which results are saved.
    modelpath = Full path to the directory containing the model. (Default = workpath)
    parmvarypath = Full path to the directory in which to save/find the
                   "tempvary###" files, which contain the individual permutations.
    parmvaryfile = Full path to the file containing the parameters to vary
                   if it is NOT: modelpath+"varying.dat".
    /no_pressure = Do not set any pressure variables free to vary.
    /no_radius = Do not set any radii variables free to vary.
    no_lev = Vector containing the levels to ignore.
            (Do not set any variables free to vary in these aerosol layers.)
    /no_pi0 = Do not set any pi0 variables free to vary.
    /no_tau = Do not set any optical depth variables free to vary.
    /converge = Do not reset the model to the initial one after running each
                permutation of free variables. This results in a converged model.
    /verbose = Display minimal update messages.
    /disp_all = Display all information regarding permutation creation and
                modeling.

 REQUIRES COMMON VARIABLES:
    workpath, afull, varyflag, varylist, npi0

 CALLS:
    READCOL_N, READCOL, GETMODEL, PARMFIT, PERCENTCOMPLETE, FORPRINT

 REVISION HISTORY:
    02 April 2010 -- Vary/no vary flag values can be set to 3 for pi0 variables.

(See varymodel.pro)


WORKSCAT

[Previous Routine] [List of Routines]
 WORKSCAT  --  Don Banfield  --  ???

 PURPOSE:
    This procedure will take a look at the and rawmodelxxx files
    to determine the model, and then also the output file dubl.xxx to
    find the modelling result.  It will then plot them in the 4 composite
    plot style
    modified 15 December 2009 to show pi0 for all layers

 CALLS:
    READMODEL, READCOL, PLOT_SETUP, MAPKEY

(See workscat.pro)