Jscript Tutorial Wolfgang Unger and Tobias Sommer



Yüklə 0,62 Mb.
Pdf görüntüsü
səhifə16/21
tarix07.11.2018
ölçüsü0,62 Mb.
#78679
1   ...   13   14   15   16   17   18   19   20   21

gether with the other spectra of the fit scenario in the Specbar and the limits for the shift

are visible in the Fitting window.

Remarks

• By loading a new spectrum into the fit scenario, only the spectrum itself, meaning



the channel/wavelength-intensity plot and the file name is changed. The “ObjectKey”

property however does not change and, if required, must be changed separately by

using the command:

fit.ReferencesInfo[0].ObjectKey = "..."

• When limiting the shift it is important that the default value of the shift is in between

the low limit and the high limit.

• The “squeeze” of each reference spectrum can be limited in a similar way. Just sub-

stitute


DoasFitReferenceInfo.Coefficients.Shift

by

DoasFitReferenceInfo.Coefficients.Squeeze



• Spectra can only be implemented in a fit scenario with JScript, if the were opened

within the same JScript before. Hence it is not possible to include a spectrum which

was opened manually beforehand and the using the the command:

MeasSpec = Specbar.CurrentSpectrum;

In this case

fit.ReferencesInfo[0].ReferenceSpectrum = MeasSpec;

will not work.

• For setting the low limit of the fit range the command:

fit.FitRanges[0].LimitLow = 300;

is used. FitRanges[] is an array thus several fit ranges can be defined if required.

The value “0” here represents the first fit range. It can be useful to define several fit

ranges though if e.g. broken pixels or strong absorption lines of interfering absorbers

should be excluded.

• For more information to modify the settings of the different reference spectra search

for “DoasFitReferenceInfo” in the Programming Documentation of DOASIS (Help

menu - Programming Documentation). For properties of the fit itself (like fit range,

polynomial...) search for “DoasFit”.

• Sometimes it is useful to fix the fit coefficient of certain reference spectra (see Fig. 11.2

“Fix Parameter”. For setting the parameters of the fit coefficient the Tab “Coefficient”

instead of “Shift” has to be chosen). However it does not work with JScript using the

SetCoefficientFixed()

command. No solution is known by now.

• Unfortunately linking parameters of reference spectra (see Fig. 11.2 “LinkParameter”)

spectra with JScript does not work either.

11.5

Save the residual of the fit result



In 11.3, we stored the fit results by using the AppendResultToFile function. It stores fit

coefficients, errors, etc. in a file. Sometimes it is useful to store as well the whole spectrum

of the residual. Unfortunately, there is no easy accessible function implemented in DOASIS

so far, so the example given here is quite hard to understand, and it will not be explained

62



here in detail. Fitting is done as in 11.3, for saving the spectrum see 8.9.

import System;

import DoasCore.Spectra;

import DoasCore.Math;

var MeasSpec :

ISpectrum = Specbar.CurrentSpectrum;

var ResidualSpec:

ISpectrum = Specbar.GetSpectrum("Residual");

// the Spectrum "ResidualSpec" will get the same number of channels as

// the spectrum "MeasSpec"

ResidualSpec.NChannel = MeasSpec.NChannel;

var fit = DoasFit.Open("c:

\\scripttest\\fitscenario.fs");

if(fit.DoFit(MeasSpec))

{

// get a vector, containing wavelength info from target spectrum



var wavelength = fit.TargetSpectrum.Wavelength.ToVector();

// get an empty vector

var resultSpec = new DoasCore.Math.Fit.Vector(int(wavelength.Size));

// fill the vector with intensity values of result function

fit.ResultSpectrum.GetValues(wavelength, resultSpec);

// create a new vector

var targetSpec = new DoasCore.Math.Fit.Vector(int(wavelength.Size));

// fill the vector with the intensity values of the target spectrum

fit.TargetSpectrum.GetValues(wavelength, targetSpec);

// subtract resultSpec from targetSpec:

the result is the residual

targetSpec.Sub(resultSpec);

// packs the two vectors into the residual spectrum

ResidualSpec.Wavelength.FromVector(wavelength);

ResidualSpec.Intensity.FromVector(targetSpec);

}

else



System.Console.WriteLine("Error while fitting!");

Remarks


• ResultSpectrum is a function that you can actually see after fitting manually in the

Fit Result window. For a good fit, it should be similar to the “TargetSpectrum”.

“TargetSpectrum” is the spectrum in the Active Spectrum Sheet, that we want to fit.

By subtracting the ResultSpectrum from the TargetSpectrum we get the residual.

• Don´t create the variable fit by writing var fit:

DoasFit = new DoasFit()

, be-

cause then, TargetSpectrum does not support the function GetValues.



But: If you want to get access to the properties of fit.ReferencesInfo like FitCoefficient

or ObjectKey, you have to create the variable fit in that way! In case you want to get

63



the Residual and get access to fit.ReferencesInfo use two different variables fit1 and

fit2, where you create each in a different way.

• We created three vectors here: targetSpec, resultSpec and wavelength. All vectors

have as many entries, as the number of channels of the spectrum that we want to

fit (TargetSpectrum). In the vector wavelength, each entry consists of a wavelength

corresponding to the specific channel. The other two vectors contain intensity values.

Make sure to take the logarithm of the spectrum you want to fit either by pressing

“Logarithm” in the “Math” menu of DOASIS, or by activating the “Log. spectrum”

control box in the fitting sheet of the console window.

• Is it possible to extract the fit functions of the reference spectra as well? No. At least

not very easily.

64



Yüklə 0,62 Mb.

Dostları ilə paylaş:
1   ...   13   14   15   16   17   18   19   20   21




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə