Extended IDL Help

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

     ? mk_html_help

at the IDL command line prompt.

Last modified: Tue Jan 4 12:52:38 2011.


List of Routines


Routine Descriptions

CH_LINE_LIST

[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

(See synt_spec/ch_line_list.pro)


CH_SS

[Previous Routine] [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.

       V.13, 3-Oct-2005 GDZ
          Replaced FOR i=0, calls with FOR i=0L, calls, so 
          the routine does not crash with a large number of lines.


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

 VERSION     :  V.13, 3-Oct-2005

(See synt_spec/ch_ss.pro)


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.

         v.28,  31-Aug-2005, GDZ
                 Fixed bug concerning the case when multiple temperatures 
                 (i.e. logt_isothermal) were defined as input. The program
                 was, in some cases, returning null values.
                 The problem was the use of nt, the number of good temperatures
                 for each ion, for the definition of the arrays, instead of
                 using the number of logt_isothermal values (and the t_index).

         v.29,  22-Aug-2008, Peter Young
                 Changed list_goft_new and this_goft to be double
                 precision, and changed str.goft to be double precision.

         v.30,  12-Jun-2009, Enrico Landi
                 Changed the definition of the temperature array for ion fractions
                 in the IONREC variable, now taken directly from the output of
                 READ_IONEQ.PRO

 VERSION     : 30,  12-Jun-2009

(See synt_spec/ch_synthetic.pro)


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.
  
       ALL        Include all lines, i.e. also those for which wavelengths 
                  are only theoretical and not observed. 

  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.
 
       V.8, 14-Sept-2005 GDZ 
              Added ALL keyword and modified header, error message.

       V.9, 3-Oct-2005, GDZ
              Now the FOR loop accepts more than 32000 lines.

       V.10, 7-Oct-2009, Peter Young
              The keyword EM_INT is now used in the call to the
              continuum routines.


 VERSION     : 
       Version 10, 7-Oct-2009
        

(See synt_spec/isothermal.pro)


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  If set, then print out information while the routine is
              running.

     KEV      If set, then the output spectrum is in units 
              erg cm^-2 s^-1 keV^-1.

 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). 

               v.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.

               v.16, 31-Aug-2005, GDZ
                 Fixed a typo (keyowrd_set).

               v.17, 10-Mar-2006, Peter Young
                 The /keV keyword is now passed to the continuum routines,
                 rather than make_chianti_spec performing the conversion
                 itself.

               v.18, 4-May-2006, Peter Young
                 Changed LAMBDA to be a double array in order to correct a
                 problem with line profiles for very small bin sizes.
                 Problem pointed out by Matthew West (Imperial).

               v.19, 16-Nov-2007, Vincenzo Andretta, INAF/OACN (andretta@oacn.inaf.it)
                 Fixed a problem with units when LOGT_ISOTHERMAL is set.

               v.20, 7-Oct-2009, Peter Young
                 Modified call to continuum routines to use new
                 EM_INT keyword (for isothermal plasmas).
                 
 
 VERSION     :  20, 7-Oct-2009, Vincenzo Andretta

 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

(See synt_spec/make_chianti_spec.pro)


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


(See synt_spec/synthetic.pro)


SYNTHETIC_PLOT

[Previous 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

(See synt_spec/synthetic_plot.pro)