Skip to content
This repository was archived by the owner on Sep 21, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4486426
Merge pull request #164 from ACCESS-Community-Hub/prerelease
paolap Aug 23, 2024
55edbf5
Update meta.yaml to hardcode version
paolap Aug 23, 2024
98d3818
Update meta.yaml
paolap Aug 23, 2024
5d99fdb
Update mopper-conda-release.yaml
paolap Aug 23, 2024
95dfb70
Merge pull request #165 from ACCESS-Community-Hub/paolap-patch-1
paolap Aug 23, 2024
560d243
started adding geopotential calculation and transects
paolap Aug 28, 2024
11d663a
fixed tables all functionality issue #169 and #168
paolap Aug 28, 2024
ba18e7a
Merge branch 'tables' into transect
paolap Aug 28, 2024
caf0df4
added new pressure level and progress on geopot height calculation
paolap Aug 30, 2024
a3c15d3
added plev17 and new AM3_Amon.json table
paolap Aug 30, 2024
1e32dbf
added new version AM3 with intial table and mappings
paolap Aug 30, 2024
cbd35fd
fixing bug #171
paolap Aug 30, 2024
1474ce9
added calculation to var on model elvels for AM3 mappings
paolap Aug 30, 2024
7599b23
calculations docs added, fixed #171, #172, #173
paolap Sep 9, 2024
37bcd9d
fixing autodoc
paolap Sep 9, 2024
b0a3195
fixing autodoc 2
paolap Sep 9, 2024
f12662d
fixing autodoc 3
paolap Sep 9, 2024
5380a10
fixing autodoc 4
paolap Sep 9, 2024
04a66f5
fixing autodoc 5
paolap Sep 9, 2024
61c3d31
fixing autodoc 6
paolap Sep 9, 2024
45535b5
fixing autodoc 7
paolap Sep 9, 2024
fa98fd6
fixing autodoc 8
paolap Sep 9, 2024
47c0b10
fixing autodoc 9
paolap Sep 9, 2024
7d89062
update to calculations docstrings
paolap Sep 9, 2024
709f283
solved #176
paolap Sep 10, 2024
ef07c9e
fixed #177 #167
paolap Sep 17, 2024
fa19895
added test_setup_utils
paolap Sep 18, 2024
5ffeec5
added more tests to test_setuo_utils.py
paolap Sep 18, 2024
8f90822
added more tests to setup_utils, changed define_files as in #179
paolap Sep 19, 2024
5381d0d
merge with tables
paolap Sep 23, 2024
4f1a136
added test for define_file, possibly fixed issue with missing data su…
paolap Sep 23, 2024
20287f1
more adjustment to date ranges and pyproject data packaging
paolap Sep 24, 2024
9855688
fixed small bug
paolap Sep 24, 2024
9ba8160
fixed detection of time ranges and handling of dates, added tests and…
paolap Sep 26, 2024
745c82a
solved issue #153
paolap Sep 26, 2024
fcd3eca
reviewed an updated docs
paolap Sep 27, 2024
97b2cd4
fixed issue with data packaging
paolap Oct 2, 2024
f0cdb0a
updated docs for calculations
paolap Oct 2, 2024
f9beff1
added test for sum timeshot
paolap Oct 2, 2024
0e05387
solved #170 and progress on #180, rebuilt db after cleaning mappings …
paolap Oct 3, 2024
3eac399
solved #185 #182 #180
paolap Oct 8, 2024
678960d
checked that #91 is completely fixed
paolap Oct 8, 2024
97e6062
close: #183, #180, #185
paolap Oct 10, 2024
7fe1aca
updated docs for calculations
paolap Oct 10, 2024
5cbd519
adjuted calculations import in tests
paolap Oct 10, 2024
eff45de
fixed bugs after testing CM2 monthly
paolap Oct 11, 2024
81d624b
more fixes of small bugs
paolap Oct 14, 2024
c8d1530
minor adjustments
paolap Oct 16, 2024
3cf0cb5
change conda git tag
paolap Oct 16, 2024
451ccd2
weirdly it was getting very old xarray from defaults channel
paolap Oct 16, 2024
12f66d1
weirdly it was getting very old xarray from defaults channel 2
paolap Oct 16, 2024
2c4ddb2
weirdly it was getting very old xarray from defaults channel 3
paolap Oct 16, 2024
e177801
weirdly it was getting very old xarray from defaults channel 4
paolap Oct 17, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/mopper-conda-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Build of mopper conda package for new release

