export_results()
c
ommand to save the maps as RPL files (TIF didn't work for me, not quite sure why), but Hi Francisco,thanks for the quick reply. I'm trying to get a grip on all those concepts at once ( - just now figured that I should use the TAB for auto-complete and getting an idea of what I can do with what object ),
so at any time some code-snippets are welcome ;c)From your message, I gather that I can/should do
import numpy as np
import hyperspy.api as hs
filename = "C:\\test.dm3" # some STEM EELS SI
dataSI = hs.load(filename)
print('Source data:', dataSI )
dataSI.add_elements(('Ti', 'N', 'O'))
fitModel = dataSI.create_model() # no LowLoss
print('Fit model:')
print(fitModel.components)
fitModel.smart_fit()
fitModel.quantify()
print('Fit model parameters:')
fitModel.print_current_values()
fitModel["PowerLaw"].r.as_signal # ???
--
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.
Hi Thomas,
Yes, the “function()” was what I was trying to get at, thanks.
I think the confusion was causes by me asking two things in a single post 8-], as I was also asking for the parameter-maps. Which I get with the “as_signal”, I guess.
However, will the as_signal returned values be a numpy array already, or do I need to call something of that?
I don’t get the “fitModel.axis.axis“ part yet, put I need to think/check through it in more detail myself first.
Thanks for the link to the chat, I’ll eventually jump on to that as well.
For now, I need my “time” thinking/testing things through and keeping a “paper trail” of information to review later, so email suits me a bit better at the moment.
Regards and thanks again (to both of you),
Bernhard
Hi Thomas,
Thanks a lot. I’ll digest that info with some trial & testing now and will eventually bug you with some more questions, if I may.
As for the smartfit(), I’m essentially piecing all information I get together, this particular from
http://hyperspy.org/hyperspy-doc/current/user_guide/eels.html#eels-curve-fitting
(It was also a bit unfortunate that I started with that section first and only then realized that a lot of what I need is in the “Model fitting” section before that.)
Bernhard
PS: In case if you’re wondering: I’m currently working (for fun & personal interest) on an old idea of mine, which I so far never had the chance trying: Calling out to Python scripts from DigitalMicrograph.
And at the same time, I want to compare some of the functionality and results between the programs. I’ve been tiptoeing around Python and HyperSpy for a while (-no longer doing scientific data analysis in application myself-), so I’m glad I finally got things started at least…
Thomas, why do you think that smart_fit is "very old and outdated"? It should be as useful as ever to fit EELS core loss data with fine structure.
Hi,
I’ve made a bit more progress with the whole thing yesterday evening, but I stumbled about something I don’t know is either a bug or something I still don’t know about. Maybe you can enlighten me :c)
Following previous suggestions, I’ve cobbled together the following script (run on a 6x6x2048 EELS SI)
import numpy as np
import hyperspy.api as hs
filename = "C:\\EELS_1.0nA_CoreLoss_binned2.dm3" # Test-data 6x6x2048
dataSI = hs.load(filename)
print('Source data:', dataSI )
dataSI.add_elements(('Ti', 'N', 'O'))
fitModel = dataSI.create_model() # no LowLoss
print('Fit model:')
print(fitModel.components)
fitModel.smart_fit()
fitModel.quantify()
print('Fit model parameters:')
fitModel.print_current_values()
print('PERFORMING SI FIT. BE VERY PATIENT:')
fitModel.multifit( show_progressbar=False )
# iterate over fitted parameters (info only)
for comp in fitModel:
print( comp.trait_get('name').get('name') )
for par in comp.free_parameters:
print( "-",par.trait_get('name').get('name') )
print( 'Data type:', dataArray.dtype )
print( dataArray )
This gives me the “map” as float64 numpy array. However, something is fishy about the array.
Further processing of that array in a pipeline tested with other float64 arrays comes up with nonsensical numbers.
However, if I do a simple numpy-array copy and use the copied array, all works fine again.
print( 'Data type:', dataArray.dtype )
print( dataArray )
dataArray2 = dataArray.copy()
print( 'Data type:', dataArray2.dtype )
print( dataArray2 )
The two arrays seem “identical” on the surface of it, but I wouldn’t know how to compare them on deeper level or to understand what’s “wrong” with the original.
Any ideas?
The actual print-output (showing that there are no stupid NaNs etc in the array)
PERFORMING SI FIT. BE VERY PATIENT:
Data type: float64
[[-0.40869008 3.0840393 4.70018472 6.3182053 6.00980115 0.31944671]
[-0.36471608 2.78945432 2.48835507 7.07445396 11.31741117 2.40420006]
[ 0.08022761 3.60850085 2.83486668 6.99945442 12.28993755 2.70031988]
[ 0.40889855 4.07521977 2.36466091 8.88673975 12.83003037 2.4048956 ]
[-0.29364582 3.02107615 2.68336018 6.78201372 13.50250115 2.29713747]
[-0.33466722 3.1132138 5.0523999 6.68046332 6.53065061 -0.33731116]]
Data type: float64
[[-0.40869008 3.0840393 4.70018472 6.3182053 6.00980115 0.31944671]
[-0.36471608 2.78945432 2.48835507 7.07445396 11.31741117 2.40420006]
[ 0.08022761 3.60850085 2.83486668 6.99945442 12.28993755 2.70031988]
[ 0.40889855 4.07521977 2.36466091 8.88673975 12.83003037 2.4048956 ]
[-0.29364582 3.02107615 2.68336018 6.78201372 13.50250115 2.29713747]
[-0.33466722 3.1132138 5.0523999 6.68046332 6.53065061 -0.33731116]]
BTW, I did this initially with Numpy 1.14.0 but have then upgraded to 1.15.0 – still the same.
Best regards,
Bernhard Schaffer
PS: If you have any other comments on my scripts, i.e. things that could be done much nicer than I did, please let me know! Still learning…
From: hypersp...@googlegroups.com <hypersp...@googlegroups.com> On Behalf Of Thomas Aarholt
Sent: 24 July 2018 09:51
To: hyperspy-users <hypersp...@googlegroups.com>
Subject: Re: [hyperspy-users] Re: Model fitting, getting fit-models as array
Apologies, I am completely wrong in this regard. I thought smart_fit was a legacy fitting function for some reason.