Beispiel #1
0
def test_fetch_hitemp_OH(verbose=True, *args, **kwargs):
    """Test proper download of HITEMP OH database.

    Good to test fetch_hitemp.
    ``13_HITEMP2020.par.bz2`` is only 900 kb so it can be run on online
    tests without burning the planet ЁЯМ│

    тЪая╕П if using the default `chunksize=100000`, it uncompresses in one pass
    (only 57k lines for OH) and we cannot test that appending to the same HDF5
    works. So here we use a smaller chunksize of 20,000.
    .

    """

    df = fetch_hitemp("OH",
                      cache="regen",
                      chunksize=20000,
                      verbose=3 * verbose)

    assert "HITEMP-OH" in getDatabankList()

    assert len(df) == 57019

    # Load again and make sure it works (ex: metadata properly loaded etc.):
    fetch_hitemp("OH")
Beispiel #2
0
def test_partial_loading(*args, **kwargs):
    """ Assert that using partial loading of the database works """

    wmin, wmax = 2500, 4500

    # First ensures that the database is wider than this (else test is irrelevant) :
    df = fetch_hitemp("OH")
    assert df.wav.min() < wmin
    assert df.wav.max() > wmax

    # Now fetch with partial loading
    df = fetch_hitemp("OH", load_wavenum_min=wmin, load_wavenum_max=wmax)
    assert df.wav.min() >= wmin
    assert df.wav.max() <= wmax
Beispiel #3
0
def test_fetch_hitemp_all_molecules(molecule, verbose=False, *args, **kwargs):
    """Test fetch HITEMP for all molecules whose download URL is available.

    ..warning::
        this downloads gigabytes of data. It is unselected by default by Pytest
        (see radis/setup.cfg)

    The bz2 compression factor gives about 17 MB / million lines :

    - OH (57 k lines) is only 900 kb
    - CO (0.7 M lines) is only ~14 Mb
    - CH4 (114 M lines) is 435 MB

    If it fails, check the databases downloaded in ~/.radisdb



    Notes
    -----

    Performance tests of chunksize tested on CO :
        - chunksize=1000000  > 22s  , 1 iteration ~ 22s
        - chunksize=100000 > 18s,  , 1 iteration ~ 4s
        - chunksize=50000 > 19s   ,1 iteration ~ 2s
        - chunksize=1000 --> 90s  ,  1 iteration << 1s
    """

    df = fetch_hitemp(molecule, verbose=verbose)

    assert f"HITEMP-{molecule}" in getDatabankList()

    assert len(df) == INFO_HITEMP_LINE_COUNT[molecule]
Beispiel #4
0
def test_local_hdf5_lines_loading(*args, **kwargs):
    """
    We use the OH HITEMP line database to test :py:func:`~radis.io.hitemp.fetch_hitemp`
    and :py:func:`~radis.io.hdf5.hdf2df`

    - Partial loading (only specific wavenumbers)
    - Only certain isotopes
    - Only certain columns

    """

    fetch_hitemp("OH")  # to initialize the database

    path = getDatabankEntries("HITEMP-OH")["path"]

    # Initialize the database
    fetch_hitemp("OH")
    path = getDatabankEntries("HITEMP-OH")["path"][0]
    df = hdf2df(path)
    wmin, wmax = df.wav.min(), df.wav.max()
    assert wmin < 2300  # needed for next test to be valid
    assert wmax > 2500  # needed for next test to be valid
    assert len(df.columns) > 5  # many columns loaded by default
    assert len(df.iso.unique()) > 1

    # Test loading only certain columns
    df = hdf2df(path, columns=["wav", "int"])
    assert len(df.columns) == 2 and "wav" in df.columns and "int" in df.columns

    # Test loading only certain isotopes
    df = hdf2df(path, isotope="2")
    assert df.iso.unique() == 2

    # Test partial loading of wavenumbers
    df = hdf2df(path, load_wavenum_min=2300, load_wavenum_max=2500)
    assert df.wav.min() >= 2300
    assert df.wav.max() <= 2500

    # Test with only one
    assert hdf2df(path, load_wavenum_min=2300).wav.min() >= 2300

    # Test with the other
    assert hdf2df(path, load_wavenum_max=2500).wav.max() <= 2500
Beispiel #5
0
# -*- coding: utf-8 -*-
"""
Download HITEMP H2O database, parse & cache them, to make sure the example notebooks run fast 
"""

from radis.test.utils import setup_test_line_databases
from radis.io.hitemp import fetch_hitemp

setup_test_line_databases()  # init radis.json etc if needed

for (wmin, wmax) in [(0, 50), (50, 150), (150, 250), (250, 350), (350, 500),
                     (500, 600), (600, 700), (700, 800), (800, 900),
                     (900, 1000), (1000, 1150), (1150, 1300), (1300, 1500),
                     (1500, 1750), (1750, 2000), (2000, 2250), (2250, 2500),
                     (2500, 2750), (2750, 3000), (3000, 3250), (3250, 3500),
                     (3500, 4150), (4150, 4500), (4500, 5000), (5000, 5500),
                     (5500, 6000), (6000, 6500), (6500, 7000), (7000, 7500),
                     (7500, 8000), (8000, 8500), (8500, 9000), (9000, 11000),
                     (11000, 30000)]:
    fetch_hitemp(
        "H2O",
        isotope='1',  # only 1 HITEMP file so all isotopes are downloaded anyway
        load_wavenum_min=wmin,
        load_wavenum_max=wmax,
        verbose=3)
Beispiel #6
0
# -*- coding: utf-8 -*-
"""
Download HITEMP database, parse & cache them, to make sure the example notebooks run fast 
"""

from radis.test.utils import setup_test_line_databases
from radis.io.hitemp import fetch_hitemp

setup_test_line_databases()  # init radis.json etc if needed

# Download other species
for molecule in ["OH", "CO", "NO", "NO2"]:
    print("Downloading and caching ", molecule)
    fetch_hitemp(molecule, isotope='1',                   # only 1 HITEMP file so all isotopes are downloaded anyway
                 load_wavenum_min=2000,  # keep memory usage low. only 1 HITEMP file so everything is downloaded anyway
                 load_wavenum_max=5000,   
                 verbose=3)

# Not downloaded because to big for Binder / GESIS : CH4, N2O (we could actually try N2O)

# Downloaded and computed separately: CO2, H2O