Skip to content

Commit b4caa8a

Browse files
committed
dev
1 parent 415a055 commit b4caa8a

4 files changed

Lines changed: 43 additions & 53 deletions

File tree

Changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Version NEXTVERSION
66
* New methods to allow changing units in a chain: `cf.Field.to_units`,
77
`cf.Data.to_units`
88
(https://github.com/NCAS-CMS/cf-python/issues/874)
9+
* Allow multiple conditions for the same axis in `cf.Field.subspace`
10+
and `cf.Field.indices`
11+
(https://github.com/NCAS-CMS/cf-python/issues/881)
912
* New method: `cf.Field.create_latlon_coordinates`
1013
(https://github.com/NCAS-CMS/cf-python/issues/???)
1114
* New HEALPix methods: `cf.Field.healpix_info`,

cf/field.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13475,6 +13475,8 @@ def subspace(self):
1347513475
* Multiple domain axes may be subspaced simultaneously, and it
1347613476
doesn't matter which order they are specified in.
1347713477

13478+
* Multiple criteria may be specified for the same domain axis.
13479+
1347813480
* Subspace criteria may be provided for size 1 domain axes that
1347913481
are not spanned by the field construct's data.
1348013482

cf/mixin/fielddomain.py

Lines changed: 38 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,66 +1640,66 @@ def del_coordinate_reference(
16401640
"""Remove a coordinate reference construct and all of its domain
16411641
ancillary constructs.
16421642
1643-
.. versionadded:: 3.0.0
1643+
.. versionadded:: 3.0.0
16441644
1645-
.. seealso:: `del_construct`
1645+
.. seealso:: `del_construct`
16461646
1647-
:Parameters:
1647+
:Parameters:
16481648
1649-
identity: optional
1650-
Select the coordinate reference construct by one of:
1649+
identity: optional
1650+
Select the coordinate reference construct by one of:
16511651
1652-
* The identity of a coordinate reference construct.
1652+
* The identity of a coordinate reference construct.
16531653
1654-
{{construct selection identity}}
1654+
{{construct selection identity}}
16551655
1656-
* The key of a coordinate reference construct
1656+
* The key of a coordinate reference construct
16571657
1658-
* `None`. This is the default, which selects the
1659-
coordinate reference construct when there is only
1660-
one of them.
1658+
* `None`. This is the default, which selects the
1659+
coordinate reference construct when there is only
1660+
one of them.
16611661
1662-
*Parameter example:*
1663-
``identity='standard_name:atmosphere_hybrid_height_coordinate'``
1662+
*Parameter example:*
1663+
``identity='standard_name:atmosphere_hybrid_height_coordinate'``
16641664
1665-
*Parameter example:*
1666-
``identity='grid_mapping_name:rotated_latitude_longitude'``
1665+
*Parameter example:*
1666+
``identity='grid_mapping_name:rotated_latitude_longitude'``
16671667
1668-
*Parameter example:*
1669-
``identity='transverse_mercator'``
1668+
*Parameter example:*
1669+
``identity='transverse_mercator'``
16701670
1671-
*Parameter example:*
1672-
``identity='coordinatereference1'``
1671+
*Parameter example:*
1672+
``identity='coordinatereference1'``
16731673
1674-
*Parameter example:*
1675-
``identity='key%coordinatereference1'``
1674+
*Parameter example:*
1675+
``identity='key%coordinatereference1'``
16761676
1677-
*Parameter example:*
1678-
``identity='ncvar%lat_lon'``
1677+
*Parameter example:*
1678+
``identity='ncvar%lat_lon'``
16791679
1680-
*Parameter example:*
1681-
``identity=cf.eq('rotated_pole')'``
1680+
*Parameter example:*
1681+
``identity=cf.eq('rotated_pole')'``
16821682
1683-
*Parameter example:*
1684-
``identity=re.compile('^rotated')``
1683+
*Parameter example:*
1684+
``identity=re.compile('^rotated')``
16851685
1686-
construct: optional
1687-
TODO
1686+
construct: optional
1687+
TODO
16881688
1689-
default: optional
1690-
Return the value of the *default* parameter if the
1691-
construct can not be removed, or does not exist.
1689+
default: optional
1690+
Return the value of the *default* parameter if the
1691+
construct can not be removed, or does not exist.
16921692
1693-
{{default Exception}}
1693+
{{default Exception}}
16941694
1695-
:Returns:
1695+
:Returns:
16961696
1697-
The removed coordinate reference construct.
1697+
The removed coordinate reference construct.
16981698
1699-
**Examples**
1699+
**Examples**
17001700
1701-
>>> f.del_coordinate_reference('rotated_latitude_longitude')
1702-
<CF CoordinateReference: rotated_latitude_longitude>
1701+
>>> f.del_coordinate_reference('rotated_latitude_longitude')
1702+
<CF CoordinateReference: rotated_latitude_longitude>
17031703
17041704
"""
17051705
if construct is None:
@@ -2115,23 +2115,9 @@ def healpix_indexing_scheme(self, new_indexing_scheme, sort=False):
21152115

21162116
_healpix_indexing_scheme(healpix_index, hp, new_indexing_scheme)
21172117

2118-
# # Ensure that healpix indices are auxiliary coordinates
2119-
# if healpix_index.construct_type == "dimension_coordinate":
2120-
# f.dimension_to_auxiliary(hp["coordinate_key"], inplace=True)
2121-
21222118
if sort:
21232119
# Sort the HEALPix axis so that the HEALPix indices are
21242120
# monotonically increasing.
2125-
2126-
# # Test for the common case of
2127-
# # already-ordered global nested or ring indices (which is
2128-
# # a relatively fast compared to do doing any actual
2129-
# # sorting and subspacing).
2130-
# h = healpix_index
2131-
# if not (
2132-
# indexing_scheme in ("nested", "ring")
2133-
# and (h == da.arange(h.size, chunks=h.data.chunks)).all()
2134-
# ):
21352121
d = healpix_index.data
21362122
if (d.diff() < 0).any():
21372123
index = d.compute()

cf/test/test_Field.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,6 @@ def test_Field_indices(self):
14911491
self.assertEqual(g.shape, (1, 10, 3))
14921492
self.assertTrue((x == [120, 200, 280]).all())
14931493

1494-
cf.log_level(1)
14951494
# 2-d
14961495
lon = f.construct("longitude").array
14971496
lon = np.transpose(lon)

0 commit comments

Comments
 (0)