Beispiel #1
0
def test_irrelevant_file_loading(*args, **kwargs):
    """ check that irrelevant files (irrelevant wavenumber) are not loaded """

    # For cdsd-hitemp files :

    # Ensures file is not empty
    df = cdsd2df(getTestFile("cdsd_hitemp_09_header.txt"), cache="regen")
    assert len(df) > 0

    # Now test nothing is loaded if asking for outside the wavenumber range
    with pytest.raises(IrrelevantFileWarning):
        df = cdsd2df(getTestFile("cdsd_hitemp_09_header.txt"),
                     load_wavenum_min=100000)
    with pytest.raises(IrrelevantFileWarning):
        df = cdsd2df(getTestFile("cdsd_hitemp_09_header.txt"),
                     load_wavenum_max=0.5)

    # For HITRAN files :

    # Ensures file is not empty
    df = hit2df(getTestFile("hitran_2016_H2O_2iso_2000_2100cm.par"),
                cache="regen")
    assert len(df) > 0

    # Now test nothing is loaded if asking for outside the wavenumber range
    with pytest.raises(IrrelevantFileWarning):
        df = hit2df(getTestFile("hitran_2016_H2O_2iso_2000_2100cm.par"),
                    load_wavenum_min=100000)
    with pytest.raises(IrrelevantFileWarning):
        df = hit2df(getTestFile("hitran_2016_H2O_2iso_2000_2100cm.par"),
                    load_wavenum_max=0.5)
Beispiel #2
0
def test_hitran_h2o(verbose=True, warnings=True, **kwargs):
    
    # 1. Load
    df = hit2df(getTestFile('hitran_2016_H2O_2iso_2000_2100cm.par'), cache='regen')
    if verbose:
        print('Read hitran_2016_H2O_2iso_2000_2100cm.par')
        print('-----------------------------------------')
        print(df.head())
        
    # 2. Test
    assert (list(df.loc[0, ['v1u', 'v2u', 'v3u', 'v1l', 'v2l', 'v3l']]) ==
            [0, 2, 0, 0, 1, 0])
    
    assert df.loc[26, 'ju'] == 5    # in .par : line 27, column 99-100
    assert df.loc[27, 'ju'] == 18   # in .par : line 28, column 99-100
    
    
    assert df.dtypes['v1l'] == np.int64
    assert df.dtypes['v3u'] == np.int64
    
    assert df.dtypes['ju'] == np.int64
    assert df.dtypes['Kau'] == np.int64
    assert df.dtypes['Kcu'] == np.int64
    assert df.dtypes['jl'] == np.int64
    assert df.dtypes['Kal'] == np.int64
    assert df.dtypes['Kcl'] == np.int64
    
    return True
Beispiel #3
0
def test_local_hitran_h2o(verbose=True, warnings=True, **kwargs):

    # 1. Load
    df = hit2df(getTestFile("hitran_2016_H2O_2iso_2000_2100cm.par"),
                cache="regen")
    if verbose:
        print("Read hitran_2016_H2O_2iso_2000_2100cm.par")
        print("-----------------------------------------")
        print(df.head())

    # 2. Test
    assert list(df.loc[0, ["v1u", "v2u", "v3u", "v1l", "v2l", "v3l"]]) == [
        0,
        2,
        0,
        0,
        1,
        0,
    ]

    assert df.loc[26, "ju"] == 5  # in .par : line 27, column 99-100
    assert df.loc[27, "ju"] == 18  # in .par : line 28, column 99-100

    assert df.dtypes["v1l"] == np.int64
    assert df.dtypes["v3u"] == np.int64

    assert df.dtypes["ju"] == np.int64
    assert df.dtypes["Kau"] == np.int64
    assert df.dtypes["Kcu"] == np.int64
    assert df.dtypes["jl"] == np.int64
    assert df.dtypes["Kal"] == np.int64
    assert df.dtypes["Kcl"] == np.int64

    return True
Beispiel #4
0
def test_hitran_parser(verbose=True, warnings=True, **kwargs):
    ''' Analyse some default files to make sure everything still works'''
    
    t0 = time()
    df = hit2df(getTestFile('hitran_CO_fragment.par'))
    if verbose: print('File loaded in {0:.0f}s'.format(time()-t0))
    if verbose: print(df.head())
    assert (list(df.loc[0, ['v1u', 'v1l']]) == [4, 4])

    t0 = time()
    df = hit2df(getTestFile('hitran_CO2_fragment.par'))
    if verbose: print('File loaded in {0:.0f}s'.format(time()-t0))
    if verbose: print(df.head())
    assert (list(df.loc[0, ['v1u', 'v2u', 'l2u', 'v3u', 'v1l', 'v2l', 'l2l', 'v3l']]) ==
              [4, 0, 0, 0, 0, 0, 0, 1])
    
    return True
Beispiel #5
0
def test_hitran_co2(verbose=True, warnings=True, **kwargs):
    
    # 1. Load
    df = hit2df(getTestFile('hitran_CO2_fragment.par'), cache='regen')
    if verbose:
        print('Read hitran_CO2_fragment.par')
        print('----------------------------')
        print(df.head())
        
    # 2. Test
    assert (list(df.loc[0, ['v1u', 'v2u', 'l2u', 'v3u', 'v1l', 'v2l', 'l2l', 'v3l']]) ==
            [4, 0, 0, 0, 0, 0, 0, 1])
    assert df.dtypes['v1l'] == np.int64
    assert df.dtypes['v3u'] == np.int64

    return True
Beispiel #6
0
def test_hitran_co(verbose=True, warnings=True, **kwargs):
    ''' Analyse some default files to make sure everything still works'''

    # 1. Load
    df = hit2df(getTestFile('hitran_CO_fragment.par'), cache='regen')
    if verbose:
        print('Read hitran_CO_fragment.par')
        print('---------------------------')
        print(df.head())
        
    # 2. Test
    assert (list(df.loc[0, ['vu', 'vl']]) == [4, 4])
    assert df.dtypes['vu'] == np.int64
    assert df.dtypes['vl'] == np.int64
    
    return True
Beispiel #7
0
def test_local_hitran_co(verbose=True, warnings=True, **kwargs):
    """Analyse some default files to make sure everything still works."""

    # 1. Load
    df = hit2df(getTestFile("hitran_CO_fragment.par"), cache="regen")
    if verbose:
        print("Read hitran_CO_fragment.par")
        print("---------------------------")
        print(df.head())

    # 2. Test
    assert list(df.loc[0, ["vu", "vl"]]) == [4, 4]
    assert df.dtypes["vu"] == np.int64
    assert df.dtypes["vl"] == np.int64

    return True
Beispiel #8
0
def test_local_hitran_co2(verbose=True, warnings=True, **kwargs):

    # 1. Load
    df = hit2df(getTestFile("hitran_CO2_fragment.par"), cache="regen")
    if verbose:
        print("Read hitran_CO2_fragment.par")
        print("----------------------------")
        print(df.head())

    # 2. Test
    assert list(
        df.loc[0,
               ["v1u", "v2u", "l2u", "v3u", "v1l", "v2l", "l2l", "v3l"]]) == [
                   4, 0, 0, 0, 0, 0, 0, 1
               ]
    assert df.dtypes["v1l"] == np.int64
    assert df.dtypes["v3u"] == np.int64

    return True