Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.arcetri.astro.it/science/chianti/chianti_5.1/list_sel.html
Дата изменения: Thu Sep 15 17:22:53 2005
Дата индексирования: Sat Dec 22 08:33:22 2007
Кодировка:

Поисковые слова: annular solar eclipse
Extended IDL Help

List of Routines


Routine Descriptions

CH_SS

[Next Routine] [List of Routines]
 PROJECT

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 

 NAME

     CH_SS

 PURPOSE:
       Widget-based multi-purpose routine 
       to calculate CHIANTI line intensities and continua, to create a 
       synthetic spectrum, to make tables of lines, etc. 

 CALLING SEQUENCE:

       IDL> ch_ss


 PROCEDURE:

     This routine calculates a synthetic spectrum by merging line 
     intensities and continua. 


     The widget is organised into four Sections: 

     SECTION 1:

      -The Calculation of the  CHIANTI line intensities. 
      
       This can be  done in two ways:

       1-Restore a save file with the CHIANTI line intensities already
       calculated.   

       2-Calculate CHIANTI line intensities  with a call to CH_SYNTHETIC. 

       In this case, A series of parameters must be set:

       - Minimum and maximum wavelengths in Angstroms

       - The model used for the calculation. Three are the options:
          1) a constant  density (cm^-3) 
          2) a constant pressure (cm^-3 K) 
          3) a general (Te,Ne) model. In this case, a file will be read.
             This file should have two columns, one with the Te (K)
             values, and one with the Ne (cm^-3) values.

       - The  ionization fraction file to be used.  "*.ioneq"  files
          can be selected from  either  the CHIANTI database, the 
          working directory or selected via a widget.

       - All ions ?  If set to yes (default), then all the ions present in the
                     database will be included.
 
                     If set to no, then it is possible to select a list of ions
                     with a widget 

       - All lines ? If set to no (default), only the lines for which there are
                      observed energy levels are included 
       
                     If set to yes, also the lines that do not have
                     corresponding observed energy levels are included. In this
                     case, the wavelengths are calculated from the theoretical
                     energy levels, and might not be very accurate.
       
       - Isothermal ?  If set to no (default), a DEM file must be selected. 
                         "*.dem"  files (i.e. files with a .dem extension)
                       can be selected from either  the CHIANTI database, the 
                       working directory or selected via a widget.
       
                       If set to yes, then the user is requested to enter one
                       or more temperatures (as logarithmic values - Log T )
                       and correspondent column emission measures EM
                       logarithmic values.
                       NOTE: if more than one value is entered, then the
                             sequence must be  separated by commas (e.g.: 6.0,
                             6.5, 7.), and both Log T and Log EM must have the
                             same number of values 

       - Photoexcitation ?
                       If set to yes, you have to define:
                       Trad: The blackbody radiation field temperature
                       R/Ro: Distance from the centre of the star in stellar
                             radius units 

       Units:  Photons or Ergs'
       
       Protons: If set to Yes, the proton data are used to calculate the level population    


     Once all the parameters have been defined, the user should click on the
     "Calculate intensities" button to start the calculation (which calls 
     CH_SYNTHETIC). 

     Once the calculation is finished, an IDL  structure is loaded into
     memory. It is then possible to save it for later use by clicking  on the
     "SAVE" button. 
      The RESTORE button is to restore previously saved files into an IDL
      structure in memory.

     Once the IDL structure with the line intensities is in the memory, it is
     then possible to calculate and plot a spectrum (SECTION 2).

     SECTION 2:

              This section controls the parameters that are needed to fold the
              line intensities and the continua into a synthetic
              spectrum. These parameters are used by MAKE_CHIANTI_SPEC.

              Before this is done, a set of line intensities MUST be in the
              program memory. This is done either by calculating the
              intensities  or by restoring a save file with
              previously calculated values (SECTION 1). 

              Setting the parameters:

              -Minimum and maximum wavelengths in Angstroms

              -spectrum bin size in Angstroms. Disallowed if an Effective area
                 file is used.
              
              -instrumental FWHM: Setting this to a non-zero value broadens
                                  each of the spectral lines with a Gaussian of
                                  the specified FWHM (in Angstroms) so
                                  mimicking the effects of instrumental
                                  broadening. 
              
              -continuum: Add continua to the binned spectrum:
                          free-free, free-bound and two-photon.
                          Please note that the continuum calculation takes some
                          time and you may want to define a minimum abundance
                          value to speed the calculations.

              - All lines ? If set to no (default), only the lines for which there are
                           observed energy levels are included.
                           If set to yes, the "unobserved lines" will be added, but
                           only if they are present in the structure.


              -elemental abundances
                          "*.abund"  files (i.e. files with a .abund
                         extension) can be selected either from the CHIANTI database,
                          the  working directory, or via a widget. 

              -select a minimum abundance value
                         If set not null, only the lines of those elements
                         which have an abundance greater than the value set are
                         selected. Also, the continuum is calculated only for
                         those elements which  have an abundance greater than
                         the value set. This can significantly speed up the
                         calculations. By default, the minimum value in the
                         selected abundance file is used. To have an idea of
                         what minimum abundance should be set, the abundances
                         of Allen (1973) give: 

                         abundance (H)  = 1.
                         abundance (He) = 0.085
                         abundance (C)  = 3.3e-4
                         abundance (O)  = 6.6e-4
                         abundance (Si) = 3.3e-5
                         abundance (Fe) = 3.9e-5

              
              Eff. Area: Yes/No 

              If you want to fold the spectrum with an effective area.  
              If set to Yes, you are requested to choose an input ascii file
              with two columns, the wavelength and the effective area values
              (cm^2). 
              The wavelenghts in the file (that might not be linear)  are used
              to create the spectrum, that is multiplied with the effective
              area values.
		    Note that this option only works well if a sufficient number
		    of bins is given. The line intensities contributing to each
		    bin are summed, and  subsequently convolved with a gaussian
		    of full-width-half-maximum FWHM, if FWHM is not set = 0.
                   Please note that the convolution might not work if a small
                   number of  bins is defined. 

                Also note that to have the correct output units  (counts s-1
                bin-1) the appropiately scaled DEM (or EM) values must be provided.


              After this, by clicking on the "Calculate and plot" button the
               program calculates and plots the synthetic spectrum. 
              
              Once the spectrum is displayed, it is then possible to
              view the details of the lines by clicking with the mouse in the
              plot window, and to  perform various operations by clicking on
              the buttons in SECTION 3
              
     SECTION 3:

              This Section allows the user to select a few parameters for the
              plotting, and to create different types of OUTPUT.
              
              Labels ? : Setting this to yes plots a vertical line for each
                         spectral line in the spectrum, and also writes a label
                         above the strongest lines indicating the ion from
                         which the line arises. 
              
              Min.:      Only lines which have an intensity greater than  the
                         value set here will be listed and, if requested,
                         labelled and selected for inclusion in the various
                         outputs.  Setting the value=0.  will result in all
                         lines being listed and written in the outputs.
              
              X,Y, XOOM, UNZOOM: It si possible to select a region of the
                                 spectrum, by zooming with the use of the mouse
                                 or by setting the X,Y ranges.

                                NOTE that only the line details and portion of
                                the spectrum shown will be output.

              LINEAR/LOG  To plot the spectrum in linear or log scale
 
              Create PS file: A postscript file is created. 

              Hardcopy: the postscript file "idl.ps" is created and sent to the
                        default printer. 
              
              Save Line details (latex): The  details of the lines shown in the
                                         plot will be  saved in a latex file.
              
              Save Line details (ascii): The  details of the lines shown in the
                                         plot will be  saved in an ascii file.
              
              

              Save Spectrum (ascii): The  X,Y values of the plot are saved in
                                     an ascii file.

              Save Spectrum (IDL/FITS): The details of all the lines and the arrays
                                   of the X,Y values of the plot are saved into
                                   an IDL or FITS file. The  IDL structure 
                                   has the following tags: 

            .LAMBDA:   The array of wavelength X values

            .SPECTRUM: The array of spectrum Y values

            .UNITS       The units of LAMBDA, SPECTRUM 
            .INSTR_FWHM  The Instrumental FWHM
            .BIN_SIZE         Width of the Bins  (fixed) in angstroms
            .ABUND_NAME  The CHIANTI abundance file name
            .ABUND       The abundance values
            .MIN_ABUND   The minimum abundance value used
            .ABUND_REF   The references
            .CONTINUUM   The values of the continuum (if
                                                calculated)
            .EFFAREA       The array of effective area
                                      values (optional)
            .FILE_EFFAREA  The name of the effective area file used (optional).


            .IONEQ_NAME     The ion balance file used (full path).
            .IONEQ_LOGT        The Log10 T values associated.
            .IONEQ_REF      The references.

            .DEM_NAME       The differential emission measure file eventually  used
                            (full path).
            .DEM            The Log10 DEM values 
            .DEM_LOGT          The Log10 T values associated.
            .DEM_REF        The references.

            .MODEL_NAME    A string indicating the model used 
                     (e.g. constant density or constant pressure).

            .MODEL_NE    the Ne value.
            .MODEL_PE    the Pe value.


            .WVL_UNITS  The wavelength units.

            .WVL_LIMITS    The wavelength limits specified by the user.

            .INT_UNITS  The intensity units

            .LOGT_ISOTHERMAL
                       The Log10(T) values used. 

            .LOGEM_ISOTHERMAL
                       The Log10(EM) values used. 

            .TIME      The date and time when the structure was created.

            .VERSION   The version number of the CHIANTI database used.

            .ADD_PROTONS 
                       A flag (0/1) to indicate whether proton data were used (1)
                       or not (0) to calculate the level population.

            .PHOTOEXCITATION
                       A flag (0/1) to indicate if photoexcitation was included (1)
                       or not (0).

            .RADTEMP 
                      The blackbody radiation field temperature used (if
                      photoexcitation was included).

            .RPHOT
                   Distance from the centre of the star in stellar radius units  
                   (if photoexcitation was included).

                                       THEN, FOR EACH LINE USED TO CALCULATE THE
                                       SPECTRUM:

            .LINES     A structure containing information about the lines. 
                       Its size is the number of lines in the spectrum. The 
                       tags are:

                  .peak   The peak intensity value 

                  .iz     The atomic number of the elements (e.g., 26=Fe)

                  .ion    The ionisation stage (e.g., 13=XIII)

                  .snote  The identification of the ion (e.g., 'Fe XXIV d')

                  .ident  The identification of the transition, configuration
                           and terms in text form.

                  .ident_latex
                          The identification of the transition, configuration
                           and terms in latex form.

                  .lvl1   The lower level of the transition (see .elvlc 
                          file for ion)

                  .lvl2   The upper level for transition.

                  .tmax   The temperature of maximum emission of the line 
                          (i.e., the temperature at which the product of 
                          the emissivity and the ion fraction has its 
                          maximum). Rounded to nearest 0.1, and zero in case
                          the isothermal approximation is used. 

                  .fwhm 

                  .wvl    Wavelength of the transition, in Angstroms.

                  .flag   A flag, =-1 if the line has only theoretical energy
                          levels. Otherwise flag=0.

                  .int    Intensity of line  (with the  abundance factor multiplied)



              Save Spectrum (FITS): The entire information contained in the
                                    IDL structure is stored in a FITS file. 
                                    
     SECTION 4:
              Here, text information messages are printed. 

 INPUTS

     None.

 OPTIONAL INPUTS:
     The font 

 OUTPUTS:
     Many.
 
 KEYWORD PARAMETERS:
     
     FONT  the font to be used. Can be useful to customize the appearance of
           the widget.

 CALLS:

     CH_SYNTHETIC, CH_LINE_LIST, CH_DRAWBOX, MAKE_CHIANTI_SPEC, CH_XMENU_SEL,
     plus many other CHIANTI and SolarSoft routines.


 PROGRAMMING NOTES

     Within CH_SS, there are several other routines which are:

     OPLOT_LINES   This overplots lines and a label on the displayed 
                   spectrum.
     SYN_CURSOR    When the mouse is clicked when on the spectrum window, 
                   this routine prints out the list of nearby lines and 
                   their IDs in the text window.

     CALC_SYN_SPECTRUM
                   Calculates line intensities with a call to CH_SYNTHETIC

     PLOT_SYN_SPECTRUM  This calls make_chianti_spec to produce the 
                        intensity vs. wavelength plot.
     SYN_MAIN_EVENT  This handles the widget operations

     SYN_WID       This creates the widgets.     

 COMMON BLOCKS:
        many

 RESTRICTIONS:

 SIDE EFFECTS:

 EXAMPLE:

     IDL> ch_ss

 CATEGORY:
	
	spectral synthesis.


 WRITTEN     : 

       Ver.1, 7-Nov-01, Giulio Del Zanna (GDZ) and Peter Young (PRY)  

 MODIFICATION HISTORY:

       V.2, 7-Nov-01, GDZ . Fixed a small bug (now the spectrum plot is always
       plotted within the widget), and modified the option to add continua.
       Changed the suggested  names of the outputs. 
       Corrected a bug when creating an IDL save file with the spectrum, when
       no line details are present.

       V.3 28-Jan-02 GDZ
           fixed a bug in the density text widget, added a few buttons 
           and options, including the effective area.
            Added noprot, rphot, radtemp keywords to the call to ch_synthetic

       V 4, 18-Apr-2002, GDZ 
           Added  photoexcitation, changed IDL save files to FITS files,

       V.5, 21-May-2002, GDZ 
        fixed a few small bugs: checking min_abund before calculating the
                                spectrum; checking the ioneq file when
                                restoring the structure; changed the status of
                                all lines;  chnaged the font system.
                               generalized directory concatenation to work for 
                               Unix, Windows  and VMS.

       V.6, 15-July-2002, GDZ - New major revision.

           Changed the chianti top directory (for Effective areas).
           Changed  Linear/Log button. 

            Rearranged the sizes of the buttons and added a special cursor to
            highlight the area where  details of the lines will be given. Works
            only in linear scale.

           Added quite a lot of new checks to avoid crashes and
           fixed the problem with the zoom/unzoom/change units.

       V.7, 2-Aug-02, GDZ

           Modified the output labels on the plot, inside and on the axis.
           Also modified a few minor things like the appearance of the Log T,EM
           values. 
           Fixed a bug when creating the latex output.
           Now it restores at the end  previous colors and settings. 
 
       V.8, 8-Aug-02, GDZ
           Changed the CHIANTI system variables. Fixed.
           Also fixed a problem with the element ab. file.

      V.9, 13-Aug-02, GDZ 

           Restored the correct use of ch_line_int, now only the lines in the
           plot window are listed, and the ALL keyword is in use. 
           Now the correct xrange is loaded into COMMON when line int. are
           restored. Now it checks if all ions were in the structure, when
           restoring the line intensities, and flags the widget button accordingly.
           Added a device,decomposed=0. to remove problems with colors.
           Corrected the use of the DEM, IONEQ and ABUND pulldown menus,
           avoiding conflicts between files in the working and CHIANTI
           directory having the same name.
           Added printing of references for ancillary files, and a check on the
           element abundances vs. the elements present in the structure.

       V.10, 7-Nov-03  GDZ

          Modified format e8.2 to e9.2 for Windows compatibility.
          Replaced f9.4 with f11.4 format for the wavelengths.
          Some minor modifications to the widget.

          Added extended details in the ascii output spectrum.

          Added more explanations in the HELP buttons.

       V.11,  22-Jul-2005  GDZ 

          -Added keV option and a few more extra checks.

       V.12,  2-Aug-2005 GDZ
           put RETAIN=2 in the main plotting window.

 TO DO LIST:
           Control the range of Angstroms when clicking
           kev
           Allow plots in intensities instead of intensities A-1

 VERSION     :  V.12,  2-Aug-2005


CH_SYNTHETIC