# Controls when the action will run.
on:
release:
types: ['released', 'prereleased']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand Down
24 changes: 18 additions & 6 deletions ACDD_conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
cmor:
# If test true it will just run the setup but not launch the job automatically
test: false
appdir: /g/data/ua8/Working/packages/ACCESS-MOPPeR
# working directory if default uses current directory
appdir: default
# output directory for all generated data (CMORISED files & logs)
# if default it is set to /scratch/$project/$user/MOPPER_OUTPUT<exp>
outpath: default
Expand All @@ -29,6 +30,11 @@ cmor:
access_version: CM2
# reference date for time units (set as 'default' to use start_date)
reference_date: 1970-01-01
# Path and file templates can be changed based on the experiment.
# The example below should be considered a minimum requirement.
# Consider adding 'table_id" if using the "all tables" option to list
# the variables to process as variables can be present at same frequency
# in more than one tables
path_template: "{product_version}/{frequency}"
# date_range is automatically added at the end of filename
file_template: "{variable_id}_{source_id}_{experiment_id}_{frequency}"
Expand All @@ -41,6 +47,7 @@ cmor:
shuffle: 1
# Variables to CMORise:
# CMOR table/variable to process; default is 'all'.
# 'all' will use all the tables listed in the mapping file
# Or create a yaml file listing variables to process (VAR_SUBSET[_LIST]).
# each line: <table: [var1, var2, var3 ..]>
tables: CMIP6_Amon
Expand Down Expand Up @@ -81,16 +88,21 @@ cmor:
_AXIS_ENTRY_FILE: "ACDD_coordinate.json"
_FORMULA_VAR_FILE: "ACDD_formula_terms.json"
grids: "ACDD_grids.json"
# Additional NCI information:
# Additional NCI information:
# NCI project to charge compute; $PROJECT = your default project
project: v45
# additional NCI projects to be included in the storage flags
# additional NCI projects to be included in the storage flags, comma separated list
addprojs: []
# queue and memory (GB) per CPU (depends on queue),
# hugemem is reccomended for high reoslution data and/or derived variables
# hugemem is recommended for high reoslution data and/or derived variables
# hugemem requires a minimum of 6 cpus this is handled by the code
queue: hugemem
mem_per_cpu: 32
max_cpus: 24
# Mopper uses multiprocessing to produce files in parallel, usually 1 cpu per worker
# is a good compromise, occasionally you might want to pass a higher number
# if running out of memory
cpuxworker: 1
# walltime in "hh:mm:ss"
walltime: '8:00:00'
mode: custom
Expand All @@ -99,7 +111,7 @@ cmor:
# you can override that by supplying the env to pass to "source"
# Ex
# conda_env: <custom-env-path>/bin/activate
# or you can set "test: true" and modify mopper_job.sh manually
# to allow other settings use "test: true" and modify mopper_job.sh manually
conda_env: default

#
Expand Down Expand Up @@ -174,4 +186,4 @@ attrs:
parent: !!bool false
# CMOR will add a tracking_id if you want to define a prefix add here
tracking_id_prefix:
comment: "post-processed using ACCESS-MOPPeR v1.0.0 https://doi.org/10.5281/zenodo.10346216"
comment: "post-processed using ACCESS-MOPPeR v1.1.0 https://doi.org/10.5281/zenodo.13841181"
20 changes: 16 additions & 4 deletions CMIP6_conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
cmor:
# If test true it will just run the setup but not launch the job automatically
test: false
appdir: /g/data/ua8/Working/packages/ACCESS-MOPPeR
# working directory if default uses current directory
appdir: default
# output directory for all generated data (CMORISED files & logs)
# if default it is set to /scratch/$project/$user/MOPPER_OUTPUT<exp>
outpath: default
Expand Down Expand Up @@ -38,6 +39,7 @@ cmor:

