Exemplo n.º 1
0
def _compress(s, sjson):
    ''' if True, removes all quantities that can be regenerated with s.update(),
    e.g, transmittance if abscoeff and path length are given, radiance if
    emisscoeff and abscoeff are given in non-optically thin case, etc.
    Default False '''

    from radis.spectrum.rescale import get_redundant
    redundant = get_redundant(s)

    discarded = []
    for key in list(sjson['_q'].keys()):
        if key == 'wavespace': continue
        if redundant[key]:
            del sjson['_q'][key]
            discarded.append(key)
    for key in list(sjson['_q_conv'].keys()):
        if key == 'wavespace': continue
        if redundant[key]:
            del sjson['_q_conv'][key]
            discarded.append(key)

    if len(discarded) > 0:
        print(('Redundant quantities removed: {0}. Use s.update() after '.format(discarded)+\
              'loading to regenerate them'))

    return sjson
Exemplo n.º 2
0
def test_compression(verbose=True, warnings=True, *args, **kwargs):
    """Test that redundant quantities are properly infered from already known
    spectral quantities"""

    # Get spectrum
    s1 = load_spec(getTestFile("CO_Tgas1500K_mole_fraction0.01.spec"),
                   binary=True)

    s1.conditions["thermal_equilibrium"] = True
    s1.update()

    # Analyse redundant spectral quantities
    redundant = get_redundant(s1)
    if verbose:
        print(redundant)

    assert redundant == {
        "emissivity_noslit": True,
        "radiance_noslit": True,
        "emisscoeff": True,
        "transmittance_noslit": True,
        "absorbance": True,
        "abscoeff": False,
    }

    return True
Exemplo n.º 3
0
def test_compression(verbose=True, warnings=True, *args, **kwargs):
    ''' Test that redundant quantities are properly infered from already known 
    spectral quantities '''

    # Get spectrum
    s1 = load_spec(getTestFile('CO_Tgas1500K_mole_fraction0.01.spec'), binary=True)
    
    s1.conditions['thermal_equilibrium'] = True
    s1.update()

    # Analyse redundant spectral quantities
    redundant = get_redundant(s1)
    if verbose:
        print(redundant)

    assert redundant == {'emissivity_noslit': True, 'radiance_noslit': True,
                         'emisscoeff': True, 'transmittance_noslit': True,
                         'absorbance': True, 'abscoeff': False}

    return True