input4mips_validation.xarray_helpers#
| Sub-package | Description |
|---|---|
| iris | Helpers for interchanging with iris |
| time | Helpers for time handling |
| variables | Helpers for determining what is and isn't a variable |
input4mips_validation.xarray_helpers
#
Helpers for working with xarray
add_time_bounds(ds, monthly_time_bounds=True, yearly_time_bounds=False, output_dim_bounds='bounds', create_cftime_datetime=None)
#
Add time bounds to a dataset
This should be pushed upstream to cf-xarray at some point probably
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset to which to add time bounds |
required |
monthly_time_bounds
|
bool
|
Are we looking at monthly data i.e. should the time bounds run from the start of one month to the next (which isn't regular spacing but is most often what is desired/required) |
True
|
yearly_time_bounds
|
bool
|
Are we looking at yearly data i.e. should the time bounds run from the start of one year to the next (which isn't regular spacing but is sometimes what is desired/required) |
False
|
output_dim_bounds
|
str
|
What is the name of the bounds dimension
(either already in |
'bounds'
|
create_cftime_datetime
|
Callable[[int, int, int], datetime] | None
|
Function to use to create cftime.datetime objects from date information. If not supplied, we use cftime.datetime. |
None
|
Returns:
| Type | Description |
|---|---|
Dataset with time bounds
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Both |
Notes
There is no copy here, ds is modified in place
(call xarray.Dataset.copy before passing if you don't want this).
Source code in src/input4mips_validation/xarray_helpers/time.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |