Skip to content
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

Remove spacedomain vertical dimension #69

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7ff16b0
review temporal resolution constraint in Clock
Nov 3, 2021
e00cac5
review spatial resolution constraint in Compass
Nov 3, 2021
4b185b7
add missing abstract method for spans_same_region_as
Nov 3, 2021
42e88d9
add newly added doctests to test suites
Nov 3, 2021
2bbd706
add missing test cases from utils
Nov 3, 2021
8718f29
update dummy component resolutions in tests to comply with new constr…
Nov 3, 2021
6e86ae1
reflect changes in YAML configuration filenames in docs/docstrings
Nov 3, 2021
47a2de4
document new space and time constraints in tutorial
Nov 3, 2021
30f90fb
log changes
Nov 3, 2021
4e9e14a
update docs html
Nov 3, 2021
5f10507
fix floating point precision problem in doctest using ellipsis option
Nov 3, 2021
314a4a7
drop support for python 3.6
Nov 4, 2021
3eab4fa
update URLs for PyPI following change of host GH organisation
Nov 4, 2021
9b200b8
update docs html
Nov 4, 2021
1395936
change simulation periods mentioned in test docstring
Nov 12, 2021
6cc5f79
fix inaccuracies in test suite method names/comments
Nov 12, 2021
0546db5
add method and property to interact with SpaceDomain vertical axis
Nov 12, 2021
09b9784
fix bug not modifying array slice in place
Nov 12, 2021
a9b188f
enforce 2D arrays for transfers through `Exchanger`
Nov 12, 2021
16e6a01
drop vertical dimension for land_sea_mask, flow_direction, cell_area
Nov 12, 2021
ac902f3
tidy up
Nov 12, 2021
7ddeb40
add space shape check on variable given for routing
Nov 12, 2021
47af38b
add missing cell_area in `Grid` config interface
Nov 12, 2021
c5cd0f3
drop Z axis in dummyfortran and dummyc components
Nov 12, 2021
914e59a
tell Cython to compile pyx with Python 3
Nov 12, 2021
6f1d042
drop Z axis in dummy data for tests
Nov 12, 2021
d3d0611
drop Z axis in config files for tests
Nov 12, 2021
da413f5
drop Z axis in space domains of test suite
Nov 12, 2021
6aca7f2
"deactivate" vertical axis in `Grid` for now
Nov 15, 2021
316f622
Merge branch 'dev' into revise-spacedomain-vertical-dimension
Nov 15, 2021
c028c41
log changes
Nov 15, 2021
e1c0d07
update docs html
Nov 15, 2021
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
5 changes: 5 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Yet to be versioned and released. Only available from *dev* branch until then.
* constrain temporal and spatial resolutions of components forming a
model to be integer multiples of one another
(`#67 <https://github.com/cm4twc-org/cm4twc/pull/67>`_)
* enforce two-dimensional spatial domains for components
(`#69 <https://github.com/cm4twc-org/cm4twc/pull/69>`_)

.. rubric:: API changes

Expand All @@ -23,6 +25,9 @@ Yet to be versioned and released. Only available from *dev* branch until then.
(`#46 <https://github.com/cm4twc-org/cm4twc/pull/46>`_)
* remove science components (Artemis and RFM) from framework
(`#45 <https://github.com/cm4twc-org/cm4twc/issues/45>`_)
* remove vertical dimension (i.e. altitude) in `LatLonGrid`,
`RotatedLatLonGrid`, and `BritishNationalGrid`
(`#69 <https://github.com/cm4twc-org/cm4twc/pull/69>`_)

.. rubric:: Bug fixes

Expand Down
33 changes: 28 additions & 5 deletions cm4twc/_utils/exchanger.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ def set_up(self, clock, compass, overwrite=False):
# set up each transfer
for t in self.transfers:
histories = []
shape = self.transfers[t]['src_sd'].shape

# determine shape of transfer while dropping Z axis if
# spacedomain is 3D because transfers are along 2D interface
shape = (
self.transfers[t]['src_sd'].shape[1:]
if self.transfers[t]['src_sd'].has_vertical_axis()
else self.transfers[t]['src_sd'].shape
)

# special case for transfers towards a DataComponent or
# a NullComponent (or towards outside framework, which will
Expand All @@ -88,9 +95,17 @@ def set_up(self, clock, compass, overwrite=False):
# to None to avoid unnecessary remapping
src_sd = self.transfers[t]['src_sd']
src_fld = src_sd.to_field()
dst_fld = compass.spacedomains[c].to_field()
dst_sd = compass.spacedomains[c]
dst_fld = dst_sd.to_field()

# eliminate Z axis by squeezing fields because
# remapping for transfers on a 2D interface
if src_sd.has_vertical_axis():
src_fld.squeeze(src_sd.vertical_axis, inplace=True)
if dst_sd.has_vertical_axis():
dst_fld.squeeze(dst_sd.vertical_axis, inplace=True)

if src_sd.is_space_equal_to(dst_fld, ignore_z=True):
if src_sd.is_space_equal_to(dst_fld):
self.transfers[t][c]['remap'] = None
else:
# now assign a tuple to 'remap' where first item
Expand Down Expand Up @@ -335,7 +350,7 @@ def set_transfer(self, name, array):
lhs[:] = rhs[:]

self.transfers[name]['slices'][:] = lhs
self.transfers[name]['slices'][-1] = array
self.transfers[name]['slices'][-1][:] = array

def update_transfers(self, transfers):
for name, array in transfers.items():
Expand Down Expand Up @@ -363,7 +378,15 @@ def create_transfers_dump(filepath, transfers_info, timedomain, spacedomains):
for c in spacedomains:
g = f.createGroup(c)
spacedomain = spacedomains[c]
axes = spacedomain.axes

# drop Z axis if spacedomain is 3D because transfers are
# along 2D interface only
axes = (
spacedomain.axes[1:]
if spacedomain.has_vertical_axis()
else spacedomain.axes
)

# dimensions and coordinate variables
for axis in axes:
# dimension (domain axis)
Expand Down
Loading