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

cond unit and Hitran cross-sections #630

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

erwanp
Copy link
Member

@erwanp erwanp commented Nov 1, 2023

  • Parse dimensioned values (i.e. with units) in Spectrum conditions

  • Parse and generate Spectrum from manually downloaded HITRAN cross section files (https://hitran.org/xsc/)

  • Add tests

  • Add Gallery example

Note : this PR might raise errors when units are not defined in user-scripts; in particular path_length and pressure. Spectrum.cond_units should be used to define them.


from radis import Spectrum
from radis.phys.units import Unit as u

# Here we use a downloaded cross-section file from the test suite :
from radis.test.utils import getTestFile

datafile = getTestFile("CH3COCH3_233.4_375.2_700.0-1780.0_13.xsc")

# Temperature and pressure are given by the cross-section file used (above: 233.4 K; 375.2 Torr)
# Mole fraction and path length can be recomputed arbitrarily :
conditions = {"mole_fraction": 0.1, "path_length": 20 * u("mm")}

s = Spectrum.from_xsc(datafile, conditions)

s.plot("transmittance_noslit", lw=2)

# Rescale for other path lengths, and plot :
s.rescale_path_length(100 * u("mm")).plot(nfig="same")

import matplotlib.pyplot as plt

plt.title(s.c["molecule"])

image

Fix #628


Note @HajimeKawahara the cross-section parsing is added directly in the API (hitranapi)

to retrieve Spectrum condition in arbitrary unit
also ensure S.I units are used when converting xsection to abscoeff and vice versa
@erwanp erwanp added this to the 0.15 milestone Nov 1, 2023
@erwanp erwanp added interface not related to the physics of the code db:hitran related to HITRAN database labels Nov 1, 2023
@erwanp
Copy link
Member Author

erwanp commented Nov 1, 2023

@EkulRF have a look and confirm this is what you need; then we'll merge

@EkulRF
Copy link

EkulRF commented Nov 8, 2023

Thanks @erwanp

I get the following error when I have the relevant xsc files saved to a local directory:

datafile = getTestFile(filepath)

Exception has occurred: FileNotFoundError Test file ~/CH3COCH3_297.8_700.0_700.0-1780.0_13.xsc` does not exist. Choose one of:

  • hitran_co2_626_bandhead_4165_4200nm.par
  • geisa_CO2_fragment.par
  • co2_cdsd_hamiltonian_fragment.levels
  • geisa_CO_fragment.par
  • N2C_specair_380nm.spec
  • synth-NH3-1-500-2000cm-P10-mf0.01-p1.spec
  • cdsd_hitemp_09_header.txt
  • CO2_measured_spectrum_4-5um.spec
  • geisa_H2O_fragment.par
  • hitran_co_3iso_2000_2300cm.par
  • hitran_CO_fragment.par
  • CO_Tgas1500K_mole_fraction0.01.spec
  • Corentin_0_100cm_DownSampled_20cm_10pctCO2_1-wc-gw450-gr300-sl1500-acc5000-.spec
  • CO_Tgas1500K_mole_fraction0.5.spec
  • CO2abscoeff_300K_4150_4400nm.txt
  • geisa_O2_fragment.par
  • hitran_2016_H2O_2iso_2000_2100cm.par
  • cdsd_hitemp_09_fragment.txt
  • calc_N2C_spectrum_Trot1200_Tvib3000.txt
  • hitran_CO2_fragment.par
  • slitfunction.txt
  • calc_N2C_spectrum_Trot1200_Tvib3000_slit0.1.txt or use force=True`

The file is correctly pathed, etc. Am I missing something or have I stored the .xsc file incorrectly?

@minouHub
Copy link
Collaborator

@erwanp any update on this one?

@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
db:hitran related to HITRAN database interface not related to the physics of the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for different molecules from HITRAN
3 participants