laserkelvin / PySpecTools

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

reset_assignment() functionality #23

Closed HoustonSmith-uwmad closed 4 years ago

HoustonSmith-uwmad commented 4 years ago

Does the reset_assignment() currently work if the transitions are assigned via process_linelist_batch command. I cannot figure out how to reset an assigned transition when assigned this way. Any help is appreciated.

laserkelvin commented 4 years ago

I believe you're referring to the Transition.reset_assignment() method? AFAIK this should be working regardless of the method for assigning.

The behavior of this function is to remove the assignment information from a transition, in the event that the auto-assignment makes a bad call. To give you an example, maybe peak number 100 is messed up:

session.line_lists["Peaks"].transitions[99].reset_assignment()

This will remove the assignment information for that peak, retaining only the peak information.

Related to this is the Transition.choose_assignment() method, which can be used in the event that the auto-assignment finds overlapping coincidences (i.e. more than one candidate from multiple catalogs). In those cases, additional coincidences will be stored as items in the Transition.multiple list attribute. The Transition.choose_assignment() method takes the index corresponding to the assignment you want to pick out of the multiple list.

Let me know if this resolves your problem!

HoustonSmith-uwmad commented 4 years ago

It seems I was trying to use the transition.reset_assignment() incorrectly. I would like to remove an assignment for a singular peak that has been attributed to a molecule. The experimental peak is correct however the molecule assigned is incorrect. This assignment isn't feasible since several other transitions that should be present aren't in the spectrum. I was hoping to just remove the assignment for a singular peak after the process_linelist_batch() command was ran. Is there a built in command to do this?

laserkelvin commented 4 years ago

I think you were using it for the right reason: reset_assignment() just removes the molecule assignment, but keeps the frequency/intensity of the peak. Basically it reverts it back to the state before you made any assignments. Does that make sense?

You should be able to achieve this with the code snippet I gave above, substituting obviously the peak number with the one you want tor reset.

HoustonSmith-uwmad commented 4 years ago

In substituting the peak into the code above it does not show an error in juptyer which makes me believe it was successful. However, the line is still present after I finalize assignment and view via the summary page. The code I used is below. This reset assignment segment was completed before the finalize and identifications portion of the notebook if that has any significance.

acetone.line_lists["Peaks"].transitions[1886].reset_assignment()

laserkelvin commented 4 years ago

You should run it after you run the identifications:

  1. Peak find
  2. Assignments
  3. Reset identification
  4. Finalize
HoustonSmith-uwmad commented 4 years ago

I have found my issue. I was using the line number from assigned transitions instead of the peak number so that was leading to the misunderstanding. Thank you for the help!