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

Commit a376cc2

Browse files
committed
minor adjustment to docs, conf files and code after tests
1 parent 3cef828 commit a376cc2

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

ACDD_conf.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,4 @@ attrs:
174174
parent: !!bool false
175175
# CMOR will add a tracking_id if you want to define a prefix add here
176176
tracking_id_prefix:
177-
comment: "post-processed using ACCESS-MOPPeR v0.6.0 https://doi.org/10.5281/zenodo.10346216"
177+
comment: "post-processed using ACCESS-MOPPeR v1.0.0 https://doi.org/10.5281/zenodo.10346216"

CMIP6_conf.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ cmor:
9191
# walltime in "hh:mm:ss"
9292
walltime: '8:00:00'
9393
mode: cmip6
94+
# conda_env: <custom-env-path>/bin/activate
95+
conda_env: default
9496

9597
# Global attributes: these will be added to each files comment unwanted ones
9698
# the labels CMIP6/ACDD indicates which ones are necessary to comply with respective standards
@@ -161,4 +163,4 @@ attrs:
161163
#CMOR will add a tracking_id if you want to define a prefix add here
162164
tracking_id_prefix:
163165
Conventions: "CF-1.7 CMIP-6.2"
164-
comment: "post-processed using ACCESS-MOPPeR v0.6.0 https://doi.org/10.5281/zenodo.10346216"
166+
comment: "post-processed using ACCESS-MOPPeR v1.0.0 https://doi.org/10.5281/zenodo.10346216"

docs/mopdb_command.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,19 @@ A user that wants to create a mapping table for another AUS2200 simulation can u
5757

5858
Create a mapping file
5959
---------------------
60-
.. code-block::
6160

6261
This can be done by providing the model output path and a pattern to match or directly a varlist file
6362

6463
From output path:
6564

65+
.. code-block::
66+
6667
mopdb template -f <output-path> -m <string-to-match> -v <access-version>
6768
6869
From varlist file:
6970

71+
.. code-block::
72+
7073
mopdb template -f <varlist-out> -v <access-version>
7174
7275
This will create a map_<exp>.csv file using, if available, information from the mapping table.
@@ -110,20 +113,25 @@ The other groups of records require checking, as either the version or the frequ
110113

111114
Create an intake catalogue
112115
--------------------------
113-
.. code-block::
114116

115117
This represents an extra step on top of the mapping, so it can be start directly from an existing mapping or from scratch by providing the model ouptut path and a match.
116118

117119
From output path:
118120

121+
.. code-block::
122+
119123
mopdb intake -f <output-path> -m <string-to-match> -v <access-version> { -a <alias> }
120124
121125
From varlist file:
122126

127+
.. code-block::
128+
123129
mopdb intake -f <output-path> -fl <varlist-out> -v <access-version> { -a <alias> }
124130
125131
From mapping file:
126132

133+
.. code-block::
134+
127135
mopdb intake -f <output-path> -fl <mapping-out> -v <access-version> { -a <alias> }
128136
129137
NB the model output path is still needed even when passing an existing mapping or variable list.

src/mopdata/update_db.py.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def update_map(conn, varid, ctable):
3737
"""Read mappings for variable from map file and
3838
update them in filelist
3939
"""
40-
keys = ['frequency','realm','timeshot','calculation', 'positive', 'resample']
40+
keys = ['frequency','realm','timeshot','calculation',
41+
'positive', 'resample']
4142
keys2 = {'vin': 'input_vars', 'in_units': 'units'}
4243
fname = f"maps/{ctable}.json"
4344
with open(fname, 'r') as f:
@@ -48,6 +49,12 @@ def update_map(conn, varid, ctable):
4849
args = {k: row[k] for k in keys}
4950
for k,v in keys2.items():
5051
args[k] = row[v]
52+
if 'datadir' in row.keys():
53+
paths = row['file_structure'].split()
54+
infile = ''
55+
for x in paths:
56+
infile += f"{row['datadir']}/{x} "
57+
args['infile'] = infile
5158
cur = conn.cursor()
5259
sql = f"UPDATE filelist SET"
5360
for k,v in args.items():

src/mopper/mop_utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,13 @@ def get_coords(ctx, ovar, coords):
564564
var_log = logging.getLogger(ctx.obj['var_log'])
565565
# open ancil grid file to read vertices
566566
#PP be careful this is currently hardcoded which is not ok!
567-
ancil_file = ctx.obj[f"grid_{ctx.obj['realm']}"]
567+
ancil_dir = ctx.obj.get('ancils_path', '')
568+
ancil_file = ancil_dir + "/" + ctx.obj.get(f"grid_{ctx.obj['realm']}", '')
569+
if ancil_file == '' or not Path(ancil_file).exists():
570+
var_log.error(f"Ancil file {ancil_file} not set or inexistent")
571+
sys.exit()
568572
var_log.debug(f"getting lat/lon and bnds from ancil file: {ancil_file}")
569-
ds = xr.open_dataset(f"{ctx.obj['ancils_path']}/{ancil_file}")
573+
ds = xr.open_dataset(ancil_file)
570574
var_log.debug(f"ancil ds: {ds}")
571575
# read lat/lon and vertices mapping
572576
cfile = import_files('mopdata').joinpath('latlon_vertices.yaml')
@@ -793,8 +797,9 @@ def get_bounds_values(ctx, ds, bname):
793797
calc = False
794798
var_log = logging.getLogger(ctx.obj['var_log'])
795799
var_log.debug(f"Getting bounds values for {bname}")
796-
ancil_file = ctx.obj[f"grid_{ctx.obj['realm']}"]
800+
ancil_file = ctx.obj.get(f"grid_{ctx.obj['realm']}", '')
797801
if bname in ds.variables:
802+
var_log.debug(f"Bounds for {bname} in file")
798803
bnds_val = ds[bname].values
799804
elif ancil_file != "":
800805
fname = f"{ctx.obj['ancils_path']}/{ancil_file}"

0 commit comments

Comments
 (0)