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

querying any absorption coefficient gives always the same result #21

Open
gfacciol opened this issue Jul 5, 2020 · 7 comments
Open

Comments

@gfacciol
Copy link

gfacciol commented Jul 5, 2020

Hi,
I'm trying to extract the transmittance spectrum for several gases.
I followed the manual, however I always get the same profile.
What am I doing wrong?
Thanks in advance!

import hapi
hapi.db_begin('hitran_data')
for x in ['NO2', 'CO2']:
    hapi.fetch(x,1,1,3000,7000)
    nu,coef = hapi.absorptionCoefficient_Lorentz(SourceTables=x, HITRAN_units=False)
    nu,trans = hapi.transmittanceSpectrum(nu,coef)
    plt.figure()
    plt.plot(nu,trans)
@GibClark
Copy link

GibClark commented Aug 27, 2020

Hi @gfacciol, hapi.fetch() requires integer inputs that specify the molecule ID and isotopologue ID in the HITRAN database. These inputs are M and I respectively in the fetch() documentation:

fetch(TableName, M, I, numin, numax, ParameterGroups=[], Parameters=[])

the first line in your for loop is actually fetching the 1st isotopologue of H2O molecule from HITRAN and naming the table with your iterating variable x . To access the molecules NO2 and CO2, you need to specify molecule ID's 10, and 2, respectively. A dictionary with the molecule string as the key and the molecule ID as the value might be a better structure to iterate through for your example above.

Species = {
    'NO2': 10,
    'CO2': 2
    }

for x,M in Species.items():
    hapi.fetch(x,M,1,3000,7000)
    . . .

EDIT
NB the above analyzes only the 1st isotopologue.

@dima72
Copy link

dima72 commented Jan 24, 2023

Hi guys,
should fetch('CH4',2,1,2000,2100) and fetch('NH3',2,1,2000,2100) and any other molecule use different set of data?
I have enabled DISPLAY_FETCH_URL and can see that fetch on any molecule uses the same URL

https://hitran.org/lbl/api?iso_ids_list=7&numin=2000&numax=2100

is this how it supposed to be?

I'm also having the same Spectrum for absorptionCoefficient_Lorentz with different molecules.

@erwanp
Copy link

erwanp commented Jan 24, 2023

The molecule name is more of a key for the local database. The molecule index is what matters
I have a converter there just copy and paste : https://github.com/radis/radis/blob/27a80617bb2675ef8b7c88e549c430ef947418c2/radis/db/classes.py#L220

@dima72
Copy link

dima72 commented Jan 24, 2023

Erwanp,
why fetch(MoleculeName, 2,1,2000, 2100 ) on any molecule brings all the same data for any molecule?
it uses all the same query https://hitran.org/lbl/api?iso_ids_list=7&numin=2000&numax=2100

@erwanp
Copy link

erwanp commented Jan 24, 2023

Use

fetch(MoleculeName, get_molecule_identifier(MoleculeName),isotope_number,2000, 2100 ) 

with the get_molecule_identifier code mentioned above (copy-paste it)

@dima72
Copy link

dima72 commented Jan 25, 2023

Erwanp,
thank you for clarification! Now it is clear that the first parameter TableName has no effect on the data, but parameters M_id and I_id are determining the iso_ids_list parameter of http query.

The RADIS library looks awesome addition to Hitran!

@erwanp
Copy link

erwanp commented Jan 25, 2023

Radis is simpler to use but hapi is more complete for advanced spectroscopy usages

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