def calc_radis():

        # %% Calculate with RADIS
        # ----------
        pl = SpectrumFactory(
            wavenum_min=wmin,
            wavenum_max=wmax,
            mole_fraction=1,
            path_length=L,
            wstep=dnu,
            molecule=molecule,
            pressure=p,
            broadening_max_width=broadening_max_width,
            cutoff=1e-23,
            isotope=iso,
        )
        pl.warnings["MissingSelfBroadeningWarning"] = "ignore"
        pl.warnings["HighTemperatureWarning"] = "ignore"
        pl.fetch_databank(
            source="hitran",
            load_energies=False,
            db_use_cached=True,
        )

        s = pl.eq_spectrum(Tgas=T)  # , Ttrans=300)
        s.name = "RADIS"

        if plot:
            pl.plot_broadening()

        return s
    def calc_radis():

        # %% Calculate with RADIS
        # ----------
        pl = SpectrumFactory(wavenum_min=wmin,
                             wavenum_max=wmax,
                             mole_fraction=1,
                             path_length=L,
                             wstep=dnu,
                             molecule=molecule,
                             pressure=p,
                             broadening_max_width=broadening_max_width,
                             cutoff=1e-23,
                             db_use_cached=True,
                             isotope=iso)  # 0.2)
        pl.warnings['MissingSelfBroadeningWarning'] = 'ignore'
        pl.warnings['HighTemperatureWarning'] = 'ignore'
        pl.fetch_databank(format='hitran', load_energies=False)

        s = pl.eq_spectrum(Tgas=T)  # , Ttrans=300)
        s.name = 'RADIS'

        if plot:
            pl.plot_broadening()

        return s
Ejemplo n.º 3
0
    pressure_bar = 1.01315
    T = 296
    isotopes = [1, 2, 3, 4]

    sf = SpectrumFactory(
        wavenum_min=wavenum_min,
        wavenum_max=wavenum_max,
        isotope=isotopes,  #'all',
        verbose=2,
        wstep=dnu,  # depends on HAPI benchmark.
        cutoff=1e-23,
        broadening_max_width=
        5.73,  # Corresponds to WavenumberWingHW/HWHM=50 in HAPI
        molecule=molecule,
    )
    sf.fetch_databank("astroquery", load_energies=False)

    s = sf.eq_spectrum(Tgas=T, pressure=pressure_bar)
    s.name = "RADIS ({0:.1f}s)".format(s.conditions["calculation_time"])

    # Print our HWHM for comparison (a posteriori)
    print(("HWHM max {0:.2f} cm-1".format(sf.df1.hwhm_voigt.max())))
    print((
        "WavenumberWingHW/HWHM",
        int(sf.params.broadening_max_width / (sf.df1.hwhm_voigt.max())),
    ))
    assert (int(sf.params.broadening_max_width /
                (sf.df1.hwhm_voigt.max()))) == benchmark_line_brd_ratio

    # %% Run HAPI
    print("Now calculating with HAPI")
Ejemplo n.º 4
0
    pressure_bar = 1.01315
    T = 296
    isotopes = [1, 2, 3, 4]

    sf = SpectrumFactory(
        wavenum_min=wavenum_min,
        wavenum_max=wavenum_max,
        isotope=isotopes,  #'all',
        verbose=2,
        wstep=dnu,  # depends on HAPI benchmark. 
        cutoff=1e-23,
        broadening_max_width=
        5.73,  # Corresponds to WavenumberWingHW/HWHM=50 in HAPI
        molecule=molecule,
    )
    sf.fetch_databank('astroquery', load_energies=False)

    s = sf.eq_spectrum(Tgas=T, pressure=pressure_bar)
    s.name = 'RADIS ({0:.1f}s)'.format(s.conditions['calculation_time'])

    # Print our HWHM for comparison (a posteriori)
    print(('HWHM max {0:.2f} cm-1'.format(sf.df1.fwhm_voigt.max() / 2)))
    print(
        ('WavenumberWingHW/HWHM',
         int(sf.params.broadening_max_width / (sf.df1.fwhm_voigt.max() / 2))))
    assert (int(sf.params.broadening_max_width /
                (sf.df1.fwhm_voigt.max() / 2))) == benchmark_line_brd_ratio

    # %% Run HAPI
    print('Now calculating with HAPI')
