EFerriss / Pynams

Python package for interpreting FTIR spectra of nominally anhydrous minerals (NAMs)
MIT License
13 stars 4 forks source link

Henry working #34

Open whtowbin opened 6 years ago

whtowbin commented 6 years ago

Updated make_area function and added an automated_baseline function. I have 2 additional automated baseline algorithms that can be implemented as well.

I am still pretty unfamiliar with git but it says I made many more changes than I did. I only made additions to the spectra.py file and nothing else.

EFerriss commented 6 years ago

Exciting!! I won't have time to look at this for awhile, alas, but check the file endings of the stuff it says you changed. A lot of them might be .pyc files.

EFerriss commented 6 years ago

Hey, I'm about to:

  1. Add some small updates from my version that I think will help Anna out with her new issue.
  2. Issue a new release with only those updates, so that'll be pynams version 0.2.0
  3. Make all my olivine code, which uses pynams v0.2.0, public.
  4. Test and merge this pull request.
EFerriss commented 6 years ago

Hey @whtowbin - I looked at it a little bit. The updates to make_area and documentation look reasonable, but why not just include your automated baselines as options in make_baseline? That way you don't have to keep track of two different functions. I leave it to you and Anna to decide what you want the default to be.

Also, I think it will be a huge help if you could also update EXAMPLES.ipynb to include the new options and defaults for both baselines and areas.

As you're doing this - don't worry too much about legacy support for me. My paper will use v0.2.0, and going forward, you and Anna should make this the best thing you can for yourselves and others.

EFerriss commented 6 years ago

And don't worry about the conflicts between .pyc files. I think I know how to sort that out when it's all ready to merge.

whtowbin commented 6 years ago

Thank you for the updates! I agree that is might be easier to just have one baseline function with several options. I left it separate for the time being because I actually have several other types of automated baseline and I was considering if there was a way to role them all into one. The current routine is good for most situations but sometimes conflicts with an automated peak fitting routine I have been working on.

For now it might be best to keep them separate until I figure out how best to sort them out.

I am happy to make examples. I will try to do it in the next few weeks. Thanks again, Henry

EFerriss commented 6 years ago

An automated peak fitting routine! Whoa! That's like the holy grail of pynams. You should check out the open source Matlab program (Google peakfit.m, I think) if you haven't already. There are a couple of commercial programs out there as well - I think one I've read about, maybe in one of Jannick Ingrin's olivine papers, is called PeakFit. I'm all about open-source, but if the existing pynams setup isn't good enough, it might not be worth a lot of your time if you can just buy something satisfactory for maybe not that much money.

I will wait to merge everything into master until you've sorted out what exactly you want to do and added examples (but Anna or whoever can still get the version from your branch if they want it), so just let me know when you want me to look at it again.

whtowbin commented 6 years ago

Thanks for the tips. I started working on it for my quantitative data analysis class. So far its slow but works well for fitting highly overlapping peaks after you roughly identify the peaks you want to fit in one spectra. It uses Montecarlo methods to sample peak heights and widths and then makes error estimates based on a likelihood function.

At the moment the choice of baseline has a huge effect in my profiles where the baseline varies a lot from spectra to spectra in a profile. This might not be a problem for more straight-forward baselines. After I am done with my master's paper I should try it out on San Carlos.

My ultimate goal is to sample baselines in the Monte Carlo method so thats why I have come up with multiple automated baseline methods.

EFerriss commented 6 years ago

Super interesting. I look forward to seeing what you come up with.