[Previous Routine] [Next Routine] [List of Routines]
 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	CH_SYNTHETIC

 PURPOSE:

       to calculate CHIANTI line intensities or G(T) and output an IDL structure. 

 PROCEDURE:

       This routine calculates as default line intensities for a user-specified 
       differential emission measure and ionisation balance. The actual 
       creation of a synthetic spectrum (i.e., wavelength vs. intensity) 
       is performed by other routines - see CH_SS.PRO and 
       MAKE_CHIANTI_SPEC.PRO.

       Note that this routine does not include the element abundances 
       in the line intensities, as this will be performed by 
       make_chianti_spec. One of the reasons why  element abundances are not
       included in the line intensities calculation is so that it is easier 
       for the user to see how  modifying abundances affects their spectra in
       e.g. CH_SS.PRO. 

       The calculations are performed at constant pressure or 
       at constant density.

       The routine can also output line intensities calculated with an
       isothermal approximation.

	If the isothermal approximation is not used, then the user will be asked
	to select two  files, that can either be in the 
	standard CHIANTI database or in the working directory. 

       These files are: 
       
       - an ionization fraction file 
       - a differential emission measure (DEM) file.

       The routine can also output the contribution functions G(T) of the lines,
       instead of the intensities, if the keyword GOFT is used. In this case,
       only the ionization equilibrium file needs to be selected.
       The G(T), or intensity per emission measure, is calculated as:

        G=(hc/lambda_ij)*A_ji*(N_j(X^+m)/N(X^+m))*(N(X^+m)/N(X))/ N_e /(4.*!pi)

       where A_ji is the A-value of the transition;
             (N_j(X^+m)/N(X^+m)) is the population of the upper level,
             calculated by solving the statistical equilibrium equations; 
             (N(X^+m)/N(X)) is the ionization equilibrium
             N_e is the electron density.

       unless    /PHOTONS is set, in which case the  (hc/lambda_ij) factor
       is not included.  

       If not specified otherwise, with the use of the MASTERLIST or SNG_ION
       keywords,  then the standard masterlist of the ions, which has 
       all the ions in the current CHIANTI database, is used.

       PROGRAMMING NOTES

       The DEM is not assumed to be specified at 0.1 logT intervals (which 
       is how the ion fraction are specified). Thus this routine reads 
       in the DEM vs. logT information and then uses the IDL spline 
       function to tabulate the DEM over 0.1 logT intervals. The minimum 
       and maximum temperatures are those in the DEM file, rounded up to 
       the nearest 0.1. The new DEM function tabulated over 0.1 logT 
       intervals is contained in 'dem_int'.

       For some of the dielectronic files, radiative decays that were in 
       the standard .wgfa file will also be present in the dielectronic 
       version of the .wgfa file. In these cases the line intensity 
       produced from the latter file needs to be ignored and so we have a 
       check in ch_synthetic to do this. An example is the 1-7 decay in 
       the ca_19.wgfa and ca_19d.wgfa files. In the latter case, the 
       model of the ion does not include electron excitation to level 7 
       and so the model for the 1-7 decay is incorrect, hence we ignore 
       it.

 CATEGORY:

	spectral synthesis.

 CALLING SEQUENCE:

       IDL> ch_synthetic,wmin,wmax, output=output, pressure=pressure,$
            [MODEL_FILE=MODEL_FILE, err_msg=err_msg, msg=msg, $
            density=density,all=all,sngl_ion=sngl_ion, $
            photons=photons,  masterlist=masterlist, $
            save_file=save_file , verbose=verbose, $
            logt_isothermal=logt_isothermal,$
            logem_isothermal=logem_isothermal,$
            goft=goft, ioneq_name=ioneq_name, dem_name=dem_name,$
            noprot=noprot, rphot=rphot, radtemp=radtemp, progress=progress ]



 INPUTS:

	Wmin:  minimum of desired wavelength range in Angstroms
	Wmax:  maximum of desired wavelength range in Angstroms

       PRESSURE:  pressure in emitting region (Pe,  cm^-3 K). 
                  Only a single value is accepted, and the calculation is
                  performed at constant pressure.


 OPTIONAL INPUTS :

       DENSITY:   density in emitting region (Ne, cm^-3). 
                  Only a single value is accepted, and the calculation is
                  performed at constant  density, unless LOGT_ISOTHERMAL is
                  defined. In this case, DENSITY can be an array of values, but
                  has to have the same number of elements as LOGT_ISOTHERMAL.


       MODEL_FILE    Full path of the (Te,Ne) file if defined. 
                     This file should have two columns, one with the Te (K)
                     values, and one with the Ne (cm^-3) values. If these
                     values are not sorted in ascending order of Te, the
                     routine does sort them.
                     


	SNGL_ION:  specifies  a single ion (e.g. SNGL_ION='Fe_10' to include
                 only Fe X lines) or an array (e.g. SNGL_ION=['Fe_10','Fe_11']
                 to include only Fe X and Fe XI lines) of ions to be used
                 instead of the complete set of ions specified in
                 !xuvtop/masterlist/masterlist.ions 

       MASTERLIST: string of a specific masterlist file (full path). 
                   If defined as a keyword (i.e. MASTERLIST=1 or /MASTERLIST)
                   then a widget allows the user to select a  user-defined
                   masterlist file. Shortcut for SNGL_ION.   



	IONEQ_NAME:  Name of the ionization equilization name to use.  If not
		     passed, then the user is prompted for it.

       DEM_NAME:  Name of the DEM file to used.  If not passed, then the user
		   is prompted for it.

       LOGT_ISOTHERMAL
                  Array of logarithmic temperatures.
                  If defined, the emissivities are calculated with an
                  isothermal approximation. The values are sorted in ascending
                  order.

       LOGEM_ISOTHERMAL
                  Array of logarithmic emission measures.
                  If defined, the emissivities are calculated with an
                  isothermal approximation. The values are sorted in ascending
                  order. If LOGT_ISOTHERMAL is specified without 
                  LOGEM_ISOTHERMAL then the emission measures are set to 1 
                  (logem_isothermal=0).

       RADTEMP   The blackbody radiation field temperature (default 6000 K).

       RPHOT    Distance from the centre of the star in stellar radius units.
                I.e., RPHOT=1 corresponds to the star's surface. (Default is
                infinity, i.e., no photoexcitation.)


 OUTPUTS:

       OUTPUT:    The name of the structure containing the line intensities and
                  details.  
                  The tags of the  structure are:

       .lines     A structure containing information about the lines. 
                  Its size is the number of lines in the spectrum. The 
                  tags are:

                  .iz     The atomic number of the elements (e.g., 26=Fe)

                  .ion    The ionisation stage (e.g., 13=XIII)

                  .snote  The identification of the ion (e.g., 'Fe XXIV d')

                  .ident  The identification of the transition, configuration
                           and terms in text form.

                  .ident_latex
                          The identification of the transition, configuration
                           and terms in latex form.

                  .lvl1   The lower level of the transition (see .elvlc 
                          file for ion)

                  .lvl2   The upper level for transition.

                  .tmax   The temperature of maximum emission of the line.

                          If the G(T) are output, tmax is the maximum of G(T).

                          If the isothermal approximation is used  tmax=0.

                          If a DEM is used,  tmax is the maximum of the 
                          emissivity that includes the product of the ion
                          fraction and the DEM.
                          Rounded to nearest 0.1

                  .wvl    Wavelength of the transition, in Angstroms.

                  .flag   A flag, =-1 if the line has only theoretical energy
                          levels. Otherwise flag=0.

                  .int    Intensity of line (erg/cm2/s/sr or phot/cm2/s/sr), 
                          divided by the element abundance (exclusive with .goft). 

                  .goft   The G(T) of the line (optional /exclusive with .int).


       .ioneq_name     The ion balance file used (full path).
       .ioneq_logt        The Log10 T values associated.
       .ioneq_ref      The references.

       .dem_name       The differential emission measure file eventually  used
                       (full path).
       .dem            The Log10 DEM values 
       .dem_logt          The Log10 T values associated.
       .dem_ref        The references.

       .model_name    A string indicating the model used: 

                    1- Constant density
                    2- Constant pressure
                    3- Function (Te,Ne)

       .model_file    Full path of the (Te,Ne) file if defined. Null string otherwise.

       .model_ne    the Ne value(s).

                     - a scalar if 'Constant density' is selected.
                     - an array if 'Function' is selected.
                     - 0. if constant pressure is selected.

       .model_pe    the Pe value.

                     - a scalar if constant pressure is selected.
                     - 0. if 'Constant density' is selected.
                     - an array=density*temperature if 'Function' is selected.
                          
       .model_te    the Te values if 'Function' is selected. Otherwise 0.

       .wvl_units  The wavelength units.

       .wvl_limits    The wavelength limits specified by the user.

       .int_units  The intensity units.

                   1) If LOGT_ISOTHERMAL is defined, we have two cases:
                      a) LOGEM_ISOTHERMAL is not defined, and is therefore
                         assumed to be 0 (EM=1). In this case, units are
                         'photons cm+3 sr-1 s-1' or 'erg cm+3 sr-1 s-1'.
                      b)  LOGEM_ISOTHERMAL is defined. In this case, units are
                         'photons cm-2 sr-1 s-1' or 'erg cm-2 sr-1 s-1'.

                   2) If LOGT_ISOTHERMAL is not defined, we have two cases:
                      a) intensities are calculated. In this case, units are
                         'photons cm-2 sr-1 s-1' or 'erg cm-2 sr-1 s-1'.
                      b) Contribution functions G(T) are calculated. In this
                         case, units are 
                         'photons cm+3 sr-1 s-1' or 'erg cm+3 sr-1 s-1'.

       .logt_isothermal
                  The Log10(T) values used. 

       .logem_isothermal
                  The Log10(EM) values used. 

       .date      The date and time when the structure was created.

       .version   The version number of the CHIANTI database used.

       .add_protons 
                  A flag (0/1) to indicate whether proton data were used (1)
                  or not (0) to calculate the level population.

       .photoexcitation
                  A flag (0/1) to indicate if photoexcitation was included (1)
                  or not (0).

       .radtemp 
                 The blackbody radiation field temperature used (if
                 photoexcitation was included).

       .rphot
              Distance from the centre of the star in stellar radius units  
              (if photoexcitation was included).


 OPTIONAL OUTPUTS:


       SAVE_FILE: If defined, then an IDL save file is created, with the output
                  structure. 


       GOFT:      If set,  the G(T) of the lines are calculated, and put in
                  the output structure, instead  of the line intensities.
                  Units are 'photons cm+3 sr-1 s-1' or 'erg cm+3 sr-1 s-1'



 KEYWORDS:


       ALL:  if set, then all lines are included.  This means that lines for
             which  only an approximate wavelength is known, 
             denoted by a  negative wavelength value in the .wgfa file, are
             included. These are the lines for which there are no observed
             energy levels. 


       PHOTONS:   The output intensities will be in photons instead of 
                  ergs.

       VERBOSE:   If set, the routine will list each ion it is looking at, 
                  and how many lines from each ion it is including in the 
                  spectrum.

       GOFT:      If set,  the G(T) of the lines are calculated, and put in
                  the output structure, instead  of the line intensities.
                  Units are 'photons cm+3 sr-1 s-1' or 'erg cm+3 sr-1 s-1'

       NOPROT     Switch off the inclusion of proton rates in the level 
                  balance (default).

      PROGRESS    If set, a widget appears, showing the progress of the
                  calculation and allowing the user to halt the calculation.

      NO_SUM_INT  Prevents the summing of intensities over temperature. 
                  Only works in conjunction with the LOGT_ISOTHERMAL 
                  option, and is implemented in order to work the 
                  ISOTHERMAL routine. The .INT tag in OUT.LINES becomes 
                  an array with the same number of elements as 
                  LOGT_ISOTHERMAL, corresponding to the intensities at 
                  each temperature.

 CALLS:  CH_GET_FILE
          many CHIANTI standard routines,  including:
          READ_IONEQ, READ_DEM, READ_MASTERLIST, ION2SPECTROSCOPIC,
          ZION2FILENAME, READ_WGFA,READ_ELVLC,READ_SPLUPS,POP_SOLVER,
          DESCALE_UPS, CONVERT_TERMS. 
          CONVERT_TERMS uses some standard SolarSoft routines: 
          REPSTR, STR_INDEX, DATATYPE, 
          VALID_NUM, DELVARX, INFO_PROGRESS, SAVEGEN

 COMMON BLOCKS:
          wgfa, wvl,gf,a_value
          upsilon,splstr
          elvlc,l1a,term,conf,ss,ll,jj,ecm,eryd,ecmth,erydth,eref 
          elements,abund,abund_ref,ioneq,ioneq_logt,ioneq_ref
          radiative, radt, dilute
          proton, pstr
          ionrec,rec_rate,ci_rate,temp_ionrec,luprec,lupci,status

 RESTRICTIONS:

 SIDE EFFECTS:

 CATEGORY:
	spectral synthesis.
	
 EXAMPLE:

       This routine can be called in this way:

       IDL> ch_synthetic,5.,10., output=structure, pressure=1.e+15

       To make use of the output structure, use MAKE_CHIANTI_SPEC or CH_SS
       

 PREV. HIST. :
       Based on synthetic.pro, written by Ken Dere


 WRITTEN     : 
       Ver.1, 22-Jun-00, Peter Young (PRY) and Giulio Del Zanna (GDZ)

 MODIFICATION HISTORY:

       Ver.1, 22-Jun-00, Peter Young and Giulio Del Zanna

       Ver.2, 25-Jul-00, PRY
               Removed /all keyword; make_chianti_spec can be 
                used to filter out negative wavelengths.
               Added flabel tag to output in order to pick out 
                dielectronic recombination lines.

       Ver.3, 4-Oct-00, PRY
               Replaced /all keyword.
               Corrected bug when .wgfa files contain two A-values 
                for the same transition.

       Ver.4, 5-Oct-00, PRY
               Corrected bug that gave rise to lines from the same 
                transition when the dielectronic file existed.

       V.5, 11-Oct-2000, GDZ
            eliminate the abundance call; reinstate the /masterlist keyword;
            added the tag  ident_latex to have the identification in 
            late-style format; added a tag flag=-1 for the unobserved lines,
            and =0 otherwise; reinstated all wavelengths > 0. ;
            added the calculation of the G(T);
            added  a few other tags in the output, and various checks and
            comments. 
       V.6 15-Oct-2000 ,GDZ
             Replaced calls to solarsoft routines to  standard IDL ones. 
             Corrected an error in the output creation, in relation to the
             isothermal case. Added isothermal in the output. added checks to
             the wavelengths. Default output name is TRANSITIONS. changed
             const_net and added const_net_value + a few other things.

       v.7, 27-Nov-2000, GDZ. Corrected an error in the calculation of the
       G(T). 

       Version 8, 5-Dec-2000, GDZ, DAMTP. Fixed a bug when checking the 
       values in the .splups files.

       V. 9, GDZ, 10-Apr-2001, corrected another error in the G(T) calc.

       V. 10, GDZ, 30-Oct-2001 added CHIANTI Version number, changed isothermal
            to logt_isothermal and added logem_isothermal to the output.
            Removed the use of log T values, and the calculation. 
            Added err_msg, a text string with an error message.
 
       Version 11, 8-Nov-01, GDZ

            Changed the MASTERLIST keyword. Allowed double use, as a keyword 
            and as a string.

       Version 12, 18-Nov-01, Peter Young

            Added /NOPROT, RPHOT and RADTEMP keywords; changed upsilon 
            common block.

        Version 13, 29-Apr-02, GDZ

            Added no_protons, photoexcitation, rphot, radtemp 
            tags into the output  structure. 
            Revised Header. Added the PROGRESS widget.
            Added a check if the ion is present in the Ion. Frac. file.
            Added informative MSG keyword.
            Now uses  savegen.pro to save the structure.

        V. 14, 28-May-2002, GDZ: 
                  generalize directory concatenation to work for Unix, Windows
                  and VMS. 

           modified tags: 
                          limits -> wvl_limits
                          ioneq_t -> ioneq_logt
                          wvlunits -> wvl_units
                          intunits -> int_units
                          time --> date 
                          no_protons -> add_protons
                         dem_t -> dem_logt 
                const_nte -> model_name
                const_nte_value -> model_ne, model_pe, model_te
                   removed from the main STR:   .ioneq  ctemp 
                   removed from the LINES STR:  fwhm flabel

            Added model_file  input for model Ne(T). Had to considerably
            modify the routine.

         V. 15, 16-Jul-2002, Peter Young
                  Added keyword /NO_SUM_INT.

         V. 16, 22-Jul-2002, Peter Young
                  Corrected a bug related to /NO_SUM_INT; logt_isothermal 
                  can now be specified without logem_isothermal.

         V. 17, 23-July-2002, GDZ
                  Modified a few checks on the input. Also, now it prints the
                  error message whenever the program aborts

         V.18, 2-Aug-02, GDZ
                  Replaced all DBLARR and DOUBLE calls with floats.
                  Added a comment at the end of the routine when it finishes.

         V.19, 8-Aug-02, GDZ 
                  Added more error info. Changed the use of the DENSITY
                  keyword. It is possible to input an array of values if
                  LOGT_ISOTHERMAL is defined.

         V. 20, 17-Sep-02, GDZ
                  Corrected a bug: the functional (T,N) form
                  is now only accepted if DENSITY is an array with at least two
                  values.
         V. 21, 19-Sep-02, GDZ
                  Corrected the definition of the UNITS in case LOGT_ISOTHERMAL
                  is defined.

         V. 22, 19-Aug-03, Peter Young
                  when logem_isothermal is input, the derived EM is now a
                  DOUBLE array rather than FLOAT, preventing infinities when
                  logem_isothermal values are large.

         V. 23,   4-Oct-2003, GDZ
                  modified the input to POP_SOLVER, now it is dealt with an
                  input structure.

         V.24,    10-Oct-2003, K.Dere
                  added modifications from K.Dere, regarding the satellite
                  lines. 

         V 25,    3-Nov-2003, GDZ
                 Added GROUP keyword, and modified so the progress widget can
                 be stopped within IDL Windows.

         V 26,    17-Apr-2004, Enrico Landi (EL)
                  Added the recombination/ionization population processes.

         V.27,    13-Apr-2005, EL
                  Replaced the main loop to calculate individual line intensities
                  with operations among arrays, to speed the whole program in case
                  of large numbers of lines.

 VERSION     : 27,    13-Apr-2004


SYNTHETIC

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	SYNTHETIC

 PURPOSE:

       calculates a synthetic spectrum


 PROCEDURE:

                 Calculations are done assuming either constant density or
                 constant pressure. See CH_SYNTHETIC for details.


 CALLING SEQUENCE:

       SYNTHETIC,Wmin, Wmax, Fwhm, Pressure= , Lambda, Spectrum ,List_wvl, List_ident
                 ,[/all, density=, /cont, min_abund=]


 INPUTS:


	Wmin:   lower limit of the wavelength/energy range of interest (Angstroms)

	Wmax:   upper limit of the wavelength/energy range of interest (Angstroms)

       Pressure:  pressure in emitting region (cm^-3 K), or 
       Density:   density in emitting region (cm^-3).

       Fwhm:  gaussian full width at half maximum of the resolution of the output 
                  spectrum, for example, to correspond to an observed spectrum


 OPTIONAL INPUTS:

	SNGL_ION:  specifies  a single ion (e.g. SNGL_ION='Fe_10' to include
                 only Fe X lines) or an array (e.g. SNGL_ION=['Fe_10','Fe_11']
                 to include only Fe X and Fe XI lines) of ions to be used
                 instead of the complete set of ions specified in
                 !xuvtop/masterlist/masterlist.ions 

       MASTERLIST: string of a specific masterlist file (full path). 
                   If defined as a keyword (i.e. MASTERLIST=1 or /MASTERLIST)
                   then a widget allows the user to select a  user-defined
                   masterlist file. Shortcut for SNGL_ION.   


       MIN_ABUND:  If set, calculates the continuum only from those elements which 
                   have an abundance greater than min_abund. 

	DEM_NAME:  Name of the DEM file to used.  If not passed, then the user
		   is prompted for it.

	ABUND_NAME:  Name of the abundance file to use.  If not passed, then
		     the user is prompted for it.

	IONEQ_NAME:  Name of the ionization equilization name to use.  If not
		     passed, then the user is prompted for it.

       RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

       RADTEMP The blackbody radiation field temperature (default 6000 K).
 

 OUTPUTS:

       Lambda:  wavelength array of calculated synthetic spectrum
       Spectrum:  intensity array (erg cm^-2 s^-1 str^-1 Ang^-1),
                  unless keyword photons is set then output is is
                  photons cm^-2 s^-1 str^-1 Ang^-1
       List_wvl:  a list of wavelengths for use with synthetic_plot.pro
       List_ident:  a list of line identifications for use with 
                        synthetic_plot.pro

 OPTIONAL OUTPUTS:

	
 KEYWORD PARAMETERS:

     
	ALL:  if set, then all lines are included.  This means that lines for which
             only an approximate wavelength is known (only theoretical energy
             levels are known) are included.

	SNGL_ION:  specifies  a single ion (e.g. SNGL_ION='Fe_10' to include
                 only Fe X lines) or an array (e.g. SNGL_ION=['Fe_10','Fe_11']
                 to include only Fe X and Fe XI lines) of ions to be used
                 instead of the complete set of ions specified in
                 !xuvtop/masterlist/masterlist.ions 

       MASTERLIST: string of a specific masterlist file (full path). 
                   If defined as a keyword (i.e. MASTERLIST=1 or /MASTERLIST)
                   then a widget allows the user to select a  user-defined
                   masterlist file. Shortcut for SNGL_ION.   

       CONTINUUM:   if set, then the continuum (free-free, free-bound and
                  two-photon) are  included 

       MIN_ABUND:  If set, calculates the continuum only from those elements which 
                   have an abundance greater than min_abund.  Can speed up the 
                   calculations.  For example, from Allen (1973):
                   abundance (H)  = 1.
                   abundance (He) = 0.085
                   abundance (C)  = 3.3e-4
                   abundance (O)  = 6.6e-4
                   abundance (Si) = 3.3e-5
                   abundance (Fe) = 3.9e-5



	PHOTONS:  if set, intensities are in photons cm^-2 s^-1 sr^-1 Ang^-1

	DEM_NAME:  Name of the DEM file to used.  If not passed, then the user
		   is prompted for it.

	ABUND_NAME:  Name of the abundance file to use.  If not passed, then
		     the user is prompted for it.

	IONEQ_NAME:  Name of the ionization equilization name to use.  If not
		     passed, then the user is prompted for it.

       NOPROT   If set, then proton rates are not included.

	RADTEMP	Specify background radiation temperature (default: 6000 K)

	RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

 CALLS:
       
       CH_SYNTHETIC, MAKE_CHIANTI_SPEC, READ_ABUND, STRPAD


 COMMON BLOCKS: None


 RESTRICTIONS:

 SIDE EFFECTS:


 EXAMPLE:

       > synthetic,100.,200.,.1, pressure=1.e+16,lambda,spectrum,list_wvl,list_ident


 CATEGORY:

	spectral synthesis.

 WRITTEN     : 

       Version 1, 8-Nov-01, Giulio Del Zanna (GDZ). 

       Rewritten as a wrapper routine using the new procedures.

       Compared to the previous SYNTHETIC, these are the main changes:

       1-Now the PRESSURE value is a keyword as the DENSITY value
       2-The keyword CONT is now renamed CONTINUUM
       3-Added keywords PHOTONS, DEM_NAME, ABUND_NAME, IONEQ_NAME
       4-MASTERLIST can now be used both as an input string or as a keyword.
       5-The description of the line details now has the spectroscopic 
         designation at the end.


 MODIFICATION HISTORY:

       Version 2, 18-Nov-01, Peter Young
           Added /noprot, rphot and radtemp keywords.

       Version 3, 11-Dec-01, Peter Young
           Changed call to ch_strpad to strpad.

       Version 4, 28-Apr-02, GDZ, changed the call to make_chianti_spec and the
       continuum keyword.

       V. 5, 22-May-2002 GDZ.  Removed const_net definitions.

       V.6, 14-Feb-2003 GDZ.
             Fixed a bug (keyword PHOTONS was not active). 
             
 VERSION     : 6, 14-Feb-2003



SYNTHETIC_PLOT

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 

 NAME:
	synthetic_plot

 PURPOSE:

       to plot out synthetic spectra calculated with Synthetic
       and interactively identify spectral lines


 CATEGORY:
	
	spectroscopy

 CALLING SEQUENCE:

       SYNTHETIC_PLOT,Wvl,Spectrum,List_wvl,List_ident,fwhm


 INPUTS:

       Wvl:  wavelength array from synthetic
       Spectrum:  spectrum intensity array from synthetic
       List_wvl:  string array of spectral line wavelengths
       List_ident:  string array of spectral line identifications
       Fwhm:  when the cursor is clicked, spectral lines with fwhm
              (Angstroms) of the cursor are printed out


 KEYWORDS

	xrange:  similar to IDL keyword to determine wavelength range of plot

 OUTPUTS:

       None


 PROCEDURE:

	Click the left mouse button to select a wavelength
       Click the right mouse button to exit

 EXAMPLE:

      > synthetic,100.,200.,.1,1.e+15,wvl,spectrum,list_wvl,list_ident
      > synthetic_plot,wvl,spectrum,list_wvl,list_ident,0.1
                     
      note:  it is not necessary for the two fwhm values to be the same      

 MODIFICATION HISTORY:
 	Written by:	Ken Dere
	May 1996:     Version 2.0
       Dec. 1998:    revised by Ken Dere
       V.4,  23 Oct 2000 GDZ, added the log keyword, and changed a few things
       in the plot. 

       Ver.5, 12-Dec-2001, Peter Young
           Changed style of printing, and made method of extracting the 
           intensity from list_ident compatible with the new version of 
           isothermal.pro.

 VERSION 5   12 Dec 2001 Peter Young


ISOTHERMAL

