Other background than polynomial

28 views
Skip to first unread message

ivo.a...@psi.ch

unread,
May 4, 2017, 2:06:49 AM5/4/17
to hyperspy-users
Dear all

I seems that the only way I can define a background in the models for a fit is by

 model.add_polynomial_background(order=bg_order)

Is it possible to define a custom background or to add an additional component to the polynomial (I would need a narrow gaussian to take care of a large spike at E=0.0 in my EDX spectra)?

Thanks for any advice

Thomas Aarholt

unread,
May 4, 2017, 3:38:55 AM5/4/17
to hyperspy-users
Gruss gott Ivo,

It's absolutely possible to do :) it might be easiest if we try for your exact use case - what sort of background do you want to add?

For the gaussian you can use hs.components1D.Gaussian (or some variation of that, possibly with hs.model first. I'm on mobile). Press Tab in Jupyter Notebook to see the suggested Methods. 

You can feed the gaussian arguments for centre, A (height), and sigma. 

I suggest you join the gitter chat (bottom right on the hyperspy webpage) for easier discussion!

Vennlig hilsen Thomas 

--
You received this message because you are subscribed to the Google Groups "hyperspy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hyperspy-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Aarholt

unread,
May 4, 2017, 5:12:01 AM5/4/17
to hyperspy-users
I had the wrong syntax for the gaussian:

`gaussian = hs.model.components1D.Gaussian(centre=0.0)`

You then append it to the model by:
`m.append(gaussian)`

ivo.a...@psi.ch

unread,
May 4, 2017, 9:12:14 AM5/4/17
to hyperspy-users
Ok,

so does this mean it is up to me to keep track which components belong to the background and which describe my signal. In this case what does ``model.fit_background()`` do? I.e. how are background components distinguished from signal componens?

Thanks

Tomas Ostasevicius

unread,
May 4, 2017, 9:17:19 AM5/4/17
to hyperspy-users

Hi,

Each component has `comp.isbackground` boolean value that I hope is used to distinguish this.

Tomas


--

Thomas Aarholt

unread,
May 4, 2017, 11:14:28 AM5/4/17
to hyperspy-users
Tomas is correct. Reading the code (this should *really* be documented better) in edsmodel.py, it fits all components with isbackground == True.

On 4 May 2017 at 15:17, Tomas Ostasevicius <t.ostas...@gmail.com> wrote:

Hi,

Each component has `comp.isbackground` boolean value that I hope is used to distinguish this.

Tomas

On Thu, 4 May 2017, 14:12 , <ivo.a...@psi.ch> wrote:
Ok,

so does this mean it is up to me to keep track which components belong to the background and which describe my signal. In this case what does ``model.fit_background()`` do? I.e. how are background components distinguished from signal componens?

Thanks

--
You received this message because you are subscribed to the Google Groups "hyperspy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hyperspy-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "hyperspy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hyperspy-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Thomas M. Aarholt
Reading for DPhil in Nuclear Materials
University of Oxford
 
Mobile: 07794820885
Reply all
Reply to author
Forward
0 new messages