Skip to content

Commit

Permalink
Merge pull request #80 from ACCESS-NRI/78/driver-swap-um2nc-standalone
Browse files Browse the repository at this point in the history
Swap to um2netcdf standalone
  • Loading branch information
blimlim authored Aug 20, 2024
2 parents eb574f3 + d47d5f1 commit ece960d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:

- name: Lint
shell: bash -l {0}
run: pylint --extension-pkg-whitelist=netCDF4 --ignored-modules=um2netcdf4,umpost -E umpost
run: pylint --extension-pkg-whitelist=netCDF4 --ignored-modules=umpost -E umpost

- name: Run tests
shell: bash -l {0}
Expand Down
11 changes: 2 additions & 9 deletions test/test_conversion_driver_esm1p5.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,8 @@ def test_find_matching_fields_files():

@pytest.fixture
def base_mock_process():
# Create a patch of um2netcdf4.process

# FIXME: use temp guard block while working between gadi/local environments
# replace when full umpost.um2netcdf is ready
if esm1p5_convert.hostname.startswith("gadi"):
patcher = mock.patch("um2netcdf4.process")
else:
patcher = mock.patch("umpost.um2netcdf.process")

# Create a patch of um2netcdf.process
patcher = mock.patch("umpost.um2netcdf.process")
yield patcher.start()
patcher.stop()

Expand Down
19 changes: 5 additions & 14 deletions umpost/conversion_driver_esm1p5.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
ESM1.5 conversion driver
Wrapper script for automated fields file to NetCDF conversion
during ESM1.5 simulations. Runs conversion module (currently
um2netcdf4) on each atmospheric output in a specified directory.
during ESM1.5 simulations. Runs conversion module
on each atmospheric output in a specified directory.
Adapted from Martin Dix's conversion driver for CM2:
Adapted from Martin Dix's conversion driver for CM2:
https://github.com/ACCESS-NRI/access-cm2-drivers/blob/main/src/run_um2netcdf.py
"""

Expand All @@ -20,16 +20,7 @@
import argparse
import errno
from pathlib import Path

# FIXME: use temp guard block while working between gadi/local envs, local umpost.um2netcdf &
# gadi's um2netcdf4. Replace when full umpost.um2netcdf is ready
import socket
hostname = socket.gethostname()

if hostname.startswith("gadi"):
import um2netcdf4
else:
import umpost.um2netcdf as um2netcdf4
from umpost import um2netcdf


# TODO: um2netcdf will update the way arguments are fed to `process`.
Expand Down Expand Up @@ -152,7 +143,7 @@ def convert_fields_file_list(fields_file_paths, nc_write_dir):
nc_write_path = get_nc_write_path(fields_file_path, nc_write_dir)

try:
um2netcdf4.process(fields_file_path, nc_write_path, ARG_VALS)
um2netcdf.process(fields_file_path, nc_write_path, ARG_VALS)
succeeded.append((fields_file_path, nc_write_path))

except Exception as exc:
Expand Down

0 comments on commit ece960d

Please sign in to comment.