@@ -1427,8 +1427,25 @@ the only differences being:
14271427 : longitude(5) = [157.5, ..., -22.5] degrees_east
14281428 : time(1) = [2019-01-01 00:00:00]
14291429
1430+ An index that is a list of integers may also be provided as a `numpy `
1431+ array, a `dask ` array, a `cf.Data ` instance, or a metadata construct
1432+ that has data:
1433+
1434+ .. code-block:: python
1435+ :caption: *Create a new field construct for longitudes greater than
1436+ 180. *
1437+
1438+ >>> lon = q.dimension_coordinate('X')
1439+ >>> print(q[:, lon > 180])
1440+ Field: specific_humidity (ncvar%q)
1441+ ----------------------------------
1442+ Data : specific_humidity(latitude(5), longitude(4)) 1
1443+ Cell methods : area: mean
1444+ Dimension coords: latitude(5) = [-75.0, ..., 75.0] degrees_north
1445+ : longitude(4) = [202.5, ..., 337.5] degrees_east
1446+ : time(1) = [2019-01-01 00:00:00]
14301447
1431- A `cf.Data ` instance can also directly be indexed in the same way :
1448+ A `cf.Data ` instance can also directly be indexed in the same ways :
14321449
14331450.. code-block:: python
14341451 :caption: *Create a new 'Data' instance by indexing. *
@@ -1536,6 +1553,27 @@ A `cf.Data` instance can also assigned values in the same way:
15361553 >>> print(t[0, 0, -1].array)
15371554 [[[-99.]]]
15381555
1556+ An index that is a list of integers may also be provided as a `numpy `
1557+ array, a `dask ` array, a `cf.Data ` instance, or a metadata construct
1558+ that has data:
1559+
1560+ .. code-block:: python
1561+ :caption: *Assign to elements which correspond to positive grid
1562+ latitudes. *
1563+
1564+ >>> y = t.dimension_coordinate('Y')
1565+ >>> t[:, y > 0] = -6
1566+ >>> print(t)
1567+ [[[ -6.0 -4.0 -6.0 -6.0 -6.0 -6.0 -6.0 -6.0 -6.0]
1568+ [ -6.0 -4.0 -6.0 -6.0 -6.0 -6.0 -6.0 -6.0 -6.0]
1569+ [ -6.0 -4.0 -6.0 -6.0 -6.0 -6.0 -6.0 -6.0 -6.0]
1570+ [ -6.0 -4.0 -6.0 -6.0 -6.0 -6.0 -6.0 -6.0 -6.0]
1571+ [ -6.0 -4.0 -6.0 -6.0 -6.0 -6.0 -6.0 -6.0 -6.0]
1572+ [263.9 -2.0 272.1 3.0 4.0 5.0 260.0 263.5 270.2]
1573+ [273.8 -2.0 268.5 0.0 1.0 2.0 270.6 273.0 270.6]
1574+ [-11.0 -2.0 279.8 260.3 261.2 275.3 271.2 260.8 268.9]
1575+ [270.9 -2.0 273.2 261.7 271.6 265.8 273.0 278.5 266.4]
1576+ [276.4 -2.0 276.3 266.1 -4.0 268.1 277.0 273.4 -5.0]]]
15391577
15401578.. _Masked-values:
15411579
0 commit comments