Skip to content

Commit

Permalink
Merge branch 'develop' into feature/4d_data
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianDeconinck authored Sep 30, 2024
2 parents f3cf32d + a667d29 commit f894a49
Show file tree
Hide file tree
Showing 12 changed files with 792 additions and 106 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
- name: Install Python packages
run: pip3 install .[test]

- name: prepare input eta files
run: |
python tests/grid/generate_eta_files.py
- name: Run serial-cpu tests
run: coverage run --rcfile=setup.cfg -m pytest -x tests

Expand Down
2 changes: 1 addition & 1 deletion external/dace
Submodule dace updated 162 files
2 changes: 1 addition & 1 deletion external/gt4py
Submodule gt4py updated 605 files
4 changes: 1 addition & 3 deletions ndsl/grid/eta.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ class HybridPressureCoefficients:


def _load_ak_bk_from_file(eta_file: str) -> Tuple[np.ndarray, np.ndarray]:
if eta_file == "None":
raise ValueError("eta file not specified")
if not os.path.isfile(eta_file):
raise ValueError("file " + eta_file + " does not exist")
raise ValueError(f"eta file {eta_file} does not exist")

# read file into ak, bk arrays
data = xr.open_dataset(eta_file)
Expand Down
36 changes: 29 additions & 7 deletions ndsl/grid/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def __init__(
dy_const: float = 1000.0,
deglat: float = 15.0,
extdgrid: bool = False,
eta_file: str = "None",
eta_file: Optional[str] = None,
ak: Optional[np.ndarray] = None,
bk: Optional[np.ndarray] = None,
):
Expand Down Expand Up @@ -297,12 +297,34 @@ def __init__(
self._dy_center = None
self._area = None
self._area_c = None
(
self._ks,
self._ptop,
self._ak,
self._bk,
) = self._set_hybrid_pressure_coefficients(eta_file, ak, bk)
if eta_file is not None:
(
self._ks,
self._ptop,
self._ak,
self._bk,
) = self._set_hybrid_pressure_coefficients(eta_file, ak, bk)
else:
self._ks = self.quantity_factory.zeros(
[],
"",
dtype=Float,
)
self._ptop = self.quantity_factory.zeros(
[],
"Pa",
dtype=Float,
)
self._ak = self.quantity_factory.zeros(
[Z_INTERFACE_DIM],
"Pa",
dtype=Float,
)
self._bk = self.quantity_factory.zeros(
[Z_INTERFACE_DIM],
"",
dtype=Float,
)
self._ec1 = None
self._ec2 = None
self._ew1 = None
Expand Down
1 change: 1 addition & 0 deletions ndsl/stencils/corners.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ def fill_corners_dgrid_defn(
with computation(PARALLEL), interval(...):
# this line of code is used to fix the missing symbol crash due to the node visitor depth limitation
acoef = mysign
x_out = x_out
# sw corner
with horizontal(region[i_start - 1, j_start - 1]):
x_out = mysign * y_in[0, 1, 0]
Expand Down
19 changes: 15 additions & 4 deletions ndsl/stencils/testing/test_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,19 @@ def test_sequential_savepoint(
near_zero=case.testobj.near_zero,
)
if not metric.check:
os.makedirs(OUTDIR, exist_ok=True)
log_filename = os.path.join(
OUTDIR,
f"details-{case.savepoint_name}-{varname}-rank{case.rank}.log",
)
metric.report(log_filename)
pytest.fail(str(metric), pytrace=False)
passing_names.append(failing_names.pop())
ref_data_out[varname] = [ref_data]
if len(failing_names) > 0:
get_thresholds(case.testobj, input_data=original_input_data)
os.makedirs(OUTDIR, exist_ok=True)
out_filename = os.path.join(OUTDIR, f"translate-{case.savepoint_name}.nc")
nc_filename = os.path.join(OUTDIR, f"translate-{case.savepoint_name}.nc")
input_data_on_host = {}
for key, _input in input_data.items():
input_data_on_host[key] = gt_utils.asarray(_input)
Expand All @@ -226,7 +232,7 @@ def test_sequential_savepoint(
[output],
ref_data_out,
failing_names,
out_filename,
nc_filename,
)
if failing_names != []:
pytest.fail(
Expand Down Expand Up @@ -353,11 +359,16 @@ def test_parallel_savepoint(
near_zero=case.testobj.near_zero,
)
if not metric.check:
os.makedirs(OUTDIR, exist_ok=True)
log_filename = os.path.join(
OUTDIR, f"details-{case.savepoint_name}-{varname}.log"
)
metric.report(log_filename)
pytest.fail(str(metric), pytrace=False)
passing_names.append(failing_names.pop())
if len(failing_names) > 0:
os.makedirs(OUTDIR, exist_ok=True)
out_filename = os.path.join(
nct_filename = os.path.join(
OUTDIR, f"translate-{case.savepoint_name}-{case.grid.rank}.nc"
)
try:
Expand All @@ -370,7 +381,7 @@ def test_parallel_savepoint(
[output],
ref_data,
failing_names,
out_filename,
nct_filename,
)
except Exception as error:
print(f"TestParallel SaveNetCDF Error: {error}")
Expand Down
2 changes: 2 additions & 0 deletions ndsl/stencils/testing/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def make_storage_data_input_vars(self, inputs, storage_vars=None, dict_4d=True):
for p in self.in_vars["parameters"]:
if type(inputs_in[p]) in [np.int64, np.int32]:
inputs_out[p] = int(inputs_in[p])
elif type(inputs_in[p]) is bool:
inputs_out[p] == inputs_in[p]
else:
inputs_out[p] = Float(inputs_in[p])
for d, info in storage_vars.items():
Expand Down
Loading

0 comments on commit f894a49

Please sign in to comment.