From 83ad3ace310efa1ed1ea74689fc686e2519b56ef Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 17:06:14 +0900 Subject: [PATCH 01/15] first trial --- requirements.txt | 2 +- setup.py | 37 +++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/requirements.txt b/requirements.txt index cac7b877..1855d827 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,4 +25,4 @@ plotly psutil seaborn PyMieScatt -numpy<2 +#numpy<2 diff --git a/setup.py b/setup.py index 69e0ff0e..397c0f24 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,7 @@ 'Programming Language :: Python', "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Operating System :: OS Independent", ] @@ -72,27 +73,27 @@ def read_requirements(): ) # VAEX UNISTALL and REINSTALL See Issue 2376 vaex https://github.com/vaexio/vaex/issues/2376 -import subprocess -import sys +#import subprocess +#import sys -def install_radis_develop(): - subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", 'git+https://github.com/radis/radis@develop#egg=radis']) +#def install_radis_develop(): +# subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", 'git+https://github.com/radis/radis@develop#egg=radis']) -def uninstall(package): - subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", package]) +#def uninstall(package): +# subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", package]) -def reinstall(package): - subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", package]) - subprocess.check_call([sys.executable, "-m", "pip", "install", package]) +#def reinstall(package): +# subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", package]) +# subprocess.check_call([sys.executable, "-m", "pip", "install", package]) -install_radis_develop() -uninstall('vaex-core') -uninstall('vaex-astro') -uninstall('vaex-jupyter') -uninstall('vaex-ml') -uninstall('vaex-hdf5') -uninstall('vaex-server') -uninstall('vaex-viz') +#install_radis_develop() +#uninstall('vaex-core') +#uninstall('vaex-astro') +#uninstall('vaex-jupyter') +#uninstall('vaex-ml') +#uninstall('vaex-hdf5') +#uninstall('vaex-server') +#uninstall('vaex-viz') -reinstall('vaex') +#reinstall('vaex') From 08fee4fc85b84ffa512d8320113eafc841bd4855 Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 17:18:30 +0900 Subject: [PATCH 02/15] temp --- .github/workflows/main.yml | 4 ++-- requirements.txt | 2 ++ tests/unittests/install/func.py | 22 ---------------------- 3 files changed, 4 insertions(+), 24 deletions(-) delete mode 100644 tests/unittests/install/func.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 789de469..5c6abdf6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,10 +17,10 @@ jobs: uses: actions/checkout@v2 # Setup Python - - name: Set up Python 3.10 + - name: Set up Python 3.11 uses: actions/setup-python@v2 with: - python-version: '3.10' + python-version: '3.11' # install package - name: Install dependencies diff --git a/requirements.txt b/requirements.txt index 1855d827..dc8047f9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +radis jax jaxlib hitran-api @@ -25,4 +26,5 @@ plotly psutil seaborn PyMieScatt +vaex #numpy<2 diff --git a/tests/unittests/install/func.py b/tests/unittests/install/func.py deleted file mode 100644 index 0db85540..00000000 --- a/tests/unittests/install/func.py +++ /dev/null @@ -1,22 +0,0 @@ -import pytest -import jax.numpy as jnp -from jax.lax import scan - - -def test_cuDNN(): - # convolution requires cuDNN - v = jnp.array([1, 9, 1]) - s = jnp.array([0, 0, 0, 0, 1, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1]) - c = jnp.convolve(s, v, mode='same') - res = c-jnp.array([0., 0., 0., 1., 11., 19., 2., 0., - 2., 18., 2., 0., 0., 0., 1., 9., ]) - assert jnp.sum(res**2) == 0.0 - - -def test_vaex(): - import vaex - - -if __name__ == '__main__': - test_cuDNN() - test_vaex() From 2a4efd112746ba6c6f3c40c02eaf4c6b0deeffda Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 17:41:29 +0900 Subject: [PATCH 03/15] requirements.txt --- requirements.txt | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/requirements.txt b/requirements.txt index 7a939d74..71a5afde 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,30 +1,9 @@ -radis jax jaxlib hitran-api beautifulsoup4 hjson # Json with comments (for default_radis.json) tqdm -lxml # parser used for ExoMol website -publib>=0.3.2 # Plotting styles for Matplotlib -peakutils -ruamel.yaml -json-tricks>=3.15.0 # to deal with non jsonable formats -mpldatacursor -configparser -cython -termcolor -tables -joblib -pandas -plotly -progressbar2 -numba -mpldatacursor -publib -plotly -psutil -seaborn PyMieScatt vaex -#numpy<2 +radis From 9061acb90e9cd21250d7520658433f1b5bdbb7d2 Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 17:44:48 +0900 Subject: [PATCH 04/15] removed vaex --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 71a5afde..19a71b51 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,4 @@ beautifulsoup4 hjson # Json with comments (for default_radis.json) tqdm PyMieScatt -vaex radis From 4e724b932f22415b0f13007323d34874d0929e4a Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 19:52:17 +0900 Subject: [PATCH 05/15] added numba and pandas --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 19a71b51..9343050f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,6 @@ hjson # Json with comments (for default_radis.json) tqdm PyMieScatt radis +numba +pandas +vaex From e86f7e4066504ccd583a2da180538c5fd82b753f Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 19:56:00 +0900 Subject: [PATCH 06/15] 3.10 --- .github/workflows/main.yml | 4 ++-- src/exojax/spec/api.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5c6abdf6..789de469 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,10 +17,10 @@ jobs: uses: actions/checkout@v2 # Setup Python - - name: Set up Python 3.11 + - name: Set up Python 3.10 uses: actions/setup-python@v2 with: - python-version: '3.11' + python-version: '3.10' # install package - name: Install dependencies diff --git a/src/exojax/spec/api.py b/src/exojax/spec/api.py index 33055045..f97aa038 100644 --- a/src/exojax/spec/api.py +++ b/src/exojax/spec/api.py @@ -10,7 +10,6 @@ import numpy as np import jax.numpy as jnp import pathlib -import vaex import warnings from exojax.spec.hitran import line_strength_numpy from exojax.spec.hitran import gamma_natural as gn @@ -29,6 +28,8 @@ from radis.api.hdf5 import update_pytables_to_vaex from radis.db.classes import get_molecule from radis.levels.partfunc import PartFuncTIPS +import vaex + import warnings __all__ = ["MdbExomol", "MdbHitemp", "MdbHitran"] From ec341f9c0049d72c3268fc8ae9b766d990630f15 Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 20:44:02 +0900 Subject: [PATCH 07/15] vaex/pytables in api.py --- src/exojax/spec/api.py | 191 ++++++++++++++++++++++++++++++----------- 1 file changed, 140 insertions(+), 51 deletions(-) diff --git a/src/exojax/spec/api.py b/src/exojax/spec/api.py index f97aa038..dbb7f1c7 100644 --- a/src/exojax/spec/api.py +++ b/src/exojax/spec/api.py @@ -6,6 +6,7 @@ * MdbCommonHitempHitran is the common MDB for HITEMP and HITRAN """ + from os.path import exists import numpy as np import jax.numpy as jnp @@ -28,7 +29,7 @@ from radis.api.hdf5 import update_pytables_to_vaex from radis.db.classes import get_molecule from radis.levels.partfunc import PartFuncTIPS -import vaex +from radis.api.dbmanager import get_auto_MEMORY_MAPPING_ENGINE import warnings @@ -107,6 +108,7 @@ def __init__( self.skip_optional_data = not optional_quantum_states self.activation = activation wavenum_min, wavenum_max = self.set_wavenum(nurange) + self.engine = get_auto_MEMORY_MAPPING_ENGINE() super().__init__( str(self.path), @@ -114,7 +116,7 @@ def __init__( molecule=self.simple_molecule_name, name="EXOMOL-{molecule}", nurange=[wavenum_min, wavenum_max], - engine="vaex", + engine=self.engine, crit=crit, bkgdatm=self.bkgdatm, broadf=self.broadf, @@ -135,7 +137,7 @@ def __init__( local_files, # columns=[k for k in self.__dict__ if k not in ["logsij0"]], # lower_bound=([("Sij0", 0.0)]), - output="vaex", + output=self.engine, ) self.df_load_mask = self.compute_load_mask(df) @@ -227,17 +229,32 @@ def instances_from_dataframes(self, df_masked): if len(df_masked) == 0: raise ValueError("No line found in ", self.nurange, "cm-1") - if isinstance(df_masked, vaex.dataframe.DataFrameLocal): - self.A = df_masked.A.values - self.nu_lines = df_masked.nu_lines.values - self.elower = df_masked.elower.values - self.jlower = df_masked.jlower.values - self.jupper = df_masked.jupper.values - self.line_strength_ref = df_masked.Sij0.values - self.logsij0 = np.log(self.line_strength_ref) - self.gpp = df_masked.gup.values + if self.engine == "vaex": + self.instances_from_dataframes_vaex(df_masked) + elif self.engine == "pytables": + self.instances_from_dataframes_pytables(df_masked) else: - raise ValueError("Use vaex dataframe as input.") + raise ValueError("Use vaex or pytables as input.") + + def instances_from_dataframes_pytables(self, df_masked): + self.A = df_masked.cols.A[:] + self.nu_lines = df_masked.cols.nu_lines[:] + self.elower = df_masked.cols.elower[:] + self.jlower = df_masked.cols.jlower[:] + self.jupper = df_masked.cols.jupper[:] + self.line_strength_ref = df_masked.cols.Sij0[:] + self.logsij0 = np.log(self.line_strength_ref) + self.gpp = df_masked.cols.gup[:] + + def instances_from_dataframes_vaex(self, df_masked): + self.A = df_masked.A.values + self.nu_lines = df_masked.nu_lines.values + self.elower = df_masked.elower.values + self.jlower = df_masked.jlower.values + self.jupper = df_masked.jupper.values + self.line_strength_ref = df_masked.Sij0.values + self.logsij0 = np.log(self.line_strength_ref) + self.gpp = df_masked.gup.values def apply_mask_mdb(self, mask): """Applys mask for mdb class for Exomol @@ -275,7 +292,7 @@ def Sij0(self): return self.line_strength_ref def generate_jnp_arrays(self): - """(re)generates jnp.arrays. + """(re)generates jnp.arrays. Note: We have nd arrays and jnp arrays. We usually apply the mask to nd arrays and then generate jnp array from the corresponding nd array. For instance, self._A is nd array and self.A is jnp array. @@ -375,6 +392,7 @@ def __init__( self.activation = activation self.load_wavenum_min, self.load_wavenum_max = self.set_wavenum(nurange) self.with_error = with_error + self.engine = get_auto_MEMORY_MAPPING_ENGINE() def QT_for_select_line(self, Ttyp): if self.isotope is None or self.isotope == 0: @@ -671,7 +689,7 @@ def __init__( if parfile is not None: from radis.api.hitranapi import hit2df - df = hit2df(parfile, engine="vaex", cache="regen") + df = hit2df(parfile, engine=self.engine, cache="regen") if isotope is None: mask = None elif isotope == 0: @@ -691,9 +709,12 @@ def __init__( converted = [] for f in download_files: - if exists(f.replace(".hdf5", ".h5")): + if exists(f.replace(".hdf5", ".h5") and self.engine == "vaex"): update_pytables_to_vaex(f.replace(".hdf5", ".h5")) converted.append(f) + if exists(f.replace(".hdf5", ".h5") and self.engine == "pytables"): + converted.append(f) + download_files = [f for f in download_files if f not in converted] # do not re-download remaining files that exist. Let user decide what to do. # (download & re-parsing is a long solution!) @@ -718,7 +739,7 @@ def __init__( local_files, self.load_wavenum_min, self.load_wavenum_max ) columns = (None,) - output = "vaex" + output = self.engine isotope_dfform = _convert_proper_isotope(self.isotope) df = self.load( @@ -748,6 +769,33 @@ def instances_from_dataframes(self, df_masked): """ self.check_line_existence_in_nurange(df_masked) + + if self.engine == "vaex": + self.instances_from_dataframes_vaex(df_masked) + elif self.engine == "pytables": + self.instances_from_dataframes_pytables(df_masked) + else: + raise ValueError("Use vaex or pytables as input.") + + def instances_from_dataframes_pytables(self, df_masked): + self.nu_lines = df_masked.cols.wav[:] + self.line_strength_ref = df_masked.cols.int[:] + self.logsij0 = np.log(self.line_strength_ref) + self.delta_air = df_masked.cols.Pshft[:] + self.A = df_masked.cols.A[:] + self.n_air = df_masked.cols.Tdpair[:] + self.gamma_air = df_masked.cols.airbrd[:] + self.gamma_self = df_masked.cols.selbrd[:] + self.elower = df_masked.cols.El[:] + self.gpp = df_masked.cols.gp[:] + # isotope + self.isoid = df_masked.cols.iso[:] + self.uniqiso = np.unique(self.isoid) + if self.with_error: + # uncertainties + self.ierr = df_masked.cols.ierr[:] + + def instances_from_dataframes_vaex(self, df_masked): self.nu_lines = df_masked.wav.values self.line_strength_ref = df_masked.int.values self.logsij0 = np.log(self.line_strength_ref) @@ -758,18 +806,18 @@ def instances_from_dataframes(self, df_masked): self.gamma_self = df_masked.selbrd.values self.elower = df_masked.El.values self.gpp = df_masked.gp.values - # isotope + # isotope self.isoid = df_masked.iso.values self.uniqiso = np.unique(self.isoid) if self.with_error: - # uncertainties + # uncertainties self.ierr = df_masked.ierr.values.to_numpy().astype(np.int64) def generate_jnp_arrays(self): """(re)generate jnp.arrays. Note: - We have nd arrays and jnp arrays. We usually apply the mask to nd arrays and then generate jnp array from the corresponding nd array. For instance, self._A is nd array and self.A is jnp array. + We have nd arrays and jnp arrays. We usually apply the mask to nd arrays and then generate jnp array from the corresponding nd array. For instance, self._A is nd array and self.A is jnp array. """ # jnp.array copy from the copy sources @@ -821,7 +869,7 @@ def __init__( nonair_broadening=False, with_error=False, ): - """Molecular database for HITRAN/HITEMP form. + """Molecular database for HITRAN/HITEMP form. Args: path: path for HITRAN/HITEMP par file @@ -892,7 +940,7 @@ def __init__( # Load and return columns = None - output = "vaex" + output = self.engine isotope_dfform = _convert_proper_isotope(self.isotope) df = self.load( @@ -927,39 +975,80 @@ def instances_from_dataframes(self, df_load_mask): ValueError: _description_ """ self.check_line_existence_in_nurange(df_load_mask) - if isinstance(df_load_mask, vaex.dataframe.DataFrameLocal): - self.nu_lines = df_load_mask.wav.values - self.line_strength_ref = df_load_mask.int.values - self.logsij0 = np.log(self.line_strength_ref) - self.delta_air = df_load_mask.Pshft.values - self.A = df_load_mask.A.values - self.n_air = df_load_mask.Tdpair.values - self.gamma_air = df_load_mask.airbrd.values - self.gamma_self = df_load_mask.selbrd.values - self.elower = df_load_mask.El.values - self.gpp = df_load_mask.gp.values - # isotope - self.isoid = df_load_mask.iso.values - self.uniqiso = np.unique(self.isoid) - if self.with_error: - # uncertainties - self.ierr = df_load_mask.ierr.values + if self.engine == "vaex": + self.instances_from_dataframes_vaex(df_load_mask) + elif self.engine == "pytables": + self.instances_from_dataframes_pytables(df_load_mask) + else: + raise ValueError("Invalid engine") + + def instances_from_dataframes_pytables(self, df_load_mask): + self.nu_lines = df_load_mask.cols.wav[:] + self.line_strength_ref = df_load_mask.cols.int[:] + self.logsij0 = np.log(self.line_strength_ref) + self.delta_air = df_load_mask.cols.Pshft[:] + self.A = df_load_mask.cols.A[:] + self.n_air = df_load_mask.cols.Tdpair[:] + self.gamma_air = df_load_mask.cols.airbrd[:] + self.gamma_self = df_load_mask.cols.selbrd[:] + self.elower = df_load_mask.cols.El[:] + self.gpp = df_load_mask.cols.gp[:] + # isotope + self.isoid = df_load_mask.cols.iso[:] + self.uniqiso = np.unique(self.isoid) + if self.with_error: + # uncertainties + self.ierr = df_load_mask.cols.ierr[:] + + if hasattr(df_load_mask, "n_h2") and self.nonair_broadening: + self.n_h2 = df_load_mask.cols.n_h2[:] + self.gamma_h2 = df_load_mask.cols.gamma_h2[:] + + if hasattr(df_load_mask, "n_he") and self.nonair_broadening: + self.n_he = df_load_mask.cols.n_he[:] + self.gamma_he = df_load_mask.cols.gamma_he[:] + + if hasattr(df_load_mask, "n_co2") and self.nonair_broadening: + self.n_co2 = df_load_mask.cols.n_co2[:] + self.gamma_co2 = df_load_mask.cols.gamma_co2[:] + + if hasattr(df_load_mask, "n_h2o") and self.nonair_broadening: + self.n_h2o = df_load_mask.cols.n_h2o[:] + self.gamma_h2o = df_load_mask.cols.gamma_h2o[:] + + def instances_from_dataframes_vaex(self, df_load_mask): + self.nu_lines = df_load_mask.wav.values + self.line_strength_ref = df_load_mask.int.values + self.logsij0 = np.log(self.line_strength_ref) + self.delta_air = df_load_mask.Pshft.values + self.A = df_load_mask.A.values + self.n_air = df_load_mask.Tdpair.values + self.gamma_air = df_load_mask.airbrd.values + self.gamma_self = df_load_mask.selbrd.values + self.elower = df_load_mask.El.values + self.gpp = df_load_mask.gp.values + # isotope + self.isoid = df_load_mask.iso.values + self.uniqiso = np.unique(self.isoid) + if self.with_error: + # uncertainties + self.ierr = df_load_mask.ierr.values - if hasattr(df_load_mask, "n_h2") and self.nonair_broadening: - self.n_h2 = df_load_mask.n_h2.values - self.gamma_h2 = df_load_mask.gamma_h2.values + if hasattr(df_load_mask, "n_h2") and self.nonair_broadening: + self.n_h2 = df_load_mask.n_h2.values + self.gamma_h2 = df_load_mask.gamma_h2.values - if hasattr(df_load_mask, "n_he") and self.nonair_broadening: - self.n_he = df_load_mask.n_he.values - self.gamma_he = df_load_mask.gamma_he.values + if hasattr(df_load_mask, "n_he") and self.nonair_broadening: + self.n_he = df_load_mask.n_he.values + self.gamma_he = df_load_mask.gamma_he.values - if hasattr(df_load_mask, "n_co2") and self.nonair_broadening: - self.n_co2 = df_load_mask.n_co2.values - self.gamma_co2 = df_load_mask.gamma_co2.values + if hasattr(df_load_mask, "n_co2") and self.nonair_broadening: + self.n_co2 = df_load_mask.n_co2.values + self.gamma_co2 = df_load_mask.gamma_co2.values - if hasattr(df_load_mask, "n_h2o") and self.nonair_broadening: - self.n_h2o = df_load_mask.n_h2o.values - self.gamma_h2o = df_load_mask.gamma_h2o.values + if hasattr(df_load_mask, "n_h2o") and self.nonair_broadening: + self.n_h2o = df_load_mask.n_h2o.values + self.gamma_h2o = df_load_mask.gamma_h2o.values def generate_jnp_arrays(self): """(re)generate jnp.arrays. From 2099086d2d01ef1f46673d88333e3ba9c2936391 Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 20:49:49 +0900 Subject: [PATCH 08/15] save option (vaex/hdf for tables) in atomll.py --- src/exojax/spec/atomllapi.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/exojax/spec/atomllapi.py b/src/exojax/spec/atomllapi.py index 890da0f4..7f8bb2fd 100644 --- a/src/exojax/spec/atomllapi.py +++ b/src/exojax/spec/atomllapi.py @@ -4,7 +4,7 @@ import pandas as pd from exojax.utils.constants import ccgs, ecgs, mecgs, eV2wn import io -import vaex +#import vaex import pkgutil from io import BytesIO @@ -132,7 +132,7 @@ ] -def read_ExAll(allf): +def read_ExAll(allf, engine="vaex"): """IO for linelists downloaded from VALD3 with a query of "Long format" in the format of "Extract All" or "Extract Element". Note: @@ -166,9 +166,10 @@ def read_ExAll(allf): Damping Rad. Damping Stark Damping Waals + engine: "vaex" or "pytables" (default: "vaex") Returns: - line data in vaex DataFrame + line data in vaex/pytables DataFrame """ dat = pd.read_csv( allf, @@ -247,8 +248,12 @@ def read_ExAll(allf): dat.iloc[:, 1] = np.where( dat.iloc[:, 1] > 2000, air_to_vac(dat.iloc[:, 1]), dat.iloc[:, 1] ) - dat = vaex.from_pandas(dat) - dat.export_hdf5(allf.with_suffix(".hdf5")) + if engine == "vaex": + import vaex + dat = vaex.from_pandas(dat) + dat.export_hdf5(allf.with_suffix(".hdf5")) + elif engine == "pytables": + dat.to_hdf(allf.with_suffix(".h5"), key="dat", mode="w",fomrat="table") return dat From 9e15ff02213ad1f12fb58af2d2f1edad516f8b4b Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 20:55:14 +0900 Subject: [PATCH 09/15] made vaex option --- .github/workflows/main.yml | 4 +-- src/exojax/spec/moldb.py | 63 ++++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 789de469..5c6abdf6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,10 +17,10 @@ jobs: uses: actions/checkout@v2 # Setup Python - - name: Set up Python 3.10 + - name: Set up Python 3.11 uses: actions/setup-python@v2 with: - python-version: '3.10' + python-version: '3.11' # install package - name: Install dependencies diff --git a/src/exojax/spec/moldb.py b/src/exojax/spec/moldb.py index b615167b..00c403ac 100644 --- a/src/exojax/spec/moldb.py +++ b/src/exojax/spec/moldb.py @@ -4,11 +4,9 @@ import numpy as np import jax.numpy as jnp import pathlib -import vaex import warnings from exojax.spec import atomllapi, atomll from exojax.utils.constants import Tref_original -from exojax.spec import api __all__ = ['AdbVald', 'AdbSepVald', 'AdbKurucz'] explanation_states = "Note: Couldn't find the hdf5 format. We convert data to the hdf5 format. After the second time, it will become much faster." @@ -47,23 +45,24 @@ class AdbVald(object): QTref_284 (jnp array): partition function at the reference temperature Q(Tref), for 284 species Note: - For the first time to read the VALD line list, it is converted to HDF/vaex. After the second-time, we use the HDF5 format with vaex instead. + For the first time to read the VALD line list, it is converted to HDF/vaex. After the second-time, we use the HDF5 format with vaex instead. """ - def __init__(self, path, nurange=[-np.inf, np.inf], margin=0.0, crit=0., Irwin=False, gpu_transfer=True, vmr_fraction=None): + def __init__(self, path, nurange=[-np.inf, np.inf], margin=0.0, crit=0., Irwin=False, gpu_transfer=True, vmr_fraction=None, engine="vaex"): """Atomic database for VALD3 "Long format". Args: - path: path for linelists downloaded from VALD3 with a query of "Long format" in the format of "Extract All", "Extract Stellar", or "Extract Element" - nurange: wavenumber range list (cm-1) or wavenumber array - margin: margin for nurange (cm-1) - crit: line strength lower limit for extraction - Irwin: if True(1), the partition functions of Irwin1981 is used, otherwise those of Barklem&Collet2016 - gpu_transfer: tranfer data to jnp.array? - vmr_fraction: list of the vmr fractions of hydrogen, H2 molecule, helium. if None, typical quasi-"solar-fraction" will be applied. + path: path for linelists downloaded from VALD3 with a query of "Long format" in the format of "Extract All", "Extract Stellar", or "Extract Element" + nurange: wavenumber range list (cm-1) or wavenumber array + margin: margin for nurange (cm-1) + crit: line strength lower limit for extraction + Irwin: if True(1), the partition functions of Irwin1981 is used, otherwise those of Barklem&Collet2016 + gpu_transfer: tranfer data to jnp.array? + vmr_fraction: list of the vmr fractions of hydrogen, H2 molecule, helium. if None, typical quasi-"solar-fraction" will be applied. + engine: "vaex" or "pandas" Note: - (written with reference to moldb.py, but without using feather format) + (written with reference to moldb.py, but without using feather format) """ self.dbtype = "vald" @@ -80,12 +79,16 @@ def __init__(self, path, nurange=[-np.inf, np.inf], margin=0.0, crit=0., Irwin=F # load vald file print('Reading VALD file') - if self.vald3_file.with_suffix('.hdf5').exists(): + if self.vald3_file.with_suffix('.hdf5').exists() and engine == "vaex": + import vaex valdd = vaex.open(self.vald3_file.with_suffix('.hdf5')) + elif self.vald3_file.with_suffix('.hdf5').exists() and engine == "pytables": + import pandas as pd + valdd = pd.read_hdf(self.vald3_file.with_suffix('.hdf5')) else: print( "Note: Couldn't find the hdf5 format. We convert data to the hdf5 format.") - valdd = atomllapi.read_ExAll(self.vald3_file) # vaex.DataFrame + valdd = atomllapi.read_ExAll(self.vald3_file, engine=engine) # vaex.DataFrame pvaldd = valdd.to_pandas_df() # pandas.DataFrame # compute additional transition parameters @@ -129,7 +132,7 @@ def masking(self, mask): """applying mask. Args: - mask: mask to be applied. self.mask is updated. + mask: mask to be applied. self.mask is updated. """ # numpy float 64 Do not convert them jnp array @@ -157,7 +160,7 @@ def generate_jnp_arrays(self): """(re)generate jnp.arrays. Note: - We have nd arrays and jnp arrays. We usually apply the mask to nd arrays and then generate jnp array from the corresponding nd array. For instance, self._A is nd array and self.A is jnp array. + We have nd arrays and jnp arrays. We usually apply the mask to nd arrays and then generate jnp array from the corresponding nd array. For instance, self._A is nd array and self.A is jnp array. """ # jnp arrays @@ -198,11 +201,11 @@ def QT_interp(self, atomspecies, T): Collet (2016) are adopted. Args: - atomspecies: species e.g., "Fe 1" - T: temperature + atomspecies: species e.g., "Fe 1" + T: temperature Returns: - Q(T): interpolated in jnp.array for the Atomic Species + Q(T): interpolated in jnp.array for the Atomic Species """ gQT = self.Atomic_gQT(atomspecies) QT = jnp.interp(T, self.T_gQT, gQT) @@ -214,11 +217,11 @@ def QT_interp_Irwin_Fe(self, T, atomspecies='Fe 1'): I (Other species are not yet implemented). Args: - atomspecies: species e.g., "Fe 1" - T: temperature + atomspecies: species e.g., "Fe 1" + T: temperature Returns: - Q(T): interpolated in jnp.array for the Atomic Species + Q(T): interpolated in jnp.array for the Atomic Species """ gQT = self.Atomic_gQT(atomspecies) QT = atomllapi.partfn_Fe(T) @@ -229,11 +232,11 @@ def qr_interp(self, atomspecies, T): Barklem & Collet (2016) are adopted. Args: - T: temperature - atomspecies: species e.g., "Fe 1" + T: temperature + atomspecies: species e.g., "Fe 1" Returns: - qr(T)=Q(T)/Q(Tref): interpolated in jnp.array + qr(T)=Q(T)/Q(Tref): interpolated in jnp.array """ return self.QT_interp(atomspecies, T)/self.QT_interp(atomspecies, Tref_original) @@ -243,11 +246,11 @@ def qr_interp_Irwin_Fe(self, T, atomspecies='Fe 1'): (1981) for Fe I (Other species are not yet implemented). Args: - T: temperature - atomspecies: species e.g., "Fe 1" + T: temperature + atomspecies: species e.g., "Fe 1" Returns: - qr(T)=Q(T)/Q(Tref): interpolated in jnp.array + qr(T)=Q(T)/Q(Tref): interpolated in jnp.array """ return self.QT_interp_Irwin_Fe(T, atomspecies)/self.QT_interp_Irwin_Fe(Tref_original, atomspecies) @@ -255,10 +258,10 @@ def QT_interp_284(self, T): """(DEPRECATED) interpolated partition function of all 284 species. Args: - T: temperature + T: temperature Returns: - Q(T)*284: interpolated in jnp.array for all 284 Atomic Species + Q(T)*284: interpolated in jnp.array for all 284 Atomic Species """ warn_msg = "Deprecated Use `atomll.interp_QT_284` instead" warnings.warn(warn_msg, FutureWarning) From 06468d73833a87185208e84127554b987ce76a0c Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 20:57:15 +0900 Subject: [PATCH 10/15] removed vaex from requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 9343050f..273c0e9b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,5 +7,5 @@ tqdm PyMieScatt radis numba +tables pandas -vaex From 90fa00694b5e3626697e4832ab83b1ba566184ca Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 21:35:44 +0900 Subject: [PATCH 11/15] added termcolor in requirements.txt --- requirements.txt | 1 + setup.py | 86 ++++++++++++++++++++++-------------------------- 2 files changed, 41 insertions(+), 46 deletions(-) diff --git a/requirements.txt b/requirements.txt index 273c0e9b..5f7afc4c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ jax jaxlib hitran-api beautifulsoup4 +termcolor hjson # Json with comments (for default_radis.json) tqdm PyMieScatt diff --git a/setup.py b/setup.py index 397c0f24..1e197a01 100644 --- a/setup.py +++ b/setup.py @@ -5,11 +5,11 @@ from setuptools import find_packages, setup # PROJECT SPECIFIC -NAME = 'ExoJAX' -PACKAGES = find_packages(where='src') -META_PATH = os.path.join('src', 'exojax', '__init__.py') +NAME = "ExoJAX" +PACKAGES = find_packages(where="src") +META_PATH = os.path.join("src", "exojax", "__init__.py") CLASSIFIERS = [ - 'Programming Language :: Python', + "Programming Language :: Python", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -21,79 +21,73 @@ def read(*parts): - with codecs.open(os.path.join(HERE, *parts), 'rb', 'utf-8') as f: + with codecs.open(os.path.join(HERE, *parts), "rb", "utf-8") as f: return f.read() def find_meta(meta, meta_file=read(META_PATH)): meta_match = re.search( - r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta), meta_file, - re.M) + r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta), meta_file, re.M + ) if meta_match: return meta_match.group(1) - raise RuntimeError('Unable to find __{meta}__ string.'.format(meta=meta)) + raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta)) def read_requirements(): - with open('requirements.txt', 'r') as file: + with open("requirements.txt", "r") as file: return file.readlines() - - -if __name__ == '__main__': +if __name__ == "__main__": setup( name=NAME, use_scm_version={ - 'write_to': - os.path.join('src', 'exojax', '{0}_version.py'.format(NAME)), - 'write_to_template': - '__version__ = "{version}"\n', + "write_to": os.path.join("src", "exojax", "{0}_version.py".format(NAME)), + "write_to_template": '__version__ = "{version}"\n', }, - version='1.5', - author=find_meta('author'), - author_email=find_meta('email'), - maintainer=find_meta('author'), - maintainer_email=find_meta('email'), - url=find_meta('uri'), - license=find_meta('license'), - description=find_meta('description'), - long_description=open('README.md').read(), - long_description_content_type='text/markdown', + version="1.5", + author=find_meta("author"), + author_email=find_meta("email"), + maintainer=find_meta("author"), + maintainer_email=find_meta("email"), + url=find_meta("uri"), + license=find_meta("license"), + description=find_meta("description"), + long_description=open("README.md").read(), + long_description_content_type="text/markdown", packages=PACKAGES, - python_requires='>=3.9', - package_dir={'': 'src'}, + python_requires=">=3.9", + package_dir={"": "src"}, include_package_data=True, install_requires=read_requirements(), classifiers=CLASSIFIERS, zip_safe=False, - options={'bdist_wheel': { - 'universal': '1' - }}, + options={"bdist_wheel": {"universal": "1"}}, ) -# VAEX UNISTALL and REINSTALL See Issue 2376 vaex https://github.com/vaexio/vaex/issues/2376 -#import subprocess -#import sys +# VAEX UNISTALL and REINSTALL See Issue 2376 vaex https://github.com/vaexio/vaex/issues/2376 +# import subprocess +# import sys -#def install_radis_develop(): +# def install_radis_develop(): # subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", 'git+https://github.com/radis/radis@develop#egg=radis']) -#def uninstall(package): +# def uninstall(package): # subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", package]) -#def reinstall(package): +# def reinstall(package): # subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", package]) # subprocess.check_call([sys.executable, "-m", "pip", "install", package]) -#install_radis_develop() -#uninstall('vaex-core') -#uninstall('vaex-astro') -#uninstall('vaex-jupyter') -#uninstall('vaex-ml') -#uninstall('vaex-hdf5') -#uninstall('vaex-server') -#uninstall('vaex-viz') +# install_radis_develop() +# uninstall('vaex-core') +# uninstall('vaex-astro') +# uninstall('vaex-jupyter') +# uninstall('vaex-ml') +# uninstall('vaex-hdf5') +# uninstall('vaex-server') +# uninstall('vaex-viz') -#reinstall('vaex') +# reinstall('vaex') From b2c246f798efd20ef1d4182800d7009db5b9049c Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 21:39:42 +0900 Subject: [PATCH 12/15] h5py added --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5f7afc4c..ae732512 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ jax jaxlib hitran-api beautifulsoup4 -termcolor hjson # Json with comments (for default_radis.json) tqdm PyMieScatt @@ -10,3 +9,5 @@ radis numba tables pandas +termcolor +h5py From e005ee318ee8198f131a14837e9171af9403699e Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 22:20:02 +0900 Subject: [PATCH 13/15] numpy<2 needed --- requirements.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/requirements.txt b/requirements.txt index ae732512..51320dc3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,8 @@ tables pandas termcolor h5py +joblib +astropy +psutil +json_tricks +numpy<2 From c4c1dd7dc1e9ecb4b8f9b607d9e39c4d3cf2b66b Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 22:27:00 +0900 Subject: [PATCH 14/15] removed .cols --- src/exojax/spec/api.py | 74 +++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/exojax/spec/api.py b/src/exojax/spec/api.py index dbb7f1c7..2e6a1d3d 100644 --- a/src/exojax/spec/api.py +++ b/src/exojax/spec/api.py @@ -237,14 +237,14 @@ def instances_from_dataframes(self, df_masked): raise ValueError("Use vaex or pytables as input.") def instances_from_dataframes_pytables(self, df_masked): - self.A = df_masked.cols.A[:] - self.nu_lines = df_masked.cols.nu_lines[:] - self.elower = df_masked.cols.elower[:] - self.jlower = df_masked.cols.jlower[:] - self.jupper = df_masked.cols.jupper[:] - self.line_strength_ref = df_masked.cols.Sij0[:] + self.A = df_masked.A[:] + self.nu_lines = df_masked.nu_lines[:] + self.elower = df_masked.elower[:] + self.jlower = df_masked.jlower[:] + self.jupper = df_masked.jupper[:] + self.line_strength_ref = df_masked.Sij0[:] self.logsij0 = np.log(self.line_strength_ref) - self.gpp = df_masked.cols.gup[:] + self.gpp = df_masked.gup[:] def instances_from_dataframes_vaex(self, df_masked): self.A = df_masked.A.values @@ -778,22 +778,22 @@ def instances_from_dataframes(self, df_masked): raise ValueError("Use vaex or pytables as input.") def instances_from_dataframes_pytables(self, df_masked): - self.nu_lines = df_masked.cols.wav[:] - self.line_strength_ref = df_masked.cols.int[:] + self.nu_lines = df_masked.wav[:] + self.line_strength_ref = df_masked.int[:] self.logsij0 = np.log(self.line_strength_ref) - self.delta_air = df_masked.cols.Pshft[:] - self.A = df_masked.cols.A[:] - self.n_air = df_masked.cols.Tdpair[:] - self.gamma_air = df_masked.cols.airbrd[:] - self.gamma_self = df_masked.cols.selbrd[:] - self.elower = df_masked.cols.El[:] - self.gpp = df_masked.cols.gp[:] + self.delta_air = df_masked.Pshft[:] + self.A = df_masked.A[:] + self.n_air = df_masked.Tdpair[:] + self.gamma_air = df_masked.airbrd[:] + self.gamma_self = df_masked.selbrd[:] + self.elower = df_masked.El[:] + self.gpp = df_masked.gp[:] # isotope - self.isoid = df_masked.cols.iso[:] + self.isoid = df_masked.iso[:] self.uniqiso = np.unique(self.isoid) if self.with_error: # uncertainties - self.ierr = df_masked.cols.ierr[:] + self.ierr = df_masked.ierr[:] def instances_from_dataframes_vaex(self, df_masked): self.nu_lines = df_masked.wav.values @@ -983,38 +983,38 @@ def instances_from_dataframes(self, df_load_mask): raise ValueError("Invalid engine") def instances_from_dataframes_pytables(self, df_load_mask): - self.nu_lines = df_load_mask.cols.wav[:] - self.line_strength_ref = df_load_mask.cols.int[:] + self.nu_lines = df_load_mask.wav[:] + self.line_strength_ref = df_load_mask.int[:] self.logsij0 = np.log(self.line_strength_ref) - self.delta_air = df_load_mask.cols.Pshft[:] - self.A = df_load_mask.cols.A[:] - self.n_air = df_load_mask.cols.Tdpair[:] - self.gamma_air = df_load_mask.cols.airbrd[:] - self.gamma_self = df_load_mask.cols.selbrd[:] - self.elower = df_load_mask.cols.El[:] - self.gpp = df_load_mask.cols.gp[:] + self.delta_air = df_load_mask.Pshft[:] + self.A = df_load_mask.A[:] + self.n_air = df_load_mask.Tdpair[:] + self.gamma_air = df_load_mask.airbrd[:] + self.gamma_self = df_load_mask.selbrd[:] + self.elower = df_load_mask.El[:] + self.gpp = df_load_mask.gp[:] # isotope - self.isoid = df_load_mask.cols.iso[:] + self.isoid = df_load_mask.iso[:] self.uniqiso = np.unique(self.isoid) if self.with_error: # uncertainties - self.ierr = df_load_mask.cols.ierr[:] + self.ierr = df_load_mask.ierr[:] if hasattr(df_load_mask, "n_h2") and self.nonair_broadening: - self.n_h2 = df_load_mask.cols.n_h2[:] - self.gamma_h2 = df_load_mask.cols.gamma_h2[:] + self.n_h2 = df_load_mask.n_h2[:] + self.gamma_h2 = df_load_mask.gamma_h2[:] if hasattr(df_load_mask, "n_he") and self.nonair_broadening: - self.n_he = df_load_mask.cols.n_he[:] - self.gamma_he = df_load_mask.cols.gamma_he[:] + self.n_he = df_load_mask.n_he[:] + self.gamma_he = df_load_mask.gamma_he[:] if hasattr(df_load_mask, "n_co2") and self.nonair_broadening: - self.n_co2 = df_load_mask.cols.n_co2[:] - self.gamma_co2 = df_load_mask.cols.gamma_co2[:] + self.n_co2 = df_load_mask.n_co2[:] + self.gamma_co2 = df_load_mask.gamma_co2[:] if hasattr(df_load_mask, "n_h2o") and self.nonair_broadening: - self.n_h2o = df_load_mask.cols.n_h2o[:] - self.gamma_h2o = df_load_mask.cols.gamma_h2o[:] + self.n_h2o = df_load_mask.n_h2o[:] + self.gamma_h2o = df_load_mask.gamma_h2o[:] def instances_from_dataframes_vaex(self, df_load_mask): self.nu_lines = df_load_mask.wav.values From 522964408493ca73f6bf41d3d228d7e7a06dab5a Mon Sep 17 00:00:00 2001 From: Hajime Kawahara Date: Sat, 3 Aug 2024 22:38:11 +0900 Subject: [PATCH 15/15] uses .values even for pytables --- src/exojax/spec/api.py | 96 ++++-------------------------------- src/exojax/spec/atomllapi.py | 5 +- 2 files changed, 11 insertions(+), 90 deletions(-) diff --git a/src/exojax/spec/api.py b/src/exojax/spec/api.py index 2e6a1d3d..f40cffc7 100644 --- a/src/exojax/spec/api.py +++ b/src/exojax/spec/api.py @@ -229,24 +229,9 @@ def instances_from_dataframes(self, df_masked): if len(df_masked) == 0: raise ValueError("No line found in ", self.nurange, "cm-1") - if self.engine == "vaex": - self.instances_from_dataframes_vaex(df_masked) - elif self.engine == "pytables": - self.instances_from_dataframes_pytables(df_masked) - else: - raise ValueError("Use vaex or pytables as input.") - - def instances_from_dataframes_pytables(self, df_masked): - self.A = df_masked.A[:] - self.nu_lines = df_masked.nu_lines[:] - self.elower = df_masked.elower[:] - self.jlower = df_masked.jlower[:] - self.jupper = df_masked.jupper[:] - self.line_strength_ref = df_masked.Sij0[:] - self.logsij0 = np.log(self.line_strength_ref) - self.gpp = df_masked.gup[:] + self._instances_from_dataframes(df_masked) - def instances_from_dataframes_vaex(self, df_masked): + def _instances_from_dataframes(self, df_masked): self.A = df_masked.A.values self.nu_lines = df_masked.nu_lines.values self.elower = df_masked.elower.values @@ -769,33 +754,9 @@ def instances_from_dataframes(self, df_masked): """ self.check_line_existence_in_nurange(df_masked) + self._instances_from_dataframes(df_masked) - if self.engine == "vaex": - self.instances_from_dataframes_vaex(df_masked) - elif self.engine == "pytables": - self.instances_from_dataframes_pytables(df_masked) - else: - raise ValueError("Use vaex or pytables as input.") - - def instances_from_dataframes_pytables(self, df_masked): - self.nu_lines = df_masked.wav[:] - self.line_strength_ref = df_masked.int[:] - self.logsij0 = np.log(self.line_strength_ref) - self.delta_air = df_masked.Pshft[:] - self.A = df_masked.A[:] - self.n_air = df_masked.Tdpair[:] - self.gamma_air = df_masked.airbrd[:] - self.gamma_self = df_masked.selbrd[:] - self.elower = df_masked.El[:] - self.gpp = df_masked.gp[:] - # isotope - self.isoid = df_masked.iso[:] - self.uniqiso = np.unique(self.isoid) - if self.with_error: - # uncertainties - self.ierr = df_masked.ierr[:] - - def instances_from_dataframes_vaex(self, df_masked): + def _instances_from_dataframes(self, df_masked): self.nu_lines = df_masked.wav.values self.line_strength_ref = df_masked.int.values self.logsij0 = np.log(self.line_strength_ref) @@ -806,11 +767,11 @@ def instances_from_dataframes_vaex(self, df_masked): self.gamma_self = df_masked.selbrd.values self.elower = df_masked.El.values self.gpp = df_masked.gp.values - # isotope + # isotope self.isoid = df_masked.iso.values self.uniqiso = np.unique(self.isoid) if self.with_error: - # uncertainties + # uncertainties self.ierr = df_masked.ierr.values.to_numpy().astype(np.int64) def generate_jnp_arrays(self): @@ -975,48 +936,9 @@ def instances_from_dataframes(self, df_load_mask): ValueError: _description_ """ self.check_line_existence_in_nurange(df_load_mask) - if self.engine == "vaex": - self.instances_from_dataframes_vaex(df_load_mask) - elif self.engine == "pytables": - self.instances_from_dataframes_pytables(df_load_mask) - else: - raise ValueError("Invalid engine") - - def instances_from_dataframes_pytables(self, df_load_mask): - self.nu_lines = df_load_mask.wav[:] - self.line_strength_ref = df_load_mask.int[:] - self.logsij0 = np.log(self.line_strength_ref) - self.delta_air = df_load_mask.Pshft[:] - self.A = df_load_mask.A[:] - self.n_air = df_load_mask.Tdpair[:] - self.gamma_air = df_load_mask.airbrd[:] - self.gamma_self = df_load_mask.selbrd[:] - self.elower = df_load_mask.El[:] - self.gpp = df_load_mask.gp[:] - # isotope - self.isoid = df_load_mask.iso[:] - self.uniqiso = np.unique(self.isoid) - if self.with_error: - # uncertainties - self.ierr = df_load_mask.ierr[:] + self._instances_from_dataframes_vaex(df_load_mask) - if hasattr(df_load_mask, "n_h2") and self.nonair_broadening: - self.n_h2 = df_load_mask.n_h2[:] - self.gamma_h2 = df_load_mask.gamma_h2[:] - - if hasattr(df_load_mask, "n_he") and self.nonair_broadening: - self.n_he = df_load_mask.n_he[:] - self.gamma_he = df_load_mask.gamma_he[:] - - if hasattr(df_load_mask, "n_co2") and self.nonair_broadening: - self.n_co2 = df_load_mask.n_co2[:] - self.gamma_co2 = df_load_mask.gamma_co2[:] - - if hasattr(df_load_mask, "n_h2o") and self.nonair_broadening: - self.n_h2o = df_load_mask.n_h2o[:] - self.gamma_h2o = df_load_mask.gamma_h2o[:] - - def instances_from_dataframes_vaex(self, df_load_mask): + def _instances_from_dataframes_vaex(self, df_load_mask): self.nu_lines = df_load_mask.wav.values self.line_strength_ref = df_load_mask.int.values self.logsij0 = np.log(self.line_strength_ref) @@ -1054,7 +976,7 @@ def generate_jnp_arrays(self): """(re)generate jnp.arrays. Note: - We have nd arrays and jnp arrays. We usually apply the mask to nd arrays and then generate jnp array from the corresponding nd array. For instance, self._A is nd array and self.A is jnp array. + We have nd arrays and jnp arrays. We usually apply the mask to nd arrays and then generate jnp array from the corresponding nd array. For instance, self._A is nd array and self.A is jnp array. """ # jnp.array copy from the copy sources diff --git a/src/exojax/spec/atomllapi.py b/src/exojax/spec/atomllapi.py index 7f8bb2fd..5f3492f3 100644 --- a/src/exojax/spec/atomllapi.py +++ b/src/exojax/spec/atomllapi.py @@ -4,7 +4,6 @@ import pandas as pd from exojax.utils.constants import ccgs, ecgs, mecgs, eV2wn import io -#import vaex import pkgutil from io import BytesIO @@ -646,10 +645,10 @@ def partfn_Fe(T): """Partition function of Fe I from Irwin_1981. Args: - T: temperature + T: temperature Returns: - partition function Q + partition function Q """ # Irwin_1981 a = np.zeros(6)