Welcome to the eocis_chuk_api documentation
Creating, loading and exporting CHUK data
CHUKDataSetUtils
Provide utility functions for working with CHUK datasets, based on xarray data structures.
This class helps users to work with CHUK datasets, providing support for creating and converting data and metadata
Examples:
>>> import xarray as xr
>>> import numpy as np
>>> from eocis_chuk_api import CHUKDataSetUtils
>>> utils = CHUKDataSetUtils("EOCIS-CHUK-GRID-100M-v1.0.nc")
>>> chuk_ds = utils.create_new_dataset(
title="My CHUK dataset",
institution = "EOCIS CHUK",
Conventions = "CF-1.10",
tracking_id = "12345678",
product_version = "1.0",
summary = "Shows estimates of the squirrel population in each CHUK grid cell",
license = "Creative Commons Licence by attribution (https://creativecommons.org/licenses/by/4.0/)",
history = "Developed from the squirrel population dataset",
comment = "This is a made up example",
creator_url = "https:///www.example.com",
creator_name = "Institute of Squirrel Studies",
creator_email = "enquiries@squirrel-studies.org.uk",
creator_processing_institution = "Institute of Squirrel Studies")
>>> # create an array to hold the data
>>> population_data = np.zeros(utils.get_grid_shape())
>>> # populate the data
>>> population_data[...] = ...
>>> # attach the data
>>> chuk_ds["squirrel_population"] = xr.DataArray(population_data,dims=("y","x"), attrs={
"long_name":"estimated_squirrel_population",
"coordinates": "lat lon",
"grid_mapping": "crsOSGB"
})
>>> # save the dataset
>>> utils.save(chuk_ds, "EOCIS-CHUK-L4-SQUIRRELPOP-MERGED-20231204-v0.1.nc")
Source code in eocis_chuk_api/chuk_dataset_utils.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 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 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | |
__init__(chuk_grid_path)
Initialise an instance with the path to the CHUK grid file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chuk_grid_path
|
str
|
path to a grid file |
required |
Notes
grid files can be obtained from https://gws-access.jasmin.ac.uk/public/nceo_uor/eocis-chuk/
Examples:
>>> from eocis_chuk_api import CHUKDataSetUtils
>>> utils = CHUKDataSetUtils("EOCIS-CHUK-GRID-100M-v0.4.nc")
Source code in eocis_chuk_api/chuk_dataset_utils.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
add_latlon(ds)
Add lat and lon 2D arrays from the reference grid
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
the dataset to mondify in-place |
required |
Source code in eocis_chuk_api/chuk_dataset_utils.py
457 458 459 460 461 462 463 464 465 | |
add_latlon_bnds(ds)
Add lat and lon 2D bounds from the reference grid
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
the dataset to mondify in-place |
required |
Source code in eocis_chuk_api/chuk_dataset_utils.py
467 468 469 470 471 472 473 474 475 | |
add_variable(to_dataset, data, variable_name, standard_name=None, long_name=None, units=None, source=None, **other_attrs)
Add a new variable to a dataset. The dataset is updated in-place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_dataset
|
Dataset
|
The xarray.Dataset to which the variable will be added |
required |
data
|
array
|
a numpy array containing the data, organised by (y,x), (time,y,x) or (y,x,time) |
required |
variable_name
|
str
|
the name of the variable to be added to the dataset |
required |
standard_name
|
str
|
CF standard name (if appropriate) |
None
|
long_name
|
str
|
A longer descriptive name of the variable |
None
|
units
|
str
|
units from UDUNITS |
None
|
other_attrs
|
dict
|
dictionary containing other attributes to add to the new variable |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if the data parameter does not match the expected shape |
Source code in eocis_chuk_api/chuk_dataset_utils.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
check(ds)
Check a dataset against CHUK format, returning details of any problems found
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
the xarray.Dataset to check |
required |
Returns:
| Type | Description |
|---|---|
([(str, str)], [(str, str)])
|
2-tuple (warnings, errors) containing lists of (code,detail) tuples |
Source code in eocis_chuk_api/chuk_dataset_utils.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | |
create_filename(project, processing_level, product_type, product_string, datetime, version, additional_segregator=None, suffix='.nc')
Create an EOCIS standards compliant filename
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
str
|
the EOCIS project string (see the appropriate standards doc) |
required |
processing_level
|
str
|
specify the processing level in (L0, L1A, L1B, L1C, L2, L2P, L3, L3U, L3C, L3S, L4, IND) |
required |
product_type
|
str
|
standardised term to describe the main product type in te dataset, see standards doc |
required |
product_string
|
str
|
descriptive name chosen from the team, should not contain hyphens, can contain underscores |
required |
datetime
|
str
|
date and optionally time, format YYYY[MM[DD[HH[MM[SS]]]]] |
required |
version
|
str
|
File version number one or more digits followed by an optional "." and another one or more digits |
required |
additional_segregator
|
str
|
an optional extra segregator, to be used if otherwise different data sets would generate the same filename |
None
|
suffix
|
str
|
the file suffix, including the "." |
'.nc'
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted filename |
Source code in eocis_chuk_api/chuk_dataset_utils.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
create_new_dataset(title='', include_lon_lat=False, institution='EOCIS CHUK', source='', history='', references='', tracking_id='', Conventions='CF-1.10', product_version='', format_version='', summary='', keywords='', id='', naming_authority='', keywords_vocabulary='', cdm_data_type='', comment='', date_created='', creator_name='', creator_url='', creator_email='', project='Earth Observation Climate Information Service (EOCIS)', geospatial_lat_min='47.089', geospatial_lat_max='61.133', geospatial_lon_min='-15.374', geospatial_lon_max='4.750', geospatial_vertical_min='0', geospatial_vertical_max='0', time_coverage_start='', time_coverage_end='', time_coverage_duration='', time_coverage_resolution='', standard_name_vocabulary='', license='Creative Commons Attribution 4.0 International (CC-BY 4.0 license)', platform='', sensor='', spatial_resolution='100m', geospatial_lat_units='degrees_north', geospatial_lon_units='degrees_east', geospatial_lon_resolution='0.0009', geospatial_lat_resolution='0.00086', key_variables='', acknowledgement='Funded by UK EOCIS. Use of these data should acknowledge EOCIS', publisher_url='https://eocis.org', publisher_name='EOCIS', publisher_email='EOCIS@reading.ac.uk', **other_attributes)
Create a new CHUK dataset with expected global attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_lon_lat
|
bool
|
True if lon and lat 2d variables should be included |
False
|
title
|
str
|
a title for the dataset |
''
|
institution
|
str
|
Succinct description of the dataset |
'EOCIS CHUK'
|
source
|
str
|
Comma separated list of original data sources (+DOIs if available) |
''
|
history
|
str
|
Processing history of the dataset |
''
|
references
|
str
|
References to algorithm, ATBD, technical note describing dataset |
''
|
tracking_id
|
str
|
A UUID (Universal Unique Identifier) value |
''
|
Conventions
|
str
|
The CF Version e.g. CF-1.10 |
'CF-1.10'
|
product_version
|
str
|
The product version of this data file |
''
|
format_version
|
str
|
The EOCIS data format used e.g. “EOCIS Data Standards v1.x” |
''
|
summary
|
str
|
A paragraph describing the dataset |
''
|
keywords
|
str
|
A comma separated list of key words and phrases |
''
|
id
|
str
|
see naming_authority |
''
|
naming_authority
|
str
|
The combination of the naming authority and the id should be a globally unique identifier for the dataset |
''
|
keywords_vocabulary
|
str
|
If you are following a guideline for the words/phrases in your “keywords” attribute, put the name of that guideline here |
''
|
cdm_data_type
|
str
|
The THREDDS data type appropriate for this dataset |
''
|
comment
|
str
|
Miscellaneous information about the data |
''
|
date_created
|
str
|
The date on which the data was created |
''
|
creator_name
|
str
|
The person/organisation that created the data |
''
|
creator_url
|
str
|
A URL for the person/organisation that created the data |
''
|
creator_email
|
str
|
Contact email address for the person/organisation that created the data |
''
|
project
|
str
|
The scientific project that produced the data: “Earth Observation Climate Information Service (EOCIS)” |
'Earth Observation Climate Information Service (EOCIS)'
|
geospatial_lat_min
|
str
|
Decimal degrees north, range -90 to +90 |
'47.089'
|
geospatial_lat_max
|
str
|
Decimal degrees north, range -90 to +90 |
'61.133'
|
geospatial_lon_min
|
str
|
Decimal degrees east, range -180 to +180 |
'-15.374'
|
geospatial_lon_max
|
str
|
Decimal degrees east, range -180 to +180 |
'4.750'
|
geospatial_vertical_min
|
str
|
Assumed to be in metres above ground unless geospatial_vertical_units attribute defined otherwise |
'0'
|
geospatial_vertical_max
|
str
|
Assumed to be in metres above ground unless geospatial_vertical_units attribute defined otherwise |
'0'
|
time_coverage_start
|
str
|
Format yyyymmddThhmmssZ |
''
|
time_coverage_end
|
str
|
Format yyyymmddThhmmssZ |
''
|
time_coverage_duration
|
str
|
Should be an ISO8601 duration string, for example P1D |
''
|
time_coverage_resolution
|
str
|
Should be an ISO8601 duration string. For L2 data on the original satellite sampling it is acceptable to use 'satellite_orbit_frequency' |
''
|
standard_name_vocabulary
|
str
|
The name of the controlled vocabulary from which variable standard names are taken e.g. ‘CF Standard Name Table v82’ |
''
|
license
|
str
|
Describe the restrictions to data access and distribution |
'Creative Commons Attribution 4.0 International (CC-BY 4.0 license)'
|
platform
|
str
|
Satellite name e.g. Sentinel-5. Separate lists by commas and use angled brackets for a platform series, e.g. ‘Envisat, NOAA-<12,14,16,17,18>, Metop-A’. The platform names used should follow the naming in the CCI controlled vocabulary |
''
|
sensor
|
str
|
Sensor name e.g. AATSR. Separate lists by commas. The platform names used should follow the naming in the CCI controlled vocabulary |
''
|
spatial_resolution
|
str
|
A free-text string describing the approximate resolution of the product. For example, “1.1km at nadir”. This is intended to provide a useful indication to the user, so if more than one resolution is relevant e.g. the grid resolution and the data resolution, then both can be included. |
'100m'
|
geospatial_lat_units
|
str
|
Geospatial latitude units used |
'degrees_north'
|
geospatial_lon_units
|
str
|
Geospatial longitude units used |
'degrees_east'
|
geospatial_lon_resolution
|
str
|
Geospatial latitude resolution used |
'0.0009'
|
geospatial_lat_resolution
|
str
|
Geospatial longitude resolution used |
'0.00086'
|
key_variables
|
str
|
A comma separated list of the key primary variables in the file i.e. those that have been scientifically validated. |
''
|
acknowledgement
|
str
|
Acknowledge funding sources and/or contributors |
'Funded by UK EOCIS. Use of these data should acknowledge EOCIS'
|
other_attributes
|
dict
|
any other attributes to include |
{}
|
Returns:
| Type | Description |
|---|---|
Dataset
|
An xarray.Dataset object |
Source code in eocis_chuk_api/chuk_dataset_utils.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 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 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
get_grid_latlons()
Obtain the chuk grid lats/lons
Returns:
| Type | Description |
|---|---|
(DataArray, DataArray)
|
2-tuple containing xarray.DataArray objects (lats,lons) |
Source code in eocis_chuk_api/chuk_dataset_utils.py
83 84 85 86 87 88 89 90 | |
get_grid_shape()
Obtain the chuk grid shape (y,x)
Returns:
| Type | Description |
|---|---|
(int, int)
|
2-tuple containing the grid (height, width) |
Source code in eocis_chuk_api/chuk_dataset_utils.py
92 93 94 95 96 97 98 99 | |
load(from_path, add_latlon=False, add_latlon_bnds=False)
Load a CHUK dataset from file and return a dataset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_path
|
str
|
path to a NetCDF4 file |
required |
add_latlon
|
bool
|
add lon and lat 2D arrays to the dataset |
False
|
add_latlon_bnds
|
bool
|
add lon_bnds and lat_bnds 2D arrays to the dataset |
False
|
Returns:
| Type | Description |
|---|---|
Dataset
|
A dataset containing the loaded CHUK data |
Source code in eocis_chuk_api/chuk_dataset_utils.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
sample(ds, to_resolution)
staticmethod
Create a lower resolution sample of a CHUK dataset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
the xarray.Dataset containing CHUK data to sample |
required |
to_resolution
|
int
|
the resolution for the sampled output, must be a multiple of 100 |
required |
Returns:
| Type | Description |
|---|---|
Dataset
|
A dataset containing the sampled data |
Source code in eocis_chuk_api/chuk_dataset_utils.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | |
save(ds, to_path, add_latlon=False, add_latlon_bnds=False, x_chunk_size=1000, y_chunk_size=1000, time_chunk_size=1, custom_encodings={}, override_encodings={})
Save a CHUK dataset to file, applying the standard chunking and compression
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
an xarray dataset containing CHUK data |
required |
to_path
|
str
|
path to a NetCDF4 file |
required |
add_latlon
|
bool
|
add lon and lat 2D arrays to the dataset |
False
|
add_latlon_bnds
|
bool
|
add lon_bnds and lat_bnds 2D arrays to the dataset |
False
|
x_chunk_size
|
int
|
size of chunking in the x-dimension |
1000
|
y_chunk_size
|
int
|
size of chunking in the x-dimension |
1000
|
time_chunk_size
|
int
|
size of chunking in the time dimension |
1
|
custom_encodings
|
dict
|
dictionary mapping from variable names to a custom encoding to use by xarray |
{}
|
Source code in eocis_chuk_api/chuk_dataset_utils.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
save_as_geotif(ds, variable_name, to_path)
staticmethod
Save a CHUK dataset to a geotiff. DEPRECATED - use save_as_geotiff
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
the CHUK dataset |
required |
variable_name
|
str
|
the name of the variable to save from the dataset |
required |
to_path
|
str
|
the path to save the geotiff file to |
required |
Source code in eocis_chuk_api/chuk_dataset_utils.py
477 478 479 480 481 482 483 484 485 486 487 | |
save_as_geotiff(ds, variable_name, to_path)
staticmethod
Save a CHUK dataset to a geotiff
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
the CHUK dataset |
required |
variable_name
|
str
|
the name of the variable to save from the dataset |
required |
to_path
|
str
|
the path to save the geotiff file to |
required |
Source code in eocis_chuk_api/chuk_dataset_utils.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | |
Working with CHUK Auxilary data
CHUKAuxilaryDataCombinedMask
Bases: Mask
Source code in eocis_chuk_api/chuk_auxilary_utils.py
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 | |
__init__(*masks, operator='or')
Create a mask derived from one or more other masks
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
masks
|
list[Mask]
|
a list of one or more masks to be combined |
()
|
operator
|
str
|
the operator to use, should be "not", "or" or "and" |
'or'
|
Throws
ValueError for example if the list of masks is empty or operator is not one of "not","and","or"
Source code in eocis_chuk_api/chuk_auxilary_utils.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
CHUKAuxilaryDataMask
Bases: Mask
Source code in eocis_chuk_api/chuk_auxilary_utils.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 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 | |
__init__(dataset_name, variable_name, include_missing=False)
Construct a mask associated with a particular dataset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_name
|
str
|
the name of the dataset |
required |
variable_name
|
str
|
the name of the variable in the dataset to use to construct the mask |
required |
include_missing
|
bool
|
whether to also include missing data values (eg NaN) in the mask |
False
|
Source code in eocis_chuk_api/chuk_auxilary_utils.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
add_mask_value(mask_value)
Add a value to the mask
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask_value
|
str
|
the category value to include in the mask |
required |
Throws: ValueError if the specified value is not a valid value for this mask
Source code in eocis_chuk_api/chuk_auxilary_utils.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
get_all_mask_values()
Get a list of all the values that could be included in this mask
Returns:
| Type | Description |
|---|---|
list[str]
|
a list of values |
Source code in eocis_chuk_api/chuk_auxilary_utils.py
123 124 125 126 127 128 129 130 | |
get_selected_mask_values()
Get a list of all the values that are included in this mask
Returns:
| Type | Description |
|---|---|
list[str]
|
a list of values included in this mask |
Source code in eocis_chuk_api/chuk_auxilary_utils.py
132 133 134 135 136 137 138 139 140 141 142 | |
to_array()
Obtain the evaluated mask values Returns: an xarray DataArray object
Source code in eocis_chuk_api/chuk_auxilary_utils.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
CHUKAuxilaryUtils
Source code in eocis_chuk_api/chuk_auxilary_utils.py
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 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
create_mask(dataset_path, variable, mask_values, include_missing=False)
staticmethod
Create a mask
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_path
|
str
|
path to the netcdf file containing the auxilary data to use |
required |
variable
|
str
|
the variable in the file to use in the mask |
required |
mask_values
|
[str, list[str]]
|
a string or list of strings |
required |
include_missing
|
bool
|
whether to include missing data values in the mask or not |
False
|
Returns:
| Type | Description |
|---|---|
CHUKAuxilaryDataMask
|
A mask object containing of True or False values for every cell |
Source code in eocis_chuk_api/chuk_auxilary_utils.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
Mask
Bases: ABC
Source code in eocis_chuk_api/chuk_auxilary_utils.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
__init__()
Abstract Base Class for masks, do not instantiate directly
Source code in eocis_chuk_api/chuk_auxilary_utils.py
29 30 31 32 33 | |
and_mask(*others)
AND this mask with other masks
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
others
|
list[Mask]
|
a list of masks to be AND'd with this mask |
()
|
Returns: a combined mask
Source code in eocis_chuk_api/chuk_auxilary_utils.py
46 47 48 49 50 51 52 53 54 55 | |
count()
Count the number of True values in this mask
Returns:
| Type | Description |
|---|---|
int
|
the total number of True values |
Source code in eocis_chuk_api/chuk_auxilary_utils.py
67 68 69 70 71 72 73 74 | |
fraction()
Calculate the fraction of values that are True in this mask
Returns:
| Type | Description |
|---|---|
float
|
the fraction of values that are True |
Source code in eocis_chuk_api/chuk_auxilary_utils.py
76 77 78 79 80 81 82 83 84 85 86 87 | |
not_mask()
Invert this mask
Returns:
| Type | Description |
|---|---|
Mask
|
a new mask that is the negation of this mask |
Source code in eocis_chuk_api/chuk_auxilary_utils.py
58 59 60 61 62 63 64 65 | |
or_mask(*others)
OR this mask with other masks
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
others
|
list[Mask]
|
a list of masks to be OR'd with this mask |
()
|
Returns: a combined mask
Source code in eocis_chuk_api/chuk_auxilary_utils.py
35 36 37 38 39 40 41 42 43 44 | |
to_array()
abstractmethod
Convert this mask to an xarray.DataArray and return it
Returns:
| Type | Description |
|---|---|
DataArray
|
an xarray.DataArray containing the mask values |
Source code in eocis_chuk_api/chuk_auxilary_utils.py
89 90 91 92 93 94 95 96 97 | |