diff --git a/.github/workflows/mopper-conda-release.yaml b/.github/workflows/mopper-conda-release.yaml index 9d23954..00fa7a3 100644 --- a/.github/workflows/mopper-conda-release.yaml +++ b/.github/workflows/mopper-conda-release.yaml @@ -9,7 +9,7 @@ on: jobs: conda_deployment_with_new_tag: - name: Test conda deployment of package with Python ${{ matrix.python-version }} + name: Deploy conda package with Python ${{ matrix.python-version }} runs-on: ubuntu-latest strategy: matrix: diff --git a/ACDD_conf.yaml b/ACDD_conf.yaml index 6e5fcd7..5ab33ef 100755 --- a/ACDD_conf.yaml +++ b/ACDD_conf.yaml @@ -71,14 +71,17 @@ cmor: # use this to indicate the path used for new or modified tables # these will be used in preference to the package tables tables_path: "" - # ancillary files path - # when running model with payu ancil files are copied to work//INPUT - # you can leave these empty if processing only atmos + # Ancil files are needed only for specific variables when + # grid information is not fully available from output + # you can usually leave these empty if processing only atmos + # ancillary files relative path to or fullpath ancils_path: "localdata/ancils" grid_ocean: "" grid_ice: "" mask_ocean: "" + # to supply land area fraction if not available in output land_frac: "" + # to supply tile area fraction if not available in output tile_frac: "" # defines Controlled Vocabularies and required attributes # leave ACDD to follow NCI publishing requirements diff --git a/CMIP6_conf.yaml b/CMIP6_conf.yaml index ae18c01..2deb98e 100755 --- a/CMIP6_conf.yaml +++ b/CMIP6_conf.yaml @@ -1,6 +1,8 @@ ################################################################ # USER OPTIONS # Settings to manage cmorisation and set tables/variables to process +# This config file is to produce files to submit to CMIP6 project +# It's more restrictive than ACDD_conf.yaml cmor: # If test true it will just run the setup but not launch the job automatically test: false @@ -62,14 +64,17 @@ cmor: # as you should use official CMOR cmip6 tables for CMIP6 mode # use this only if current package version is obsolete tables_path: "" - # ancillary files path - # when running model with payu ancil files are copied to work//INPUT - # you can leave these empty if processing only atmos - ancils_path: "data/ancils" + # Ancil files are needed only for specific variables when + # grid information is not fully available from output + # you can usually leave these empty if processing only atmos + # ancillary files relative path to or fullpath + ancils_path: "localdata/ancils" grid_ocean: "" - mask_ocean: "" grid_ice: "" + mask_ocean: "" + # to supply land area fraction if not available in output land_frac: "" + # to supply tile area fraction if not available in output tile_frac: "" history_data: '' # DO NOT REMOVE OR ALTER this if you don't know what you're doing :-) diff --git a/conda/meta.yaml b/conda/meta.yaml index 24f8949..90b87fb 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,17 +1,16 @@ package: name: mopper #version: "{{ environ.get('GIT_DESCRIBE_TAG', '1.0') }}" - version: '1.1.1' + version: '1.1.2' #source: -# path: ./ +# path: ../. source: - #url: https://github.com/ACCESS-Hive/ACCESS-MOPPeR/archive/refs/tags/{{version}}.tar.gz + #url: https://github.com/ACCESS-Hive/ACCESS-MOPPeR/archive/refs/tags/{{ environ.get('RELEASE_VERSION') }}.tar.gz git_url: https://github.com/ACCESS-Hive/ACCESS-MOPPeR.git - git_tag: prerelease + git_tag: "1.1.2" #git_rev: "1.1.0" #git_depth: 1 # (Defaults to -1/not shallow) - #path: ../. build: number: 1 diff --git a/src/mopper/mop_utils.py b/src/mopper/mop_utils.py index b322f18..95745be 100755 --- a/src/mopper/mop_utils.py +++ b/src/mopper/mop_utils.py @@ -1110,9 +1110,10 @@ def define_attrs(ctx): ctx : click context Includes obj dict with 'cmor' settings, exp attributes """ - #var_log = logging.getLogger(ctx.obj['var_log']) - attrs = ctx.obj['attrs'] + var_log = logging.getLogger(ctx.obj['var_log']) + attrs = ctx.obj['attrs'].copy() notes = attrs.get('notes', '') + var_log.debug(f"in define_attrs, notes: {notes}") # open file containing notes fname = import_files('mopdata').joinpath('notes.yaml') data = read_yaml(fname)['notes'] @@ -1125,7 +1126,8 @@ def define_attrs(ctx): fval = ctx.obj[field] for k,v in data[field].items(): if k == fval or (k[0] == '~' and k[1:] in fval): - notes += v + notes += f" {v} " if notes != '': - attrs['notes'] = notes + attrs['notes'] = notes.strip() + var_log.debug(f"in define_attrs, attrs: {attrs}") return attrs diff --git a/tests/test_mop_utils.py b/tests/test_mop_utils.py index dd64697..908fcee 100644 --- a/tests/test_mop_utils.py +++ b/tests/test_mop_utils.py @@ -22,7 +22,8 @@ import logging from pathlib import Path -from mopper.mop_utils import (check_timestamp, get_cmorname,) +from mopper.mop_utils import (check_timestamp, get_cmorname, + define_attrs) ctx = click.Context(click.Command('cmd'), @@ -121,8 +122,25 @@ def test_get_cmorname(caplog): assert iname == 'longitude' assert jname == 'latitude' assert zname == 'plev3' - # test generic axis alevel ctx.obj['axes'] = 'longitude latitude alevel time' with ctx: zname = get_cmorname('theta_model_level_number') assert zname == 'hybrid_height' + +def test_define_attrs(caplog): + global ctx + caplog.set_level(logging.DEBUG, logger='varlog_1') + ctx.obj['attrs'] = {'notes': "some existing note"} + ctx.obj['variable_id'] = "ta" + ctx.obj['calculation'] = "... plevinterp(var[0]) " + with ctx: + out = define_attrs() + 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" + # repeating to make sure we are not using reference to ctx see issue #190 + with ctx: + out = define_attrs() + 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" + ctx.obj['attrs'] = {} + with ctx: + out = define_attrs() + 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"