Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c9deb3b
Added integration test script
atteggiani Feb 14, 2025
284cf26
Added parallelization for tests with dynamic capture of PIDs and exit…
atteggiani Feb 21, 2025
e732985
Redirected tests STDOUT to /dev/null
atteggiani Feb 21, 2025
37c3ff0
Updated trap function. Updated compare function. Updated paths
atteggiani Feb 21, 2025
a1e85dd
Minor fix to a comment
atteggiani Feb 22, 2025
6701970
Updated integration README
atteggiani Feb 23, 2025
fb5ffa8
Updated README
atteggiani Feb 23, 2025
731e0bc
Added dependencies to dev environment
atteggiani Feb 24, 2025
2f97856
Added tests/test_integration.py to be run with pytest.
atteggiani Feb 25, 2025
8d225ce
Re-factored test to:
atteggiani Feb 26, 2025
ad7ea52
Added tests for hres_eccb entry point
atteggiani Feb 27, 2025
3b035eb
Deleted old ibash ntegration tests
atteggiani Feb 27, 2025
a750336
Revert changes on src/replace_landsurface files
atteggiani Feb 27, 2025
fdbebc5
Incorporated Tom's suggestions
atteggiani Feb 27, 2025
80f9957
Updated README
atteggiani Feb 28, 2025
ce90376
Removed fixture to set env variable
atteggiani Feb 28, 2025
0806a01
Turned get_error_message fixture to a normal function
atteggiani Feb 28, 2025
abe5945
Removed unused variable from fixture
atteggiani Feb 28, 2025
71800c3
Turned all path concatenation to 'os.path.join'
atteggiani Feb 28, 2025
deb4432
Fixed hres_eccb test to call the right function
atteggiani Feb 28, 2025
24359ce
Removed hres_eccb script and renamed 'hres_ic' to 'replace_landsurfac…
atteggiani Feb 28, 2025
8eec4fe
Embedded old 'test_hres_eccb' test (test n. 4) within the 'test_repla…
atteggiani Feb 28, 2025
3b0df76
Updated docstrings
atteggiani Feb 28, 2025
b0b6ee7
Restructured hres_ic.py and replace_landsurface_with_BARRA2R_IC.py:
atteggiani Feb 22, 2025
ee36b8b
Removed unused imports
atteggiani Feb 22, 2025
bfab0b5
- Removed --mask dependency from replace_landsurface_with_ERA5land_IC…
atteggiani Feb 22, 2025
ac1f9c4
- Removed dependency of replace_landsurface_with_FF_IC from --mask an…
atteggiani Feb 22, 2025
40eb164
Removed mask input from regression tests
atteggiani Mar 2, 2025
897295e
Removed egg-info folder
atteggiani Mar 2, 2025
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
17 changes: 17 additions & 0 deletions .conda/env_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
channels:
- accessnri
- conda-forge
- coecms
- nodefaults

dependencies:
- mule
- numpy <= 1.23.4 # https://stackoverflow.com/a/75148219/21024780
- scitools-iris
- xarray
- versioneer
- ipykernel
- pytest
- pytest-cov
- pytest-xdist
- hypothesis
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
test_data/
.coverage
*.sh
__pycache__/
*.py[cod]
.ruff_cache/
.mypy_cache/
.pytest_cache/
.vscode/
.vscode/
build/
*.egg-info/
49 changes: 46 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)

# replace_landsurface

This repository contains Python scripts for use by Regional Nesting Suites to replace specific land surface fields in static input data.
## About

`replace_landsurface` is a `Python` utility to be used within ACCESS-NRI versions of the Regional Nesting Suites to replace specific land surface initial/boundary conditions.


## Development/Testing instructions
For development/testing, it is recommended to install `replace_landsurface` as a development package within a `micromamba`/`conda` testing environment.

### Clone replace_landsurface GitHub repo
```
git clone git@github.com:ACCESS-NRI/replace_landsurface.git
```

