Skip to content

Commit

Permalink
Merge branch 'main' into trans_update
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Kiefer committed Oct 27, 2023
2 parents 09b6450 + d462282 commit 5e148aa
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 67 deletions.
18 changes: 6 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.8", "3.9", "3.10" ]
python-version: [ "3.9", "3.10" ]
steps:
- uses: actions/checkout@v2
- name: Cache conda
Expand All @@ -34,18 +34,16 @@ jobs:
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: test_env # Defined in ci/environment*.yml
auto-update-conda: false
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
python-version: ${{ matrix.python-version }}
environment-file: ci/environment-${{ matrix.python-version }}.yml
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Set up petitRADTRANS
shell: bash -l {0}
run: |
python -m pip install petitRADTRANS==2.4.9
python -m pip install prt-phasecurve
- name: Set up conda environment
shell: bash -l {0}
run: |
python -m pip install --no-deps molmass miepython git+https://github.com/MITgcm/xmitgcm.git petitRADTRANS==2.4.9 prt-phasecurve
python -m pip install -e .
conda list
- name: Run Tests
Expand Down Expand Up @@ -77,14 +75,10 @@ jobs:
auto-update-conda: false
environment-file: ci/environment-xarraymaster.yml
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Set up petitRADTRANS
shell: bash -l {0}
run: |
python -m pip install petitRADTRANS==2.4.9
python -m pip install prt-phasecurve
- name: Set up conda environment
shell: bash -l {0}
run: |
python -m pip install --no-deps molmass miepython git+https://github.com/MITgcm/xmitgcm.git petitRADTRANS==2.4.9 prt-phasecurve
python -m pip install -e .
conda list
- name: Run Tests
Expand Down
21 changes: 14 additions & 7 deletions ci/environment-3.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ dependencies:
- cubedsphere
- pytest
- codecov
- xmitgcm
- pytest-cov
- xarray
- h5py
- numpy=1.21.5
- setuptools=61.2.0
- matplotlib
- astropy
- numpy
- scipy
- setuptools
- netcdf4
- pandas
- numba
- corner
- tqdm
- h5py
- pre-commit
- pymultinest
- seaborn
- pip
- pip:
- git+https://github.com/MITgcm/xmitgcm.git
- miepython
18 changes: 0 additions & 18 deletions ci/environment-3.8.yml

This file was deleted.

23 changes: 15 additions & 8 deletions ci/environment-3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ dependencies:
- cubedsphere
- pytest
- codecov
- xmitgcm
- pytest-cov
- xarray
- h5py
- numpy=1.21.5
- setuptools=61.2.0
- matplotlib
- astropy
- numpy
- scipy
- setuptools
- netcdf4
- pip
- pip:
- git+https://github.com/MITgcm/xmitgcm.git
- miepython
- pandas
- numba
- corner
- tqdm
- h5py
- pre-commit
- pymultinest
- seaborn
- pip
19 changes: 14 additions & 5 deletions ci/environment-xarraymaster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ dependencies:
- cubedsphere
- pytest
- codecov
- xmitgcm
- pytest-cov
- h5py
- numpy=1.21.5
- setuptools=61.2.0
- matplotlib
- astropy
- numpy
- scipy
- setuptools
- netcdf4
- pandas
- numba
- corner
- tqdm
- h5py
- pre-commit
- pymultinest
- seaborn
- pip
- pip:
- git+https://github.com/MITgcm/xmitgcm.git
- git+https://github.com/pydata/xarray.git
- miepython
44 changes: 27 additions & 17 deletions gcm_toolkit/tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,21 @@ def test_prt_interface(petitradtrans_testdata, all_raw_testdata):
)

# add cloud properties
dsi_clouds = tools.get_models('0')
tmp = np.ones((len(dsi_clouds['time']), len(dsi_clouds['lat']),
len(dsi_clouds['lon']), len(dsi_clouds['Z_l'])))
dsi_clouds['ClAb'] = (('time', 'lat', 'lon', 'Z_l'), tmp*1e-5)
dsi_clouds['ClDs'] = (('time', 'lat', 'lon', 'Z_l'), tmp*1e2)
dsi_clouds['ClDr'] = (('time', 'lat', 'lon', 'Z_l'), tmp*1e3)
dsi_clouds['ClVf_Test1[s]'] = (('time', 'lat', 'lon', 'Z_l'), tmp*0.5)
dsi_clouds['ClVf_Test2[s]'] = (('time', 'lat', 'lon', 'Z_l'), tmp*0.5)
tools._replace_model('0', dsi_clouds)
dsi_clouds = tools.get_models("0")
tmp = np.ones(
(
len(dsi_clouds["time"]),
len(dsi_clouds["lat"]),
len(dsi_clouds["lon"]),
len(dsi_clouds["Z"]),
)
)
dsi_clouds["ClAb"] = (("time", "lat", "lon", "Z"), tmp * 1e-5)
dsi_clouds["ClDs"] = (("time", "lat", "lon", "Z"), tmp * 1e2)
dsi_clouds["ClDr"] = (("time", "lat", "lon", "Z"), tmp * 1e3)
dsi_clouds["ClVf_Test1[s]"] = (("time", "lat", "lon", "Z"), tmp * 0.5)
dsi_clouds["ClVf_Test2[s]"] = (("time", "lat", "lon", "Z"), tmp * 0.5)
tools._replace_model("0", dsi_clouds)

phases = np.linspace(0, 1, 50)
interface = tools.get_prt_interface(pRT)
Expand Down Expand Up @@ -113,9 +119,11 @@ def test_prt_interface(petitradtrans_testdata, all_raw_testdata):
)

# test transit calculation set up
interface.set_data(time=expected["times"][-1], terminator_avg=True, lon_resolution=60)
assert (interface.dsi['lon'].values == [-90, 90]).all()
assert interface.dsi['lat'].values == [0]
interface.set_data(
time=expected["times"][-1], terminator_avg=True, lon_resolution=60
)
assert (interface.dsi["lon"].values == [-90, 90]).all()
assert interface.dsi["lat"].values == [0]

# test transit calculation
interface.chem_from_poorman("T", co_ratio=0.55, feh_ratio=0.0)
Expand All @@ -129,7 +137,9 @@ def test_prt_interface(petitradtrans_testdata, all_raw_testdata):

# test transit calculation
interface.chem_from_poorman("T", co_ratio=0.55, feh_ratio=0.0)
wave, spectra = interface.calc_transit_spectrum(mmw=2.33, clouds=True, use_bruggemann=True)
wave, spectra = interface.calc_transit_spectrum(
mmw=2.33, clouds=True, use_bruggemann=True
)
assert sum(spectra) == 45237213620.53514

# Test if Pa works
Expand Down Expand Up @@ -253,7 +263,7 @@ def test_PAC_interface(all_nc_testdata):
pac2d.set_data(time=expected["times"][-1])

with pytest.raises(OSError):
pac1d.write_inputfile('non/existent/path')
pac2d.write_inputfile('non/existent/path')
pac2d.generate_lptfile('non/existent/path')
pac2d.generate_aptfiles('non/existent/path')
pac1d.write_inputfile("non/existent/path")
pac2d.write_inputfile("non/existent/path")
pac2d.generate_lptfile("non/existent/path")
pac2d.generate_aptfiles("non/existent/path")

0 comments on commit 5e148aa

Please sign in to comment.