[Previous Routine] [Next Routine] [List of Routines]
 NAME

       ISOTHERMAL

 PURPOSE:
       Computes spectra from isothermal plasmas. A number of isothermal 
       plasmas can be included.
       Note that this routine has a number of unique features that 
       distinguish it from the other CHIANTI synthetic spectra routines. 
       See the Programming Notes section.

 INPUTS:

       WMIN      Minimum of desired wavelength range in Angstroms.

       WMAX      Maximum of desired wavelength range in Angstroms.

       WAVESTEP  Bin size of spectrum (in Angstroms)

       TEMP      Electron temperature (or array).

 OPTIONAL INPUTS

       PRESSURE  Electron pressure in units of cm^-3 K.

       EDENSITY  Electron density in units of cm^-3.

       EM        Emission measure. The units of EM govern the intensity 
                 units of the emission lines (i.e., column or volume 
                 emission measure units). If EM is not specified, then the 
                 emission measure is set to (N_e * N_H) where N_e is 
                 derived from the user-specified PRESSURE or EDENSITY, 
                 and N_H is derived from the routine PROTON_DENS.PRO.

       SNGL_ION  Rather than include the entire list of CHIANTI ions in 
                 the calculation, this input can be used to select a 
                 single ion, or a number of different ions. E.g., 
                 SNGL_ION='s_2' or SNGL_ION=['s_2','s_3','s_4'].

       RADTEMP   The blackbody radiation field temperature (default 6000 K).

       RPHOT    Distance from the centre of the star in stellar radius units.
                I.e., RPHOT=1 corresponds to the star's surface. (Default is
                infinity, i.e., no photoexcitation.)

       MASTERLIST  The list of ions that will be considered for the 
                   spectrum is contained in the masterlist file in the 
                   CHIANTI directories. The user can specify his own file 
                   through this keyword. E.g., 
                   masterlist='/user/home/masterlist.ions'


	ABUND_NAME:  Name of the abundance file to use.  If not passed, then
		     the user is prompted for it.

	IONEQ_NAME:  Name of the ionization equilization name to use.  If not
		     passed, then the user is prompted for it.


  KEYWORDS

       NOPROT     Switch off the inclusion of proton rates in the level 
                  balance.

       ERGS       The units of the output spectrum are by default in photons. 
                  Setting /ERGS switches to erg units.

       CONT       Adds continuum (free-free, free-bound, two-photon) to 
                  spectrum.

  OUTPUTS:

        LAMBDA   Wavelength array of calculated synthetic spectrum.

        SPECTRUM Intensity array. The units depend on the user inputs to 
                 ISOTHERMAL -- see note below. 

        LIST_WVL A list of wavelengths for use with synthetic_plot.pro

        LIST_IDENT A list of line identifications for use with 
                   synthetic_plot.pro

 PROGRAMMING NOTES

        Intensity Units
        ---------------
        The units are of the form photons cm^3 s^-1 sr^-1 * (units of EM), 
        changing to ergs if the /ergs keyword is set.

        The volume emission measure (N_e*N_H*V) has units cm^-3.

        The column emission measure (N_e*N_H*h) has units cm^-5.


        Unique features
        ---------------
        The emission lines in the final spectrum have no width and thus 
        each occupies a single pixel of the spectrum. The size of the 
        pixels are set by WAVESTEP.

        As stated above, the units of the output spectrum are 
        photons cm^3 s^-1 sr^-1, i.e., there is no "per angstrom" term. 
        This means that (i) the height of the emission lines in the 
        spectrum does not change with varying WAVESTEP, and (ii) the height
        of continuum does change with WAVESTEP.

 COMMON BLOCKS

        ELEMENTS

 CALLS

        CH_SYNTHETIC, READ_ABUND, CH_GET_FILE, CONCAT_DIR, FREEFREE, 
        FREEBOUND, TWO_PHOTON

 HISTORY
        Ver.1, 8-Apr-02, Peter Young  Rutherford Appleton Laboratory,
        p.r.young@rl.ac.uk 
        Tries to replicate the behaviour of the original ISOTHERMAL which 
        was found in earlier versions of CHIANTI (v.3 and earlier). 

 MODIFICATION HISTORY

       Ver. 2, Giulio Del Zanna (GDZ), 28-Apr-02 
               Added abund_name,ioneq_name keywords.
               Also, added photons keyword in call to MAKE_CHIANTI_SPEC.

       Ver. 3, Peter Young, 24-May-02
                 Modified to produce arrays of spectra when an array of 
                 temperatures is given

       V.4, GDZ, 28-May-02 
              Added a couple of checks on file existence and modified the call
              to ch_synthetic and make_chianti_spec  due to change of keyword
              names.  

       V.5, Peter Young, 16-Jul-02
              Restructured routine to avoid crashes when a large number of 
              temperatures is input.

       V.6, 8-Aug-02 GDZ
              Added one error checking

       V.7, 18-Aug-03, Peter Young
              Added EM= keyword.


 VERSION     : 
       Version 6, 8-Aug-02 
        


MAKE_CHIANTI_SPEC

[Previous Routine] [Next Routine] [List of Routines]
 PROJECT     :  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 

                   
 NAME        : MAKE_CHIANTI_SPEC
     		          
 PURPOSE     : 
              To create a CHIANTI synthetic spectrum 
               
 CALLING SEQUENCE:

       IDL> make_chianti_spec, TRANSITIONS,  LAMBDA, SPECTRUM,$ 
                    [BIN_SIZE= ,  ,INSTR_FWHM= , PIXEL=PIXEL, BINSIZE = BINSIZE, $
                    WRANGE= , ALL=ALL, continuum=continuum, $
                    ABUND_NAME= , MIN_ABUND=, photons=photons, effarea=effarea


 PROCEDURE : 
 		
     From information contained in the structure TRANSITIONS, constructs 
     a synthetic spectrum

     By default, routine assumes thermal widths for lines.

   PROGRAMMING NOTES

     The line profile is constructed using the IDL gaussint routine. 
     For a wavelength pixel centred at l and with width dl, gaussint 
     is used to integrate the Gaussian up to l-dl/2 and up to l+dl/2. 
     The difference between the two is the intensity in this pixel.


    
 INPUTS      : 
		
               TRANSITIONS, the structure created by ch_synthetic.pro.
               
 OPT. INPUTS : 

     LAMBDA   Array of wavelengths (X-values). If not defined as input, it is
              calculated on the basis of BIN_SIZE, and returned as an output. 
              If defined as input, the routine checks that there are at least
              10 points in the wavelength range defined by WRANGE. If there
              are, the corresponding subset of LAMBDA is returned, otherwise
              the routine exits with an error.

     BIN_SIZE      Bin size  in Angstroms of the spectrum to be created. A linear
              spectrum is assumed. In case an effective area file is used, the
              wavelenghts in the file (that might not be linear) are used to
              create the spectrum, and this bin size looses any meaning.

     WRANGE   Allows a subset of the wavelength range to be turned into 
              a spectrum. When using syn_plot, this speeds up the routine 
              a lot if you've elected to zoom in on a region.

     INSTR_FWHM Instrumental FWHM (Angstroms). 
                In case an effective area file is used, The line intensities
                contributing to each bin are summed, and subsequently convolved
                with a gaussian of full-width-half-maximum FWHM if FWHM is not
                set = 0 . Please make sure that the FWHM value (if not set to
                zero) is larger than  the bin size. 

     ABUND_NAME  A CHIANTI abundance file name can be set. 
                It allows the abundance file given in transitions.abund_name
                (if present)   to be over-ridden. Note that it also used for
                the continuum calculation.

     MIN_ABUND: If set, calculates line intensities only from those elements
                  which  have an abundance greater than min_abund. 
                  Can speed up the calculations. For example, from Allen
                  (1973):

                   abundance (H)  = 1.
                   abundance (He) = 0.085
                   abundance (C)  = 3.3e-4
                   abundance (O)  = 6.6e-4
                   abundance (Si) = 3.3e-5
                   abundance (Fe) = 3.9e-5

     FILE_EFFAREA
                   The Effective Area File (TWO COLUMNS - wavelengths in
                   Angstroms and cm^2 values) If defined, then the spectrum is
                   multiplied with these values.  Any input  LAMBDA value is
                   over-written by the wavelenghts in the file (that might not
                   be linear) and  are used to create the spectrum.
		    Note that this option only works well if a sufficient number
		    of bins is given. The line intensities contributing to each
		    bin are summed, and  subsequently convolved with a gaussian
		    of full-width-half-maximum FWHM, if FWHM is not set = 0.
                   Please note that the convolution might not work if a small
                   number of  bins is defined. 

               
 OUTPUTS     : 
		
		LAMBDA  Array of wavelengths (X-values).
              If not defined as input, it is
              calculated on the basis of BIN_SIZE, and returned as an output. 
              If defined as input, the routine checks that there are at least
              10 points in the wavelength range defined by WRANGE. If there
              are, the corresponding subset of LAMBDA is returned, otherwise
              the routine exits with an error.


               SPECTRUM  A structure containing all the information:

                     LAMBDA      The array of X-values
                     SPECTRUM    The array of Y-values
                     UNITS       The units of LAMBDA, SPECTRUM
                     INSTR_FWHM  The Instrumental FWHM
                     BIN_SIZE    Width of the Bins  (fixed) in angstroms
                     ABUND_NAME  The CHIANTI abundance file name             
                     ABUND       The abundance values
                     MIN_ABUND   The minimum abundance value used                 
                     ABUND_REF   The references
                     CONTINUUM   The values of the continuum (if calculated)
                     
                     FILE_EFFAREA The Effective Area File used (optional)
                     EFFAREA       The array of effective area values
                                 (optional - same size of LAMBDA)

                    .LINES      An array of structures, for all the lines used               
                                to calculate the SPECTRUM. 
                                The tags are the same as those created by 
                                CH_SYNTHETIC, plus
                       .PEAK    The peak intensity of the line in the spectrum
                                (approx. value) 
	
 OPT. OUTPUTS:
		
     BINSIZE  If BIN_SIZE  is not  specified, then the spectrum 
              bin-sizes are computed automatically, and the size of the 
              bin returned in BINSIZE.


 KEYWORDS    : 

     PIXEL    The spectrum is given in /pixel units rather /ang
        (DISABLED)
      
     ALL      Add  lines that originally had negative wavelengths  
               
     PHOTONS  If set=1, the output intensities will be in photons instead of 
                  ergs.

     CONTINUUM
              If set, then the  continuum is added to the 
              spectrum.

     verbose 

 CALLS       : 
		
		PRY:     	GET_ATOMIC_WEIGHTS
		Chianti: FREEBOUND, FREEFREE
		
 COMMON       (with freefree freebound and two_photon):
 		
		elements,abund,abund_ref,ioneq,ioneq_logt,ioneq_ref

 RESTRICTIONS: The input structure has to be of the type created by ch_synthetic.
               The LAMBDA, EFFAREA values must be ordered in wavelength and the
               LAMBDA values must be in Angstroms.
               
 SIDE EFFECTS: None known yet.
               

 EXAMPLES    : 
		
		make_chianti_spec, output_struct,  LAMBDA, SPECTRUM,$
		 bin_size=0.01, instr=0.1 

 CATEGORY    : 
               spectral synthesis.

 PREV. HIST. :

      
 WRITTEN     : 
           Peter Young , CfA, pyoung@cfa.harvard.edu  1-Sept-2000

 MODIFICATION HISTORY:  
 
               Version 1, PRY 1-Sept-2000

               Version 2, Giulio Del Zanna (GDZ)  10-Oct-2000

               put ALL keyword, removed the FWHM obsolete and
               confusing call. Reorganised various minor things.

               Version 3, PRY 19-Oct-2000
                 Corrected the way continuum is treated for an isothermal 
                 spectrum.

               V. 4, 2-Nov-2001 GDZ. Now MIN_ABUND is effective not only in the
               continuum calculation but also in the line spectrum.
               Modified for the use of logt_isothermal

               V.5, GDZ, added EFFAREA keyword: an ascii file with lambdas and
                                              effective areas can be read
                                              in. The line intensities are
                                              calculated in a different way.
                        Also, changed the output.

               V.6, GDZ, 28-Apr-02 redefined completely the OUTPUT structure. 
                    Major revision (added two_photon verbose).

               V.7, GDZ, 3-May-2002
                    fixed  a bug, when negative angpix values occur.
                     
               V.8, GDZ, 22 May 2002,  changed some tags of the output, and
                    added min_abund in the continuum call.

               V.9, GDZ, 30-May-02 replaced fix() with round() 

               V. 10, 15-July-2002 , GDZ 
                    changed the location of Effective area files.

               V.11 14-Aug-02, GDZ 
                    speeded up the routine, by changing the way the PEAK tag is
                    added to the structure. The drawback is that only the
                    'standard v.4 tags' are allowed, and future additions will
                    have to be dealt properly.
  
               v.12 2-Dec-2002, GDZ. 
                   Fixed a bug:  Removed the plotting of the window with the effective areas.

               v.13 26-Apr-2005, Enrico Landi (EL)
                   Fixed a minor bug: if the lines were more than 32768 (2^15), the main
                                loop crashed.

               v.14 22-Jul-2005 GDZ 
                 -fixed a bug. When the routine was run once without
                 defining the lambdas, and then with the lambdas
                 defined (the units were switched to photons)
                 -fixed a bug. When the effective areas were used,
                 all lines were used to create the spectrum.
                 -added hard-wired switch to photons when using
                 effective area files.

                 -added the keV option

                 -now can output a spectrum only with the continuum
                 (i.e. even if no emission lines are present). 

               15, 2-Aug-2005, GDZ 
                 Added a check on the input structure. If it was
                 calculated with ch_synthetic and the keyword
                 /no_sum_int, it cannot be used here.

 VERSION     :  15, 2-Aug-2005

 STILL TO DO: 

              -speed up the routine with the use of arrays.
              -add the option to select only a list of ions, also in the
               continuum procedures.
              -Allow the use of user-defined line profiles.
              -Enable PIXEL keyword


ASCII_WVL_DEM

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	ASCII_WVL_DEM

 PURPOSE:

	create an ascii file of predicted spectral line intensities and
       wavelengths corresponding to a selected abundance and differential
       emission measure (DEM).  


 PROCEDURE:

                 Calculations are done assuming either constant density or
                 constant pressure. See CH_SYNTHETIC for details.


 CALLING SEQUENCE:

       ASCII_WVL_DEM, Wmin, Wmax, Pressure= , [density= ], $ 
              [outfile= , mini= , sngl_ion=, /photons, /all, /masterlist], $
              [/noprot, radtemp=, rphot=]


 INPUTS:

	Wmin:   lower limit of the wavelength range of interest (Angstroms)	
               if kev keyword set, then wmin is in kev	
	Wmax:   upper limit of the wavelength range of interest (Angstroms)
               if kev keyword set, then wmax is in kev	

       Pressure:  pressure in emitting region (cm^-3 K), or 
       Density:   density in emitting region (cm^-3).


 OPTIONAL INPUTS:

       OUTFILE: the name of the output ascii file to be written.
	
	MINI:	Minimum intensity for a line to be included in the output.

	SNGL_ION:  specifies  a single ion (e.g. SNGL_ION='Fe_10' to include
                 only Fe X lines) or an array (e.g. SNGL_ION=['Fe_10','Fe_11']
                 to include only Fe X and Fe XI lines) of ions to be used
                 instead of the complete set of ions specified in
                 !xuvtop/masterlist/masterlist.ions 

       MASTERLIST: string of a specific masterlist file (full path). 
                   If defined as a keyword (i.e. MASTERLIST=1 or /MASTERLIST)
                   then a widget allows the user to select a  user-defined
                   masterlist file. Shortcut for SNGL_ION.   


 OUTPUTS:

	an ascii file:   linelist.txt  in the working directory by default

 OPTIONAL OUTPUTS:


 KEYWORD PARAMETERS:

	MINI:	Minimum intensity for a line to be included in the output

	SNGL_ION:  specifies  a single ion (e.g. SNGL_ION='Fe_10' to include
                 only Fe X lines) or an array (e.g. SNGL_ION=['Fe_10','Fe_11']
                 to include only Fe X and Fe XI lines) of ions to be used
                 instead of the complete set of ions specified in
                 !xuvtop/masterlist/masterlist.ions 

       MASTERLIST: string of a specific masterlist file (full path). 
                   If defined as a keyword (i.e. MASTERLIST=1 or /MASTERLIST)
                   then a widget allows the user to select a  user-defined
                   masterlist file. Shortcut for SNGL_ION.   


       PHOTONS:  units will be in photons rather than ergs

       KEV:  wavelengths will be given in kev rather than Angstroms

       ALL:  if set, then all lines are included.  This means that lines 
             for which
             only an approximate wavelength is known (only theoretical energy
             levels are known) are included.


       OUTFILE:  the name of the output ascii file to be written. By 
                default a
                file 'linelist.txt' in the user's working  directory will be
                created. 

       NOPROT  If set, then the default setting will be NOT to use 
               proton rates. This can be changed within the routine.

	RADTEMP	Specify background radiation temperature (default: 6000 K)

	RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

 CALLS:
       
       CH_SYNTHETIC, CH_LINE_LIST


 COMMON BLOCKS: None

 RESTRICTIONS:

 SIDE EFFECTS:


 EXAMPLE:

            IDL> ascii_wvl_dem,400.,800., out='linelist',$ 
               pressure=1.e+15,mini=1.,sngl_ion='o_4'

 CATEGORY:

	spectral synthesis.

 WRITTEN     : 

       Version 1, 8-Nov-01, Giulio Del Zanna (GDZ). 

       Compared to the previous ASCII_WVL_DEM, these are the main changes:

       1-Rewritten as a wrapper routine using the new procedures.
       2-Now the PRESSURE value is a keyword.
       3-The calculations can be done at constant DENSITY.
       4-Energies (keV) can be output instead of wavelengths in Angstroms    
       5-MASTERLIST can now be used both as an input string or as a keyword.

 MODIFICATION HISTORY:

      18-Nov-01, Peter Young
         Added /noprot, rphot and radtemp keywords
       V. 2, 22-May-2002 GDZ.  Removed const_net definitions.

 VERSION     : 2, 22-May-2002



LATEX_WVL_DEM

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	LATEX_WVL_DEM

 PURPOSE:

	create a latex file of predicted spectral line intensities and
       wavelengths corresponding to a selected abundance and differential
       emission measure (DEM)


 PROCEDURE:

                 Calculations are done assuming either constant density or
                 constant pressure. See CH_SYNTHETIC for details.


 CALLING SEQUENCE:

       LATEX_WVL_DEM, Wmin, Wmax, Pressure= , [density= ], $ 
              [outfile= , mini= , sngl_ion=, /photons, /all, /masterlist]


 INPUTS:

	Wmin:   lower limit of the wavelength/energy range of interest (Angstroms)
               if kev keyword set, then wmin is in kev	

	Wmax:   upper limit of the wavelength/energy range of interest (Angstroms)
               if kev keyword set, then wmax is in kev	

       Pressure:  pressure in emitting region (cm^-3 K), or 
       Density:   density in emitting region (cm^-3).


 OPTIONAL INPUTS:


       OUTFILE: the name of the output latex file to be written.
	
	MINI:	Minimum intensity for a line to be included in the output.

	SNGL_ION:  specifies  a single ion (e.g. SNGL_ION='Fe_10' to include
                 only Fe X lines) or an array (e.g. SNGL_ION=['Fe_10','Fe_11']
                 to include only Fe X and Fe XI lines) of ions to be used
                 instead of the complete set of ions specified in
                 !xuvtop/masterlist/masterlist.ions 

       MASTERLIST: string of a specific masterlist file (full path). 
                   If defined as a keyword (i.e. MASTERLIST=1 or /MASTERLIST)
                   then a widget allows the user to select a  user-defined
                   masterlist file. Shortcut for SNGL_ION.   

       RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

       RADTEMP The blackbody radiation field temperature (default 6000 K).
 

 OUTPUTS:

	a latex file:   'linelist.tex'  in the working directory by default


 OPTIONAL OUTPUTS:

	
 KEYWORD PARAMETERS:

	MINI:	Minimum intensity for a line to be included in the output

	SNGL_ION:  specifies  a single ion (e.g. SNGL_ION='Fe_10' to include
                 only Fe X lines) or an array (e.g. SNGL_ION=['Fe_10','Fe_11']
                 to include only Fe X and Fe XI lines) of ions to be used
                 instead of the complete set of ions specified in
                 !xuvtop/masterlist/masterlist.ions 

       MASTERLIST: string of a specific masterlist file (full path). 
                   If defined as a keyword (i.e. MASTERLIST=1 or /MASTERLIST)
                   then a widget allows the user to select a  user-defined
                   masterlist file. Shortcut for SNGL_ION.   


       PHOTONS:  units will be in photons rather than ergs

       KEV:  wavelengths will be given in kev rather than Angstroms

       ALL:  if set, then all lines are included.  This means that lines for which
             only an approximate wavelength is known (only theoretical energy
             levels are known) are included.


       OUTFILE:  the name of the output latex file to be written. By default a
                file 'linelist.tex' in the user's working  directory will be
                created. 

       NOPROT   If set, then proton rates are not included.


 CALLS:
       
       CH_SYNTHETIC, CH_LINE_LIST


 COMMON BLOCKS: None

 RESTRICTIONS:

 SIDE EFFECTS:


 EXAMPLE:

             > latex_wvl_dem, 400.,800., mini=1, pressure=1.e+15,sngl_ion='o_4'


 CATEGORY:

	spectral synthesis.

 WRITTEN     : 

       Version 1, 8-Nov-01, Giulio Del Zanna (GDZ). 

       Compared to the previous LATEX_WVL_DEM, these are the main changes:

       1-Rewritten as a wrapper routine using the new procedures.
       2-Now the PRESSURE value is a keyword.
       3-The calculations can be done at constant DENSITY.
       4-MASTERLIST can now be used both as an input string or as a keyword.


 MODIFICATION HISTORY:

       Version 2, 18-Nov-01, Peter Young
           Added /noprot, rphot and radtemp keywords.

       V. 3, 22-May-2002 GDZ.  Removed const_net definitions.
             
 VERSION     : Version 3, 22-May-2002


CH_LINE_LIST

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 



 NAME:
	CH_LINE_LIST

 PURPOSE:

	Create a latex or an ascii file of predicted spectral line intensities and
       wavelengths corresponding to  selected parameters, as calculated by 
       CH_SYNTHETIC. Needs as input the line intensity structure calculated by
       CH_SYNTHETIC (default)  or the SPECTRUM structure output of
       MAKE_CHIANTI_SPEC.

 CALLING SEQUENCE:

       IDL> ch_line_list, transitions, outname, latex=latex, ascii=ascii, $
       abundfile=abundfile, min_abund=min_abund, $
       wmin=wmin,wmax=wmax,$
       SPECTRUM=SPECTRUM, minI=minI,photons=photons,kev=kev, $
       all=all,no_sort=no_sort, sngl_ion=sngl_ion


 PROCEDURE:


 INPUTS:

       The structure created by CH_SYNTHETIC

 OPTIONAL INPUTS:

	Wmin:   lower limit of the wavelength/energy range of interest (Angstroms)
               if kev keyword set, then wmin is in kev	
	Wmax:   upper limit of the wavelength/energy range of interest (Angstroms)
               if kev keyword set, then wmax is in kev	

       Mini:   Minimum intensity for line to be included in output
	
	SNGL_ION:  specifies a single ion (or a list of ions) to be used instead
                 of the complete set of ions specified in the structure.


       MIN_ABUND:  If set, outputs  only  those elements which 
                   have an abundance greater than min_abund.  

                   For example, from Allen (1973):
                   abundance (H)  = 1.
                   abundance (He) = 0.085
                   abundance (C)  = 3.3e-4
                   abundance (O)  = 6.6e-4
                   abundance (Si) = 3.3e-5
                   abundance (Fe) = 3.9e-5


 KEYWORD PARAMETERS:

       LATEX:  Create a latex file (default, exclusive with /ASCII)

       ASCII:  Create an ascii file (exclusive with /LATEX)

	MINI:	Minimum intensity for line to be included in output

       PHOTONS:  units will be in photons rather than ergs

       KEV:  wavelengths will be given in kev rather than Angstroms

       ALL:  if set, then all lines are included.  This means that lines for which
             only an approximate wavelength is known, denoted by a negative 
             wavelength value in the .wgfa file, are included.
             These lines are listed in the file with a * preceding the wavelength.

       NO_SORT:
             If set, then the lines are *not* sorted in wavelength (or energy).

       SPECTRUM

             If set, IT IS ASSUMED that the input structure is the SPECTRUM
             structure output of MAKE_CHIANTI_SPEC, where the  line
             intensities have already been multiplied by the abundance factor!!


 OUTPUTS:

	A latex (default) or an ascii file with the line list

 CALLS: Many SolarSoft routines.


 COMMON BLOCKS:
        none.

 SIDE EFFECTS:


 EXAMPLE:

             > ch_line_list, trans,'linelist.tex',/latex, wmin=100.,wmax=200.,/all


 CATEGORY:

	spectral synthesis.


 WRITTEN     : 
       Version 1, Written by: Giulio Del Zanna (GDZ) Oct 31 2001.

 MODIFICATION HISTORY:

        V.2, 9-Nov-2001 GDZ. 
                 Now correctly handles the case when no
                 abundances are passed to the routine. 

        v.3, 11-Dec-2001, PRY.
                 Removed calls to get_utc and anytim2cal. Replaced with 
                 call to systime()
 
        v.4, 29-Apr-02, GDZ

                 Fixed a few small bugs, some caused by a change in the
                 database file format for V4. 
                 Added only_mini,  file_effarea keywords to be able to use as
                 input the structure created by MAKE_CHIANTI_SPEC.

        V.5, 22-May-2002, GDZ
                 generalized directory concatenation to work for
                 Unix, Windows  and VMS. changed tags.
                 Changed and added various things, including flabel

        V.6, 12-Aug-02, GDZ
           Modified the output labeling, and fixed two bugs: 1) when /all was used
           the keyword /mini was not working. 2) min_abund was not working
           properly when /spectrum was used.  Reduced size of latex output (was
           12pt)
           Changed output in isothermal case (no Tmax given). Better info printed (GDZ)

        V.7, 3-Nov-03  GDZ
           Modified format e8.2 to e9.2 for Windows compatibility.

        v.8, 18-Jul-2005 GDZ
           Modified the use of the /kev keyword. Also, now the
           routine accepts input structure with the units in keV. 

        v.9, 4-Aug-2005 GDZ
           Corrected a bug introduced in the previous version.
           Also switched to \documentclass when making the latex file.


 VERSION     : 9, 4-Aug-2005