Ejemplo n.º 5
0
    def setup(self):
        self.test_options = opt = {
            "wavelength_min": 4165,
            "wavelength_max": 4200,
            "databank": "fetch",  # not appropriate for these temperatures, but convenient for automatic testing
            "Tgas": 300,
            "Tvib": 1700,
            "Trot": 1550,
            "path_length": 0.1,
            "mole_fraction": 0.5,
            "molecule": "CO2",
            "isotope": "1,2",
            "wstep": 0.01,
            "cutoff": 1e-25,
            "use_cached": True,
            "medium": "vacuum",
            "optimization": "simple",
            "export_lines": False,
            "warnings": {
                "MissingSelfBroadeningWarning": "ignore",
                "NegativeEnergiesWarning": "ignore",
                "HighTemperatureWarning": "ignore",
            },
        }

        # Backward compatibility
        # ----------------------

        # Old version of RADIS do not necessary work with the latest parameters
        # Fix it :
        version = get_version(add_git_number=False)
        if version < "0.9.26":
            del self.test_options["optimization"]

        # Also fix problems with cache files :

        # First run to check there are no problems with Line database cache-files
        # ... Note @dev : as of 0.9.26 encountering a cache file generated with a future version
        # ... raises an error with no option to automatically regenerate the cache file
        sf = SpectrumFactory(
            **{
                k: v
                for (k, v) in opt.items()
                if k
                in [
                    "wavelength_min",
                    "wavelength_max",
                    "molecule",
                    "isotope",
                    "broadening_max_width",
                    "medium",
                ]
            }
        )

        for attempt in range(15):  # max number of failed cache files
            try:
                sf.fetch_databank()
            except ValueError as err:
                if "generated with a future version" in str(err):
                    # Get failing cache file :
                    fcache = re.search(
                        r"(?<=Cache file \().*(?=\) generated)", str(err)
                    )
                    if fcache is not None:
                        fcache = fcache.group()
                        printm(
                            "Backward compatibility : regenerating cache file",
                            fcache,
                        )
                        os.remove(fcache)
                        continue
                raise
            else:
                break
Ejemplo n.º 6
0
    pressure_bar = 1.01315
    T = 296
    isotopes = [1, 2, 3, 4]

    sf = SpectrumFactory(
        wavenum_min=wavenum_min,
        wavenum_max=wavenum_max,
        isotope=isotopes,  #'all',
        verbose=2,
        wstep=dnu,  # depends on HAPI benchmark.
        cutoff=1e-23,
        broadening_max_width=5.73,  # Corresponds to WavenumberWingHW/HWHM=50 in HAPI
        molecule=molecule,
        optimization=None,
    )
    sf.fetch_databank("hitran", load_energies=False)

    s = sf.eq_spectrum(Tgas=T, pressure=pressure_bar)
    s.name = "RADIS ({0:.1f}s)".format(s.conditions["calculation_time"])

    # Print our HWHM for comparison (a posteriori)
    print(("HWHM max {0:.2f} cm-1".format(sf.df1.hwhm_voigt.max())))
    print(
        (
            "WavenumberWingHW/HWHM",
            int(sf.params.broadening_max_width / (sf.df1.hwhm_voigt.max())),
        )
    )
    assert (
        int(sf.params.broadening_max_width / (sf.df1.hwhm_voigt.max()))
    ) == benchmark_line_brd_ratio
T_earth = 288  # average night/day Earth surface  K

# %% Get Spectral line database
sf = SpectrumFactory(
    wavenum_min=wmin,
    wavenum_max=wmax,
    molecule='CO2',
    isotope='1,2,3',
    verbose=False,
    broadening_max_width=broadening_max_width,
    wstep=wstep,
    warnings={'MissingSelfBroadeningWarning': 'ignore'},
    export_lines=False,
    chunksize='DLM',
)
sf.fetch_databank(
    load_energies=False)  # loads from HITRAN, requires an internet connection

#%% ===========================================================================
# Calculations
# =============================================================================

# Calculate ground emission
s_earth_0 = sPlanck(wmin, wmax, wstep=wstep, T=T_earth, eps=1 - albedo)

#%% Calculate atmosphere

# Calculate atmosphere layers

slabs = []
print('Calculating Atmosphere layers')
pb = ProgressBar(len(atm))