Skip to content
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

Writing JCAMP-DX files? #28

Open
sumpfralle opened this issue Dec 6, 2022 · 7 comments
Open

Writing JCAMP-DX files? #28

sumpfralle opened this issue Dec 6, 2022 · 7 comments

Comments

@sumpfralle
Copy link
Contributor

sumpfralle commented Dec 6, 2022

At the moment the jcamp module offers only the ability to parse JCAMP-DX files.

Would you consider it to be within the scope of the project to export to a file, too?

In this case I would be willing to propose an initial implementation.

@nzhagen
Copy link
Owner

nzhagen commented Dec 6, 2022

Yes, it is certainly within the scope of the project, and there must be some users who would welcome having a JCAMP writer.. If you have a proposal, I'd be glad to add it in.

@andychase
Copy link

I was able to find two libraries that implement this:

https://github.com/spectrochempy/spectrochempy/blob/2d21c1b8b109389e7b4871bdb32680d7b7061210/spectrochempy/core/writers/write_jcamp.py

https://github.com/r-hyperspec/pyspc-write-jdx

I think @nzhagen if you wanted to incorporate one of these modules (since they are both freely licensed) that would be nice. Your package is much easier to find then those two

@frenchytheasian
Copy link

Bumping this issue because this is something that I would find useful as well. I can try and work on a PR to pull in one of the libraries that @andychase mentioned to write out dx files from a dictionary.

@nzhagen
Copy link
Owner

nzhagen commented Sep 18, 2023

@frenchytheasian - thanks for raising the issue again. Seeing that there is more need for this than I expected, I went ahead and adapted some code to write JCAMP-DX files. I tried it out using a couple of the infrared spectra in the repo's data folder, but if you are interested, please give it a try and test it out. Let me know if there are any issues!

@frenchytheasian
Copy link

frenchytheasian commented Sep 18, 2023

Hey @nzhagen! Thanks for the response and the PR. I noticed that the new function does not work on infrared spectra that contain multiple blocks of spectra. I looked at some of the existing infrared files and noticed that they only contain one long block of data. I tested it on data/hnmr_spectra/ethanol_nmr.jdx which also failed with the same error. I can try adding onto the function you've built to handle blocks of data.

@nzhagen
Copy link
Owner

nzhagen commented Sep 18, 2023

@frenchytheasian - Yeah, I saw that I could quickly implement a function to create a standardized fixed-format single spectrum, but the JCAMP-DX format has so many options that I decided to start with a minimalist approach and work from there. If you are willing to give it a try to add functionality to handle multiple blocks, that would be great! I'd be glad to add that to the codebase.

@frenchytheasian
Copy link

@nzhagen - Ahh I see. I haven't dove too deep into the official spec. There are just some specific DX files that I'm trying to parse. I'll write code that can handle those and then possibly go on from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants