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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same script to compute and replot spectra #135

Open
erwanp opened this issue Dec 2, 2020 · 5 comments
Open

Same script to compute and replot spectra #135

erwanp opened this issue Dec 2, 2020 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers interface not related to the physics of the code
Milestone

Comments

@erwanp
Copy link
Member

erwanp commented Dec 2, 2020

馃幆 Describe what you'd like

Ever happened that you computed a spectrum, plotted it, then need to re-plot it few months later and therefore need to recompute it ? What if the spectrum took several minutes to compute ?

  • SpectrumFactory already comes with a feature that connects it to a SpecDatabase (a folder of Spectrum objects) which initially checks that the Spectrum exists, returns it if it does, or recomputes and add to the folder if it does not

We could have a similar feature for calc_spectrum that automatically saves to a file, and retrieves from the file if it's there already.

馃挕 Possible implementations

  1. we give an output filename to calc_spectrum.
  2. if filename exists :
  • load the spec
  • check that metadata correpsond to computational conditions
  • if not > error or recompute
  • if yes > return the Spectrum directly
  1. else:
  • compute, and save
s = calc_spectrum(Tgas=... ,   output_file='blabla.spec', **kwargs)
s.plot()

Edit : there is already a "save_to" parameter in calc_spectrum.

Questions :

  • what store parameters to use ? Allow other parameters to be given in **kwargs ? (note : saving all lines is probably a bad idea --> if this feature is used in a loop with spectra with millions of lines this would quickly use all of the disk space !)

Tip : you can vote for New Features on https://feathub.com/radis/radis

@erwanp erwanp added enhancement New feature or request interface not related to the physics of the code labels Dec 2, 2020
@dcmvdbekerom
Copy link
Member

What about we couple it with pypdfplot 馃榿?

@erwanp
Copy link
Member Author

erwanp commented Dec 2, 2020

I had forgotten about this amazing library ! (you should post it on Reddit btw, you are the living proof that it worked for RADIS ! :) ).

It sounds a bit trickier than the simple implementation I suggested above, and will answer a slightly different need. But it also bring new opportunities : one could actually share a Spectrum under .pdf, and just have to rename it to .py to be able to access the script and replot it !

Btw, could pypdfplot support .svg ? Because Word does, and that would be a perfect alternative to Origin. Should I open an Issue there ?

@minouHub
Copy link
Collaborator

minouHub commented Dec 2, 2020

Nice idea, but it seems that you already implemented it in radis.database ?

@dcmvdbekerom
Copy link
Member

[ regarding pypdfplot: go ahead and open an issue! although chances are slim... I will make a reddit post when I finish the matplotlib backend so you can use it by just calling plt.savefif() ]

One way to save plots for later that could be useful is pickling the matplotlib figure:

with open('figure.fig','wb') as f:
    pickle.dump(plt.gcf(),f)

Of course this is just for short term fix, because the spectrumfactory object would be lost in this case.
It does however let you change colors/sizes/axes limits of the plot without rerunning the code.

@erwanp erwanp mentioned this issue Mar 29, 2021
84 tasks
@erwanp erwanp added this to the 0.9.30 milestone Apr 5, 2021
@erwanp erwanp modified the milestones: 0.9.30, 0.9.31 May 7, 2021
@erwanp erwanp modified the milestones: 0.10.3, 0.10.4 Sep 23, 2021
@erwanp erwanp modified the milestones: 0.10.4, 0.10.5 Nov 1, 2021
@erwanp
Copy link
Member Author

erwanp commented Aug 10, 2022

See arunavabasu-03/radis-app#619 (comment) for new requirements

@erwanp erwanp added the good first issue Good for newcomers label Aug 10, 2022
@anandxkumar anandxkumar modified the milestones: 0.14, 0.15 Oct 28, 2022
@minouHub minouHub modified the milestones: 0.15, 0.16 Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers interface not related to the physics of the code
Projects
None yet
Development

No branches or pull requests

4 participants