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

Numpy version update #1164

Merged
merged 24 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c0f5edc
update versions of numpy, cdms, xcdat
lee1043 Oct 29, 2024
5869235
update xcdat version to 0.7.3 to work with numpy >= 2.0
lee1043 Oct 29, 2024
1112647
Merge branch 'main' into feature/1163_numpy-upgrade_lee1043
lee1043 Oct 30, 2024
35bdee5
Merge branch 'main' into feature/1163_numpy-upgrade_lee1043
lee1043 Nov 6, 2024
3525255
cartopy version conflicts with numpy, so released regulation
lee1043 Nov 6, 2024
1d304b0
released version regulations for shapely and matplotlib to avoid conf…
lee1043 Nov 6, 2024
bf0514a
update regionmask version, which resolved the error in https://github…
lee1043 Nov 6, 2024
4a92562
resolves error in https://github.com/PCMDI/pcmdi_metrics/pull/1164#is…
lee1043 Nov 7, 2024
90af0c6
Merge branch 'main' into feature/1163_numpy-upgrade_lee1043
lee1043 Nov 18, 2024
fc6475f
Merge branch 'main' into feature/1163_numpy-upgrade_lee1043
lee1043 Nov 18, 2024
b4736dd
update versions for eofs and enso
lee1043 Nov 18, 2024
06d1d66
Merge branch 'main' into feature/1163_numpy-upgrade_lee1043
lee1043 Nov 18, 2024
a395367
Merge branch 'main' into feature/1163_numpy-upgrade_lee1043
lee1043 Nov 18, 2024
54ed820
Merge branch 'main' into feature/1163_numpy-upgrade_lee1043
lee1043 Nov 19, 2024
b72c0a0
Merge branch 'main' into feature/1163_numpy-upgrade_lee1043
lee1043 Nov 19, 2024
ff13344
Update build_workflow.yml
lee1043 Nov 19, 2024
734deb6
Merge pull request #1197 from PCMDI/lee1043-patch-1
lee1043 Nov 19, 2024
e707e4b
Update build_workflow.yml
lee1043 Nov 20, 2024
592f64b
Update dev.yml
lee1043 Nov 21, 2024
77faf8d
Update ci.yml
lee1043 Nov 21, 2024
ed91962
Update dev.yml
lee1043 Nov 21, 2024
b2b3830
Update ci.yml
lee1043 Nov 21, 2024
25a91bd
change following https://github.com/PCMDI/pcmdi_metrics/pull/1164#iss…
lee1043 Nov 21, 2024
ec022df
Merge branch 'main' into feature/1163_numpy-upgrade_lee1043
lee1043 Nov 26, 2024
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
12 changes: 11 additions & 1 deletion .github/workflows/build_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,18 @@ jobs:
miniforge-version: latest
activate-environment: "pcmdi_metrics_ci"
environment-file: conda-env/ci.yml
channel-priority: strict
channel-priority: flexible
auto-update-conda: true
python-version: ${{ matrix.python-version }}
use-mamba: false
conda-solver: classic

- name: Verify Conda Environment
run: |
conda info
conda list
conda config --show-sources
conda config --show

# Used for refreshing the cache every 24 hours to avoid inconsistencies of package
# versions between the CI pipeline and local installations.
Expand Down Expand Up @@ -128,6 +137,7 @@ jobs:
environment-file: conda-env/dev.yml
channel-priority: strict
auto-update-conda: true
use-mamba: false # Disable libmamba solver

- name: Install pcmdi_metrics
# Source: https://github.com/conda/conda-build/issues/4251#issuecomment-1053460542
Expand Down
18 changes: 9 additions & 9 deletions conda-env/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ dependencies:
# NOTE: If versions are updated, also `additional_dependencies` list for mypy in `.pre-commit-config.yaml`
- python=3.10.10
- pip=23.1.2
- numpy=1.23.5
- cartopy=0.22.0
- matplotlib=3.7.1
- cdms2=3.1.5
- numpy >=2.0.0,<3.0.0
- cartopy >=0.22.0
- matplotlib >=3.7.1
- cdms2 >=3.1.5
- genutil=8.2.1
- cdutil=8.2.1
- cdp=1.7.0
- eofs=1.4.1
- eofs=2.0.0
- seaborn=0.12.2
- enso_metrics=1.1.1
- xcdat>=0.7.0
- enso_metrics=1.1.2
- xcdat=0.7.3
- xmltodict=0.13.0
- setuptools=67.7.2
- netcdf4>=1.6.3
- regionmask=0.9.0
- regionmask=0.12.1
- rasterio>=1.3.6
- shapely=2.0.1
- shapely >=2.0.1
- numdifftools
- nc-time-axis
- colorcet
Expand Down
18 changes: 9 additions & 9 deletions conda-env/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ dependencies:
# NOTE: If versions are updated, also `additional_dependencies` list for mypy in `.pre-commit-config.yaml`
- python=3.10.10
- pip=23.1.2
- numpy=1.23.5
- cartopy=0.22.0
- matplotlib=3.7.1
- cdms2=3.1.5
- numpy >=2.0.0,<3.0.0
- cartopy >=0.22.0
- matplotlib >=3.7.1
- cdms2 >=3.1.5
- genutil=8.2.1
- cdutil=8.2.1
- cdp=1.7.0
- eofs=1.4.1
- eofs=2.0.0
- seaborn=0.12.2
- enso_metrics=1.1.1
- xcdat>=0.7.2
- enso_metrics=1.1.2
- xcdat=0.7.3
- xmltodict=0.13.0
- setuptools=67.7.2
- netcdf4>=1.6.3
- regionmask=0.9.0
- regionmask=0.12.1
- rasterio>=1.3.6
- shapely=2.0.1
- shapely >=2.0.1
- numdifftools
- nc-time-axis
- colorcet
Expand Down
9 changes: 8 additions & 1 deletion pcmdi_metrics/mjo/lib/lib_mjo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@

import numpy as np
import xarray as xr
from packaging.version import Version
from scipy import signal

from pcmdi_metrics.io import base, get_time_key, select_subset
from pcmdi_metrics.utils import create_target_grid, regrid

np_ver = Version(np.__version__)
if np_ver > Version("1.20.0"):
np_float = np.float64
else:
np_float = np.float


def interp2commonGrid(ds, data_var, dlat, dlon=None, debug=False):
if dlon is None:
Expand Down Expand Up @@ -121,7 +128,7 @@ def space_time_spectrum(d_seg_x_ano: xr.Dataset, data_var: str) -> np.ndarray:
C = np.absolute(EE[NTSub // 2 : NTSub, 0 : NL // 2 + 1]) ** 2
D = np.absolute(EE[0 : NTSub // 2 + 1, 0 : NL // 2 + 1]) ** 2
# Define returning array
p = np.zeros((NTSub + 1, NL + 1), np.float)
p = np.zeros((NTSub + 1, NL + 1), np_float)
p[NTSub // 2 :, : NL // 2] = A[:, ::-1]
p[: NTSub // 2, : NL // 2] = B[:, ::-1]
p[NTSub // 2 + 1 :, NL // 2 :] = C[::-1, :]
Expand Down
9 changes: 8 additions & 1 deletion pcmdi_metrics/mjo/lib/mjo_metric_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as np
import xarray as xr
from packaging.version import Version

from pcmdi_metrics.io import get_latitude, get_longitude, get_time_key, xcdat_open
from pcmdi_metrics.mjo.lib import (
Expand All @@ -20,6 +21,12 @@
from .debug_chk_plot import debug_chk_plot
from .plot_wavenumber_frequency_power import plot_power

np_ver = Version(np.__version__)
if np_ver > Version("1.20.0"):
np_float = np.float64
else:
np_float = np.float


def mjo_metric_ewr_calculation(
mip,
Expand Down Expand Up @@ -157,7 +164,7 @@ def mjo_metric_ewr_calculation(
# -----------------------------------------------------------------

# Define array for archiving power from each year segment
Power = np.zeros((numYear, NT + 1, NL + 1), np.float)
Power = np.zeros((numYear, NT + 1, NL + 1), np_float)

# Year loop for space-time spectrum calculation
if debug:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def precip_variability_across_timescale(
lon_range = [-180.0, 180.0]
else:
lon_range = [0.0, 360.0]
rgtmp = RegridHoriz(f, var, res, regions_specs, lon_range)
rgtmp = RegridHoriz(f.compute(), var, res, regions_specs, lon_range)
if fshp is not None:
print("Cropping from shapefile")
rgtmp = region_from_file(rgtmp, fshp, attr, feature)
Expand Down
Loading