How to reset or remove tag groups and tag lists in a DM script?
Some background:
I am preparing a script for analysing series of EELS spectra in GMS 2. I fit the background to a power-law modele and obtain the fitting parameters, both value and sigma, from the Tags in the background spectrum. However, if a try to analyse various edges in a single script I find that the sigma values of the fit parameters depends on the order of the calculation. To check this I show a script. If I only define the fitting region one time it works OK, but if I do that twice (only for testing, I know that is nonsense), the sigma values decreases. The result is the same if the fitting regions are different. I would like to reset or delete the TagGroup to check if then the problem is solved, but I am unable to do that.
TagGroup Tg
Number a0, sa0, a1, sa1
taggroup bandsTgs = NewTagList()
taggroup bandTg = NewTagGroup()
image spec := GetFrontImage()
// ...............First Time.....................................
bandTg.TagGroupSetTagAsFloat( "start", 600 ) // calibrated value!
bandTg.TagGroupSetTagAsFloat( "end", 800 ) // calibrated value!
bandsTgs.TagGroupInsertTagAsTagGroup( Infinity(), bandTg )
image bkg1 := EELSFitPowerLawBackground( spec, bandsTgs )
bkg1.ShowImage()
tg = bkg1.ImageGetTagGroup() // Fit parameters(in eV) from the BKG spectrum Tags
tg.TagGroupGetTagAsNumber( "Processing:[0]:Parameters:Fit Parameters:a0:value", a0 )
tg.TagGroupGetTagAsNumber( "Processing:[0]:Parameters:Fit Parameters:a0:sigma", sa0 )
tg.TagGroupGetTagAsNumber( "Processing:[0]:Parameters:Fit Parameters:a1:value", a1 )
tg.TagGroupGetTagAsNumber( "Processing:[0]:Parameters:Fit Parameters:a1:sigma", sa1 )
Result("\n Fitting BKG parameters. First time ")
Result("\n a0 : " + a0)
Result("\n sa0 : " + sa0)
Result("\n a1 : " + a1)
Result("\n sa1 : " + sa1)
// Second Time........I get a differetn result if a repeat the fit-region definition
bandTg.TagGroupSetTagAsFloat( "start", 600 ) // calibrated value!
bandTg.TagGroupSetTagAsFloat( "end", 800 ) // calibrated value!
bandsTgs.TagGroupInsertTagAsTagGroup( Infinity(), bandTg )
image bkg2 := EELSFitPowerLawBackground( spec, bandsTgs )
bkg2.ShowImage()
tg = bkg2.ImageGetTagGroup() // Fit parameters(in eV) from the BKG spectrum Tags
tg.TagGroupGetTagAsNumber( "Processing:[0]:Parameters:Fit Parameters:a0:value", a0 )
tg.TagGroupGetTagAsNumber( "Processing:[0]:Parameters:Fit Parameters:a0:sigma", sa0 )
tg.TagGroupGetTagAsNumber( "Processing:[0]:Parameters:Fit Parameters:a1:value", a1 )
tg.TagGroupGetTagAsNumber( "Processing:[0]:Parameters:Fit Parameters:a1:sigma", sa1 )
Result("\n")
Result("\n Fitting BKG parameters. Second time ")
Result("\n a0 : " + a0)
Result("\n sa0 : " + sa0)
Result("\n a1 : " + a1)
Result("\n sa1 : " + sa1)
bandsTgs.TagGroupOpenBrowserWindow( "BandTags", 0 ) // To show the Tag structure
