From cd7fc58b9925a2fb98010c35e10f52f6b6969c01 Mon Sep 17 00:00:00 2001 From: Florian Deconinck Date: Tue, 3 Mar 2026 09:36:08 -0500 Subject: [PATCH 1/8] Remove `NumpyModule` --- examples/notebook/utilities.py | 2 +- pyshield/radiation/state.py | 17 ++++++----------- tests/integration/test_all.py | 2 +- tests/integration/test_radiation_driver.py | 4 ++-- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/examples/notebook/utilities.py b/examples/notebook/utilities.py index 9096026..ee4677e 100644 --- a/examples/notebook/utilities.py +++ b/examples/notebook/utilities.py @@ -31,7 +31,7 @@ def states_from_fortran_restarts( tracer_data = xr.open_dataset(tracer_datafile) state = PhysicsState.init_zeros(quantity_factory, schemes) - radstate = RTE_RRTMGPState.init_zeros(quantity_factory, np) + radstate = RTE_RRTMGPState.init_zeros(quantity_factory) sstate = SurfaceState.init_zeros(quantity_factory) buff_3d = np.zeros_like(state.prsi.field) diff --git a/pyshield/radiation/state.py b/pyshield/radiation/state.py index 33fbfb2..080a28d 100644 --- a/pyshield/radiation/state.py +++ b/pyshield/radiation/state.py @@ -1,13 +1,14 @@ from dataclasses import InitVar, dataclass, field, fields from typing import Any, Dict, Mapping +import numpy as np + import xarray as xr import ndsl.dsl.gt4py_utils as gt_utils from ndsl import GridSizer, Quantity, QuantityFactory from ndsl.constants import X_DIM, Y_DIM, Z_DIM, Z_INTERFACE_DIM from ndsl.dsl.typing import Float -from ndsl.types import NumpyModule @dataclass() @@ -261,14 +262,11 @@ class RTE_RRTMGPState: } ) quantity_factory: InitVar[QuantityFactory] - np_like: InitVar[NumpyModule] def __post_init__( self, quantity_factory: QuantityFactory, - np_like: NumpyModule, ): - self._np = np_like self._nz = quantity_factory.sizer.nz self._nx = quantity_factory.sizer.nx self._ny = quantity_factory.sizer.ny @@ -277,7 +275,6 @@ def __post_init__( def init_zeros( cls, quantity_factory, - np_like: NumpyModule, ) -> "RTE_RRTMGPState": initial_arrays = {} for _field in fields(cls): @@ -290,7 +287,6 @@ def init_zeros( return cls( **initial_arrays, quantity_factory=quantity_factory, - np_like=np_like, ) @classmethod @@ -323,7 +319,6 @@ def init_from_storages( return cls( **inputs, quantity_factory=quantity_factory, - np_like=np_like, ) @property @@ -368,22 +363,22 @@ def to_rterrtmgp_xr(self) -> xr.Dataset: # dims.append(f"{dim_name}_{name}") if dim_name == "z_interface": slice_list.append( - self._np.s_[:] # type: ignore[attr-defined] + np.s_[:] # type: ignore[attr-defined] ) nz = self._nz + 1 dims.append("level") elif dim_name == "z": slice_list.append( - self._np.s_[:-1] # type: ignore[attr-defined] + np.s_[:-1] # type: ignore[attr-defined] ) dims.append("layer") elif "INTERFACE" in dim_name: slice_list.append( - self._np.s_[3:-3] # type: ignore[attr-defined] + np.s_[3:-3] # type: ignore[attr-defined] ) else: slice_list.append( - self._np.s_[3:-4] # type: ignore[attr-defined] + np.s_[3:-4] # type: ignore[attr-defined] ) # We have to reshape to get the max 2D shape rterrtmgp expects: if ndims == 3: # x-y-z array: diff --git a/tests/integration/test_all.py b/tests/integration/test_all.py index f6e699f..3d02a63 100644 --- a/tests/integration/test_all.py +++ b/tests/integration/test_all.py @@ -81,7 +81,7 @@ def states_from_fortran_restarts( sfc_data = xr.open_dataset(sfc_datafile) state = PhysicsState.init_zeros(quantity_factory, schemes) sstate = SurfaceState.init_zeros(qf_sfc) - radstate = RTE_RRTMGPState.init_zeros(quantity_factory, np) + radstate = RTE_RRTMGPState.init_zeros(quantity_factory) buff_3d = np.zeros_like(state.prsi.field) npz = buff_3d.shape[2] for k in range(npz): diff --git a/tests/integration/test_radiation_driver.py b/tests/integration/test_radiation_driver.py index ca223f1..db9c0fb 100644 --- a/tests/integration/test_radiation_driver.py +++ b/tests/integration/test_radiation_driver.py @@ -102,7 +102,7 @@ def states_from_fortran_restarts( tracer_data = xr.open_dataset(tracer_datafile) state = PhysicsState.init_zeros(quantity_factory, schemes) - radstate = RTE_RRTMGPState.init_zeros(quantity_factory, np) + radstate = RTE_RRTMGPState.init_zeros(quantity_factory) sstate = SurfaceState.init_zeros(quantity_factory) buff_3d = np.zeros_like(state.prsi.field) @@ -173,7 +173,7 @@ def test_rte_rrtmgp(datapath: Path): gridlon = grid_data.lon_agrid gridlat = grid_data.lat_agrid - state = RTE_RRTMGPState.init_zeros(quantity_factory, np) + state = RTE_RRTMGPState.init_zeros(quantity_factory) sstate = SurfaceState.init_zeros(quantity_factory) fortran_restart_to_radstate( dycore_datafile=dycore_data, From 71c80b82f5f73e79a7216d26d0a58d1ebb8d6334 Mon Sep 17 00:00:00 2001 From: Florian Deconinck Date: Tue, 3 Mar 2026 09:49:31 -0500 Subject: [PATCH 2/8] [TMP] Update CI --- .github/workflows/translate.yaml | 11 ++--------- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/translate.yaml b/.github/workflows/translate.yaml index 49a66f1..a9a44ba 100644 --- a/.github/workflows/translate.yaml +++ b/.github/workflows/translate.yaml @@ -44,9 +44,9 @@ jobs: uses: actions/checkout@v6 with: submodules: 'recursive' - repository: NOAA-GFDL/PySHiELD + repository: floriandeconinck/PySHiELD path: pySHiELD - ref: develop + ref: update/numpy_2x - name: 'Setup Python ${{ inputs.python_version && inputs.python_version || env.python_default }}' uses: actions/setup-python@v6 @@ -56,13 +56,6 @@ jobs: - name: Install mpi (MPICH flavor) run: pip install mpich - - name: Install numpy==1.26.4 - # Front-load installing numpy to force its usage in the radiation - # scheme of pySHiELD. - # TODO: This is an ugly hack and it should be cleaned up latest once - # we add support for numpy >= 2.0 - run: pip install numpy==1.26.4 - - name: External trigger remove existing component in pySHiELD/develop if: ${{ inputs.component_name }} run: rm -rf ${GITHUB_WORKSPACE}/pySHiELD/${{inputs.component_name}} diff --git a/pyproject.toml b/pyproject.toml index 07b4ddf..35c8f57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ extras = [ "pyshield[pyfv3]", "pyshield[dev]" ] -ndsl = ["ndsl @ git+https://github.com/NOAA-GFDL/NDSL.git@2026.01.00"] +ndsl = ["ndsl @ git+https://github.com/floriandeconinck/NDSL.git@update/numpy_2x"] pyfv3 = ["pyfv3 @ git+https://github.com/NOAA-GFDL/PyFV3.git@develop"] test = [ "pytest", From 1acff6551f02a468b82b448b55444175ceb147dd Mon Sep 17 00:00:00 2001 From: Florian Deconinck Date: Tue, 3 Mar 2026 10:00:03 -0500 Subject: [PATCH 3/8] Update to numpy >-2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 35c8f57..f1fcd80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ classifiers = [ ] dependencies = [ "f90nml>=1.1.0", - "numpy==1.26.4", + "numpy>=2", "xarray", "pyrte-rrtmgp @ git+https://github.com/NOAA-GFDL/pyRTE-RRTMGP.git@main" ] From f06a06d938ca6a0d9d2975c552f38020a2423639 Mon Sep 17 00:00:00 2001 From: Florian Deconinck Date: Tue, 3 Mar 2026 11:35:49 -0500 Subject: [PATCH 4/8] Lint --- pyshield/radiation/state.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyshield/radiation/state.py b/pyshield/radiation/state.py index 080a28d..f9fe782 100644 --- a/pyshield/radiation/state.py +++ b/pyshield/radiation/state.py @@ -2,7 +2,6 @@ from typing import Any, Dict, Mapping import numpy as np - import xarray as xr import ndsl.dsl.gt4py_utils as gt_utils @@ -295,7 +294,6 @@ def init_from_storages( storages: Mapping[str, Any], sizer: GridSizer, quantity_factory: QuantityFactory, - np_like: NumpyModule, ) -> "RTE_RRTMGPState": inputs: Dict[str, Quantity] = {} for _field in fields(cls): From 9801c12a7a6d0788788431c8baa8c57925813a40 Mon Sep 17 00:00:00 2001 From: Florian Deconinck Date: Tue, 3 Mar 2026 11:37:10 -0500 Subject: [PATCH 5/8] Update pace test --- .github/workflows/pace_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pace_tests.yaml b/.github/workflows/pace_tests.yaml index 3edb4f3..4e51eff 100644 --- a/.github/workflows/pace_tests.yaml +++ b/.github/workflows/pace_tests.yaml @@ -10,7 +10,7 @@ on: jobs: pace_unit_tests: - uses: NOAA-GFDL/pace/.github/workflows/main_unit_tests.yaml@develop + uses: floriandeconinck/pace/.github/workflows/main_unit_tests.yaml@update/numpy_2x with: component_trigger: true component_name: pySHiELD From 6db01bdf7937235b8a37c5a3e68b237dde9e113e Mon Sep 17 00:00:00 2001 From: Florian Deconinck Date: Tue, 3 Mar 2026 15:21:32 -0500 Subject: [PATCH 6/8] [TMP] Use `numpy_2x` branch of ndsl --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f1fcd80..1f8a130 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ extras = [ "pyshield[dev]" ] ndsl = ["ndsl @ git+https://github.com/floriandeconinck/NDSL.git@update/numpy_2x"] -pyfv3 = ["pyfv3 @ git+https://github.com/NOAA-GFDL/PyFV3.git@develop"] +pyfv3 = ["pyfv3 @ git+https://github.com/floriandeconinck/PyFV3.git@update/numpy_2x"] test = [ "pytest", "pytest-subtests", From f9ffca8344c1c4140b5a2b5d799ad0a2b5021bc6 Mon Sep 17 00:00:00 2001 From: Florian Deconinck Date: Wed, 1 Apr 2026 17:59:00 -0400 Subject: [PATCH 7/8] Revert the `ndsl` configuration to `develop` --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4279ba6..deac9d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ extras = [ "pyshield[pyfv3]", "pyshield[test]" ] -ndsl = ["ndsl @ git+https://github.com/floriandeconinck/NDSL.git@update/numpy_2x"] +ndsl = ["ndsl @ git+https://github.com/NOAA-GFDL/NDSL.git@develop"] pyfv3 = ["pyfv3 @ git+https://github.com/floriandeconinck/PyFV3.git@update/numpy_2x"] test = [ "coverage", From 02ae7b06bc4faa45b641ea7ba12ad1a596e94406 Mon Sep 17 00:00:00 2001 From: Florian Deconinck Date: Thu, 2 Apr 2026 11:08:53 -0400 Subject: [PATCH 8/8] Restore `pyfv3` proper branch --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index deac9d0..b4ff27b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ extras = [ "pyshield[test]" ] ndsl = ["ndsl @ git+https://github.com/NOAA-GFDL/NDSL.git@develop"] -pyfv3 = ["pyfv3 @ git+https://github.com/floriandeconinck/PyFV3.git@update/numpy_2x"] +pyfv3 = ["pyfv3 @ git+https://github.com/NOAA-GFDL/pyFV3.git@develop"] test = [ "coverage", "pytest",