-
Notifications
You must be signed in to change notification settings - Fork 7
Implement apply cell measures #953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9c98423
22530bb
3a54a40
d8b5977
099d59d
fb6e14b
23a411c
30a912a
2ed844a
19af1b0
abe53d9
e57005b
8993a3e
34cb062
fed7074
a01acf2
190545b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |||||
| import copy | ||||||
| import logging | ||||||
| from operator import attrgetter | ||||||
| from typing import Optional, Tuple | ||||||
|
|
||||||
| import iris | ||||||
| import numpy as np | ||||||
|
|
@@ -14,12 +15,17 @@ | |||||
| DEFAULT_FILL_VALUE, has_auxiliary_latitude_longitude, check_values_equal) | ||||||
| from mip_convert.load.pp.pp_axis import (BoundedAxis, AxisHybridHeight, | ||||||
| TimeSeriesSiteAxis, ReferenceTimeAxis) | ||||||
| from mip_convert.save.cmor.cmor_outputter import AbstractCmorOutputter | ||||||
| from mip_convert.variable import Variable as CMORVariable | ||||||
| from mip_convert.variable import (CoordinateDomain, PolePoint, TripolarGrid, | ||||||
| make_masked) | ||||||
|
|
||||||
|
|
||||||
| def save(mip_output_variable, saver): | ||||||
| def save( | ||||||
| mip_output_variable, | ||||||
| saver: AbstractCmorOutputter, | ||||||
| cell_measures_config: Optional[Tuple[str, str, str, str, Optional[str], str]] = None, | ||||||
| ): | ||||||
| """Save the |MIP output variable| to an |output netCDF file| | ||||||
| using |CMOR|. | ||||||
|
|
||||||
|
|
@@ -41,10 +47,17 @@ def save(mip_output_variable, saver): | |||||
| The |MIP output variable|. | ||||||
| saver: callable | ||||||
| A function with the signature ``function(object)`` | ||||||
| cell_measures_config: tuple, optional | ||||||
| Arguments for :meth:`cmor_wrapper.apply_cell_measures` (excluding | ||||||
| ``variable_id``). When provided, cell measures are applied once, | ||||||
| after the CMOR variable is registered but before data is written. | ||||||
| """ | ||||||
| logger = logging.getLogger(__name__) | ||||||
| logger.debug('Saving MIP output variable to an output netCDF file') | ||||||
| cmor_variable = create_cmor_variable(mip_output_variable) | ||||||
| if cell_measures_config is not None and saver.varid is None: | ||||||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
CDDS/mip_convert/mip_convert/save/cmor/cmor_outputter.py Lines 304 to 305 in 6048425
|
||||||
| saver._getVarId(cmor_variable) | ||||||
| saver.cmor.apply_cell_measures(*cell_measures_config, saver.varid) | ||||||
| saver(cmor_variable) | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ | |
| from mip_convert import mip_parser | ||
| import mip_convert.common | ||
| from mip_convert.common import RelativePathChecker | ||
| from mip_convert.save.cmor.cmor_wrapper import CmorWrapper | ||
| from mip_convert.save.mip_config import MipTableFactory | ||
|
|
||
|
|
||
|
|
@@ -219,7 +220,7 @@ class AbstractCmorOutputter(object): | |
| """ | ||
|
|
||
| def __init__(self, entry, cmor_wrapper): | ||
| self.cmor = cmor_wrapper | ||
| self.cmor: CmorWrapper = cmor_wrapper | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly slightly unnecessary but this fixed the fact i couldn't get any hover info in vscode on |
||
| self.entry = entry | ||
| self._name_space = MoNameSpace() | ||
| self.varid = None | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, putting the call to
apply_cell_measuresinsaverather than in the block before thetime_sliceloop was due to problems with cmor such as it requiring the grid axes when making avaridin_makeVarid, and other issues - which would cause errors like this: