laserkelvin / PySpecTools

Routines for rotational spectroscopy analysis written in Python 3
MIT License
31 stars 5 forks source link

Issue with process_linelist #13

Closed IlsaCooke closed 4 years ago

IlsaCooke commented 4 years ago

Hi again :)

I've been trying to run some scripts that I wrote before the last pull.

I used the process_linelist function to assign lines with a .cat file. Previously this work well but now the function is not returning any assignments and I get the error: Exception: No assignments made in this session - nothing to finalize!

I used: session.process_linelist(name="vinylcyanide",formula="C3H3N",filepath="C2H3CN.cat",thres=-10.0,progressbar=True, tol=1)

If i try session.process_splatalogue(auto=True) it does assign lines.

Can you look into this for me? Maybe it's related to astroquery?

Thanks again!

Ilsa

laserkelvin commented 4 years ago

Could you send me your catalog, and I'll try and debug it from my end?

One way is to make the linelist manually, and check that it's parsing the catalog correctly, and has lines in the range of your spectrum.

from pyspectools.spectra.assignment import LineList

vinylcyanide = LineList.from_catalog("vinylcyanide", "C2H3CN.cat")

print(vinylcyanide)
print(vinylcyanide.get_frequencies())
IlsaCooke commented 4 years ago

I couldn't get it to import with your command above but it worked when I added the formula:

vinylcyanide = LineList.from_catalog("vinylcyanide","C3H3N","C2H3CN.cat")

However, printing the frequencies gave me a fat stack of zeros. I attached the .cat file below (as a txt). I also tried a few others and they likewise returned only zeros.

Thanks! C2H3CN.txt

laserkelvin commented 4 years ago

Hi Ilsa,

Woops, I think I have mislead you! I've checked the catalog, and the data is stored as the attribute catalog_frequency instead of frequency, and the vinylcyanide.get_frequencies() function returns experimental frequencies only.

If you run print(vinylcyanide), you should get the number of entries, which I confirmed actually contains numbers in the catalog_frequency fields.

Running this in IPython:

In [1]: from pyspectools.spectra.assignment import LineList

In [2]: vinylcyanide = LineList.from_catalog("vc", "C2H3CN", "C2H3CN.txt")
print(
In [3]: print(vinylcyanide)
Line list for: vc Formula: C2H3CN, Number of entries: 129888

In [4]: vinylcyanide.transitions[0].catalog_frequency
Out[4]: 17.3771

In [5]: vinylcyanide.transitions[500].catalog_frequency
Out[5]: 5312.369

In [6]: vinylcyanide.transitions[500].frequency
Out[6]: 0.0

You could also try setting the line uncertainties lower to make sure they don't overlap with the frequency field, although the way this is being read in is fixed width so that shouldn't be a problem.

If the file isn't overly large, could you send me the XXXX-analysis.log file in your log folder where you run your notebook? It should contain a little bit more detail during the assignment process.

IlsaCooke commented 4 years ago

This is the analysis.log

2020-05-25 17:57:15,759 - INFO - Peak detection threshold is: 5000000.0 2020-05-25 17:57:15,810 - INFO - Found 14 peaks in total. 2020-05-25 17:57:15,810 - INFO - Modifying the experiment LineList. 2020-05-25 17:57:15,811 - INFO - There are now 14 line entries in this session. 2020-05-25 17:57:21,235 - INFO - Processing local catalog for molecule vinylcyanide. 2020-05-25 17:57:23,653 - INFO - Assigned 0 new transitions to vinylcyanide.

These are the commands I used:

session = spectra.assignment.AssignmentSession.from_ascii( filepath="Vinyl_cyanide_filtered.txt", experiment=1005, temperature = 300, composition = ["C","H","N"], skiprows=1, col_names=["Frequency", "Intensity"] )

peaks = session.find_peaks(threshold=100e3,region=(76200,76300),min_dist = 1)

session.process_linelist(name="vinylcyanide",formula="C3H3N",filepath="C2H3CN.cat",thres=-10.0,progressbar=True, tol=1)

I'll email you the spectrum file as well so you can play around with it.

Thanks!

laserkelvin commented 4 years ago

Hi @IlsaCooke, are you okay with this or is there still an issue?

IlsaCooke commented 4 years ago

Yes, it worked well after changing the uncertainties as you suggested. Thanks!