### Create a micromamba/conda testing environment
> [!TIP]
> In the following instructions `micromamba` can be replaced with `conda`.

```
cd replace_landsurface
micromamba env create -n replace_landsurface_dev --file .conda/env_dev.yml
micromamba activate replace_landsurface_dev
```

### Install replace_landsurface as a development package
```
pip install --no-deps --no-build-isolation -e .
```

### Running the tests

The test suite currently includes only integration tests.

To manually run the tests, from the `replace_landsurface` directory, you can:

1. Activate your [micromamba/conda testing environment](#create-a-micromamba-conda-testing-environment)
2. Run the following command:
```
pytest -n 4
```

> [!TIP]
> The `-n 4` option is a [pytest-xdist](https://pytest-xdist.readthedocs.io/en/stable/) option to run the tests in parallel across 4 different workers.

> [!IMPORTANT]
> Integration tests are designed to be run on `Gadi`.
> If you run tests on a local machine, the integration tests will be skipped.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ dependencies = [
Repository = "https://github.com/ACCESS-NRI/replace_landsurface"

[project.scripts]
hres_eccb = "replace_landsurface.hres_eccb:main"
hres_ic = "replace_landsurface.hres_ic:main"
replace_landsurface = "replace_landsurface.replace_landsurface:main"

[build-system]
build-backend = "setuptools.build_meta"
Expand Down
63 changes: 0 additions & 63 deletions src/replace_landsurface/hres_eccb.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
# Created by: Chermelle Engel <Chermelle.Engel@anu.edu.au>

"""
Replace the land/surface fields in the astart file with higher-resolution
era5-land or BARRA2-R data (if requested).
Replace the land-surface fields in the astart file with higher-resolution data
"""

import argparse
import shutil
from pathlib import Path

import pandas

from replace_landsurface import (
replace_landsurface_with_BARRA2R_IC,
replace_landsurface_with_ERA5land_IC,
Expand All @@ -25,43 +22,37 @@
def main():

"""
The main function that creates a worker pool and generates single GRIB files
for requested date/times in parallel.
Calls the command line argument parser and process the arguments using the right function.

Parameters
----------
None. The arguments are given via the command-line
None
The arguments are given via the command-line

Returns
-------
None. The astart file is updated and overwritten
None
An output file is written
"""

# Parse the command-line arguments
parser = argparse.ArgumentParser()
parser.add_argument('--mask', required=True, type=Path)
parser.add_argument('--file', required=True, type=Path)
parser.add_argument('--start', required=True, type=pandas.to_datetime)
parser.add_argument('--start', required=True, type=str, help="A date in the format 'YYYYmmddHHMM'.")
parser.add_argument('--type', default="era5land")
parser.add_argument('--hres_ic', type=Path)
args = parser.parse_args()
print(args)

# Convert the date/time to a formatted string
t = args.start.strftime("%Y%m%dT%H%MZ")
print(args.mask, args.file, t)

# If necessary replace ERA5 land/surface fields with higher-resolution options
if "era5land" in args.type:
replace_landsurface_with_ERA5land_IC.swap_land_era5land(args.mask, args.file, t)
replace_landsurface_with_ERA5land_IC.swap_land_era5land(args.file, args.start)
shutil.move(args.file.as_posix(), args.file.as_posix().replace('.tmp', ''))
elif "barra" in args.type:
replace_landsurface_with_BARRA2R_IC.swap_land_barra(args.mask, args.file, t)
replace_landsurface_with_BARRA2R_IC.swap_land_barra(args.file, args.start)
shutil.move(args.file.as_posix(), args.file.as_posix().replace('.tmp', ''))
elif "astart" in args.type:
replace_landsurface_with_FF_IC.swap_land_ff(args.mask, args.file, args.hres_ic,t)
replace_landsurface_with_FF_IC.swap_land_ff(args.file, args.hres_ic)
shutil.move(args.file.as_posix(), args.file.as_posix().replace('.tmp', ''))

else:
print("No need to swap out IC")

Expand Down
Loading