@@ -743,7 +743,7 @@ def indices(self, *mode, **kwargs):
743
743
"""Create indices that define a subspace of the domain
744
744
construct.
745
745
746
- The indices returned by this method be used to create the
746
+ The indices returned by this method may be used to create the
747
747
subspace by passing them to the `subspace` method of the
748
748
original domain construct.
749
749
@@ -778,34 +778,22 @@ def indices(self, *mode, **kwargs):
778
778
may still need to be inserted into the field construct's
779
779
data.
780
780
781
+ **Halos**
782
+
783
+ {{subspace halos}}
784
+
781
785
.. versionadded:: 3.11.0
782
786
783
787
.. seealso:: `subspace`, `where`, `__getitem__`,
784
788
`__setitem__`, `cf.Field.indices`
785
789
786
790
:Parameters:
787
791
788
- mode: `str`, *optional*
789
- There are two modes of operation, each of which provides
790
- indices for a different type of subspace:
791
-
792
- ============== ======================================
793
- *mode* Description
794
- ============== ======================================
795
- ``'compress'`` This is the default mode. Unselected
796
- locations are removed to create the
797
- returned subspace. Note that if a
798
- multi-dimensional metadata construct
799
- is being used to define the indices
800
- then some missing data may still be
801
- inserted at unselected locations.
802
-
803
- ``'envelope'`` The returned subspace is the smallest
804
- that contains all of the selected
805
- indices.
806
- ============== ======================================
807
-
808
- kwargs: *optional*
792
+ {{mode: optional}}
793
+
794
+ {{subspace valid modes Domain}}
795
+
796
+ kwargs: optional
809
797
A keyword name is an identity of a metadata construct,
810
798
and the keyword value provides a condition for
811
799
inferring indices that apply to the dimension (or
@@ -857,19 +845,6 @@ def indices(self, *mode, **kwargs):
857
845
: time(1) = [2019-01-01 00:00:00]
858
846
859
847
"""
860
- if len (mode ) > 1 :
861
- raise ValueError (
862
- "Can't provide more than one positional argument. "
863
- f"Got: { ', ' .join (repr (x ) for x in mode )} "
864
- )
865
-
866
- if not mode or "compress" in mode :
867
- mode = "compress"
868
- elif "envelope" in mode :
869
- mode = "envelope"
870
- else :
871
- raise ValueError (f"Invalid value for 'mode' argument: { mode [0 ]!r} " )
872
-
873
848
# Get the indices for every domain axis in the domain, without
874
849
# any auxiliary masks.
875
850
domain_indices = self ._indices (mode , None , False , kwargs )
@@ -1120,19 +1095,19 @@ def roll(self, axis, shift, inplace=False):
1120
1095
return d
1121
1096
1122
1097
def subspace (self , * mode , ** kwargs ):
1123
- """Create indices that define a subspace of the domain
1124
- construct.
1098
+ """Create a subspace of the field construct.
1125
1099
1126
- The indices returned by this method be used to create the subspace
1127
- by passing them to the `subspace` method of the original domain
1128
- construct.
1100
+ Creation of a new domain construct which spans a subspace of
1101
+ the domain of an existing domain construct is achieved by
1102
+ identifying indices based on the metadata constructs
1103
+ (subspacing by metadata). The new domain construct is created
1104
+ with the same properties as the original domain construct.
1129
1105
1130
- The subspace is defined by identifying indices based on the
1131
- metadata constructs.
1106
+ **Subspacing by metadata**
1132
1107
1133
- Metadata constructs are selected conditions are specified on their
1134
- data. Indices for subspacing are then automatically inferred from
1135
- where the conditions are met.
1108
+ Subspacing by metadata selects metadata constructs and
1109
+ specifies conditions on their data. Indices for subspacing are
1110
+ then automatically inferred from where the conditions are met.
1136
1111
1137
1112
Metadata constructs and the conditions on their data are defined
1138
1113
by keyword parameters.
@@ -1142,6 +1117,9 @@ def subspace(self, *mode, **kwargs):
1142
1117
* Multiple domain axes may be subspaced simultaneously, and it
1143
1118
doesn't matter which order they are specified in.
1144
1119
1120
+ * Subspace criteria may be provided for size 1 domain axes that
1121
+ are not spanned by the field construct's data.
1122
+
1145
1123
* Explicit indices may also be assigned to a domain axis
1146
1124
identified by a metadata construct, with either a Python `slice`
1147
1125
object, or a sequence of integers or booleans.
@@ -1156,41 +1134,21 @@ def subspace(self, *mode, **kwargs):
1156
1134
acting along orthogonal dimensions, some missing data may still
1157
1135
need to be inserted into the field construct's data.
1158
1136
1159
- .. versionadded:: 3.11.0
1160
-
1161
- .. seealso:: `indices`
1162
-
1163
- :Parameters:
1137
+ **Halos**
1164
1138
1165
- mode: `str`, *optional*
1166
- There are two modes of operation, each of which provides
1167
- indices for a different type of subspace:
1139
+ {{subspace halos}}
1168
1140
1169
- ============== ==========================================
1170
- *mode* Description
1171
- ============== ==========================================
1172
- ``'compress'`` Return indices that identify only the
1173
- requested locations.
1141
+ .. versionadded:: 3.11.0
1174
1142
1175
- This is the default mode.
1143
+ .. seealso:: `indices`, `cf.Field.subspace`
1176
1144
1177
- Note that if a multi-dimensional metadata
1178
- construct is being used to define the
1179
- indices then some unrequested locations
1180
- may also be selected.
1145
+ :Parameters:
1181
1146
1182
- ``'envelope'`` The returned subspace is the smallest that
1183
- contains all of the requested locations.
1147
+ {{mode: optional}}
1184
1148
1185
- ``'test'`` May be used on its own or in addition to
1186
- one of the other positional arguments. Do
1187
- not create a subspace, but return `True`
1188
- or `False` depending on whether or not it
1189
- is possible to create the specified
1190
- subspace.
1191
- ============== ==========================================
1149
+ {{subspace valid modes Domain}}
1192
1150
1193
- kwargs: * optional*
1151
+ kwargs: optional
1194
1152
A keyword name is an identity of a metadata construct, and
1195
1153
the keyword value provides a condition for inferring
1196
1154
indices that apply to the dimension (or dimensions)
0 commit comments