Skip to content

Commit

Permalink
Merge branch 'main' into joss-paper
Browse files Browse the repository at this point in the history
  • Loading branch information
navidcy authored Apr 23, 2024
2 parents f56bade + 8e598a7 commit 8b33143
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 1,155 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Packaging

on:
release:
types: [created]

jobs:
build_and_upload:
name: Build sdist and wheels
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- run: pipx run build
- name: Publish package to TestPyPI
if: github.event_name == 'release' && github.event.release.prerelease
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
if: github.event_name == 'release' && ! github.event.release.prerelease
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ The above installs the version of `regional-mom6` (plus any required dependencie

#### "*I want to live on the edge! I want the latest developments*"

To install `regional-mom6` directly via GitHub using `pip`, first install `esmpy` as described above. Then:
To install `regional-mom6` directly from the [GitHub repository](https://github.com/COSIMA/regional-mom6/) using `pip`, first install `esmpy` as described above. Then:

```bash
pip install git+https://github.com/COSIMA/regional-mom6.git
Expand Down
1,083 changes: 0 additions & 1,083 deletions demos/access_om2-forced.ipynb

This file was deleted.

165 changes: 111 additions & 54 deletions demos/reanalysis-forced.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/demos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Demos
:name: demo-gallery

demo_notebooks/reanalysis-forced.ipynb
demo_notebooks/access_om2-forced.ipynb

3 changes: 1 addition & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Regional MOM6 Documentation
===========================

Python package for automatic generation of regional configurations for the `Modular Ocean Model version 6`_ (MOM6).

[regional-mom6](https://github.com/COSIMA/regional-mom6/) is a Python package for automatic generation of regional configurations for the `Modular Ocean Model version 6`_ (MOM6).

In brief...
-----------
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The above installs the version of `regional-mom6` (plus any required dependencie

## "*I want to live on the edge! I want the latest developments*"

To install `regional-mom6` directly via GitHub using `pip`, first install `esmpy` as described above. Then:
To install `regional-mom6` directly from the [GitHub repository](https://github.com/COSIMA/regional-mom6/) using `pip`, first install `esmpy` as described above. Then:

```bash
pip install git+https://github.com/COSIMA/regional-mom6.git
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ authors = [
{name = "Ashley Barnes, COSIMA community, and contributors"},
]
dynamic = ["version"]
readme = "README.md"
dependencies = [
"bottleneck",
"dask[array]",
Expand Down
25 changes: 12 additions & 13 deletions regional_mom6/regional_mom6.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def rectangular_hgrid(λ, φ):
np.diff(λ), * np.ones(np.size(λ) - 1)
), "provided array of longitudes must be uniformly spaced"

# dx = R * cos(φ) * np.deg2rad(dλ) / 2
# dx = R * cos(np.deg2rad(φ)) * np.deg2rad(dλ) / 2
# Note: division by 2 because we're on the supergrid
dx = np.broadcast_to(
R * np.cos(np.deg2rad(φ)) * np.deg2rad() / 2,
Expand Down Expand Up @@ -364,7 +364,7 @@ class experiment:
Methods in this class generate the various input files needed for a MOM6
experiment forced with open boundary conditions (OBCs). The code is agnostic
to the user's choice of boundary forcing, bathymetry and surface forcing;
to the user's choice of boundary forcing, bathymetry, and surface forcing;
users need to prescribe what variables are all called via mapping dictionaries
from MOM6 variable/coordinate name to the name in the input dataset.
Expand Down Expand Up @@ -825,7 +825,8 @@ def initial_condition(
eta_out.yh.attrs = ic_raw_tracers.lat.attrs
eta_out.attrs = ic_raw_eta.attrs

# if temp units are K, convert to C
## if min(temp) > 100 then assume that units must be degrees K
## (otherwise we can't be on Earth) and convert to degrees C
if np.min(tracers_out["temp"].isel({"zl": 0})) > 100:
tracers_out["temp"] -= 273.15

Expand Down Expand Up @@ -898,8 +899,8 @@ def rectangular_boundary(
``'north'``, or ``'south'``.
segment_number (int): Number the segments according to how they'll be specified in
the ``MOM_input``.
arakawa_grid (Optional[str]): Arakawa grid staggering of input; either ``'A'``, ``'B'``,
or ``'C'``.
arakawa_grid (Optional[str]): Arakawa grid staggering type of the boundary forcing.
Either ``'A'`` (default), ``'B'``, or ``'C'``.
"""

print("Processing {} boundary...".format(orientation), end="")
Expand All @@ -924,8 +925,8 @@ def setup_bathymetry(
self,
*,
bathymetry_path,
longitude_coordinate_name="lat",
latitude_coordinate_name="lon",
longitude_coordinate_name="lon",
latitude_coordinate_name="lat",
vertical_coordinate_name="elevation",
fill_channels=False,
minimum_layers=3,
Expand Down Expand Up @@ -1167,7 +1168,7 @@ def tidy_bathymetry(
{"depth": (["ny", "nx"], bathymetry["elevation"].values)}
)
bathymetry.attrs["depth"] = "meters"
bathymetry.attrs["standard_name"] = "bathymetryraphic depth at T-cell centers"
bathymetry.attrs["standard_name"] = "bathymetric depth at T-cell centers"
bathymetry.attrs["coordinates"] = "zi"

bathymetry.expand_dims("tiles", 0)
Expand Down Expand Up @@ -1339,7 +1340,7 @@ def FRE_tools(self, layout=None):
"Running GFDL's FRE Tools. The following information is all printed by the FRE tools themselves"
)
if not (self.mom_input_dir / "bathymetry.nc").exists():
print("No bathymetry file! Need to run .setup_bathymetry method first")
print("No bathymetry file! Need to run setup_bathymetry method first")
return

for p in self.mom_input_dir.glob("mask_table*"):
Expand Down Expand Up @@ -1399,8 +1400,6 @@ def setup_run_directory(
existing files in the 'rundir' directory for the experiment.
Args:
regional_mom6_path (str): Path to the regional MOM6 source code that was cloned
from GitHub. Default is current path, ``'.'``.
surface_forcing (Optional[str]): Specify the choice of surface forcing, one
of: ``'jra'`` or ``'era5'``. If not prescribed then constant fluxes are used.
using_payu (Optional[bool]): Whether or not to use payu (https://github.com/payu-org/payu)
Expand Down Expand Up @@ -1755,7 +1754,7 @@ def __init__(

def rectangular_brushcut(self):
"""
Cut out and interpolate tracers. This method assumes that the boundary
Cut out and interpolate tracers. ``rectangular_brushcut`` assumes that the boundary
is a simple Northern, Southern, Eastern, or Western boundary.
"""
if self.orientation == "north":
Expand Down Expand Up @@ -1949,7 +1948,7 @@ def rectangular_brushcut(self):
},
}

### Generate our dz variable. This needs to be in layer thicknesses
### Generate the dz variable; needs to be in layer thicknesses
dz = segment_out[self.z].diff(self.z)
dz.name = "dz"
dz = xr.concat([dz, dz[-1]], dim=self.z)
Expand Down

0 comments on commit 8b33143

Please sign in to comment.