Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to python test environment #58

Merged
merged 10 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 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,13 +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 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 @@ -75,6 +78,7 @@ jobs:
- 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
23 changes: 14 additions & 9 deletions ci/environment-3.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +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
- petitRADTRANS==2.4.9
- prt-phasecurve
20 changes: 0 additions & 20 deletions ci/environment-3.8.yml

This file was deleted.

26 changes: 15 additions & 11 deletions ci/environment-3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +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
- petitRADTRANS==2.4.9
- prt-phasecurve

- pandas
- numba
- corner
- tqdm
- h5py
- pre-commit
- pymultinest
- seaborn
- pip
21 changes: 14 additions & 7 deletions ci/environment-xarraymaster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +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
- petitRADTRANS==2.4.9
- prt-phasecurve
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)
Comment on lines -46 to +60
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kiefersv, could you comment on these changes I had to make? I think the Z_l here is strange?!

Copy link
Collaborator

@Kiefersv Kiefersv Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double checked and you are indeed right that it should be Z. No idea why it worked before with Z_l. Did this cause the problems?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Its likely problems related to xarray's master branch. But this looked odd to me.


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")
Loading