bazefield_api
This is a wrapper to communicate with the BazeField API.
BazefieldApi
Client for the Bazefield REST API bound to an operator.
The client loads every asset configured for an operator. An operator may
expose several key-vault keys (each with its own subdomain and API key);
requests are issued per key in a loop and the results are combined into a
single :class:pandas.DataFrame. Data is aggregated per MPID (the key
strings in each key's assets mapping).
Attributes:
| Name | Type | Description |
|---|---|---|
operator |
Operator identifier (top-level key in the configuration). |
|
mpid |
Optional asset identifier restricting the client to a single asset. |
|
device_ids |
List[str]
|
Flat list of all turbine object ids loaded from the config. |
Notes
Site ids, turbine (device) ids and MPID mappings come from the
configuration; no API call is needed to resolve them on instantiation.
All time-series methods return :class:pandas.DataFrame objects.
Source code in physical_operations_utils/bazefield_utils/BazeFieldAPI.py
20 21 22 23 24 25 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 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 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | |
__init__(operator, mpid=None, logger=None)
Initialize a Bazefield API client for an operator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operator
|
str
|
Operator identifier (top-level key in the configuration). |
required |
mpid
|
Optional[str]
|
Optional asset identifier (MPID). When provided, only the turbine object ids configured for that asset are loaded. |
None
|
logger
|
Optional[Logger]
|
Optional loguru logger. A default is created when omitted. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the operator is unknown, a key is missing a subdomain, or no device ids are configured for the requested selection. |
Example
from physical_operations_utils.bazefield_utils.BazeFieldAPI import BazefieldApi
bz = BazefieldApi("ox2")
bz_single = BazefieldApi("ox2", mpid="P01MLK000")
Source code in physical_operations_utils/bazefield_utils/BazeFieldAPI.py
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 | |
get_historical_data(data_point, start_time_lb_utc, stop_time_lb_utc, interval='15m', aggregate=3, aggregation_type='sum')
Fetch historical time-series data aggregated per MPID.
All turbine object ids exposed by the same key are fetched in a single request; results are mapped back to their MPID and aggregated. When an operator spans several keys, each key is queried in turn and the frames are concatenated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_point
|
str
|
Bazefield point identifier (e.g. |
required |
start_time_lb_utc
|
Timestamp
|
Inclusive start timestamp (UTC). |
required |
stop_time_lb_utc
|
Timestamp
|
Inclusive end timestamp (UTC). |
required |
interval
|
str
|
Time resolution (e.g. |
'15m'
|
aggregate
|
int
|
Bazefield aggregation flag. |
3
|
aggregation_type
|
str
|
How to aggregate across turbines of the same MPID.
Either |
'sum'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas.DataFrame: Aggregated time-series with columns |
DataFrame
|
|
DataFrame
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If an unsupported |
Example
from physical_operations_utils.bazefield_utils.BazeFieldAPI import BazefieldApi
bz = BazefieldApi("ox2")
df = bz.get_historical_data(
data_point="CALC-AverageWindSpeed",
start_time_lb_utc="2026-06-30T00:00:00Z",
stop_time_lb_utc="2026-06-30T06:00:00Z",
aggregation_type="average",
)
Source code in physical_operations_utils/bazefield_utils/BazeFieldAPI.py
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 | |
list_points(turbine_object_id=None)
List available measurement points for a turbine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turbine_object_id
|
Optional[str]
|
Turbine object id to query. Defaults to the first configured device id when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Point schema definitions, or an empty dict if the |
Dict[str, Any]
|
turbine cannot be located. |
Source code in physical_operations_utils/bazefield_utils/BazeFieldAPI.py
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | |
list_sites()
List every site reachable across the operator's keys.
Queries the Bazefield API directly (rather than the configuration) so
that site object ids can be discovered when onboarding new assets. Each
returned dictionary is annotated with the key_secret and
subdomain it originates from.
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Site entries (API payload plus |
List[Dict[str, Any]]
|
and |
Source code in physical_operations_utils/bazefield_utils/BazeFieldAPI.py
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 | |
list_turbines(site_object_id, key_secret=None)
List turbine objects related to a site across the operator's keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_object_id
|
str
|
Bazefield site object id. |
required |
key_secret
|
Optional[str]
|
Optional key vault secret name to restrict the lookup to a single key (useful when site ids overlap across keys). |
None
|
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Turbine entries (API payload plus |
List[Dict[str, Any]]
|
and |
Source code in physical_operations_utils/bazefield_utils/BazeFieldAPI.py
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 | |
resolve_device_ids_for_site(site_object_id)
Return all turbine object ids for a site.
Intended for onboarding: pair a site id discovered via
:meth:resolve_site_id with this method to obtain the device_ids
list for the new asset's configuration entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_object_id
|
str
|
Bazefield site object id. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Turbine object ids for the site. |
Source code in physical_operations_utils/bazefield_utils/BazeFieldAPI.py
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | |
resolve_site_id(object_key)
Resolve the Bazefield site object id for an object_key (short name).
Intended for onboarding: discover the site_id to store in the config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_key
|
str
|
Site short name (e.g. |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional[str]: The matching site object id, or |
Source code in physical_operations_utils/bazefield_utils/BazeFieldAPI.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | |