# Modeling a spectrum

Experience shows that in order to identify a species in a spectral survey securely, it is often necessary to make a basic model of the candidate line. For example, you may want to check if the relative intensities of each candidate line imply a reasonable kinetic temperature. You may also want to check that other lines with similar predicted intensity are also detected.

Weeds allows to compute the emission of a source under the assumption of local thermodynamical equilibrium. The source is assumed to have, for each species, a given column density, excitation temperature, line FWHM, systemic velocity and size. Several components (with e.g. different temperatures and/or sizes) can be added. Weeds will compute the emission of these various components – taking into account the line opacity and the beam dilution factor – and it will display them on the observed spectrum. The different source parameters can be adjusted until a good match between the model and the observation is obtained. More details on the formulas used can be found in § .

Let us go back to the methanol lines that we have identified in our spectrum (see Fig. 2). The emission can be modeled using the `modsource` command, which takes two arguments: the name of the file containing the source parameters, and the size of the antenna that we have used for the observations, in meters. To model the emission, we need to use the JPL database, because the CDMS does not provide the partition function for this species:

    [fontsize=\scriptsize]
    LAS90> use in jpl
    I-USE,  jpl (online) selected

Our model file, that we have named `iras16293.mdl`, looks like this:

    [fontsize=\scriptsize]
    ! species	Ntot	Tex  source_size v_off	width
    ! 		(cm-2)	(K)	(”)	 (km/s)	(km/s)
    CH3OH		2.0e15	10	10	 0	 3.0

Lines that start with a `!` are comments: they are ignored. The last line gives the name of the species, its column density, excitation temperature, the size of the emission in arc seconds, the offset velocity (with respect to the source velocity in the class file header), and the line width. The spectrum, as it would be observed with the IRAM-30m antenna, can be computed with:

    [fontsize=\scriptsize]
    LAS> modsource iras16293.mdl 30
    I-SELECT,  4 lines found in the frequency range 96710.0 to 96770.0 MHz
    I-MODSOURCE,   4 CH3OH lines found in the frequency range
    I-MODSOURCE,  log10 of the partition function at 10.0 K from jpl is 1.3419
      # Species        Freq[MHz] Err[MHz] Eup[K]  Gup  Aij[s-1]    Upper level -- Lower level    Origin Tau
      1 CH3OH          96739.358   0.002    12.5    5  2.56e-06        2-1   0 -- 1-1   0           jpl 7.25e-01
      2 CH3OH          96741.371   0.002     7.0    5  3.41e-06        2 0 + 0 -- 1 0 + 0           jpl 1.69e+00
      3 CH3OH          96744.545   0.002    20.1    5  3.41e-06        2 0   0 -- 1 0   0           jpl 4.56e-01
      4 CH3OH          96755.501   0.002    28.0    5  2.62e-06        2 1   0 -- 1 1   0           jpl 1.59e-01
    I-MODEL,   Blanking value:   -1000.00000
    I-RESAMPLE,  Frequency resolution: .31252 MHz (observatory), .31252 MHz (rest frame)
    I-MODSOURCE,  Model has been stored in memory

For efficiency reasons, the command computes the spectrum over the frequency range covered by the current window only. In our case, four methanol lines are found in the frequency range. Note the `/verbose` option, that prints the frequency, upper level energy and statistical weight, Einstein coefficient and computed opacity at the line center. The `modsource` command itself does not plot anything; it just stores the observed and modeled spectrum into buffers. These buffers can be listed with:

    [fontsize=\scriptsize]
    LAS90> memorize
    I-MEMORIZE,  Current memories:
    OBS           TB_MODEL

The `TB_MODEL` buffer contains the modeled brightness temperature. The buffer can be retrieved with the `retrieve` command. The `OBS` buffer contains the observed spectrum, which is saved automatically by `modsource`.

The predicted spectrum can be drawn over the observed spectrum using the `modshow` command5. This command gives the spectra shown on Fig. 3. As it can be seen on this figure, our model is in quite good agreement with the observed spectrum.

Figure 3: Observed (black histogram) and predicted spectra (in red) displayed with the modshow command.

Line indexes can be used together with `modshow` to examine other lines between 90 and 100 GHz, and to check whether our model can also reproduce them. For example:

    [fontsize=\scriptsize]
    LAS90> lfind "CH3OH" 90e3 100e3 /sortby e
    I-SELECT,  142 lines found in the frequency range 90000.0 to 100000.0 MHz
    LAS90> lget 4
    LAS90> lplot
    LAS90> modsource iras16293.mdl 30
    I-SELECT,  1 lines found in the frequency range 95898.6840807 to 95929.9359193 MHz
    I-MODSOURCE: 1 CH3OH lines found in the frequency range
    I-MODEL,   Blanking value:   -1000.00000
    I-RESAMPLE,  Frequency resolution: .31252 MHz (observatory), .31252 MHz (rest frame)
    I-MODSOURCE, Model has been stored in memory
    LAS90> modshow

Note that we must use the `modsource` command again, because the command computes a spectrum only over the frequency range covered by the current scan. We must also rebuild the line index after each `modsource`, because the commands builds its own line index, containing only lines in the frequency range covered by the current window. Scripts can be easily created to loop over line index and examine each of the observed and predicted lines.