-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only consider relevant DATATYPEs (NMR SPECTRUM / FID) when reading JCAMP-DX #120
Conversation
@JLVarjo, This looks good! I have only one small suggestion. It seems like as it stands currently, only Ideally, one can make a
This way, if there are other datatypes that are considered valid later, we could just add them to this list. What do you think? |
The actual problem behind this PR was that sometimes the different DATATYPE sections have the same data tags, which messed up things if they end up to one dict. Which is why I decided here to just dump the irrelevant ones. Your idea to store other data as well is feasible though. What if I make _readrawdic to return a dict of dicts instead, i.e. the key to outer dict is the DATATYPE? The actual parser could then continue with the spectrum/fid but all the other data is still returned to user. |
I see. In that case, what do you think about returning a dict of dicts, but also unpacking |
I assume you want the main read() function to return only |
Yes, that sounds perfect. This way, none of the existing codes need to change. |
Even better! Will make the changes soon. |
Changed the behavior as discussed. I think we have to use some prefix on the subdict keys, or they may clash with the DATATYPE tag of the actual data section itself. Chose to use There is also a dummy test case to check that the dictionary structure is correct, please find it attached here: |
@JLVarjo This looks good to me. I am merging this now. Thanks, especially for the additional test. I think it really helps understand what the function does. I have an additional suggestion here. I think the function |
Yes, can agree with you on that. Thanks for the pull! |
Quite often there's all kinds of metadata embedded in JCAMP-DX files. This PR changes the parser behavior to consider only the relevant DATATYPE sections, namely NMR SPECTRUM and NMR FID. Error messaging is also improved for cases where no data is found after all.
In addition, this PR fixes a bug in recognition of JCAMP pseudodigit format.