EMISS_CALC

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 

 NAME: EMISS_CALC()
       
 PURPOSE:

       To compute the emissivities of all lines of a specified ion over
	given ranges of temperature and density.

 CATEGORY:

       Scientific analysis

 EXPLANATION:

 	This routine calculates:

		hc
       	--  * N_j  * A_ji
      	       lamb

 	where hc = 1.986 * 10^-8 erg AA, lamb is in angstroms, N_j is the 
	fraction of ions in the upper emitting level j, and A_ji is the 
	radiative decay rate for the transition.

	The emissivities are stored in a structure called EMISS that also
	holds the wavelength of the transition, the level numbers i and j 
	and also a 'flag', which is set to -1 if the wavelength is negative.

	The temperature and density ranges can be specified directly using
	the TEMP and DENS keywords. Setting TMAX to the log T_max of the 
	ion, gives emissivities for 3 temperatures: log T_max +- 0.15. 
	If DENS is not set, then it is set to 8 to 12 in 0.5 dex intervals. 
	STDENS allows the start density (of 8) to be changed to some other 
	value; ND allows the number of densities to be varied (default 9); 
	DINT allows the density interval to be varied (default 0.5).

 CALLING SEQUENCE:

       EMISS=EMISS_CALC (IZ, ION, [ TEMP=TEMP, DENS=DENS, RADT=RADT, $
				DIL=DIL, PATH=PATH, /NO_DE, /PROTON, $
				QUIET, PRESSURE=PRESSURE)

 EXAMPLES:

	EMISS=EMISS_CALC(26,13)
	EMISS=EMISS_CALC(26,13,temp=[6.2],dens=findgen(5)+8)
	EMISS=EMISS_CALC(26,13,temp=findgen(11)/100.+5.5,press=10.^15)

 INPUTS:

	IZ	The atomic number of the ion

	ION	The spectroscopic number of the ion (e.g., 12 = XII)

 OPTIONAL INPUTS:

	TEMP	Direct specification of the temperature range (log T)

	DENS	Direct specification of the density range (log Ne)

	RADTEMP	Specify background radiation temperature (default: 6000 K)

	RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

	PATH	If specified, the routine will look for the atomic data in 
		the PATH directory, rather than in the CHIANTI database

	PRESSURE	If a temperature array is given, and PRESSURE set, 
			then the emissivities will be evaluated at the 
			specified temperatures, but for densities = 
			pressure/temperature. If DENS is set, then it will 
			be ignored. The pressure is assumed to be in units 
			K * cm^-3.

       ABUND_FILE  The name of a CHIANTI abundance file. This is used for 
               calculating the proton to electron ratio. Default is 
               !abund_file.

       IONEQ_FILE  The name of a CHIANTI ion balance file. This is used for 
               calculating the proton to electron ratio and evaluating 
               the T_max of the ion. Default is !ioneq_file.

       SUM_MWL_COEFFS  An array of coefficients of the same length as 
                       the array of temperatures. Electron and proton rate 
                       coefficients will be calculated at each temperature 
                       and then a weighted sum of the coefficients is 
                       performed using SUM_MWL_COEFFS. This allows 
                       non-Maxwellian energy distributions to be 
                       incorporated into the level balance equations.
                       This keyword is not compatible with the PRESSURE
                       keyword.

       RADFUNC         The name of a user-defined function that will generate
                       a radiation spectrum as a function of temperature. 
                       This radiation field will replace the black-body that
                       is assumed when using the RADTEMP keyword in the call
                       to pop_solver.

 KEYWORDS:

	NO_DE	Drops the hc/lambda factor in the computation of the 
		emissivities. Useful for emission measure analyses involving 
		photon fluxes

       NOPROT  If set, then the default setting will be NOT to use 
               proton rates. This can be changed within the routine.

	QUIET	If set, don't list the temperatures and densities at which 
		the emissivities are caculated.

       DIEL   If the dielectronic recombination files exist for the ion, 
               then these are used to derive the emissivities.

       NO_SETUP  If emiss_calc is called from a routine where the ELEMENTS
                 common block has already been set up, then this keyword
                 stops emiss_calc loading up the common block

 OUTPUT:

	The structure that is output has the following tags:

	.ion_name	string; contains ion name, e.g., 'Fe XIII'
	.lambda		float; contains wavelength
	.level1		integer; contains lower level of transition
       .lvl1_desc      string; gives config. and term of lower level
	.level2		integer; contains upper level of transition
       .lvl2_desc      string; gives config. and term of upper level
	.flag		integer; a flag to mark particular transitions
	.em		fltarr(nt,nd); contains emissivities at particular 
			  temperatures and densities.

 PROGRAMMING NOTES:

	Transitions where only theoretical energies are available for at 
	least one of the two levels are assigned negative wavelengths in 
	the .wgfa file. With emiss_calc, the wavelength is set to be 
	positive, but emiss.flag is set to -1 for that transition, so 
	that other routines can keep track of the theoretical wavelengths.

 COMMON BLOCKS:

	ELVLC, WGFA, UPSILON, RADIATIVE, PROTON, ELEMENTS, IONREC

 CALLS:

	SETUP_ION, POP_SOLVER
       ZION2FILENAME, ZION2SPECTROSCOPIC
	READ_PROT, PROTON_DENS

 HISTORY:

	Ver 1, PRY 28-Jun-97
	Ver 2, PRY 26-Jul-97  - corrected problem with size of emiss
	Ver 3, PRY 22-Sep-97  - allowed photo-excitation to be included
	Ver 4, PRY 6-Jul-98   - added PATH
	Ver 5, PRY 5-Sep-98   - added call to choose_ioneq
       Ver 6, PRY 3-Dec-98   - dosen't crash if no params given
	Ver 7, PRY 9-Jan-99   - allowed proton rates to be added through 
				/PROTON keyword.
	Ver 8, PRY 10-Feb-99  - added /QUIET keyword
	Ver 9, PRY 8-Oct-99   - for H-like ions, there's a 2-photon 
				transition with a non-zero A-value that is 
				assigned a zero wavelength (as it does not 
				produce an emission line). This caused 
				problems for dens_plotter, so emiss_calc 
				now removes this transition from the emiss 
				structure.
	Ver 10, PRY 15-Dec-99 -	added deu to the upsilon common block in 
				order to be consistent with the main Chianti 
				routines.
	Ver 11, PRY 8-May-00  - added PRESSURE
       Ver 12, PRY 17-Aug-00 - changed elvlc common block to match new 
                               version of pop_solver
       Ver 13, PRY 10-Oct-00 - now calls setup_ion to read ion data
       Ver 14, PRY 1-Jun-00  - removed call to choose_ioneq; now makes use 
                               of the !ioneq_file system variable.
       Ver 15, PRY 25-Sep-01 - modified for 9-point splines and proton rates
       Ver 16, PRY 9-Dec-01  - completed changes for v.4

       V. 17, 29-May-2002, Giulio Del Zanna (GDZ) 
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 
                   Now we only call zion2filename, corrected the call to
                   zion2spectroscopic (dielectronic cases were not handled
                   correctly).

       V.18, 6-Aug-2002, Peter Young
                   Theoretical wavelengths weren't being flagged so this 
                   has now been corrected.

       V.19, 7-Aug-2002, Peter Young
                   Stopped "lines" with zero wavelength being included in 
                   the structure.
                   Changed the use of CHIANTI system variables.

       V.20 14-Aug-2002, GDZ 
                   Modified the use of Version, to make it compatible with the
                   other CHIANTI v.4 routines.

       V.21 10-Sep-2002, Peter Young
                   Allowed a density of 1 cm-3 to be input.

       V.22 7-Aug-2003, Peter Young
                   Added keyword /NO_SETUP

       V.23  4-Oct-2003, GDZ
                  modified the input to POP_SOLVER, now it is dealt with an
                  input structure.

       V.24  5-Mar-2004, Enrico Landi (EL)
                  included ionization and recombination as level population
                  processes

       V.25  6-May-2005, EL
                  corrected a minor incompatibility with IDL 5.6

       V.26  5-Jul-2005, Peter Young
                  added RADFUNC= and SUM_MWL_COEFFS= keywords

       V.27  1-Aug-2005, Peter Young
                  re-ordered code for setup to prevent crash

       V.28  3-Aug-2005,GDZ
                  fixed bug, only define ioneq_ionrec when files are
                  there (it was failing with neutrals)


 VERSION     :   28  3-Aug-2005


GOFNT

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	GOFNT

 PURPOSE:

	calculate G(n,T) function (line intensity per unit emission measure)
       
 PROCEDURE:

	Must specify line to form numerator and denominator
       Multiple lines can be selected and summed
       This can now be done interactively or not.

 CALLING SEQUENCE: 

	GOFNT,Ion,Wmin,Wmax,Temperature,G,Desc,density=


 INPUTS:

       Ion:   the CHIANTI style name of the ion, i.e., 'c_5' for C V

       Wmin:  minimum of wavelength wavelength range of interest in Angstroms

       Wmax:  maximum of wavelength wavelength range of interest

 OPTIONAL INPUTS:

       Many - see the keywords below.

 OUTPUTS:

	Temperature:  an array of temperatures 

       G:  Intensity  per unit emission measure N_e*N_H*dh [cm^-5].
           The resulting units are therefore erg cm^+3 s^-1 sr-1

           C(T)= 1/(4*!pi)* A_ji*(N_j(X^+m)/N(X^+m))*(N(X^+m)/N(X))*(N(X)/N(H))/N_e

            unless  /NOABUND is set, in which case 
           C(T)= 1/(4*!pi)* A_ji*(N_j(X^+m)/N(X^+m))*(N(X^+m)/N(X))/N_e

           G(T)=(hc/lambda_ij)*C(T) 
           G(T)= C(T)   if /PHOTONS is set

       Desc:  a short string description of the selected line


 OPTIONAL OUTPUTS:

	Postscript file withthe plot of G(T).

       Ascii file with the values of G(T). 
        
       VALUE      The array of G(T) values corresponding to logt0.


 KEYWORD PARAMETERS:


	PRESSURE:  specifies the pressure in units of NeT (cm^-3 K).  G is then
                  calculated at that constant pressure 
		
	DENSITY:  specifies the electron density in units of cm^-3.  G is then 
                 calculated at that value of the electron density.  If neither the 
                 density or pressure keywords are specified, a constant
                  density of 1.e+10 cm^-3 is assumed

       PHOTONS:  sets output in photons/s

       RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

       RADTEMP The blackbody radiation field temperature (default 6000 K).

       OUTFILE:  the (optional) name of the output ascii file where a 
                   listing of the line ratio intensity as a function of 
                   temperature is saved.

       PSFILE:  the (optional) name of the output postscript file 
                  where a plot of the chosen G(T) is saved.

       NOABUND: If set, the G(T)'s are not multiplied by the abundance 
                factor.

       NOPROT   If set, then proton rates are not included.


	ABUND_NAME:  Name of the abundance file to use.  If not passed, then
		     the user is prompted for it.

	IONEQ_NAME:  Name of the ionization equilization name to use.  If not
		     passed, then the user is prompted for it.

       ALL          If set, all lines are calculated, including
                    the 'unobserved' ones. 

       LOWER_LEVELS
       UPPER_LEVELS
                    Arrays with the indices of the lower and upper levels
                    pertaining to the transitions you want to get. 
                    If more than one couple is given, the G(T) of the 
                    lines are summed.
                    Obviously, the given indices must correspond to transitions
                    that are present in the database.

       ARCSECS  
                 If set, units are photons (ergs) cm^+3 s^-1 arcsecs^-2

       VERBOSE

       LOGT0       An array of log T values for which the G(T) are wanted.
       VALUE       The array of G(T) values corresponding to logt0.
 
                   If logt0 is defined, and within the limits of the 
                   temperatures for which G(T) NE 0, the array VALUE
                   is returned with a simple spline interpolation.

 CALLS:

       CH_SYNTHETIC, CH_XMENU_SEL

 COMMON BLOCKS: None

 RESTRICTIONS:

 SIDE EFFECTS:

 EXAMPLE:

      IDL> gofnt,'o_5',1000.,1500.,temp,goft,desc,density=1.e+16


 CATEGORY:

	spectral diagnostics


 MODIFICATION HISTORY:

 	Written by:	Ken Dere
	October 4, 1996:     Version 1
       14-Jul-2000     Peter Young, now calls pop_solver

       26-Oct-2000 GDZ, added keyword NOABUND to not multiply for the abundence
       factor. Corrected header for a wrong description.

	Version 4, 21-Dec-2000, William Thompson, GSFC
		Modified for better cross-platform graphics capability

  
       Version 5, 8-Nov-01, Giulio Del Zanna (GDZ). 

       Rewritten as a wrapper routine using the new procedures.
           Corrected a few inconsistencies in the plots.

       Version 6, 18-Nov-01, Peter Young
           Added /noprot, rphot and radtemp keywords.

       Version 7, 11-Dec-01, Peter Young
           Changed call to ch_strpad to strpad.

       V. 8, GDZ, 28-Apr-02 Added abund_name,ioneq_name keywords.
       v. 9  21-May-2002, GDZ
             generalized directory concatenation to work for
             Unix, Windows  and VMS. 

       V.10, 15-Aug-02, GDZ 
              Major revision:
              -Removed the call to ch_xselect_s, that did not work for long lists.
              -Added a '*' in the line lists, to identify 'unobserved' lines.
              -Replaced the commands to create PS file, to make it
               cross-platform compatible.
              -Added a large number of cosmetics, mainly lables to the axes and
               titles.
              -Added keyword ALL. If set, all lines are calculated, including
              the 'unobserved' ones. 
              -Added the CHIANTI version number in the outputs.

       V. 11, 19-Sep-02, GDZ
              Clarified output units.

       V.12, 25-Jun-03, GDZ, 
              Added many new keywords. Now is possible to use the routine 
              with background jobs, in not-interactive mode.
              Rounded the wavelengths. 

       V.13, 24-Sept-2003, GDZ 
              Corrected a bug when logt0 is not defined.

       V.14, 3-Nov-03  GDZ
             Modified format e8.2 to e9.2 for Windows compatibility.

 VERSION     :   14, 3-Nov-03 


G_OF_T

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME: G_OF_T()
       
 PURPOSE:

	To compute DE * F(T) * n_j * A_ji / N_e for selected emission lines. 
	Option to also multiply by abundance.

 CATEGORY:

       Atomic data analysis

 EXPLANATION:

	The G-of-T function has a number of different definitions in the 
	literature. In the most basic form it contains only the temperature 
	dependent parts (i.e., 0.83*n_j*A_ji*F(T)/N_e), but often a Delta-E 
	and Ab(X) are added as well. Here, the _default_ form is:

	Delta-E * 0.83 * n_j * A_ji * F(T) / N_e

	By using the NO_DE keyword, the Delta-E can be omitted, while the 
	ABUND keyword allows the abundance to be added.

	The function that is output is tabulated over 4.0 <= logT <= 8.0 
	in 0.1 dex intervals. If you want the function tabulated over 
	smaller intervals, run the ION_INTERP routine afterwards.

 CALLING SEQUENCE:


 EXAMPLES:

	RESULT=G_OF_T(26,13)

	RESULT=G_OF_T(26,13,DENS=7)

	RESULT=G_OF_T(26,13,GOFTFILE='my_gofts.dat')

       RESULT=G_OF_T(26,13,/ABUND)

       RESULT=G_OF_T(26,13,ABUND_FILE=ABUND_FILE, IONEQ_FILE=IONEQ_FILE)

 INPUTS:

	IZ:	The atomic number of the ion (e.g., 26 = Fe)

	ION:	The spectroscopic number of the ion (e.g., 12 = XII)

 OPTIONAL INPUTS:

	DENS:	The logarithm (to base 10) of the density at which the 
		emissivities are calculated (default=10.)

	WRANGE: Wavelength range from which lines are required. If not 
		specified, then the 10 strongest lines are displayed.

	PATH:	If specified, the routine will look for the atomic data in 
		the PATH directory, rather than in the CHIANTI database

	GOFTFILE:	By specifying GOFTFILE as a filename, the G-of-T 
			function can be stored in this file. It is stored 
		in the form a structure (called goft_list) with the following 
		labels:

	  goft_list.label: user-specified string, e.g., 'Si XII  520.7'
	  goft_list.func:	 fltarr(41), the G-of-T function

	If the same GOFTFILE is specified for another ion, then the 
	G-of-T function is added to the existing structure. The GOFTFILE 
	option only works when the ABUND keyword is set. The GOFTFILE is 
	meant to be read by another routine called GOFT_PLOTTER.

	INDEX:	Allows the direct specification of indices within the 
		emiss structure. This allows the g_of_t routine to be 
		run without the menu widget appearing. If the /quiet 
		keyword is also used, then the routine will run "silently".

	RADTEMP	Specify background radiation temperature (default: 6000 K)

	RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

       IONEQ_FILE  Directly specify the name of the ion balance file 
               (including directory path). If not set, then a widget will 
               pop up allowing you to select a file.

       ABUND_FILE  Directly specify the name of the abundance file 
               (including directory path). One can also use /ABUND_FILE 
               to include the abundances in the G(T) function, but allow 
               the abundance file to be picked through a widget.

 KEYWORDS:

       NOPROT  If set, then the default setting will be NOT to use 
               proton rates. This can be changed within the routine.

	NO_DE:	If set, then the output function will *not* contain the 
		Delta-E. Be careful using this if you are using blends 
		(as Delta-E is different for different wavelengths).

	QUIET	If set, then don't plot the G(T) function or print out 
               information to the screen.

 CALLS:

	EMISS_CALC, READ_IONEQ, READ_ABUND, EMISS_SELECT, CH_GET_FILE

 RESTRICTIONS:


 HISTORY:

	Ver.1, PRY 28-Jul-97.
	Ver.2, PRY 22-Jun-98, added CHOOSE keyword and removed RAY
	Ver.3, PRY 4-Aug-98, cosmetic changes following comments of Giulio 
			Del Zanna
	Ver.4, PRY 5-Sep-98, added call to choose_ioneq
	Ver.5, PRY 23-Sep-98, added GOFTFILE input
	Ver.6, PRY 3-Mar-99, now calls EMISS_SELECT
       Ver.7, PRY 6-Nov-00, removed the /CHOOSE keyword; also changed 
                       PICKFILE call to DIALOG_PICKFILE and removed call 
                       to the CHIANTI routine ADD\_SUBDIR
       Ver.8, PRY 18-Oct-01, adjusted for proton rates, and 
                       photoexcitation.
       Ver.9, PRY 9-Dec-01, completed modifications for v.4 of CHIANTI.

       V.  10, 21-May-2002, Giulio Del Zanna (GDZ) 
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS.
       Ver. 11, 9-Feb-2005, Peter Young
                   changed keyword_set(abund) to keyword_set(abund_file)

 VERSION     :   11, 9-Feb-2005


DENS_PLOTTER

[Previous Routine] [Next Routine] [List of Routines]
 PROJECT

       CHIANTI   http://wwwsolar.nrl.navy.mil/chianti.html

       CHIANTI is an atomic database package for the calculation of
       continuum and emission line spectra from astrophysical plasmas. It is a 
       collaborative project involving the Naval Research Laboratory
       (Washington DC, USA), the Arcetri Observatory (Firenze, Italy), and the
       Cambridge University (United Kingdom).

 NAME
        dens_plotter

 PURPOSE:
        A widget-based routine to allow the analysis of density sensitive
        ratios. **** See RATIO_PLOTTER for details. *****

 CALLING SEQUENCE:

       IDL>  dens_plotter,  name,$ 
                  EM, PATH=PATH, NOPROT=NOPROT, $
                  IONEQ_FILE=IONEQ_FILE, ABUND_FILE=ABUND_FILE


 INPUTS:
        The ion name (e.g. 'si_3' for Si III)

 OPTIONAL INPUTS : none

 OUTPUTS:

 OPTIONAL OUTPUTS:

	EM:	Save the displayed emissivities to structure EM.
               **** See RATIO_PLOTTER for details. *****

 KEYWORDS:


	PATH:	Data in the CHIANTI format that is not in the CHIANTI 
		database can be read by specifying the directory in which 
		it lies through PATH.

       ABUND_FILE  The name of a CHIANTI abundance file. This is used for 
               calculating the proton to electron ratio. Default is 
               !abund_file.

       IONEQ_FILE  The name of a CHIANTI ion balance file. This is used for 
               calculating the proton to electron ratio and evaluating 
               the T_max of the ion. Default is !ioneq_file.

       NOPROT  If set, then the default setting will be NOT to use 
               proton rates. This can be changed within the routine.


 CALLS:   CONVERTNAME RATIO_PLOTTER
      

 COMMON BLOCKS: none


 RESTRICTIONS:

 SIDE EFFECTS:

 CATEGORY:
	spectral synthesis.
	
 EXAMPLE:
             IDL> dens_plotter, 'si_9'


 WRITTEN     : 
              Ver.1, 18-Apr-2002, Giulio Del Zanna (GDZ) written as a wrapper
              routine to call RATIO_PLOTTER.

             
 MODIFIED:   V.2,  2-Aug-2005, GDZ
              Now the routine handles the dielectronic case


 VERSION     :   2,  2-Aug-2005


DENSITY_RATIOS

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	DENSITY_RATIOS

 PURPOSE:

	to calculate line intensity ratios as a function of electron density

 CATEGORY:

	scientific analysis

 CALLING SEQUENCE:

       DENSITY_RATIOS,Ion,Wmin,Wmax,Dmin,Dmax,Density,Ratio,Description


 INPUTS:

       Ion:   the CHIANTI style name of the ion, i.e., 'c_5' for C V
	wmin:  minimum of the wavelength range of interest in Angstroms
	wmax:  maximum of the wavelength range of interest in Angstroms
       dmin:  log10 of the minimum desired density (8. = 10^8 cm^(-3) )
       dmax:  log10 of the maximum desired density range

 INTERACTIVE INPUTS:

	Must select the line for the numerator and denominator 
       It is possible to select multiple lines to be summed
	
 KEYWORD PARAMETERS:

        OUTFILE:  the (optional) name of the output ascii file where a 
                   listing of the line ratio intensity as a function of 
                   density is saved.  For example, outfile='den_rat.lis'

        PSFILE:  the (optional) name of the output postscript file 
                  where a plot of the choses density sensitive line
                  ratio is saved.  For example, psfile='den_rat.ps'

        TEMP:   to specify the temperature, otherwise the temperature at 
                  the peak 
                  of the ionization equilibrium is used.  For example, 
                  temp=1.e+6

        /PHOTONS:  if set, the ratio will be in photon units, as opposed 
                   to ergs    

	RADTEMP	Specify background radiation temperature (default: 6000 K)

	RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

       NOPROT  If set, then the default setting will be NOT to use 
               proton rates. This can be changed within the routine.

       VERBOSE To print out information about the lines.

 OUTPUTS:

	Density:  an array of the density values for which the selected 
                   intensity ratio calculated 
       Ratio:    an array of line intensity ratios
       Description:  a string describing the transitions selected

       Plots the intensity ratio of the selected line as a function of density


 COMMON BLOCKS:

       None.

 CALLS

       EMISS_CALC, ION2SPECTROSCOPIC, CONVERTNAME, READ_IONEQ,
       CH_XMENU_SEL

 EXAMPLE:

       density_ratios,'o_5',1000.,1500.,8.,13.,den,rat,desc 

       choose the ratio of 1371.294 to 1218.393 

 MODIFICATION HISTORY:
 	Written by:	Ken Dere
	March 1996:     Version 2.0
       May 28, 1996:  Ken Dere added psfile keyword/option
       Sept 1996:     modified to work with VMS
                      and added keyword TEMP, Ken Dere
       Feb. 2000:     Modified for Version 3, K. Dere
       14-Jul-2000    Peter Young, now calls pop_solver
       26-Sep-2001    Modified for 9-point splines and proton rates; 
                      added radtemp and rphot keywords for photoexcitation.
       20-Nov-2001    Routine now calls emiss_calc to get emissivities.

       V.9, 21-May-2002, Giulio Del Zanna (GDZ) 
                      generalized directory concatenation to work for
                               Unix, Windows  and VMS.
       V.10, 1-Aug-02 GDZ
          Changed all the formats.

       V.11, 06-Aug-02 GDZ
              Changed the use of CHIANTI system variables. 

       V.12, 15-Aug-02, GDZ 
              Major revision:
              -Added the keyword VERBOSE, to avoid printing out long lists of lines.
              -Removed the call to ch_xselect_s, that did not work for long lists.
              -Added a '*' in the line lists, to identify 'unobserved' lines.
              -Replaced the commands to create PS file, to make it
               cross-platform compatible.
              -Added a large number of cosmetics, mainly lables to the axes and
               titles, that were missing.
              -Removed plotting in windows already present.
              -Added the CHIANTI version number in the outputs.

        V.13, 3-Nov-03  GDZ
           Modified format e8.2 to e9.2 for Windows compatibility.

 VERSION     :   13, 3-Nov-03


CHIANTI_NE

[Previous Routine] [Next Routine] [List of Routines]
 Project     : SOHO - CDS     
                   
 Name        : CHIANTI_NE
               
 Purpose     : Calculate and plot CHIANTI density sensitive line ratios.
               
 Explanation : CHIANTI_NE (density ratios)
               calculates and plots density sensitive line ratios based on 
               the CHIANTI atomic database of Dere et. al.
               
 Use         : IDL> chianti_ne
    
 Inputs      : None
               
 Opt. Inputs : None
               
 Outputs     : None
               
 Opt. Outputs: None.
               
 Keywords    : None

 Calls       : CALC_DMM_DR, plot_dmm_dr_fig , make_ion_list

 Common      : dmm_dr_com  dmm_lines(with plot_dmm_dr_fig), 
               
 Restrictions: None
               
 Side effects: None
               
 Category    : Spectral
               
 Prev. Hist. : Started life as 'density_ratios' by Ken Dere

 Written     : C D Pike, RAL, 13-Jan-96
               
 Modified    : Added selection of els/ions from master file.  CDP, 21-Jan-96
               Added hardcopy of line list, refs etc.          CDP, 22-Jan-96
               Include multiple lines in ratio.                 CDP, 27-Jan-96
               General upgrade and added temp/unit selections.   CDP,  6-Jun-97
               Added intensity ratio selection.                 CDP, 17-Jul-97
               Added wavelength ranges.                        CDP, 18-Jul-97
               Fixed typos introduced in version 7.           CDP, 22-Jul-97
               Float the user-supplied Log Temperature.      CDP, 1-Aug-97
               Update for IDL v5.2.                         CDP, 20-Apr-99
               v. 11 Update list of elements.                    CDP, 18-Jun-99

               V.12. Added ratio plots and hardcopies in linear scale, added various
               checks and  minor things. Added a few tags to the 
               ratio output structure (temperature, units, comment). 
               Removed optional output structure. 
               Updated to be CHIANTI v.3-compatible.
               Giulio Del Zanna, DAMTP, 7-Oct-2000 
		Version 13, 21-Dec-2000, William Thompson, GSFC
			Modified for better cross-platform graphics capability

               V. 14, 1-May-02, GDZ, commented out a few refs.
               V. 15,  21-May-2002, GDZ, changed the way to deal with fonts.
               V.16, 17-Sep-2002 (GDZ) 
                    added !p.multi = 0 upon exit and added X-label.


 Version     : Version 16, 17-Sep-2002 


PLOT_CHIANTI_NE

[Previous Routine] [Next Routine] [List of Routines]
 Project     : SOHO - CDS     
                   
 Name        : PLOT_CHIANTI_NE
               
 Purpose     : Plots a density sensitive ration saved from CHIANTI_NE
               
 Explanation : The routine CHIANTI_NE allows the calculated ratio to be
               saved in an IDL save file.  This routine retrieves and
               plots the ratio.
               
 Use         : IDL> plot_chianti_ne, file, data
    
 Inputs      : file - save file name (an extension of .CH_NE will have
                                      been added, specifying this is optional)
               
 Opt. Inputs : None
               
 Outputs     : None
               
 Opt. Outputs: data - returns the retrieved ratio structure
               
 Keywords    : log. If set, a log-log plot is produced.

 Calls       : print2d_plot 

 Common      : None
               
 Restrictions: None
               
 Side effects: None
               
 Category    : Synthetic spectra
               
 Prev. Hist. : None

 Written     : C D Pike, RAL, 7-Oct-96
               
 Modified    : v.2 Added a few extra things, including possibility to create a
               postscript file. 
               Giulio Del Zanna (DAMTP), 10-Oct-2000

 Version     : Version 2, GDZ 10-Oct-2000 


TEMP_PLOTTER

[Previous Routine] [Next Routine] [List of Routines]
 PROJECT

       CHIANTI   http://wwwsolar.nrl.navy.mil/chianti.html

       CHIANTI is an atomic database package for the calculation of
       continuum and emission line spectra from astrophysical plasmas. It is a 
       collaborative project involving the Naval Research Laboratory
       (Washington DC, USA), the Arcetri Observatory (Firenze, Italy), and the
       Cambridge University (United Kingdom).

 NAME
        temp_plotter

 PURPOSE:
        A widget-based routine to allow the analysis of temperature sensitive
        ratios. **** See RATIO_PLOTTER for details. *****

 CALLING SEQUENCE:

       IDL>  temp_plotter,  name,$ 
                  EM, PATH=PATH, NOPROT=NOPROT, $
                  IONEQ_FILE=IONEQ_FILE, ABUND_FILE=ABUND_FILE


 INPUTS:
        The ion name (e.g. 'si_3' for Si III)

 OPTIONAL INPUTS : none

 OUTPUTS:

 OPTIONAL OUTPUTS:

	EM:	Save the displayed emissivities to structure EM.
               **** See RATIO_PLOTTER for details. *****

 KEYWORDS:


	PATH:	Data in the CHIANTI format that is not in the CHIANTI 
		database can be read by specifying the directory in which 
		it lies through PATH.

       ABUND_FILE  The name of a CHIANTI abundance file. This is used for 
               calculating the proton to electron ratio. Default is 
               !abund_file.

       IONEQ_FILE  The name of a CHIANTI ion balance file. This is used for 
               calculating the proton to electron ratio and evaluating 
               the T_max of the ion. Default is !ioneq_file.

       NOPROT  If set, then the default setting will be NOT to use 
               proton rates. This can be changed within the routine.


 CALLS:   CONVERTNAME RATIO_PLOTTER
      

 COMMON BLOCKS: none


 RESTRICTIONS:

 SIDE EFFECTS:

 CATEGORY:
	spectral synthesis.
	
 EXAMPLE:
             IDL> temp_plotter, 'fe_13'

 WRITTEN     : 
              Ver.1, 18-Apr-2002, Giulio Del Zanna (GDZ) written as a wrapper
              routine to call RATIO_PLOTTER (written by P. Young).

 MODIFIED:   V.2,  2-Aug-2005, GDZ
              Now the routine handles the dielectronic case


 VERSION     :   2,  2-Aug-2005


TEMPERATURE_RATIOS

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	TEMPERATURE_RATIOS

 PURPOSE:

	calculate and display temperature sensitivity of line intensity ratios

 CATEGORY:

	spectral diagnostics

 PROCEDURE :

       The intensities (Population of the upper level * A)  of the lines within
       the selected ion are first  calculated, either at constant pressure or
       at constant density (however specified in the input). They are plotted
       in window 0. The intensities  relative to the brightest  reference line
       are then plotted in window 1. A widget allows the user to select a
       number of lines (at least one!) for the numerator of the ratio, and a
       number of lines for the denominator. In case of multiple selections, the
       line intensities are summed. The ratio values are plotted in window 2, and
       optionally also saved in a text file. A postscript file can also be
       created. The ratio values, calculated at twice and half the prescribed
       density  are also calculated and overplotted, to show how the
       temperature ratio also depends on the density.

 CALLING SEQUENCE:


      > temperature_ratios,ion,wmin,wmax,Log10(tempmin),Log10(tempmax),temperature,ratio,description,$
       [pressure= ,density= , psfile= , outfile= ]


 EXAMPLE:

      > temperature_ratios,'c_4',100.,1600.,4.,6.,temp,ratio,desc,density=1.e+10,$ 
        psfile='test.ps', outfile='test.txt'

       then select  the  ratio of (384.17 + 384.19) to 1550.772



 INPUTS:

       Ion:   the CHIANTI style name of the ion, i.e., 'c_5' for C V

       Wmin:  minimum  wavelength  limit in Angstroms

       Wmax:  maximum  wavelength  limit in Angstroms

       Tempmin:  log10 of lowest temperature of interest, i.e. 4 for 10.^4 K

       Tempmax:  log10 of highest temperature of interest

 OPTIONAL INPUTS:

	Must specify indices of lines which are to form the ratio
	
       RADTEMP   The blackbody radiation field temperature (default 
                 6000 K).

       RPHOT     Distance from the centre of the star in stellar radius 
                 units. I.e., RPHOT=1 corresponds to the star's surface. 
                 (Default is infinity, i.e., no photoexcitation.)

       ABUND_FILE  The name of a CHIANTI abundance file. This is used for 
                 calculating the proton to electron ratio. Default is 
                 !abund_file.

       IONEQ_FILE  The name of a CHIANTI ion balance file. This is used for 
                 calculating the proton to electron ratio and evaluating 
                 the T_max of the ion. Default is !ioneq_file.

 OUTPUTS:

	Temperature:  an array of temperatures spanning Tempmin to Tempmax

       Ratio:  an array of the intensity ratio of the selected lines

       Desc:  a short string description of the selected line ratio


 OPTIONAL OUTPUTS:

	Ps and/or  text file with the  intensity ratio.


 KEYWORD PARAMETERS:

		
	DENSITY:  calculates the intensity ratios for constant density.

                  If neither density or pressure are specified, a constant
                  density of 1.e+10 cm^-3 is assumed as default.

       OUTFILE:  the (optional) name of the output ascii file where a 
                   listing of the line ratio intensities as a function of 
                   temperature is saved.

       PSFILE:  the (optional) name of the output postscript file 
                  where a plot of the chosen temperature sensitive line
                  ratio is saved.

       NOPROT    Switches off inclusion of proton rates.

       VERBOSE   prints out information

 CALLS: 

        read_ioneq, convertname, ion2spectroscopic,ion2filename,
        ch_xmenu_sel, emiss_calc

 COMMON:

       elvlc,l1a,term,conf,ss,ll,jj,ecm,eryd,ecmth,erydth,eref
       wgfa, wvl,gf,a_value
       upsilon,t_type,deu,c_ups,splups
       proton, pstr, pe_ratio
       radiative, radt, dilute

 RESTRICTIONS:

               
 SIDE EFFECTS: None known yet.
                 

 MODIFICATION HISTORY:
 	Written by:	Ken Dere
	May 1996:     Version 2.0, Ken Dere
       April 2000:   V. 3 Ken Dere modified for V3
       14-Jul-2000   V. 4  Peter Young, now calls pop_solver
        2-Oct-2000   V. 5 Giulio Del Zanna, corrected an error in the 
             creation of the string list of the lines in the ratio. 
             Also corrected a few minor errors.
             Removed the device,window_state call, and added a few 
             other 'cosmetic' adjustments.  
	Version 6, 21-Dec-2000, William Thompson
	      Modified for better cross-platform capability.

       Ver.7, 6-Dec-2001, Peter Young
             Revised to call emiss_calc for the emissivities.

       V.8, 21-May-2002, GDZ 
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

       V.9, 1-Aug-02 GDZ
          Fixed label mistake, and changed all the formats.

       V.10, 06-Aug-02 GDZ
              Changed the use of CHIANTI system variables. 

       V.11, 15-Aug-02, GDZ 
              Major revision:
              -Added the keyword VERBOSE, to avoid printing out long lists of lines.
              -Removed the call to ch_xselect_s, that did not work for long lists.
              -Added a '*' in the line lists, to identify 'unobserved' lines.
              -Replaced the commands to create PS file, to make it
               cross-platform compatible.
              -Added a large number of cosmetics, mainly lables to the axes and
               titles, that were missing.
              -Removed plotting in windows already present.
              -Removed the pressure keyword.
              -Added the CHIANTI version number in the outputs.

        V.12, 3-Nov-03  GDZ
           Modified format e8.2 to e9.2 for Windows compatibility.

 VERSION     :   12, 3-Nov-03


CHIANTI_TE

[Previous Routine] [Next Routine] [List of Routines]
 Project     : SOHO - CDS     
                   
 Name        : CHIANTI_TE
               
 Purpose     : Calculate and plot CHIANTI temperature sensitive line ratios.
               
 Explanation : CHIANTI_TE (temperature ratios)
               calculates and plots temp. sensitive line ratios based on 
               the CHIANTI atomic database of Dere et. al. 
               
 Use         : IDL> chianti_te 
    
 Inputs      : None
               
 Opt. Inputs : None
               
 Outputs     : None
               
 Opt. Outputs: none. 
               
 Keywords    : None

 Calls       : CALC_DMM_TR, make_ion_list

 Common      : dmm_tr_com
               
 Restrictions: None
               
 Side effects: None
               
 Category    : Spectral
               
 Prev. Hist. : Started life as 'temperature_ratios' by Ken Dere

 Written     : H.E. Mason, 3 Oct 1996 

 Modified    : Update for IDL v5.2.  CDP, 20-Apr-99
               V.3.  Update list of elements.  CDP, 18-Jun-99

               V.4 , Giulio Del Zanna (DAMTP), 10 Oct-2000
               Rewritten completely, adding possibility to select the density
               at which the intensities are calculated,  making this routine
               compatible ith CHIANTI v.3, and with the same characteristics as
               CHIANTI_TE. Added ratio plots and hardcopies in linear scale, added various
               checks and  minor things. Added a few tags to the 
               ratio output structure (density, units, comment). 
               Removed optional output structure.
		Version 5, 21-Dec-2000, William Thompson, GSFC
			Modified for better cross-platform graphics capability

               V. 6, 1-May-02, GDZ, commented out a few refs.
               V.7,  21-May-2002, GDZ, fixed a bug with the fonts.
               V.8, 17-Sep-2002 (GDZ) 
                    added !p.multi = 0 upon exit and added X-label

 Version     : Version 8, 17-Sep-2002


PLOT_CHIANTI_TE

[Previous Routine] [Next Routine] [List of Routines]
 Project     : SOHO - CDS     
                   
 Name        : PLOT_CHIANTI_TE
               
 Purpose     : Plots a temperature sensitive ratio saved from CHIANTI_TE
               
 Explanation : The routine CHIANTI_TE allows the calculated ratio to be
               saved in an IDL save file.  This routine retrieves and
               plots the ratio.
               
 Use         : IDL> plot_chianti_te, file, data
    
 Inputs      : file - save file name (an extension of .CH_TE will have
                                      been added, specifying this is optional)
               
 Opt. Inputs : None
               
 Outputs     : None
               
 Opt. Outputs: data - returns the retrieved ratio structure
               
 Keywords    : log. If set, a log-log plot is produced.

 Calls       : None

 Common      : None
               
 Restrictions: None
               
 Side effects: None
               
 Category    : Synthetic spectra
               
 Prev. Hist. : None

 Written     : C D Pike, RAL, 7-Oct-96
               
 Modified    : v.2 Added a few extra things,  including possibility to create a
               postscript file. 
               Giulio Del Zanna (DAMTP), 10-Oct-2000

 Version     : Version 2, GDZ 10-Oct-2000 


FREEFREE

[Previous Routine] [Next Routine] [List of Routines]
 PROJECT     :  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 

 NAME

     FREEFREE

  PURPOSE:

     This routine computes the free-free continuum (bremsstrahlung) 
     using the fitting formulae of Itoh et al. (ApJS 128, 125, 2000) 
     and Sutherland (MNRAS 300, 321, 1998).

     The Itoh et al. data are valid for smaller ranges for temperature 
     and wavelength than Sutherland and so for points outside of their 
     ranges we use the data of Sutherland.

 INPUTS

    TEMP    Temperature (in K).

    WVL     Wavelengths in angstroms. Can be a scalar or vector.

 OUTPUTS

    INT     Free-free continuum intensity in units of 
            10^-40 erg cm^3/s/sr/Angstrom  
            [ integral(N_H N_e dh) in cm^-5 ] if a DEM is not defined. 

            If DEM values are defined, it is assumed that they are given
            as N_H N_e dh/dT.  The units are 10^-40 erg/cm^2/s/sr/Angstrom. 

            If T is given as a 1-D array, then the output will be a 2-D array,
            with one element for each temperature and wavelength 
            (but also see SUMT).

 OPTIONAL INPUTS

    DEM_INT An array of same length as TEMP which contains the 
            differential emission measure values at each temperature. 
            The emissivity at each temperature is multiplied by the 
            DEM value and the d(logT) value.

    MIN_ABUND This keyword allows the specification of a minimum abundance, 
              such that any elements with an abundance (relative to 
              hydrogen) less than MIN_ABUND will not be included in the 
              calculation. E.g., MIN_ABUND=1e-5.

 KEYWORDS

    NO_SETUP By default the routine asks the user which ion balance 
             and abundance files to use via pop-up widgets. If 
             /no_setup is used then this data is taken from the common 
             block.

    SUMT     The default is to output the intensity array as an array 
             of size (nwvl x nT). Setting this keyword performs a sum 
             over the temperatures to yield a vector of same size as 
             the input wavelengths, thus producing the complete 
             free-free spectrum.

    PHOTONS  Gives output emissivity in photon units rather than ergs.

 CALLS

    SUTHERLAND, ITOH

 COMMON BLOCKS

    ELEMENTS

 PROGRAMMING NOTES

    The Itoh fitting formula is only valid for (6.0 LE logT LE 8.5). 
    For temperatures below this, we thus switch to the Sutherland 
    fitting formula. There is very little (<1%) between the two at 
    logT=6.

    Itoh also has a constraint on the quantity u=hc/kTl (l=wavelength), 
    such that (-4 LE log u LE 1.0). The upper limit corresponds to the 
    continuum being cut-off prematurely at low wavelengths. E.g., for 
    T=10^6 the cutoff is at 14.39 angstroms. For these low wavelengths 
    we also use the Sutherland data to complete the continuum. Note that 
    the continuum at these wavelengths is very weak

 MODIFICATION HISTORY

    Ver.1, 5-Dec-2001, Peter Young
         Completely revised to call the separate itoh.pro and 
         sutherland.pro routines.

    V. 2, 21-May-2002,  Giulio Del Zanna (GDZ),
          Corrected the description of the  units.
          Added verbose keyword and a printout.

    V. 3, 22-May-2002,  Peter Young (PRY)
          Added MIN_ABUND optional input.
          Changed ioneq_t to ioneq_logt (GDZ).

       V 4, 25-May-2005, GDZ 
                  corrected routine header.

 VERSION     :  4, 25-May-2005


FREEBOUND

[Previous Routine] [Next Routine] [List of Routines]
 PROJECT:  CHIANTI

      CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
      Astrophysical Plasmas. It is a collaborative project involving the Naval
      Research Laboratory (USA), the University of Florence (Italy), the
      University of Cambridge and the Rutherford Appleton Laboratory (UK). 

 NAME

      FREEBOUND

 PURPOSE:
      Calculates the free-bound (radiative recombination) continuum.

 INPUTS

      TEMP    Temperature in K (can be an array).

      WVL     Wavelength in angstroms (can be an array).

 OUTPUTS

      INT     Free-bound continuum intensity in units of 
              10^-40 erg cm^3/s/sr/Angstrom 
              ( integral(N_H N_e dh) in cm^-5) if a DEM is not defined. 

              If DEM values are defined, it is assumed that they are given
              as N_H N_e dh/dT.  The units are 10^-40 erg/cm^2/s/srAngstrom 

              If T is given as a 1-D array, then the output will be a 
              2-D array, with one element for each temperature and 
              wavelength (but also see SUMT).

 OPTIONAL INPUTS

      DEM_INT The intensity array is multiplied by a DEM number for 
              each temperature. DEM_INT needs to be of the same size 
              as TEMPERATURE. It is needed for the synthetic spectrum 
              routines.

      IZ     Only calculate continuum for the element with atomic 
             number IZ

      ION    (To be used in conjunction with IZ.) Calculated continuum 
             for a single ion (IZ, ION).

 KEYWORDS

      NO_SETUP If the procedure setup_elements has already been called 
               then the keyword /nosetup should be set to avoid 
               repeating this step

      MIN_ABUND If set, calculates the continuum only from those 
                elements which have an abundance greater than 
                min_abund.  Can speed up the calculations.  For 
                example:
                   abundance (H)  = 1.
                   abundance (He) = 0.085
                   abundance (C)  = 3.3e-4
                   abundance (Si) = 3.3e-5
                   abundance (Fe) = 3.9e-5

      PHOTONS  The output spectrum is given in photon units rather 
               than ergs.

      SUMT     When a set of temperatures is given to FREEBOUND, the 
               default is to output INTENSITY as an array of size 
               (nwvl x nT). With this keyword set, a summation over 
               the temperatures is performed.

      VERBOSE  Output information from FREEBOUND.

 COMMON BLOCKS

      ELEMENTS

 CALLS

      FREEBOUND_ION, SETUP_ELEMENTS, READ_KLGFB, GET_IEQ

 HISTORY

      Ver.1, 24-Jul-2002, Peter Young

      Ver.2, 26-Jul-2002, Peter Young
           revised call to freebound_ion; corrected ion fraction problem

       V 3, 25-May-2005, GDZ 
                  corrected routine header.

 VERSION     :  3, 25-May-2005


TWO_PHOTON

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	TWO_PHOTON

 PURPOSE:

	Calculate the 2 photon continuum from a hot, low density plasma.

       For the hydrogen isoelectronic sequence, A values
             Parpia, F. A., and Johnson, W. R., 1982, Phys. Rev. A, 26, 1142.
       and distribution function as a function of Z is taken from: 
             Goldman, S.P. and Drake, G.W.F., 1981, Phys Rev A, 24, 183

       For the helium isoelectronic sequence, A values are from:
             Drake, G.W.F., 1986, Phys. Rev. A, 34, 2871
       and the distribution function as a function of Z is taken from:
             Drake, G.W.F., Victor, G.A., Dalgarno, A., 1969, Phys. 
             Rev. A, 180, 25.
       in this paper the distribution is only given up to Z=10 but  
       extrapolation to higher Z appears to be OK.

       Note that, unlike the freefree and freebound routines, two_photon 
       requies the electron density to be specified. This is because there 
       is a call to pop_solver

 CALLING SEQUENCE:

       TWO_PHOTON,temperature, density, wavelength, intensity


 INPUTS:

	TEMPERATURE   Temperature in degrees Kelvin, can be a 1D array

       WAVELENGTH    Wavelengths in Angstroms.


 OPTIONAL INPUTS:

       DENSITY       Electron density in cm^-3, can also be a 1D array 
                     of the same size as Temperature. If there are several 
                     temperatures specified but only one density, then 
                     density is assumed the same at all temperatures.
                     If not specified, then default densities of 10^10 
                     electrons/cm^3 are assumed.

       DEM_INT An array of same length as TEMP which contains the 
               differential emission measure values at each temperature. 
               The emissivity at each temperature is multiplied by the 
               DEM value and the d(logT) value.
	
 KEYWORD PARAMETERS:

	NO_SETUP:   If the procedure setup_elements has already been called 
                   then the keyword /no_setup should be set to avoid 
                   repeating this step

       MIN_ABUND:  If set, calculates the continuum only from those 
                   elements which have an abundance greater than min_abund.  
                   Can speed up the 
                   calculations.  For example:
                   abundance (H)  = 1.
                   abundance (He) = 0.085
                   abundance (C)  = 3.3e-4
                   abundance (Si) = 3.3e-5
                   abundance (Fe) = 3.9e-5

       SUMT        If several temperatures have been specified, then /sumt 
                   will sum the emissivities over the different 
                   temperatures, giving an output INTENSITY that has the 
                   same size as WAVELENGTH.

       PHOTONS     If set the continuum emissivity is output in photon 
                   units rather than erg units.

       VERBOSE
 
 OUTPUTS:

	RAD         2 photon continuum intensity in units of
                   10^-40 erg cm^3/s/sr/Angstrom  per unit emission measure 
                   ( integral(N_H N_e dh) in cm^-5) if a DEM is not defined. 

                   If DEM values are defined, it is assumed that they are given
                   as N_H N_e dh/dT.  The units are 
                   10^-40 erg/cm^2/s/sr/Angstrom 

            If T is given as a 1-D array, then the output will be a 2-D array,
            with one element for each temperature and wavelength 
            (but also see SUMT).



 CALLS

       POP_SOLVER, SETUP_ION, SETUP_ELEMENTS, READ_MASTERLIST,
       CONVERTNAME

 COMMON BLOCKS:

       ELEMENTS, ELVLC, WGFA, UPSILON, PROTON

 EXAMPLE:

             > two_photon,1.e+6,3.e+10,wvl,int
             > two_photon,1.e+6,3.e+10,wvl,int,min_abund=3.e-5
             > two_photon,1.e+6,3.e+10,wvl,int,/no_setup

 PROGRAMMING NOTES

    For He 2-photon decays, the distribution function is from Table II 
    of Drake et al. (1969), except that the values have been divided by 
    the A-value from Drake (1986).


 MODIFICATION HISTORY:
 	Written by:	Ken Dere
	February 2001:  Version 1.0

       Ver.2, 19-Dec-2001, Peter Young
           Now allows an array of temperatures.
           Added /SUMT keyword.
           Added DEM_INT= optional input.
           Switched to using spl_init & spl_interp for the spline fits.
           Corrected a small bug.

       Ver.3, 20-Dec-2001, Peter Young
           Corrected a bug related to density indices.

       Ver.4, 23-Apr-2002, Peter Young
           Added /photons keyword.

       Ver.5, 28-May-2002, Peter Young
           Corrected way in which DEM_INT is handled.

       V. 6, 28-May-2002, Giulio Del Zanna (GDZ)
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 
             Corrected the description of the  units and various
             inaccuracies in the header.
    
       V.7, 14-Aug-02, GDZ
             Added keyword VERBOSE

       V.8,  4-Oct-2003, GDZ
                  modified the input to POP_SOLVER, now it is dealt with an
                  input structure.

       V.9,  8-Jun-2004, EL
                  modified the input to POP_SOLVER, now it includes ion/rec

       V.10, 5-Jul-2005
                  corrected problems with the input structure for pop_solver

       v.11 29-Jul-2005, GDZ
                  fixed bug, only define ioneq_ionrec when files are
                  there (it was failing with neutrals)

 VERSION     :   11 29-Jul-2005


SHOW_POPS

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME: SHOW_POPS
       
 PURPOSE:

	To display populations of significant levels in a CHIANTI ion 
	model

 CATEGORY:

       Scientific analysis

 EXPLANATION:

	Displays percentage level populations and level IDs for all levels 
	in the specified ion with populations greater than 0.01%. If the 
	temperature is not specified, then it is taken to be where the 
	maximum of the ionisation fraction is.

 CALLING SEQUENCE:

	SHOW_POPS, IZ, ION [, POPSTR, DENS= , TEMP= , /NOPROT,
                           RADTEMP= , RPHOT= , /ALL, /DIEL, PATH=,
                           IONEQ_FILE= , ABUND_FILE= ]

 EXAMPLES:

	show_pops,26,13,popstr
	show_pops,26,13,dens=7.5,temp=6.0,rphot=1.2

 INPUTS:

	IZ	The atomic number of the ion

	ION	The spectroscopic number of the ion (e.g., 12 = XII)

 OPTIONAL INPUTS:

	DENS	Logarithm of electron density

	TEMP	Logarithm of electron temperature. If not specified, then
               T_max of the ion is used

	RADTEMP	Specify background radiation temperature (default: 6000 K)

	RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

	PATH	Directly specify the path where the ion data is contained, 
		e.g., path='/home/other_data/fe_13'

       N_LEVELS  The size of the ion model is automatically determined 
                 from the information in the CHIANTI data files. Setting 
                 this keyword allows the number of levels in the model to 
                 be reduced. E.g., N_LEVELS=14 reduces the model to the 
                 first 14 levels given in the .ELVLC file.

       IONEQ_FILE To include proton rates in the level balance equations 
                  requires the number of density of protons to be known, 
                  and this requires an ion balance file and an abundance 
                  file to be specified, which are done through the 
                  IONEQ_FILE and ABUND_FILE keywords. If they are not set 
                  then the default files specified by !ioneq_file and 
                  !abund_file are used.

       ABUND_FILE See IONEQ_FILE.

       SUM_MWL_COEFFS  An array of coefficients of the same length as 
                       the array of temperatures. Electron and proton rate 
                       coefficients will be calculated at each temperature 
                       and then a weighted sum of the coefficients is 
                       performed using SUM_MWL_COEFFS. This allows 
                       non-Maxwellian energy distributions to be 
                       incorporated into the level balance equations.
                       If this keyword is set for an ion that has ionization
                       and recombination included in the level balance, then
                       these processes will be switched off for the
                       calculation since their rates implicitly assume a
                       single Maxwellian to describe the ion fractions of
                       the neighbouring ions.

       LEVEL   Allows the control of which level populations are displayed
               to the screen. If set to a positive scalar or array, then
               only those levels are printed. If it is set to a negative
               scalar (-n), then all level populations up to level n are
               printed. E.g., LEVEL=20 (only level 20); LEVEL=[5,7,20]
               (levels 5, 7 and 20); LEVEL=-20 (all levels up to level 20).

       RADFUNC         The name of a user-defined function that will generate
                       a radiation spectrum as a function of temperature. 
                       This radiation field will replace the black-body that
                       is assumed when using the RADTEMP keyword in the call
                       to pop_solver.

; OPTIONAL OUTPUTS

       POPSTR  Send level population information to a structure. POPSTR has 
               the tags:
               .dens    Density (cm^-3)
               .temp    Temperature (K). Can be an array if SUM_MWL_COEFFS=
                        is used.
               .radtemp RADTEMP. Set to -1 if RADTEMP not 
                        set.
               .rphot   RPHOT value. Set to -1 if RPHOT not set.
               .proton  String set to 'yes' if proton rates included, 'no' 
                        otherwise
               .version CHIANTI version used to derive populations.
               .date    Date and time at which structure created.
               .level   Structure containing level information. Tags are:
                  .index   CHIANTI level index
                  .term    String containing level identifier.
                  .pop     Population of level
               .sumtst  Set to 1 if the SUM_MWL_COEFFS keyword has been used.
                        Set to 0 otherwise.
               .sum_mwl_coeffs Contains SUM_MWL_COEFFS. Set to -1 if sumtst=0.

 KEYWORDS:

	ALL	Show populations for all levels.

       NOPROT  If set, then the default setting will be NOT to use 
               proton rates. This can be changed within the routine.

       DIEL    Use the dielectronic recombination files. E.g., for Fe XXII, 
               the routine will read in the fe_22d.* files instead of the 
               fe_22.* files.

 COMMON BLOCKS:

	ELVLC, WGFA, UPSILON, RADIATIVE, PROTON, ELEMENTS

 CALLS:

	ZION2FILENAME, POP_SOLVER, SETUP_ION, READ_IONEQ,
       READ_ABUND, PROTON_DENS, CONCAT_DIR

 HISTORY:

	Ver 1, PRY 22-Sep-97
	Ver.2, PRY 5-Sep-98  - added call to choose_ioneq
	Ver.3, PRY 23-Apr-99 - calls pop_solver now; added DENS keyword
	Ver.4, PRY 18-Dec-99 - added deu to upsilon common block to be 
			consistent with main Chianti routines.
       Ver.5, PRY 7-Aug-00  - added /DIEL keyword to allow populations of 
                       the dielectronic recombination files to be studied.
                       Also changed elvlc common block to match new 
                       version of pop_solver.
       Ver 6, PRY 10-Oct-00 - now calls setup_ion to read ion data
       Ver 7, PRY 12-Nov-01 - modified for proton rates, photoexcitation,
                       and 9 pt splines.
       Ver 8, PRY 9-Dec-01  - completed modifications for v4 of CHIANTI.

       V.  9, 25-May-2002, Giulio Del Zanna (GDZ) 
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 
                   Now we only call zion2filename

       V. 10, 9-Aug-2002, Peter Young
                   corrected !ioneq_file problem

       V. 11, 12-Aug-2002, Peter Young
                   added POPSTR output, and tidied up header.

       V. 12, 4-Oct-2003, GDZ
                  modified the input to POP_SOLVER, now it is dealt with an
                  input structure.

       V 13, 4-May-2005, Enrico Landi (EL)
                  Modified in order to include ionization and recombination
                  data in the input to POP_SOLVER

       V.14, 26-May-2005, Peter Young (implemented by GDZ)
                  added SUM_MWL_COEFFS optional input for allowing
                  non-Maxwellian distributions to be considered.

                  added LEVEL= optional input to only print the populations of
                  a few levels.

       V.15, 5-Jul-2005, Peter Young
                  added RADFUNC= and /QUIET keywords

 VERSION     :   15, 5-Jul-2005


PLOT_POPULATIONS

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	PLOT_POPULATIONS

 PURPOSE:

	plot the population of a number of the lowest levels as a function of 
       electron density for a specific temperature

 CATEGORY:

	science.

 CALLING SEQUENCE:

       PLOT_POPULATIONS,Ion,T,Nlevels


 INPUTS:

       Ion:  CHIANTI style name for the ion, i.e., 'c_6' for C VI
       T:  electron temperature (K)
       Nlevels:  the number of levels for which populations are plotted
                 starts from level 1 (the ground level)

	
 KEYWORD PARAMETERS:

	OUTFILE:   the (optional) name of the output file where the listing 
                  is produced
	PSFILE:    the (optional) name of the output file where a postscript 
                  plot produced

	RADTEMP	Specify background radiation temperature (default: 6000 K)

	RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

       NOPROT  If set, then the default setting will be NOT to use 
               proton rates. This can be changed within the routine.

               NOT_INTERACTIVE Avoid interactive use.

 OUTPUTS:


 COMMON BLOCKS:

	common elvlc,l1a,term,conf,ss,ll,jj,ecm,eryd,ecmth,erydth,eref
       common wgfa, wvl,gf,a_value
       common upsilon,t_type,c_ups,splups

 CALLS

       POP_SOLVER, ION2SPECTROSCOPIC, ION2FILENAME, READ_IP,
       CONVERTNAME, READ_ELVLC, READ_WGFA2, READ_SPLUPS

 EXAMPLE:

 to plot populations of the 5 ground configuration levels of Fe XIII
 and store these values in a file 'Fe_XIII.lis' for a temperature of 1.5 MK

             > plot_populations,'fe_13',1.5e+6,5,outfile='Fe_XIII.lis'

 MODIFICATION HISTORY:

 	Written by:	Ken Dere
	March 1996:     Version 2.0
       November 1997:  Ken Dere, added psfile keyword
       September 1999:  Ken Dere, for Version 3, 
       14-Jul-2000     Peter Young, now calls pop_solver
	Version 6, 21-Dec-2000, William Thompson
		Modified for better cross-platform capability.

       V. 7, 21-May-2002, Giulio Del Zanna (GDZ), modified the plotting bit
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

       V 8, 15-July-2002, GDZ 
         Added keyword  not_interactive

       V 9, 4-Oct-2003, GDZ
                  modified the input to POP_SOLVER, now it is dealt with an
                  input structure.

       V 10, 4-May-2005, Enrico Landi (EL)
                  Modified in order to include ionization and recombination
                  data in the input to POP_SOLVER, now it allows choice of .ioneq
                  file needed to include ionization and recombination.

 VERSION     :   10, 4-May-2005


POP_PLOT

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME: POP_PLOT
       
 PURPOSE:

	To compute n_j A_ji / N_e for a selected transition(s) and plot it
	against N_e. If it is insensitive to N_e, then the line(s) is 
	suitable for emission measure analysis.

 CATEGORY:

       Atomic data analysis

 EXPLANATION:

	The routine calls EMISS_CALC to give values of DE*n_j*A_ji at the 
	temperature TEMP and densities from 10^8 to 10^12. You are then 
	asked to select which transition(s) you are interested in. (If 
	more than one line is selected, the lines are blended.) 
	DE*n_j*A_ji/N_e is then plotted against density.

	If TEMP is not specified, then the temperature at which the 
	ionisation fraction has its maximum is calculated. For the iron 
	ions, the ion balance calcs of Arnaud & Raymond are used, 
	otherwise Arnaud & Rothenflug are used. If TEMP is specified, 
	and the value is less than 20, then it is assumed that the log 
	of the temperature has been specified.

	In emission measure work it is important to isolate lines for 
	which DE*n_j*A_ji/N_e is insensitive to density. If only such lines 
	are used, then the derived emission measure curve is independent 
	of density.

 CALLING SEQUENCE:

       POP_PLOT, IZ, ION, WRANGE=WRANGE, [TEMP=TEMP, /QUICK, DATA=DATA, $
				DENS_RANGE=DENS_RANGE, DILUTE=DILUTE]

 EXAMPLES:

	POP_PLOT, 26, 14, WRANGE=[330,360]

	- 3 lines should appear in the widget. Selecting 334.17 should show 
	a curve that falls off with density. Choosing 353.83 shows a curve 
	that rises with density. By selecting a blend of the two lines, 
	the curve will be insensitive to density, telling us that only a 
	blend of 334.17 and 353.83 is suitable for emission measure work.

	POP_PLOT, 8, 4, WRANGE=[550,560], TEMP=6.0, /QUICK, DENS_RANGE=[6,10]

	- O IV is a member of the boron sequence, and so calculations take a 
	lot longer. Giving the QUICK keyword speeds things up. The 
	temperature is well away from the T_max of the ion

 INPUTS:

	IZ	The atomic number of the ion

	ION	The spectroscopic number of the ion (e.g., 12 = XII)

 OPTIONAL INPUTS:

	DILUTE	Used to set radiative dilution factor. (Default: 0.0)

	TEMP	The temperature at which calculations are required. Usually 
		this will be the Tmax of the ion.

	DENS_RANGE  The default density range is log Ne = 8 to 12. By 
		    inputting two integers, a different range can be chosen.

	WRANGE  Wavelength range from which lines are required. If not 
		given, then the user is allowed to choose from the complete 
		set of lines for the ion.

       ABUND_FILE  The name of a CHIANTI abundance file. This is used for 
               calculating the proton to electron ratio. Default is 
               !abund_file.

       IONEQ_FILE  The name of a CHIANTI ion balance file. This is used for 
               calculating the proton to electron ratio and evaluating 
               the T_max of the ion. Default is !ioneq_file.

       RADTEMP The blackbody radiation field temperature (default 
               6000 K).

       RPHOT   Distance from the centre of the star in stellar radius 
               units. I.e., RPHOT=1 corresponds to the star's surface. 
               (Default is infinity, i.e., no photoexcitation.)

 OPTIONAL OUTPUTS:

	DATA:	An array that contains the data that is plotted: data(*,0) 
		contains
		the densities, while data(*,1) contains the Y-axis values.

 KEYWORDS:

       NOPROT  If set, then the default setting will be NOT to use 
               proton rates. This can be changed within the routine.

	QUICK:	The density range over which the calculations are done is 
		8 to 12 in 0.2 intervals. This keyword forces the 
		calculations to be done at 0.5 intervals.

 CALLS:

	EMISS_CALC, EMISS_SELECT, READ_IONEQ

 HISTORY:

	Ver.1, PRY 28-Jul-97.
	Ver.2, PRY 23-Sep-97 - added DILUTE keyword for photo-excitation
	Ver.3, PRY 30-May-98 - added DENS_RANGE
	Ver.4, PRY 5-Sep-98  - added call to choose_ioneq
	Ver.5, PRY 7-Apr-99  - tidied up, and introduced call to emiss_select
       Ver.6, PRY 7-Dec-01  - modified for v.4 of CHIANTI

       V. 7, 21-May-2002, Giulio Del Zanna (GDZ) 
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

       V.8, 06-Aug-02 GDZ
              added ABUND_FILE to the call to emiss_calc (was missing).
              Changed the use of CHIANTI system variables. 


 VERSION     : 8,  06-Aug-02


POP_PROCESSES

[Previous Routine] [Next Routine] [List of Routines]
 NAME

      POP_PROCESSES

 PROJECT

      CHIANTI

 PURPOSE:

      Outputs to the screen the contributions of the different physical 
      processes to the population of the specified level within the ion. 


      E.g., for Fe XIII, level 4, the output is:

      Population leaving level 4
        rad. decay:     1.51e+01     39.17%
        e de-exc:       3.56e-01      0.92%
        e exc:          2.28e+01     59.12%
        p de-exc:       2.63e-01      0.68%
        p exc:          4.05e-02      0.11%
        stim. emiss:    0.00e+00      0.00%
        photoexc:       0.00e+00      0.00%
                        --------
                 TOTAL  3.85e+01
      
      Population entering level 4
        rad. decay:     3.59e+01     93.19%
        e de-exc:       3.81e-02      0.10%
        e exc:          1.46e+00      3.79%
        p de-exc:       3.18e-03      0.01%
        p exc:          1.12e+00      2.91%
        stim. emiss:    0.00e+00      0.00%
        photoexc:       0.00e+00      0.00%
                        --------
                 TOTAL  3.85e+01

      which shows that the level population is dominated by electron
      excitation and cascading into the level, and by radiative decay
      out of the level.

      Note that the rates for each physical process are multiplied by the 
      population of originating level (this results in the totals for 
      entering and leaving the level to balance).

      For some ions, ionization and recombination are additional processes
      included when working out the level balance. Because of the way these
      processes are included (see the v.5 paper for details), the populations
      entering and leaving some levels *will not balance*.

 INPUTS

      IZ      The atomic number of the ion

      ION     The spectroscopic number of the ion (e.g., 12 = XII)

 OPTIONAL INPUTS

      LEVEL   The ion level for which information is required.

      DENS    Electron density at which rates calculated (units: cm^-3).
              If not specified, a value of 10^10 is assumed.

      TEMP    Temperature at which rates calculated (units: K). If not set,
              then T_max of the ion is used

      PATH    If the ion data-files are not in the CHIANTI directories, 
              then PATH allows you to choose an alternative location.

      RPHOT   Distance from the centre of the star in stellar radius units.
              I.e., RPHOT=1 corresponds to the star's surface. (Default is
              infinity, i.e., no photoexcitation.)

      RADTEMP Specify background radiation temperature (default: 6000 K)

      N_LEVELS Restrict the ion model to this number of levels. E.g., if
               the CHIANTI model contains 40 levels for the ion, then
               setting N_LEVELS=12 reduces the model to 12 levels.

      RADFUNC  The name of a user-defined function that will generate
               a radiation spectrum as a function of temperature. 
               This radiation field will replace the black-body that
               is assumed when using the RADTEMP keyword in the call
               to pop_solver.

 KEYWORDS

      NOPROT  If set, then the default setting will be NOT to use 
              proton rates. This can be changed within the routine.

 CALLS

      R2W, ZION2FILENAME, PROTON_DENS, POP_SOLVER, SETUP_ION

 EXAMPLES

      One can compare the effect of cascading on a level population by using
      the N_LEVELS keyword. Consider the case of Fe XIV:
        IDL> pop_processes,'fe_14',lev=5
        IDL> pop_processes,'fe_14',lev=5,n_levels=12
      With the first call there are two dominant terms to the population
      entering level 5: approximately 47% for radiative decays (cascading)
      and 53% for electron excitation. Setting n_levels=12, one finds that
      the cascading contribution disappears as there are no longer any
      high-lying levels that cascade into level 5. The cascading provides
      a strong contribution to the population of this level.

 HISTORY

      Ver.1, 11-Sep-2002, Peter Young
      Ver.2, 15-Jan-2004, Peter Young
          modified call to pop_solver following recent revision to
          pop_solver; changed input from IZ,ION to IONNAME to match other
          CHIANTI routines
      Ver.3, 26-May-2005, Peter Young
          changed TEMP and DENS keywords
      Ver.4, 10-Jun-2005, Peter Young
          added common block for ionization/recombination data and modified
          INPUT structure.
      Ver.5, 14-Jun-2005, Peter Young
          routine now prints the percentage contribution of each process;
          added N_LEVELS= keyword
      Ver.6, 1-Jul-2005, Peter Young
          added warning for ions with ionization/recombination


