Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion marblecutter/mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

LOG = logging.getLogger(__name__)

MAX_WORKERS = multiprocessing.cpu_count() * 5


def composite(sources, bounds, shape, target_crs, expand):
"""Composite data from sources into a single raster covering bounds, but in
Expand All @@ -33,6 +35,8 @@ def composite(sources, bounds, shape, target_crs, expand):
sources = recipes.preprocess(sources, resolution=resolution)

def _read_window(source):
if hasattr(source, "pixels") and source.pixels is not None:
return (source, source.pixels)
with get_source(source.url) as src:
LOG.info(
"Fetching %s (%s) as band %s",
Expand Down Expand Up @@ -82,7 +86,7 @@ def _read_window(source):

# iterate over available sources, sorted by decreasing "quality"
with futures.ThreadPoolExecutor(
max_workers=multiprocessing.cpu_count() * 5
max_workers=MAX_WORKERS
) as executor:
ws = executor.map(_read_window, sources)

Expand Down
3 changes: 2 additions & 1 deletion marblecutter/recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ def postprocess(windows):

windows = list(filter(None, windows))

landsat_windows = filter(lambda sw: "LC08_" in sw[0].url, windows)
# wrap url in str because url could be None
landsat_windows = filter(lambda sw: "LC08_" in str(sw[0].url), windows)
landsat_windows = dict(
[
(k, list(v))
Expand Down
5 changes: 3 additions & 2 deletions marblecutter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
"filename",
"min_zoom",
"max_zoom",
"expr"
"expr",
"pixels"
],
)
Source.__new__.__defaults__ = (
{}, {}, {}, None, None, None, None, None, None, None, None, None, None
{}, {}, {}, None, None, None, None, None, None, None, None, None, None, None
)


Expand Down