hitranonline / hapi2

HITRAN Application Programming Interface on Steroids
GNU General Public License v3.0
19 stars 5 forks source link

Documentation #14

Open mdaeron opened 11 months ago

mdaeron commented 11 months ago

It is very appreciated how much work has gone into improving HAPI, I'm very much looking forward to using it.

But is there any kind of basic documentation somewhere? With the previous version of HAPI, I could do something like this to compute an absorption spectrum:

from hapi import *

db_begin('data')
fetch_by_ids('626', [7],   5000, 7000)

nu, K = absorptionCoefficient_Voigt(
    SourceTables = '626',
    Diluent = {'self': 1., 'air': 0.},
    OmegaRange = (6230.7, 6231.2),
    OmegaStep = 0.001,
    OmegaWingHW = 1000,
    Environment = {'T': 298.15, 'p': 0.05},
    HITRAN_units = False,
    )

Now I find myself unable to achieve the same thing, lacking an elementary tutorial example. For instance, I tried:

from hapi2 import *

mols = fetch_molecules()
isos = fetch_isotopologues([Molecule('CO2')])

fetch_transitions(
    Isotopologue('626'),
    5000,
    7000,
    'CO2',
    )

Which yields the following error:

Traceback (most recent call last):
  File "/Users/daeron/ShareBox/git/hapi2/hapi2/web/api.py", line 79, in fetch_header
    req = urllib2.urlopen(url)
          ^^^^^^^^^^^^^^^^^^^^
  File "/Users/daeron/mambaforge/lib/python3.11/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/daeron/mambaforge/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/daeron/mambaforge/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/Users/daeron/mambaforge/lib/python3.11/urllib/request.py", line 563, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/daeron/mambaforge/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/Users/daeron/mambaforge/lib/python3.11/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/daeron/temp/voigt_vs_HT/./hapi2test.py", line 8, in <module>
    fetch_transitions(
  File "/Users/daeron/ShareBox/git/hapi2/hapi2/web/api.py", line 396, in fetch_transitions
    HEADER_TRANSITIONS,headfile = fetch_header('transitions',query,need_headfile=True)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/daeron/ShareBox/git/hapi2/hapi2/web/api.py", line 81, in fetch_header
    raise Exception('Failed to retrieve data for given parameters.')
Exception: Failed to retrieve data for given parameters.

When I try help(fetch_transitions) I get the following message:

Help on function fetch_transitions in module hapi2.web.api:

fetch_transitions(isos, numin, numax, llst_name)
    Fetch transitions using isotopologue objects as an input.

It's probably something very basic I'm missing, which is why a simple tutorial would be extremely useful. I can't be the only one?

bujiren commented 7 months ago

Very much looking forward to HAPI2 tutorial, similar to HAPI

kafer12138 commented 7 months ago

Very much looking forward to HAPI2 tutorial, similar to HAPI,too