RAD_LOSS

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 

 NAME:
	RAD_LOSS

 PURPOSE:

       Calculates energy loss rate by free-free (ff), radiative 
       recombination (fb) and by line (bound-bound) radiation.

 CATEGORY:
	
	synthetic spectra

 CALLING SEQUENCE:

       RAD_LOSS,Temperature,Loss_rate


 INPUTS:

	None:  The user will select an elemental abundance file and a 
              ionization equilibrium file through widgets.

  KEYWORDS:

       Pressure:  pressure in emitting region (cm^-3 K)
                  density=pressure/temperature(K)

       Density:   density (cm^-3), constant for all temperatures
                  if neither density or pressure is set, then a default 
                  constant density of 10^10 cm^-3 is used.

       Psfile:    to create a postscript plot of the radiative loss in 
                  the file specified by the name assigned to 'Psfile'

       Outfile:   name of an ascii file where the radiative loss rate 
                  as a function of temperature is output
                   
	RADTEMP	Specify background radiation temperature (default: 6000 K)

	RPHOT   Distance from the centre of the star in stellar radius units.
               I.e., RPHOT=1 corresponds to the star's surface. (Default is
               infinity, i.e., no photoexcitation.)

       NOPROT  If set, then the default setting will be NOT to use 
               proton rates. This can be changed within the routine.



 OUTPUTS:

       Temperature:  array of temperatures (K)
       Loss_rate:    energy loss rate in erg cm^3 s^-1


 PROCEDURE:


  if keyword pressure is set then calculations performed at constant pressure
  if keyword density is set then calculations performed at constant density
  otherwise, density is set to 1.e+10
  
  pressure = density * temperature  (cm^-3 K)

	the user will be asked to select an abundance file and a 
       ionization balance file.

 EXAMPLE:

       > rad_loss,t,r


 MODIFICATION HISTORY:
 	Written by:	Ken Dere
	January 1999:  version 1, adopted from synthetic.pro
	Version 2, 21-Dec-2000, William Thompson
		Modified for better cross-platform capability.

       Ver.3, 6-Dec-2001, Peter Young
               Added /noprot, radtemp and dilute keywords.
               Removed elvlc, wgfa and upsilon common blocks.
               Removed calls to read_ip and read_masterlist (not needed).

       Ver.4, 8-Jul-2003, Peter Young
               Updated routine header (no changes to code).

       V 5, 25-May-2005, GDZ 
                  corrected routine header.

 VERSION     :   5, 25-May-2005, GDZ 