# Variables to CMORise:
# CMOR table/variable to process; default is 'all'.
# 'all' will use all the tables listed in the mapping file
# Or create a yaml file listing variables to process (VAR_SUBSET[_LIST]).
# each line: <table: [var1, var2, var3 ..]>
tables: CMIP6_Amon
Expand Down Expand Up @@ -79,19 +81,29 @@ cmor:
grids: CMIP6_grids.json
# Additional NCI information:
# NCI project to charge compute; $PROJECT = your default project
# NCI queue to use; hugemem is recommended
project: v45
# additional NCI projects to be included in the storage flags
# additional NCI projects to be included in the storage flags, comma separated list
addprojs: []
# queue and memory (GB) per CPU (depends on queue)
# hugemem is reccomended for high reoslution data and/or derived variables
# hugemem is recommended for high resolution data and/or derived variables
# hugemem requires a minimum of 6 cpus this is handled by the code
queue: hugemem
mem_per_cpu: 30
max_cpus: 24
# Mopper uses multiprocessing to produce files in parallel, usually 1 cpu per worker
# is a good compromise, occasionally you might want to pass a higher number
# if running out of memory
cpuxworker: 1
# walltime in "hh:mm:ss"
walltime: '8:00:00'
mode: cmip6
# if default uses hh5 conda env
# conda_env to use by default hh5 analysis3-unstable
# as this has the code and all dependecies installed
# you can override that by supplying the env to pass to "source"
# Ex
# conda_env: <custom-env-path>/bin/activate
# to allow other settings use "test: true" and modify mopper_job.sh manually
conda_env: default

# Global attributes: these will be added to each files comment unwanted ones
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [ACCESS Model Output Post-Processor (MOPPeR)](https://access-mopper.readthedocs.io/en/latest)
[![Read the docs](https://readthedocs.org/projects/access-mopper/badge/?version=latest)](https://access-mopper.readthedocs.io/en/latest/)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.12747219.svg)](https://doi.org/10.5281/zenodo.12747219)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13841181.svg)](https://doi.org/10.5281/zenodo.13841181)

This code is derived from the [APP4](https://doi.org/10.5281/zenodo.7703469), initially created by Peter Uhe for CMIP5, and further developed for CMIP6-era by Chloe Mackallah from CSIRO, O&A Aspendale.

Expand Down Expand Up @@ -36,6 +36,6 @@ If you want to install an unstable version or a different branch:
MOPPeR is pre-installed into a Conda environment at NCI. Load it with::

module use /g/data3/hh5/public/modules
module load conda/analysis3
module load conda/analysis3-unstable

NB. You need to be a member of the hh5 project to load the modules.
1 change: 0 additions & 1 deletion conda/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: mopper_env
channels:
- conda-forge
- coecms
- default

dependencies:
- anaconda-client
Expand Down
11 changes: 6 additions & 5 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package:
name: mopper
version: "{{ environ.get('GIT_DESCRIBE_TAG', '1.0') }}"

#version: "{{ environ.get('GIT_DESCRIBE_TAG', '1.0') }}"
version: '1.1.0'
#source:
# path: ./
# path: ./

source:
#url: https://github.com/ACCESS-Hive/ACCESS-MOPPeR/archive/refs/tags/{{version}}.tar.gz
git_url: https://github.com/ACCESS-Hive/ACCESS-MOPPeR.git
#git_tag: prerelease
git_rev: "{{ version }}"
git_tag: prerelease
#git_rev: "1.1.0"
#git_depth: 1 # (Defaults to -1/not shallow)
#path: ../.

build:
number: 1
Expand Down
4 changes: 3 additions & 1 deletion conda/testenv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ channels:
dependencies:
- cmor
- click
- xarray
- conda-forge::xarray
- numpy
- dask
- pyyaml
Expand All @@ -16,3 +16,5 @@ dependencies:
- codecov
- pyfakefs
- ruff
- metpy
- gsw
78 changes: 78 additions & 0 deletions docs/calculations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
Calculating derived variables
=============================

Calculations are used to derive a variable from one or multiple inputs, to resample a variable to a new frequency or generally to modify a variable so it will match fully the corresponding definition in a CMOR table.

How calculations work
---------------------
Calculations are defined in the mapping file under the filed by the same name. The `calculation` string gets literally evaluated by the tool using python eval() function.
As an example
simple calculation could be summing avariable across all its vertical levels:

.. code-block:: bash

mrso;fld_s08i223;var[0].sum(dim='depth')

`var` represents the list of input variables, in this case there's only one which var[0] in the calculation string. In this case the calculation is very simple and can be fully defined in the mapping itself. If the calculation is more complex it's easier to use a pre-defined function, for example:

.. code-block:: bash

hus24;fld_s00i010 fld_s00i408;plevinterp(var[0], var[1], 24)

Here plevinterp is called to interpolate specific humidity from model levels to pressure levels, this function takes three input arguments, the variable to interpolate, pressure at model levels and finally the number of pressure levels, which corresponds to a specific definition of the pressure levels coordinate.
Already available functions are listed below.

.. note::

When more than one variable is used as input, if the variables are not all in the same file, more than one file pattern can be specified in the mapping row.

Resample
^^^^^^^^
If a variable is available in the raw model output but not at the desired frequency, the tool will try to see if a higher frequency is available to be resampled. For example, if a user is interested in daily surface temperature but this is available only as hourly data, during the `mop setup` phase the tool will add a `resample` attribute with value 'D' to the variable and this will used as argument for the resample function. Which kind of statistics to use for the function is defined based on the `timeshot` attribute, so if a variable is defined as a maximum, minimum or sum these are used in the resample instead of the mean.

Contributing
------------
TBA


Available functions
-------------------

Atmosphere and aerosol
^^^^^^^^^^^^^^^^^^^^^^
.. automodule:: mopper.calc_atmos
:members:
:undoc-members:
:show-inheritance:


Ocean
^^^^^
.. automodule:: mopper.calc_ocean
:members:
:undoc-members:
:show-inheritance:


SeaIce
^^^^^^
.. automodule:: mopper.calc_seaice
:members:
:undoc-members:
:show-inheritance:


Land
^^^^
.. automodule:: mopper.calc_land
:members:
:undoc-members:
:show-inheritance:


Other
^^^^^
.. automodule:: mopper.calc_utils
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/cmor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ There are custom tables for CM2 variables not yet included in the CMIP6 tables a
Experiment input file
---------------------

This provides user-supplied metadata and configuration directives used by CMOR, in cluding which controlled vocabulary (CV), grids and coordinate definitions to use and values for the attributes describing the model and simulation.
This provides user-supplied metadata and configuration directives used by CMOR, including which controlled vocabulary (CV), grids and coordinate definitions to use and values for the attributes describing the model and simulation.

We simplified this process so the user only has to pass one configuration file to control all the necessary inputs.
The `mop setup` command will then create an experiment file as expected by CMOR based on this and the selected CV file. This is described in the :ref:`Getting started section <conf-file>`.
Expand Down
26 changes: 20 additions & 6 deletions docs/cmor_conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ cmor:
# shuffle 0: off 1:on Shuffle reduces size without impacting speed
deflate_level: 4
shuffle: 1
# Variables to CMORise:
# CMOR table/variable to process; default is 'all'.
# Variables to CMORise:
# CMOR table/variable to process; default is 'all'.
# 'all' will use all the tables listed in the mapping file
# Or create a yaml file listing variables to process (VAR_SUBSET[_LIST]).
# each line: <table: [var1, var2, var3 ..]>
tables: CMIP6_Amon
Expand Down Expand Up @@ -85,12 +86,25 @@ cmor:
# NCI project to charge compute; $PROJECT = your default project
# NCI queue to use; hugemem is recommended
project: v45
# additional NCI projects to be included in the storage flags
# additional NCI projects to be included in the storage flags, comma separated list
addprojs: []
# queue and memory (GB) per CPU (depends on queue)
# queue and memory (GB) per CPU (depends on queue),
# hugemem is recommended for high reoslution data and/or derived variables
# hugemem requires a minimum of 6 cpus this is handled by the code
queue: hugemem
mem_per_cpu: 32
mem_per_cpu: 32
max_cpus: 24
# Mopper uses multiprocessing to produce files in parallel, usually 1 cpu per worker
# is a good compromise, occasionally you might want to pass a higher number
# if running out of memory
cpuxworker: 1
# walltime in "hh:mm:ss"
walltime: '8:00:00'
mode: custom
conda_env: /g/data/.../mopper_env/bin/activate
# conda_env to use by default hh5 analysis3-unstable
# as this has the code and all dependecies installed
# you can override that by supplying the env to pass to "source"
# Ex
# conda_env: <custom-env-path>/bin/activate
# to allow other settings use "test: true" and modify mopper_job.sh manually
conda_env: default
11 changes: 9 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
#
# clef documentation build configuration file, created by
# sphinx-quickstart on Fri May 13 10:16:43 2016.
# ACCESS-MOPPeR documentation build configuration file.
#
# This file is execfile()d with the current directory set to its
# containing dir.
Expand All @@ -12,11 +11,15 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../src'))


# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -48,6 +51,10 @@
# The master toctree document.
master_doc = 'index'

# adding this to avoid failure of autodoc because of missing packages
autodoc_mock_imports = ['numpy', 'xarray', 'dask', 'logging', 'click',
'yaml', 'json', 'importlib']

# General information about the project.
project = u'ACCESS-MOPPeR'
copyright = u'2023, Paola Petrelli, Sam Green'
Expand Down
11 changes: 6 additions & 5 deletions docs/customising.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ These variables will be listed in a section labelled:

# Variables with different frequency: Use with caution!

The frequency listed in the mapping template is taken directly from the file, make sure it matches the one of the listed cmor table. If they differ the `cmor table` should be updated with one that has a definition with the correct frequency.
The frequency listed in the mapping template is taken directly from the file, make sure it matches the one of the listed CMOR table. If they differ the `cmor table` should be updated with one that has a definition with the correct frequency.

.. warning::
Pay attention if the variable is an instantaneous value or not (i.e. time: point vs mean, sum, max etc in the cell_methods). This should match the frequency in the cmor table definition.
.. warning::
Pay attention if the variable is an instantaneous value or not (i.e. time: point vs mean, sum, max etc in the cell_methods). This should match the frequency in the CMOR table definition.
If it doesn't a new variable with the correct frequency, cell_methods and time _axis should be defined, see below.

A similar message precedes all the variables mapped from a different version from the selected (or default) one:
Expand All @@ -66,7 +66,7 @@ For both steps existing identical records will be overwritten. Once new records

While it's possible to modify an existing CMOR table, it's probably better to do so only for a custom table as CMIP6 has strict standards and it's important to keep these tables the same as their official version. Other things to pay attention to are:

* Check that the table to modify doesn't contain a conflicting variable, for example a variable that uses the same output name. In most cases the output name and the variable name used as key for the record are the same. However, the key name is what is used to point to the correct variable definition in the mapping table and can be different from the output name. This allows two variables with the same output name to be part of the same cmor table.
* Check that the table to modify doesn't contain a conflicting variable, for example a variable that uses the same output name. In most cases the output name and the variable name used as key for the record are the same. However, the key name is what is used to point to the correct variable definition in the mapping table and can be different from the output name. This allows two variables with the same output name to be part of the same CMOR table.
* When adding a variable, a sub-hourly frequency the frequency in the table should be `subhr` or most often `subhrPt`. This is because of the way CMOR3 is structured it only accept a defined set of frequencies. As mopper uses the frequencies to estimate the file sizes, if working with sub-hourly data you need to then specify what the exact interval is in the configuration file using the `subhr` field and `min` as units.

.. warning::
Expand Down Expand Up @@ -94,13 +94,14 @@ Here we're showing how the pressure level calculation is defined for air tempera

For context this is the function definition:

.. code-block:: ipython3
.. code-block:: python

def plevinterp(ctx, var, pmod, levnum):

where `ctx` is the `context` of the specific file including information on the original variable. This is automatically passed to the function and should not be included in the function call.

.. note::

All currently available calculations are listed in `Available functions`_.
We are planning to provide a simplified way to introduce new calculations and to update the central database with user provided mappings and variable definitions. For the moment open a `new issue on github <https://github.com/ACCESS-Community-Hub/ACCESS-MOPPeR/issues/new>`_ so we can review the updates and add them to the official version.

Loading
Loading