|
12 | 12 | from async_geotiff import GeoTIFF, Overview, RasterArray, Window |
13 | 13 | from numpy import ma |
14 | 14 |
|
15 | | -from lazycogs._executor import _run_coroutine |
| 15 | +from lazycogs._executor import get_reproject_pool |
16 | 16 | from lazycogs._mosaic_methods import FirstMethod, MosaicMethodBase |
17 | 17 | from lazycogs._reproject import ( |
18 | 18 | WarpMap, |
@@ -442,7 +442,7 @@ async def _read_band( |
442 | 442 | # Compute warp maps and apply, sharing maps across bands with identical geometry. |
443 | 443 | loop = asyncio.get_running_loop() |
444 | 444 | return await loop.run_in_executor( |
445 | | - None, |
| 445 | + get_reproject_pool(), |
446 | 446 | lambda: _apply_bands_with_warp_cache( |
447 | 447 | band_rasters, |
448 | 448 | ctx.chunk_affine, |
@@ -615,62 +615,3 @@ def _error(idx: int, exc: BaseException) -> None: |
615 | 615 | dtype=np.float32, |
616 | 616 | ) |
617 | 617 | return output |
618 | | - |
619 | | - |
620 | | -def read_chunk( |
621 | | - items: list[dict], |
622 | | - bands: list[str], |
623 | | - chunk_affine: Affine, |
624 | | - dst_crs: CRS, |
625 | | - chunk_width: int, |
626 | | - chunk_height: int, |
627 | | - nodata: float | None = None, |
628 | | - mosaic_method_cls: type[MosaicMethodBase] | None = None, |
629 | | - store: ObjectStore | None = None, |
630 | | - max_concurrent_reads: int = 32, |
631 | | - warp_cache: dict | None = None, |
632 | | - path_fn: Callable[[str], str] | None = None, |
633 | | -) -> dict[str, np.ndarray]: |
634 | | - """Run :func:`read_chunk_async` on the persistent per-thread background loop. |
635 | | -
|
636 | | - All arguments are identical to :func:`read_chunk_async`. |
637 | | -
|
638 | | - Args: |
639 | | - items: List of STAC item dicts to mosaic. Processed in order. |
640 | | - bands: Asset keys identifying the bands to read from each item. |
641 | | - chunk_affine: Affine transform of the destination chunk. |
642 | | - dst_crs: CRS of the destination chunk. |
643 | | - chunk_width: Width of the destination chunk in pixels. |
644 | | - chunk_height: Height of the destination chunk in pixels. |
645 | | - nodata: No-data fill value. |
646 | | - mosaic_method_cls: Mosaic method class instantiated once per band. |
647 | | - Defaults to :class:`~lazycogs._mosaic_methods.FirstMethod`. |
648 | | - store: Optional pre-configured obstore ``ObjectStore`` instance. |
649 | | - max_concurrent_reads: Maximum number of COG reads to run concurrently. |
650 | | - warp_cache: Optional cache shared across calls for reusing warp maps |
651 | | - from earlier time steps. |
652 | | - path_fn: Optional callable that takes an asset HREF and returns the |
653 | | - object path to use with *store*. |
654 | | -
|
655 | | - Returns: |
656 | | - ``dict`` mapping each band name to an array of shape |
657 | | - ``(cog_bands, chunk_height, chunk_width)`` with dtype matching the |
658 | | - source COGs. |
659 | | -
|
660 | | - """ |
661 | | - return _run_coroutine( |
662 | | - read_chunk_async( |
663 | | - items=items, |
664 | | - bands=bands, |
665 | | - chunk_affine=chunk_affine, |
666 | | - dst_crs=dst_crs, |
667 | | - chunk_width=chunk_width, |
668 | | - chunk_height=chunk_height, |
669 | | - nodata=nodata, |
670 | | - mosaic_method_cls=mosaic_method_cls, |
671 | | - store=store, |
672 | | - max_concurrent_reads=max_concurrent_reads, |
673 | | - warp_cache=warp_cache, |
674 | | - path_fn=path_fn, |
675 | | - ), |
676 | | - ) |
0 commit comments