Skip to content
This repository was archived by the owner on Sep 21, 2025. It is now read-only.

Commit b70c614

Browse files
authored
Merge pull request #192 from ACCESS-Community-Hub/issue190
Issue190
2 parents 6873c75 + aa470e8 commit b70c614

File tree

6 files changed

+47
-20
lines changed

6 files changed

+47
-20
lines changed

.github/workflows/mopper-conda-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
conda_deployment_with_new_tag:
12-
name: Test conda deployment of package with Python ${{ matrix.python-version }}
12+
name: Deploy conda package with Python ${{ matrix.python-version }}
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:

ACDD_conf.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@ cmor:
7171
# use this to indicate the path used for new or modified tables
7272
# these will be used in preference to the package tables
7373
tables_path: ""
74-
# ancillary files path
75-
# when running model with payu ancil files are copied to work/<realm>/INPUT
76-
# you can leave these empty if processing only atmos
74+
# Ancil files are needed only for specific variables when
75+
# grid information is not fully available from output
76+
# you can usually leave these empty if processing only atmos
77+
# ancillary files relative path to <appdir> or fullpath
7778
ancils_path: "localdata/ancils"
7879
grid_ocean: ""
7980
grid_ice: ""
8081
mask_ocean: ""
82+
# to supply land area fraction if not available in output
8183
land_frac: ""
84+
# to supply tile area fraction if not available in output
8285
tile_frac: ""
8386
# defines Controlled Vocabularies and required attributes
8487
# leave ACDD to follow NCI publishing requirements

CMIP6_conf.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
################################################################
22
# USER OPTIONS
33
# Settings to manage cmorisation and set tables/variables to process
4+
# This config file is to produce files to submit to CMIP6 project
5+
# It's more restrictive than ACDD_conf.yaml
46
cmor:
57
# If test true it will just run the setup but not launch the job automatically
68
test: false
@@ -62,14 +64,17 @@ cmor:
6264
# as you should use official CMOR cmip6 tables for CMIP6 mode
6365
# use this only if current package version is obsolete
6466
tables_path: ""
65-
# ancillary files path
66-
# when running model with payu ancil files are copied to work/<realm>/INPUT
67-
# you can leave these empty if processing only atmos
68-
ancils_path: "data/ancils"
67+
# Ancil files are needed only for specific variables when
68+
# grid information is not fully available from output
69+
# you can usually leave these empty if processing only atmos
70+
# ancillary files relative path to <appdir> or fullpath
71+
ancils_path: "localdata/ancils"
6972
grid_ocean: ""
70-
mask_ocean: ""
7173
grid_ice: ""
74+
mask_ocean: ""
75+
# to supply land area fraction if not available in output
7276
land_frac: ""
77+
# to supply tile area fraction if not available in output
7378
tile_frac: ""
7479
history_data: ''
7580
# DO NOT REMOVE OR ALTER this if you don't know what you're doing :-)

conda/meta.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
package:
22
name: mopper
3-
#version: "{{ environ.get('GIT_DESCRIBE_TAG', '1.0') }}"
3+
#version: "{{ environ.get('GIT_DESCRIBE_TAG', '1.1.0') }}"
44
version: '1.1.0'
55
#source:
6-
# path: ./
6+
# path: ../.
77

88
source:
9-
#url: https://github.com/ACCESS-Hive/ACCESS-MOPPeR/archive/refs/tags/{{version}}.tar.gz
9+
#url: https://github.com/ACCESS-Hive/ACCESS-MOPPeR/archive/refs/tags/{{ environ.get('RELEASE_VERSION') }}.tar.gz
1010
git_url: https://github.com/ACCESS-Hive/ACCESS-MOPPeR.git
11-
git_tag: prerelease
11+
git_tag: "1.1.0"
1212
#git_rev: "1.1.0"
1313
#git_depth: 1 # (Defaults to -1/not shallow)
14-
#path: ../.
1514

1615
build:
1716
number: 1

src/mopper/mop_utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,9 +1110,10 @@ def define_attrs(ctx):
11101110
ctx : click context
11111111
Includes obj dict with 'cmor' settings, exp attributes
11121112
"""
1113-
#var_log = logging.getLogger(ctx.obj['var_log'])
1114-
attrs = ctx.obj['attrs']
1113+
var_log = logging.getLogger(ctx.obj['var_log'])
1114+
attrs = ctx.obj['attrs'].copy()
11151115
notes = attrs.get('notes', '')
1116+
var_log.debug(f"in define_attrs, notes: {notes}")
11161117
# open file containing notes
11171118
fname = import_files('mopdata').joinpath('notes.yaml')
11181119
data = read_yaml(fname)['notes']
@@ -1125,7 +1126,8 @@ def define_attrs(ctx):
11251126
fval = ctx.obj[field]
11261127
for k,v in data[field].items():
11271128
if k == fval or (k[0] == '~' and k[1:] in fval):
1128-
notes += v
1129+
notes += f" {v} "
11291130
if notes != '':
1130-
attrs['notes'] = notes
1131+
attrs['notes'] = notes.strip()
1132+
var_log.debug(f"in define_attrs, attrs: {attrs}")
11311133
return attrs

tests/test_mop_utils.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
import logging
2323
from pathlib import Path
2424

25-
from mopper.mop_utils import (check_timestamp, get_cmorname,)
25+
from mopper.mop_utils import (check_timestamp, get_cmorname,
26+
define_attrs)
2627

2728

2829
ctx = click.Context(click.Command('cmd'),
@@ -121,8 +122,25 @@ def test_get_cmorname(caplog):
121122
assert iname == 'longitude'
122123
assert jname == 'latitude'
123124
assert zname == 'plev3'
124-
# test generic axis alevel
125125
ctx.obj['axes'] = 'longitude latitude alevel time'
126126
with ctx:
127127
zname = get_cmorname('theta_model_level_number')
128128
assert zname == 'hybrid_height'
129+
130+
def test_define_attrs(caplog):
131+
global ctx
132+
caplog.set_level(logging.DEBUG, logger='varlog_1')
133+
ctx.obj['attrs'] = {'notes': "some existing note"}
134+
ctx.obj['variable_id'] = "ta"
135+
ctx.obj['calculation'] = "... plevinterp(var[0]) "
136+
with ctx:
137+
out = define_attrs()
138+
assert out['notes'] == "some existing note Linearly interpolated from model levels using numpy.interp() function. NaNs are assigned to pressure levels falling out of the height range covered by the model"
139+
# repeating to make sure we are not using reference to ctx see issue #190
140+
with ctx:
141+
out = define_attrs()
142+
assert out['notes'] == "some existing note Linearly interpolated from model levels using numpy.interp() function. NaNs are assigned to pressure levels falling out of the height range covered by the model"
143+
ctx.obj['attrs'] = {}
144+
with ctx:
145+
out = define_attrs()
146+
assert out['notes'] == "Linearly interpolated from model levels using numpy.interp() function. NaNs are assigned to pressure levels falling out of the height range covered by the model"

0 commit comments

Comments
 (0)