API Reference
Auto-generated from source docstrings.
point_collocation
Top-level convenience imports:
import point_collocation as pc
pc.plan(...) # build a matchup plan
pc.matchup(...) # execute the plan
Core
plan
point_collocation.core.plan.plan
plan(points: PointsFrame, *, data_source: str = 'earthaccess', source_kwargs: dict[str, Any] | None = None, time_buffer: str | Timedelta | timedelta | int = '0h') -> Plan
Build a :class:Plan previewing which granules cover each point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
PointsFrame
|
DataFrame with at minimum |
required |
data_source
|
str
|
Data source to search. Currently only |
'earthaccess'
|
source_kwargs
|
dict[str, Any] | None
|
Keyword arguments forwarded to |
None
|
time_buffer
|
str | Timedelta | timedelta | int
|
Extra temporal margin when matching a point to a granule. A
point at time t matches a granule whose coverage is
|
'0h'
|
Returns:
| Type | Description |
|---|---|
Plan
|
The planning object; inspect with :meth: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If points is missing required columns, data_source is not
recognised, or |
ImportError
|
If the |
Source code in point_collocation/core/plan.py
matchup
point_collocation.core.engine.matchup
matchup(plan: 'Plan', *, geometry: str, variables: list[str] | None = None, open_method: str | None = None, spatial_method: str | None = None, open_dataset_kwargs: dict | None = None, silent: bool = False, batch_size: int = 10, save_dir: str | PathLike | None = None, granule_range: tuple[int, int] | None = None) -> pd.DataFrame
Extract variables from cloud-hosted granules at the given points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plan
|
'Plan'
|
A :class: |
required |
geometry
|
str
|
Data geometry type. Must be |
required |
variables
|
list[str] | None
|
Variable names to extract from each granule. When provided,
overrides any variables stored on the plan. When omitted,
falls back to |
None
|
open_method
|
str | None
|
How granules are opened. |
None
|
spatial_method
|
str | None
|
Method used for spatial matching. |
None
|
open_dataset_kwargs
|
dict | None
|
Optional dictionary of keyword arguments forwarded to
|
None
|
silent
|
bool
|
When |
False
|
batch_size
|
int
|
Number of granules to process between progress reports (and
between intermediate saves when save_dir is set). Defaults
to |
10
|
save_dir
|
str | PathLike | None
|
Directory in which intermediate results are saved as Parquet
files after each batch of batch_size granules. The directory
is created automatically if it does not exist. Each batch is
saved as |
None
|
granule_range
|
tuple[int, int] | None
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per (point, granule) pair, including a |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
ValueError
|
If a requested variable is not present in an opened dataset. |
ValueError
|
If geolocation variables cannot be detected unambiguously. |
ValueError
|
If the geolocation array dimensionality does not match geometry. |
ValueError
|
If |
ImportError
|
If |
Source code in point_collocation/core/engine.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 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 | |
Plan
point_collocation.core.plan.Plan
dataclass
A planned matchup: stores the point→granule mapping and search results.
Attributes:
| Name | Type | Description |
|---|---|---|
points |
DataFrame
|
Normalised points DataFrame (always has a |
results |
list[Any]
|
Original earthaccess result objects in search order. Passed
directly to |
granules |
list[GranuleMeta]
|
:class: |
point_granule_map |
dict[Any, list[int]]
|
Maps each row index of points to a (possibly empty) list of indices into granules. |
variables |
list[str]
|
Default variables to extract during :func: |
source_kwargs |
dict[str, Any]
|
earthaccess search kwargs used to build this plan. |
time_buffer |
Timedelta
|
Temporal buffer that was applied when matching points to granules. |
Source code in point_collocation/core/plan.py
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 | |
summary
Print a human-readable summary of the plan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int | None
|
Number of points to show in the per-point section.
Defaults to |
None
|
Source code in point_collocation/core/plan.py
show_variables
show_variables(geometry: str, open_method: str | None = None, open_dataset_kwargs: dict[str, Any] | None = None) -> None
Open the first granule and print its dimensions and variables.
Uses :meth:open_dataset (or a DataTree for
open_method="datatree-merge") to load the first result in the
plan, then prints the dataset dimensions, data variable names, and
geolocation detection results. This lets users discover available
variable names before running a full :func:~point_collocation.matchup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
str
|
Data geometry type. Must be |
required |
open_method
|
str | None
|
How to open the granule. |
None
|
open_dataset_kwargs
|
dict[str, Any] | None
|
Keyword arguments forwarded to |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the plan contains no granules. |
Source code in point_collocation/core/plan.py
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 | |
open_dataset
open_dataset(result: Any, geometry: str | None = None, open_method: str | None = None, open_dataset_kwargs: dict[str, Any] | None = None) -> 'xr.Dataset'
Open a single granule result as an :class:xarray.Dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
A single earthaccess result object, typically obtained via
|
required |
geometry
|
str | None
|
Data geometry type. |
None
|
open_method
|
str | None
|
How to open the granule. |
None
|
open_dataset_kwargs
|
dict[str, Any] | None
|
Keyword arguments forwarded to |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
|
Source code in point_collocation/core/plan.py
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 | |
open_mfdataset
open_mfdataset(results: 'list[Any] | Plan', geometry: str | None = None, open_method: str | None = None, open_dataset_kwargs: dict[str, Any] | None = None) -> 'xr.Dataset'
Open multiple granule results as a single :class:xarray.Dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
'list[Any] | Plan'
|
A list of earthaccess result objects, or a :class: |
required |
geometry
|
str | None
|
Data geometry type. |
None
|
open_method
|
str | None
|
How to open each granule. |
None
|
open_dataset_kwargs
|
dict[str, Any] | None
|
Keyword arguments forwarded to |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
|
Source code in point_collocation/core/plan.py
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 | |
IO / Adapters
point_collocation.adapters
Source adapters that normalise heterogeneous inputs into the SourceProtocol.
Built-in adapters
earthaccess : wraps file-like objects returned by earthaccess.open()
Future adapters (not yet implemented)
stac : STAC item assets url : plain HTTPS URLs local : local file paths
SourceAdapter
Bases: ABC
Abstract base for source adapters.
Subclass this to add support for a new data source. The core
engine only calls :meth:open_dataset; everything else is internal
to the adapter.
Source code in point_collocation/adapters/base.py
open_dataset
abstractmethod
Return an xarray.Dataset for this source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
object
|
Forwarded verbatim to |
{}
|
Source code in point_collocation/adapters/base.py
Search
point_collocation.core._granule
Helpers for working with individual granules (source files).
Responsibilities
- Extract a human-readable identifier from an arbitrary source object.
- Parse the temporal coverage (start/end date) from a NASA-style L3 granule filename.
Supported filename conventions
YYYYDOY — single day (DOY = day-of-year, 001–366)
YYYYDOY_YYYYDOY — multi-day range (e.g., 8-day composites, monthly)
YYYYMMDD — single day in calendar format
YYYYMMDD_YYYYMMDD — multi-day range in calendar format
The period keyword embedded in the filename (.DAY., .8D.,
.MO.) is used to infer the end date when only a start date is
present.
Examples of supported filenames
PACE_OCI_2024070.L3m.DAY.RRS.Rrs_412.4km.ncPACE_OCI_2024049_2024056.L3m.8D.CHL.chlor_a.9km.ncAQUA_MODIS.20230601.L3m.DAY.SST.sst.4km.ncAQUA_MODIS.20230601_20230630.L3m.MO.CHL.chlor_a.9km.nc
get_source_id
Return a human-readable identifier (basename) for source.
Tries, in order:
pathlib.Path→path.name- Plain
str→os.path.basename(source) - Object with a
.pathor.namestring attribute str(source)as last resort
Source code in point_collocation/core/_granule.py
parse_temporal_range
Return (start, end) timestamps for the granule named filename.
Only the basename of filename is examined.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
File path or basename. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Timestamp, Timestamp]
|
Inclusive start and end dates (time component is midnight UTC). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no recognisable date pattern is found in filename. |