weather_metadata
Weather metadata module, implementing functionality for working with weather metadata files (.bin.json).
WeatherAttributes
Weather attributes containing metadata used to construct the "metadata" element and stored in .bin.json file. Used to initiate weather metadata object. If no metadata is specified, defaults are used. If metadata dict is specified, that dictionary is used as is, without setting any defaults.
Source code in emodpy_malaria/weather/weather_metadata.py
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 | |
author
property
writable
Author of weather files.
data_years
property
writable
Data years range describing the temporal coverage.
date_created
property
writable
Date weather files are created.
id_reference
property
writable
Id reference value used to semantically bind weather files.
provenance
property
writable
Data provenance, describing the data source and how the data was obtained.
spatial_resolution
property
writable
Weather data Spatial resolution (e.g., 30arcsec or 1km)
tool
property
writable
Tool name used to prepare weather files.
update_resolution
property
writable
Data update frequency (e.g. monthly, yearly).
__eq__(other)
__init__(attributes_dict=None, reference=None, resolution=None, provenance=None, update_freq=None, start_year=None, end_year=None, start_doy=None, lat_min=None, lat_max=None, lon_min=None, lon_max=None, tool=None, author=None, schema_version=None)
Initialize the weather attributes object by either passing the metadata dictionary or setting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attributes_dict
|
Dict[str, Union[str, int, float]]
|
(Optional) A dictionary containing user specified metadata attributes. Used to initiate weather attributes object. A typical usage is to set metadata attributes including those not required or explicitly implemented by this class. For example, when reading existing metadata file (.bin.json), the dictionary read from the file allows persisting all found attributes, including those explicitly implemented by this class. This dictionary can be used in combination with other init arguments. |
None
|
reference
|
str
|
(Optional) Reference string expected by EMOD as a way to bind weather and demographic files. |
None
|
resolution
|
str
|
(Optional) Spatial weather data resolution. |
None
|
provenance
|
str
|
(Optional) Data provenance describing data source and how it was obtained. |
None
|
update_freq
|
str
|
(Optional) The frequency. |
None
|
start_year
|
int
|
(Optional) Weather data start year. Used to construct years range attribute. |
None
|
end_year
|
int
|
(Optional) Weather data end year. Used to construct years range attribute. |
None
|
start_doy
|
int
|
(Optional) The start day of year. By default, it is set to 1. |
None
|
lat_min
|
float
|
(Optional) Minimal or top latitude of the weather spatial coverage. |
None
|
lat_max
|
float
|
(Optional) Maximum or bottom latitude of the weather spatial coverage. |
None
|
lon_min
|
float
|
(Optional) Minimal or top longitude of the weather spatial coverage. |
None
|
lon_max
|
float
|
(Optional) Maximum or top longitude of the weather spatial coverage. |
None
|
tool
|
str
|
(Optional) The tool used to prepare weather files. |
None
|
author
|
str
|
(Optional) The author of weather files. |
None
|
schema_version
|
str
|
(Optional) The EMOD weather file schema version. |
None
|
Source code in emodpy_malaria/weather/weather_metadata.py
metadata_defaults_dict()
classmethod
Metadata defaults dictionary.
Source code in emodpy_malaria/weather/weather_metadata.py
required_metadata_defaults_dict(exclude_keys=None)
classmethod
Dictionary of required metadata defaults.
Source code in emodpy_malaria/weather/weather_metadata.py
update(value)
validate()
Validate metadata contains requires argument.
Source code in emodpy_malaria/weather/weather_metadata.py
WeatherMetadata
Bases: WeatherAttributes
Weather metadata containing weather data attributes, counts and node offsets. Used to initiate WeatherData, expose metadata programmatically and create weather metadata files (.bin.json).
Source code in emodpy_malaria/weather/weather_metadata.py
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 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | |
attributes
property
Cast back into WeatherAttributes.
datavalue_count
property
Number of data values in each weather time series (must be > 0).
node_count
property
The number of node in the node-offset dictionary.
node_offset_str
property
The node offset string, as it will appear in the weather metadata file (.bin.json).
node_offsets
property
Node-offset dictionary, mapping node ids (keys) to node offsets (values).
nodes
property
The list of nodes (node ids) in the node-offset dictionary.
offset_nodes
property
The offset-nodes dictionary, grouping nodes (values) by offset (key). Used to find unique series.
series_count
property
The number of weather time series (expected based on metadata), corresponding to the number of offsets.
series_len
property
Number of data values in each timeseries, should be > 0.
series_unique_count
property
The number of unique weather time series (expected based on metadata), based on offsets.
total_value_count
property
The total count of all values, in all weather time series (expected based on metadata).
__eq__(other)
Equality operator for WeatherMetadata objects
Source code in emodpy_malaria/weather/weather_metadata.py
__init__(node_ids, series_len=None, attributes=None)
Initiate WeatherMetadata object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_ids
|
Union[List[int], Dict[int, int]]
|
A dictionary with node ids as keys and offsets as values, or just a list of node ids. If node-offset dictionary is provided, node offsets are set per that dictionary. If a list of nodes ids is provided, offsets are calculated based on weather time series length. |
required |
series_len
|
int
|
The length of a weather time series (aka "data value count"). |
None
|
attributes
|
Union[WeatherMetadata, WeatherAttributes, Dict[str, Union[str, int, float]]]
|
Weather attributes, either as an objects or a dictionary. |
None
|
Source code in emodpy_malaria/weather/weather_metadata.py
from_file(file_path)
classmethod
Read weather metadata file into a weather metadata object.
Source code in emodpy_malaria/weather/weather_metadata.py
to_file(file_path)
Save weather metadata object as weather metadata file (.bin.json).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Union[str, Path]
|
The path of the output weather metadata file. |
required |
Returns:
| Type | Description |
|---|---|
NoReturn
|
None |
Source code in emodpy_malaria/weather/weather_metadata.py
validate()
Validate metadata object node-related counts. Relies on inherited validation of metadata attributes.