- Home
- Documentation
- API reference
- Archive
- hyperproc.archive.interactive
hyperproc.archive.interactive¶
Source-derived reference
Generated from the current hyperproc 0.1.2 checkout.
Implementation: hyperproc/archive/interactive.py. Signatures, defaults, docstrings, and expandable source are extracted statically; the module is not imported or executed. Names beginning with _ are implementation details, not a stable public API.
Use the function signature as the authority for individual parameter defaults and return annotations. Original docstrings sometimes group parameter names or wrap return descriptions across lines; these descriptions are preserved rather than inferred or rewritten.
Draw a box on a map, search it, click the footprints you want.
>>> import hyperproc as hp
>>> m = hp.search_map() # displays; draw a rectangle with the toolbar
>>> m # in Jupyter the map is the cell output
>>> m.search("EMIT", "L2A", date=("2023-04-01", "2023-04-30"))
>>> m.selected # what you clicked
>>> hp.download(m.selected, "data/")
Everything the panel does is a method you can call instead, and everything a
method does the panel can do, so a notebook can start by pointing and end by
scripting. The map needs ipyleaflet::
pip install 'hyperproc[search-map]'
The logic underneath - which box, which granules, which of them are selected -
is :class:SearchState, which needs no widgets at all.
FOUND = '#3388ff'
module-attribute
¶
PICKED = '#ff7800'
module-attribute
¶
SearchState
¶
The part of the map that is not a map: a box, a result set, a selection.
| ATTRIBUTE | DESCRIPTION |
|---|---|
bbox |
|
results |
the last :class:
|
selected |
the granules picked out of it, in the order they were picked.
TYPE:
|
Source code in hyperproc/archive/interactive.py
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 | |
bbox = tuple(bbox) if bbox else None
instance-attribute
¶
results = Results([])
instance-attribute
¶
selected: list[Granule] = []
instance-attribute
¶
__init__(bbox=None)
¶
set_bbox_from_geojson(geometry: dict) -> tuple
¶
Take the bounds of a drawn shape, whatever shape it is.
The draw toolbar can produce a rectangle, a polygon or a circle marker; a search takes a box, so the bounds of whatever was drawn is the honest reading of the gesture.
Source code in hyperproc/archive/interactive.py
search(sensor: str, level: str | None = None, **kwargs) -> Results
¶
Search the drawn box. Selection is cleared, since it named old granules.
Source code in hyperproc/archive/interactive.py
toggle(name: str) -> bool
¶
Pick a granule by name, or unpick it. Returns whether it is now picked.
Source code in hyperproc/archive/interactive.py
select_all() -> list[Granule]
¶
clear() -> None
¶
geojson() -> dict
¶
The footprints as a FeatureCollection, ready for a map layer.
A footprint with no area - NEON publishes a site's coordinates, not its flight box - comes out as a Point rather than a zero-width polygon, so it is visible instead of invisible.
Source code in hyperproc/archive/interactive.py
bounds() -> tuple[float, float, float, float] | None
¶
(west, south, east, north) covering every footprint, for a zoom.
Source code in hyperproc/archive/interactive.py
summary() -> str
¶
One line for a status bar.
Source code in hyperproc/archive/interactive.py
Map
¶
A slippy map with a draw tool, a search panel and clickable footprints.
| PARAMETER | DESCRIPTION |
|---|---|
center
|
DEFAULT:
|
zoom
|
starting zoom.
TYPE:
|
height
|
CSS height of the map.
TYPE:
|
bbox
|
start with an area already chosen, instead of drawing one.
DEFAULT:
|
results
|
footprints to draw straight away, from a search you have already run. Saves searching twice when you want to look at a result set you are holding.
DEFAULT:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
state |
the :class:
|
map |
the raw
|
widget |
what is displayed - the map and the panel side by side. Show
|
bbox, results and selected read through to the state, so
hp.download(m.selected, "data/") works straight from the map.
Source code in hyperproc/archive/interactive.py
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 | |
state = SearchState(bbox)
instance-attribute
¶
_layer = None
instance-attribute
¶
_height_px = _px(height, 600)
instance-attribute
¶
_width_px = 900
instance-attribute
¶
map = leaflet.Map(center=center, zoom=zoom, scroll_wheel_zoom=True, layout=widgets.Layout(height=height, flex='1 1 auto'))
instance-attribute
¶
draw = leaflet.DrawControl(rectangle={'shapeOptions': {'color': '#00a0a0', 'fillOpacity': 0.05}}, polygon={}, circle={}, circlemarker={}, polyline={}, marker={}, edit=False, remove=True)
instance-attribute
¶
_panel = self._build_panel()
instance-attribute
¶
widget = widgets.HBox([self.map, self._panel], layout=widgets.Layout(width='100%', align_items='flex-start'))
instance-attribute
¶
bbox
property
¶
results: Results
property
¶
selected: list[Granule]
property
¶
__init__(center=(20.0, 0.0), zoom: int = 2, height: str = '600px', bbox=None, results=None)
¶
Source code in hyperproc/archive/interactive.py
_ipython_display_()
¶
__repr__() -> str
¶
_build_panel()
¶
Source code in hyperproc/archive/interactive.py
_sensor_changed(_change=None)
¶
Source code in hyperproc/archive/interactive.py
_status_html(extra: str = '') -> str
¶
_say(extra: str = '') -> None
¶
_drawn(_control, action, geo_json)
¶
_show_bbox()
¶
_list_changed(_change=None)
¶
Source code in hyperproc/archive/interactive.py
_select_all()
¶
_hovered(feature=None, **_kw)
¶
Name the footprint under the pointer, the way a listing would.
Source code in hyperproc/archive/interactive.py
preview_html(props: dict) -> str
¶
The quicklook for one footprint, as a scrap of HTML.
The onerror fallback matters: CMR lists a browse image for every
PACE granule and none of them were ever written, so the URL is there
and 404s. A broken-image icon says less than a sentence does.
Source code in hyperproc/archive/interactive.py
_preview(props: dict) -> None
¶
_clicked(feature=None, **_kw)
¶
Source code in hyperproc/archive/interactive.py
search(sensor: str | None = None, level: str | None = None, **kwargs)
¶
Search the drawn box. With no arguments, uses the panel's settings.
Returns the :class:~hyperproc.archive.results.Results, and draws the
footprints on the map.
Source code in hyperproc/archive/interactive.py
show(results, fit: bool = True)
¶
Draw a result set you already have, without searching again.
| PARAMETER | DESCRIPTION |
|---|---|
results
|
a :class:
|
fit
|
zoom to the footprints.
TYPE:
|
Returns the results, so it chains.
Source code in hyperproc/archive/interactive.py
fit() -> None
¶
Centre and zoom on the footprints, or on the drawn box if there are none.
Sets center and zoom rather than only calling fit_bounds:
those are traits, so they are saved with the notebook and the map opens
on the data when the file is reopened without a kernel. fit_bounds
is still called, because a live browser refines the fit.
Source code in hyperproc/archive/interactive.py
_apply(res) -> None
¶
Put a result set into the list, the map and the status line.
Source code in hyperproc/archive/interactive.py
_redraw()
¶
Source code in hyperproc/archive/interactive.py
download(out_dir: str | None = None, **kwargs)
¶
Download the selected granules. Same as hp.download(m.selected, ...).
Credentials come from the environment exactly as they do there; nothing is typed into the map.
Source code in hyperproc/archive/interactive.py
has_cloud(sensor: str, level: str | None = None) -> bool
¶
Does this collection publish a cloud fraction?
Read from the collection table rather than kept as a second list, because it is not a property of the sensor: PACE reports one at L2 and none at L1B. Offering the slider where there is none would silently drop every granule, which is how a working search looks broken.
Source code in hyperproc/archive/interactive.py
sensors() -> dict[str, list[str]]
¶
{sensor: [levels]} for everything searchable, for a dropdown.
Source code in hyperproc/archive/interactive.py
zoom_for(bounds, width_px: int = 900, height_px: int = 500) -> int
¶
The web-Mercator zoom at which bounds fills a map that size.
ipyleaflet.Map.fit_bounds sends a message to the browser, so it does
nothing when there is no browser - which is every notebook executed by
nbconvert. The map is then saved at whatever it was constructed with, and
opens on the wrong continent. Computing the zoom here instead puts it in
the widget's own state, where it survives saving.
Source code in hyperproc/archive/interactive.py
_flatten(coords) -> list
¶
Every [lon, lat] pair in an arbitrarily nested coordinate array.
Source code in hyperproc/archive/interactive.py
_px(css: str, default: int) -> int
¶
"420px" -> 420. Anything else keeps the default.