PLOT_IONEQ

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 
                   
 Name        : PLOT_IONEQ
               
 Purpose     : Plots the ionisation equilibrium values for an element.

 Explanation : 
               
 Use         : IDL> plot_ioneq, element [ ion=ion]
    
 Inputs      : element - the element name
               
 Opt. Inputs : Ion (as keyword)
               
 Outputs     : None
               
 Opt. Outputs: a postscript file.
               
 Keywords    : ION_RANGE - specify range of ions. E.g., ion_range=[5,8] 
                    means V to VIII inclusive.
               IONEQ_NAME:  Name of the ionization equilization name to use.
                    If not passed, then the user is prompted for it.
               NOT_INTERACTIVE Avoid interactive use.

 Calls       :  Other CHIANTI routines

 Common      :
               
 Restrictions:  None
               
 Side effects:  None
               
 Category    :  Spectral
               
 Prev. Hist. :  None

 Written     :  C D Pike, RAL, 9-Jun-97
               
 Modified    :  V.2. Update element list. modified definition of XUVTOP, and
               allowed selection of ionization eq. file and creation of
               postscript file. 
               Giulio Del Zanna  (DAMTP) 10-Oct-2000 

       V.3, Giulio Del Zanna (GDZ)
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

       V 4, 15-July-2002, GDZ 
         Added keywords ioneq_name, not_interactive

       V.5, 9-Feb-2005, Peter Young
            Changed ion= keyword to ion_range=

 VERSION     :    5, 9-Feb-2005



MAX_TEMP

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 

 Name        : MAX_TEMP
               
 Purpose     : Calculates temperature at max ionisation ratio for an ion

 Explanation : 
               
 Use         : IDL> print,max_temp(ion)
    
 Inputs      :  ion - the specific ion in the form eg 'Fe_XII' or 'Fe XII'
               
 Opt. Inputs :  None
               
 Outputs     :  Function returns log of max temperature
               
 Opt. Outputs:  None
               
 Keywords    :  ALL - if set produces a plot of all temperatures

 Calls       :  Other CHIANTI routines

 Common      :
               
 Restrictions:  None
               
 Side effects:  None
               
 Category    :  Spectral
               
 Prev. Hist. :  None

 Written     :  C D Pike, RAL, 9-Jun-97
               
 Modified    :  V.2 Update element list.  CDP, 18-Jun-99 
                V.3 modified definition of XUVTOP, and allowed selection of
                ionization eq. file. Giulio Del Zanna (DAMTP) 10-Oct-2000

                V.4, Giulio Del Zanna (GDZ)
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

 VERSION     :   4, 21-May-2002, GDZ 


CHIANTI_DEM

[Previous Routine] [Next Routine] [List of Routines]
 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 

                   
 Name        : CHIANTI_DEM
     		          
 Purpose     : Calculates the Differential Emission Measure DEM(T) using 
		the CHIANTI database, from a given set of observed lines.
		Constant pressure or density can be used.

 Category    : diagnostic analysis
               
 Explanation : This routine has several options, all in the form of keywords.
 		First, the input file with the observed fluxes is read.
		THE FIRST TIME YOU USE THIS ROUTINE
		you'll have to do the calculation of the contribution
		functions G(T), so the routine GET_CONTRIBUTIONS will come 
		into play. You'll have to specify the value of the 
		pressure or density, and  you'll be asked to select an  
		ionization equilibrium file and an abundance file.
		GET_CONTRIBUTIONS searches the CHIANTI database (ion per ion) 
		for all the theoretical lines corresponding to the observed 
		lines, i.e. that lie in a OBS_WVL(i) +/- DELTA_LAMBDA_OBS(i) 
		interval centered on the observed wavelength OBS_WVL(i).
		The routine calculates the C(T) values (G(T)=Ab(element)*C(T))
		for the temperature interval log(T)= 4.0 - 8.0  
		with steps of log(T) = 0.1 .
		You can either select a constant pressure OR a constant 
		density for all the lines; if you select a constant pressure,
               for each ion the contribution function is calculated at an 
               electron density N_e equal to the ratio of the pressure 
               and the temperature of maximum ionization fraction:  
               C=C( T, N_e= P/T_ion )  
               The C(T) values are stored by GET_CONTRIBUTIONS in the output 
		file OUTPUT.CONTRIBUTIONS that can be used later to calculate
		the DEM, changing various parameters,
		without having to start again and read the CHIANTI database,
		which can take long time.

		In the case no theoretical lines corresponding to an observed
		line are found, the routine writes the wavelength of the line
		(to be excluded from the fit) in the array
		EXCLU_OBS_WVL_NO_TEO. The lines with no theoretical 
		counterparts are then automatically  excluded from the fit by 
	 	CHIANTI_DEM. You might consider the possibility to start again
		incrementing the DELTA_LAMBDA_OBS, to see if there are 
		theoretical lines in the vicinity.
		Note: if you want to exclude some of the observed lines from 
		the fit, you just have to use the keyword EXCLUDE_OBS_WVL, 
		BUT  GET_CONTRIBUTIONS will store anyway the results (if any)
		in the C(T) file.

		After having excluded the lines in EXCLUDE_OBS_WVL, 
		any *.abund file present in the CHIANTI database or in 
		the working directory can be selected, and eventually edited,
		if you like to change some abundances. 
		Then the $G(T)$ are calculated, multiplying each theoretical
		line by the abundance factor. Then the
		theoretical lines contributing to each blend are sorted by
		intensity and then their G(T) can be plotted if the keyword
		PLOT_GT is activated. It is recommended to do this the first 
		time, to check if there are some observed lines terribly 
		blended with lines of other elements, in which case it is
		better to exclude them with a second run (if you are not 
		sure about the abundances).
		Then the G(T) for each blend are summed and plotted.
		Then  the fit starts calling DEM_FIT. 
		A series of parameters can change the 
		result (DEM), especially the number and position of the mesh
		points of the spline that represents the DEM. The keyword
		MESH_POINTS serves for this purpose. 
		The other keywords that control the fit are N_ITER, DCHISQ_M.
   		At the end of the fit, the files OUTPUT.DEM and OUTPUT.GENERAL
		are created.



 Use         : IDL>chianti_dem,output='serts89',file_input='serts89.obs',$
				pressure=3.e15


 Examples    : 
		Assume you have a file input 'serts89.obs' like this:
		
		243.031   491.    97.    0.1  He II
		256.323   1580.   186.   0.1  He II b
		315.024   253.    31.    0.1  Mg VIII
		335.401   10400.  1650.  0.1  Fe XVI
		319.839   113.    14.    0.1  Si VIII
		356.027   218.    25.    0.1  Si X 
		
		IDL>chianti_dem,output='serts89',file_input='serts89.obs',$
		   pressure=3.e15,cut_gt=1e-30,/plot_gt

		After having selected the  ionization file,
		the C(T) (with MAX(C(T)) gt 1e-30)  are stored in the file
		'serts89.contributions'. Then select one of the abundance 
		files. 
		Have a look at the plots of the  G(T), and annotate
		if there is a line you want to exclude, let's say the second.
		Have a look at the DEM obtained ('serts89.dem') and at 
		the details contained in the file 'serts89.general'. 
		Maybe there is another line you want to exclude, let's say 
		the last one. Maybe you want to change the mesh points, too.
		So run
		IDL>chianti_dem,output='serts89_2',file_input='serts89.obs',$
		file_gt='serts89.contributions',$
		exclude_obs_wvl=[243.031,356.027 ],$
		mesh_points= [4.5,5.,5.5,6.2,7.5]
		
		The files 'serts89_2.dem' and 'serts89_2.general' will be
		created. They have the essential information about what you 
		did.

    
 Inputs      : various, all in form of keywords. The required ones are 
		OUTPUT and FILE_GT (or  PRESSURE/DENSITY)
               
               
 Opt. Inputs : various... see the software note.
               
 Outputs     : OUTPUT.CONTRIBUTIONS  
		Created only if the keyword FILE_GT is NOT set. 
		Is the file where all the contribution  functions G(T) are 
		stored. In the first two lines  the ionization equilibrium 
		file name, and the constant value of pressure or density 
		adopted are reported. Then for each line you have reported  
               the observed wavelength, the theoretical one, the element and
		ionization stage, then the C(T) values. At the end the 
		specification for each transition.

		OUTPUT.DEM
		Is the file where the log T and log DEM values are 
		written, with a format suitable 
		as input for the DMM_SS procedure,that calculates the 
		synthetic spectrum. At the end some info on how it was 
		calculated are printed.

		OUTPUT.GENERAL
		Is the file where general information is stored.
		The abundance file, the ionization equilibrium file and the
		constant value of pressure or density  used are reported. 
		Then there is one line for each
		observed line, with the provisional identification, the 
		observed wavelength, the observed flux, the theoretical one
		(corresponding to the DEM), the error on the flux,
		the square of the difference between the theoretical and the 
		observed fluxes divided by the error (this number should be 
		close to zero if the line is well reproduced), and finally
		the ratio of the theoretical flux versus the observed one 
		(which should be close to 1).
		After this line, there is one line per each theoretical line
		contributing to the blend, with the identification, the 
		theoretical wavelength, the configuration and terms, and the
		contribution to the total theoretical flux (in percentage) 
		of each line in the blend.

		OUTPUT.OUT
		This file , toghether with OUTPUT.DEM , 
		can be used to reproduce the results  using 
		user-written software. See the software notes.
		The ouput has this format: 
		format='(a20,1x, 1f10.3,1x, 3e10.3, 1x,  f4.2,1x,f6.3)'	
	
 Opt. Outputs:
		An abundance file with the modifications inserted.
	
		Postscript files of the G(T).
	
		A postscript file with the DEM (OUTPUT.DEM.PS)
		
               A postscript file with other plots too (OUTPUT_4PLOTS.PS)

 Keywords    : 


	ARCSEC: 
		optional. If set, it means that the intensities in the input
		file are per arcsec-2 .
		These intensities are then  converted to 
		 sterad-1 .

	CUT_GT:	
		optional. If set, only the those theoretical lines that
		have a MAX(C(T))  greater than the value set, are kept; 
		it is useful to set this value in order to reduce the number 
		of lines in the file where the C(T) are stored.;  
		if not set, a default value of 1e-30 is adopted.

	DCHISQ_M:
		optional. If not set, a default value of DCHISQ_MIN=1.e-5 
		is assumed. For each iteration, the CHISQ and it's variation 
		are calculated. As long as the iteration achieves an
		improvement in CHISQ greater than  DCHISQ_MIN , another 
		iteration will be performed.

	DEM_FILE:
		optional.If set (,/DEM_FILE) you have to choose a DEM file to 
		be used as a start, instead of the default constant value of 
		10.^22.
		You can either choose one of the files in the CHIANTI database
		or any you have in the working directory. 
		The values in the file are marked as crosses, the mesh points
		are marked with triangles.

	DENSITY : 
		the value of the density (Ne). Required if you do NOT have
		already the contribution  functions G(T). 

	EXCLUDE_OBS_WVL:
		optional.
		If set, you can  exclude some of the observed lines from 
               the fit. Note that even if you set this keyword and run 
		GET_CONTRIBUTIONS all the theoretical lines found corresponding
		to all the lines in the input file are written in the C(T) 
		file. It is only in the fit that the lines are excluded.

	FILE_GT:
		optional.
		If NOT set, the routine GET_CONTRIBUTIONS is called.
               If set, it has to specify the name of the file created by 
		GET_CONTRIBUTIONS, where all the contribution  functions G(T) 
               are stored. In the first two lines the ionization equilibrium 
		file name, and the value of the pressure or density 
               adopted is reported. Then for each line you have reported  
               the observed wavelength, the theoretical one, the element and
               ionization stage, then the C(T) values. At the end the 
               specification for each transition.

	FILE_INPUT:
		optional.
 		if set, you are not requested to select the observation file
		using a widget-type search.
		The input file  must contain 5 columns, unformatted:
		1)the observed wavelength (A)
		2)the observed flux in erg cm-2 s-1 st-1
		3)the corresponding error on the flux in erg cm-2 s-1 st-1
		4)half the width (A) of the range (centered on the observed 
		  wavelength) where you want to look for the corresponding 
		  theoretical lines. A value of HWHM or more would do.
		5)The identification, written as string (max 20 characters)

	MESH_POINTS:    	
		optional. It is a vector that specifies the mesh points for the
		spline that represent the fitted DEM, in log(T).
		If not set, the default values 
		[4.,4.5,5.,5.5,6.,6.5,7.,7.5,8.0] are assumed.

	N_ITER:
		optional.It is the number of iterations of the fitting routine.
		If not set, a default value of 20 is assumed. 
		Changing this value alone might not affect the fit, since 
		also the value of DCHISQ_MIN is checked during the fit.

	N_MATCHES:   
		optional.          
		In the unlikely event that more than 50 (default value for 
		N_MATCHES) theoretical lines corresponding to an observed
		line are found, the routine stops; in this case, you have to 
		start again setting N_MATCHES equal to a greater number. 

	OUTPUT  :
		required.
	  	It is the output name. Suffixes will be added when creating 
		the various outputs.

	PHOT:
		optional.
		If set, it means that in the input file the intensities
		are in photons instead of ergs. 

	PLOT_GT:
		optional.
		If set (,/PLOT_GT),  plots of the  G(T) for each 
		observed line not excluded are created.

	PRESSURE:     		
		the value of the pressure (Ne T). Required if you do NOT have
		already the contribution  functions G(T).

	QUIET:
		optional. Set to avoid various messages and the details of the 
		result.

 Calls       : GET_CONTRIBUTIONS
		DEM_FIT
		ZION2SPECTROSCOPIC
		print2d_plot
		
 Common      : obs, 	obs_int,obs_sig,n_obs
		obs_o,	obs_wvl,obs_id,obs_delta_lambda
 		dem, 	d_dem_temp,dem_temp,log_dem_temp,log_t_mesh,log_dem_mesh
		contr,	ch_tot_contr
		ab,	abund_name,abund_info,xuvtop,ioneq_name

		these are the commons with GET_CONTRIBUTIONS.PRO:

		various,	exclu_obs_wvl_no_teo,const_net,$
		 dem_temp_min,dem_temp_max,n_dem_temp,$
		 ch_wvl,ch_l1,ch_l2,ch_id,ch_z,ch_ion,ch_contr_wa,$
		 ch_pop,ch_contr_list,	 ch_term,ch_n_contr

 Restrictions: 
		In the unlikely event that more than 50 (default value for 
		N_MATCHES) theoretical lines corresponding to an observed
		line are found, the routine stops; in this case, you have to 
		start again setting N_MATCHES equal to a greater number. 

		Also, if the starting DEM values are not proper, or you 
		don't have enough constraints at lower and higher temperatures,
		you might get "strange" results, and should consider using 
		different starting values.

		Of course you need to have the enviroment variable CDS_SS_DERE
		pointing to the CHIANTI database top directory.

               
 Side effects: None known yet.
               
 Category    : spectrum
               
 Prev. Hist. :
       Written by Ken Dere (NRL) as part of the CHIANTI package 
       in collaboration with Brunella Monsignori Fossi, Enrico Landi
       (Arcetri Observatory, Florence), Helen Mason and Peter Young
       (DAMTP, Cambridge Univ.). Incorporated into the CDS software.  

 Written     : 
       V. 1.0  5 November  1997 Giulio Del Zanna (GDZ), 
	UCLAN  (University of Central Lancashire, UK)


 Modified    : Removed the print2d_plot subroutine. Increased the default value
               of N_MATCHES from 20 to 50.  Changed way to deal with xuvtop.
               GDZ, 31-Oct-2000

 Version     : 2.0 GDZ, DAMTP,  31-Oct-2000

              V.3, Giulio Del Zanna (GDZ)
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

 VERSION     :  3, 21-May-2002, GDZ 


PLOT_DEM

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	PLOT_DEM

 PURPOSE:

	To plot differential emission measure (DEM) values

 CATEGORY:

	Widgets.

 CALLING SEQUENCE:

       PLOT_DEM,filename


 INPUTS:

	filename:  the name of the DEM file to be plotted.  The file must b
                  in the standard CHIANTI format for DEM files.  If filename 
                  is a blank string ('') then an interactive window will come 
                  up to allow the user to select a DEM file from the CHIANTI 
                  DEM directory or some other directory.	

	
 KEYWORD PARAMETERS:

	PSFILE:	If set, the a postscript plot will be place in the 
               file 'psfile' specified by the user


 OUTPUTS:

       None, other than a plot




 EXAMPLE:

             > plot_dem,'ademfile.dem'
         or
             > plot_dem,''

 MODIFICATION HISTORY:

 	Written by:	Ken Dere
	June 1998:     Version 1.0
	Version 2, 21-Dec-2000, William Thompson, GSFC
		Modified for better cross-platform graphics capability

       V.   3, 21-May-2002, Giulio Del Zanna (GDZ) 
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

 VERSION     :   3, 21-May-2002 



INTEGRAL_CALC

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME: INTEGRAL_CALC
       
 PURPOSE:

       To compute the atomic data integral for use in column or volume
	emission measure work.

 CATEGORY:

       Scientific analysis

 EXPLANATION:

 	Defining

	G(T) = 0.83 * Fr(T) * N_j * A_ji / N_e

	where Fr(T) is the ionisation fraction (e.g., from Arnaud & 
	Rothenflug), N_j the relative population of level j, A_ji the 
	A-value for the j->i transition and N_e the electron density. The 
	0.83 is the ratio of hydrogen to free electrons, which is constant 
	above around 10^4 K. This function is sharply-peaked at a 
	temperature T_mem (the temperature of maximum emission, which can 
	be different from the temperature of maximum ionisation, T_max) 
	and so an oft-used approximation is to take G(T) constant in the 
	range log T_mem - 0.15 to log T_mem + 0.15 and zero outside. The 
	value of the constant, which we call C_lambda here, is then given 
	by

	C_lambda =    integral { G(T) dT }
                     --------------------
                  T_mem * (10^0.15 - 10^-0.15)

	If EM(s) is the column emission measure, F the flux (erg cm-2 s-1)
	in a line lambda, Ab the abundance of the element and DE (erg) the
	energy for the transition, then:

	F = DE * Ab * C_lambda * EM(s)

	If we are dealing with intensities I (erg cm-2 s-1 sr-1) then:

	4pi * I = DE * Ab * C_lambda * EM(s)

	This program extracts the ionisation balance and emissivities from 
	the CHIANTI database and calculates C_lambda for all lines in the 
	specified wavelength interval WRANGE by integrating over 
	0.02 dex temperature intervals, using the IDL INT_TABULATED function.

	The C_lambda functions for all the lines in the selected wavelength 
	range WRANGE are displayed as well as the temperature of maximum 
	emission (T_mem), DE*C_lambda and 4pi/(DE*C_lambda). These latter 
	two quantities are useful for the emission measure analysis.

	Any combination of the displayed lines can then be blended and the 
	corresponding quantities for the blend will be displayed.

	The function Fr(T) * N_j * A_ji can also be plotted at this stage.

 CALLING SEQUENCE:

       INTEGRAL_CALC, IZ, ION, [WRANGE=WRANGE, /CHOOSE, DENS=DENS]

 EXAMPLES:

	INTEGRAL_CALC, 26, 13, WRANGE=[200,205], /CHOOSE

	INTEGRAL_CALC, 14, 10, WRANGE=[250,270], DENS=10.

 INPUTS:

	IZ:	The atomic number of the ion
	ION:	The spectroscopic number of the ion (e.g., 12 = XII)

 OPTIONAL INPUTS:

	DENS:	The density at which the emissivities are calculated 
		(default=10.)
	WRANGE: Wavelength range for which C_lambda functions are 
		calculated. If not given, then the 10 strongest lines 
		are printed.
	INDEX:	Particular elements in the emissivity structure can be 
		selected with INDEX. This allows integral_calc to be run 
		'silently'. The output is contained in the OUTSTR structure. 
		If index is given as, e.g., [7,8], then the C_lambda 
		functions for these two lines are summed and output.
	PATH:	Directly specify the directory path where the Chianti data 
		for the ion is found

       ABUND_FILE  The name of a CHIANTI abundance file. This is used for 
               calculating the proton to electron ratio. Default is 
               !abund_file.

       IONEQ_FILE  The name of a CHIANTI ion balance file. This is used for 
               calculating the proton to electron ratio and evaluating 
               the T_max of the ion. Default is !ioneq_file.

       RADTEMP  The blackbody radiation field temperature (default 
                6000 K).

       RPHOT    Distance from the centre of the star in stellar radius 
                units. I.e., RPHOT=1 corresponds to the star's surface. 
                (Default is infinity, i.e., no photoexcitation.)

 KEYWORDS:

	CHOOSE:	Allow ion balance calculations to be selected manually 
		(see choose_ioneq.pro routine).

 OPTIONAL OUTPUTS:

	OUTSTR:	A structure with the following tags

		.tmem	- the T_mem for the line(s)
		.dec	- total( de * c_lambda )
		.pidec	- 4 * pi / total( de * c_lambda )

	Only output when INDEX is specified.

 COMMON BLOCKS:

	None.

 CALLS:

	EMISS_CALC, CH_GET_FILE, READ_IONEQ

 HISTORY:

	Ver.1: PRY, 28-JUN-97.
	Ver.2: PRY, 7-OCT-97. Added TEMPI and GOFT, for plotting.
	Ver.3: PRY, 31-JUL-98. Added PATH.
	Ver.4: PRY, 6-APR-99. Added INDEX, OUTSTR. Removed TEMPI and GOFT 
		(these can be got from the g_of_t routine).
       Ver.5: PRY, 9-Dec-01. Modified for v.4 of CHIANTI.

       V.6, 21-May-2002, Giulio Del Zanna (GDZ) 
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

       V.7, 06-Aug-02 GDZ
              Changed the use of CHIANTI system variables. 
       

 VERSION     :   7, 06-Aug-02 


READ_ABUND

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	READ_ABUND

 PURPOSE:

	to read CHIANTI abundance files

 CATEGORY:

	science.

 CALLING SEQUENCE:

       READ_ABUND,File,Abundance,Reference


 INPUTS:

	File:  the name (string) of the file containing the abundance values
                (relative to hydrogen) usually of the form 
                 '!xuvtop/abundance/*.abund'


	

 OUTPUTS:

	Abundance:  an array of abuncance values
       Reference:  a string containing the reference to the chosen set
                   of abundances in the scientific literature



 PROCEDURE:

	You can describe the foobar superfloatation method being used here.

 EXAMPLE:

             > read_abund,'allen.abund',abundance,ref
               abundance(26) = abundance of iron relative to hydrogen
               quoted by C.W. Allen in Astrophysical Quantities

 MODIFICATION HISTORY:
 	Written by:	Ken Dere
	March 1996:     Version 2.0

       V.   3, 21-May-2002, Giulio Del Zanna (GDZ) 
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

 VERSION     :   3, 21-May-2002 


READ_DEM

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	READ_DEM

 PURPOSE:

	to read values the differential emission measure as a function 
       of temperature

 CATEGORY:

	science.

 CALLING SEQUENCE:

       READ_DEM, File, T, Dem, Ref


 INPUTS:

	File:  the name of the file containing the DEM values, usually in
               !xuvtop/dem/*.dem	


 OUTPUTS:

	T:  Log10 values of temperature (K)
       Dem:  Log10 values of the differential emission measure
       Ref:  the reference to the DEM values in the scientific literature


 OPTIONAL OUTPUTS:

	Describe optional outputs here.  If the routine doesn't have any, 
	just delete this section.



 EXAMPLE:

             > read_dem,!xuvtop+'/dem/active_region.dem',t,dem,ref

 MODIFICATION HISTORY:
 	Written by:	Ken Dere
	March 1996:     Version 2.0

       V.   3, 21-May-2002, Giulio Del Zanna (GDZ) 
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

       Ver.4, 20-Nov-2002, Peter Young
           DEM values of -1 caused errors, so this has been corrected.

 VERSION     :   4, 20-Nov-2002 


READ_IONEQ

[Previous Routine] [Next Routine] [List of Routines]

 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
	READ_IONEQ

 PURPOSE:

	to read files containing the ionization equilibrium values

 CATEGORY:

	science.

 CALLING SEQUENCE:

       READ_IONEQ, File, T, Ioneq, Ref


 INPUTS:

	File:	for example, !xuvtop+'/ioneq/arnaud_rothenflug.ioneq'

 OPTIONAL INPUTS:

	None:
	

 OUTPUTS:

	T:  array of log10 temperatures
       Ioneq:  3-d array (T,element,ion) 
               of the fractional abundance of the ion in
              ionization equilibrium.
       Ref:  reference in the scientific literature


 EXAMPLE:

             > read_ioneq,!xuvtop+'/ioneq/arnaud_rothenflug.ioneq'
             > help,t,ioneq
             > T               FLOAT     = Array(41)
             > IONEQ           FLOAT     = Array(41, 28, 29)
             > print, minmax(t)
             >  4.00000      8.00000
             > print,t(20)
             >  6.0000
             > print,ioneq(20,25,9)
             >   0.269                  = fractional abundance of  Fe X in
                                          ionization equilibrium 

 MODIFICATION HISTORY:
 	Written by:	Ken Dere (KPD)
	March 1996:     Version 2.0
       March 1999:     KPD to read both number of temperature and number 
                       of elements

       25-Oct-2000     V. 4, Giulio Del Zanna (GDZ).
                       Corrected to interpret the '-1' as a reference only
                       if within the first 3 columns

       V.  5, 21-May-2002, Giulio Del Zanna (GDZ) 
                   generalized directory concatenation to work for
                   Unix, Windows  and VMS. 

       v.6, 25-Oct-2004, Peter Young
            modified format statement so that it will read any number of
            temperatures.

       V 7, 25-May-2005, GDZ 
                  corrected routine header.

 VERSION     :   7, 25-May-2005


CH_READ_FITS

[Previous Routine] [Next Routine] [List of Routines]
 PROJECT:  CHIANTI

       http://wwwsolar.nrl.navy.mil/chianti.html

       CHIANTI is an atomic database package for the calculation of
       continuum and emission line spectra from astrophysical plasmas. It is a 
       collaborative project involving the Naval Research Laboratory
       (Washington DC, USA), the Arcetri Observatory (Firenze, Italy), and the
       Cambridge University (United Kingdom).


 NAME:
       CH_READ_FITS

 PURPOSE:

       Read  standard CHIANTI FITS binary table data containing the output from
       CH_SYNTHETIC and output a TRANSITIONS structure.

 CALLING SEQUENCE:

       CH_READ_FITS,  Filename, TRANSITIONS

 INPUTS:

       Filename = String containing the name of the CHIANTI FITS file written
       by CH_WRITE_FITS.

 OUTPUTS:

       TRANSITIONS = Structure to be written.

 OPTIONAL INPUTS: none

 KEYWORDS: none


 NOTES:
 

 CALLS:
        MRDFITS, ADD_TAG
	
 COMMON BLOCKS: none.

 RESTRICTIONS:

       (3)     The input FITS file must have been written by  CH_WRITE_FITS

 PREV. HIST. :


 EXAMPLE:

         ch_read_fits,  'file.fits', transitions 

 WRITTEN     : 

       Ver.1, 8-Apr-02 Giulio Del Zanna (GDZ)
       V.2 GDZ 31 May 2002 added more checks.

 MODIfICATION HISTORY:

 VERSION     : 2, 31 May 2002 


CH_WRITE_FITS

[Previous Routine] [Next Routine] [List of Routines]
 PROJECT:  CHIANTI

       CHIANTI is an Atomic Database Package for Spectroscopic Diagnostics of
       Astrophysical Plasmas. It is a collaborative project involving the Naval
       Research Laboratory (USA), the University of Florence (Italy), the
       University of Cambridge and the Rutherford Appleton Laboratory (UK). 


 NAME:
       CH_WRITE_FITS

 PURPOSE:
       Write  standard FITS binary table data from CHIANTI input  structure.

 CALLING SEQUENCE:
       CH_WRITE_FITS, Input, Filename

 INPUTS:

       Input = Structure to be written to FITS file.


 OUTPUTS:


       Filename = String containing the name of the file to be written.
                CH_WRITE_FITS creates two binary table extension in a single
                FITS file. The second one is appended as a new extension.

 OPTIONAL INPUTS:  Header COMMENTS.

 KEYWORDS: 
           head1, head2
          Additional  COMMENTS to be added at the bottom of the two binary tables.


 NOTES:
 
       Any existing FITS file can be over-written or not.
       Use CH_READ_FITS  to convert the FITS file back into a structure. 

 CALLS:

	FXPAR(), FXADDPAR, IS_IEEE_BIG(), HOST_TO_IEEE, DIALOG_MESSAGE

 COMMON BLOCKS: none.

 RESTRICTIONS:
       (1)     Limited to 127 columns in tables by IDL structure limits.
       (2)     String columns with all columns of zero length crash the
               program
       (3)     The input structure has to be of the type TRANSITIONS.

 PREV. HIST. :

       The subroutines in this procedure are extracted without modifications from
       the MWRFITS.PRO routine, written by T. McGlynn Version 0.95 2000-11-06
       and present in the ASTRON library (in SolarSoft under /gen/idl_libs/astron/).

 EXAMPLE:

         ch_write_fits, transitions , 'test.fits'

 WRITTEN     : 
       Ver.1, 22-May-02 Giulio Del Zanna (GDZ)


 MODIfICATION HISTORY:

 VERSION     : 1, 22-May-02, GDZ


WHICH_LINE

[Previous Routine] [Next Routine] [List of Routines]
 NAME

     WHICH_LINE

 PROJECT

     CHIANTI

 PURPOSE:

     Upon given an ion name and wavelength, this routine prints out a list
     of possible line IDs for the wavelength. Wavelengths within 1% of the
     input wavelength are searched for.

 INPUTS

     IONNAME  Name of an ion in the CHIANTI format. E.g., 'fe_13' for Fe XIII.

     WVL      A wavelength in angstroms.

 OUTPUTS (to screen)

     Prints a list of atomic transitions and wavelengths for lines close to
     the input wavelength. A '*' is placed next to the closest wavelength
     match.

 KEYWORDS

     NARROW   Narrows the search range to 0.02% of the specified wavelength.

 EXAMPLE

     IDL> which_line,'o_6',1032
     Wavelength   i   j Lower level           Upper level             A-value
       1037.615   1   2 1s2.2s 2S1/2        - 1s2.2p 2P1/2          4.21e+008
       1031.914   1   3 1s2.2s 2S1/2        - 1s2.2p 2P3/2          4.28e+008

 CALLS

     CONVERTNAME, ZION2FILENAME, READ_WGFA2, READ_ELVLC

 HISTORY

     Ver.1, 22-Jun-2004, Peter Young


USE_CHIANTI

[Previous Routine] [List of Routines]
 Project     : CHIANTI

       CHIANTI is an atomic database package for the calculation of
       continuum and emission line spectra from astrophysical plasmas. It is a 
       collaborative project involving the Naval Research Laboratory
       (Washington DC, USA), the Arcetri Observatory (Firenze, Italy), and the
       Cambridge University (United Kingdom).
 
                   
 Name        : USE_CHIANTI
               
 Purpose     : Sets up system variables for use of CHIANTI routines
               
 Explanation : The  CHIANTI software uses system variables
               that have to be defined. This routine is called by the 
               CHIANTI routines if these system variables are not defined.

               ** If one is using the solar-soft package, these should 
               already be defined*****.

               ** If the CHIANTI package is used as stand-alone, then 
               this routine can be used for the setup with e.g.:

               use_chianti,'/home/data/chianti/'

               if /home/data/chianti/ points to the actual place where 
               the CHIANTI top directory is.

               
 Use         : IDL> use_chianti, '/home/data/chianti/', $
                                 [ioneq= , abund=]
    
 Inputs      : None
               
 Opt. Inputs : The full pathname of the CHIANTI top directory.
               
 Outputs     : None
               
 Opt. Outputs: None
               
 Keywords    : IONEQ  - to define the default ionization eq. file to be used.
               ABUND  -  to define the default abundance file to be used.

 Calls       : None

 Common      : None
               
 Restrictions: None
               
 Side effects: None
               
 Category    : 
               
 Prev. Hist. : Based on use_dere_chianti, written by C D Pike, RAL

 Written     : Giulio Del Zanna (GDZ)  DAMTP  (University of Cambridge, UK) 
               
 Modified    : Version 1, GDZ 10-Oct-2000
               Version 2, GDZ 10-Jan-2001
               added the definition of the !abund_file

               V. 3, GDZ, 2-May-2002 Modified substantially, adding a new
               system variable.

               V.4, 10-July-2002 GDZ
                 Removed the definition of !chianti_top, upon request.

               V.5, 25-July-2002, GDZ 
                Fixed a problem with IDL versions earlier than 5.3 (the routine
                would not compile). ALso, introduced the use of concat_dir for
                cross-platform compatibility.
                    
               V.6, 06-Aug-02 GDZ
                 Changed the use of CHIANTI system variables. Added comments on
                 the which CHIANTI version is used.
               V.7 12-Aug-02 GDZ Changed default abundance file. Removed '***'
               V.8, GDZ 13-Feb-2003
                   Changed default ioneq  file, to include ALL the elements.

 Version     : V.8,  13-Feb-2003