Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added crop functionality to trollflow2 #210

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions trollflow2/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,25 @@
logger.debug("area: %s, area_conf: %s", area, str(area_conf))
job['resampled_scenes'][area] = scn.resample(area, **area_conf)

def crop(job):
"""Crop the scene to some areas. Cropping to the llbox and xybox are not supported jet."""

product_list = job["product_list"]
conf = _get_plugin_conf(product_list, "/product_list", "")
job["resampled_scenes"] = {}
scn = job["scene"]
for area in product_list["product_list"]["areas"]:
area_conf = _get_plugin_conf(

Check warning on line 181 in trollflow2/plugins/__init__.py

View check run for this annotation

Codecov / codecov/patch

trollflow2/plugins/__init__.py#L176-L181

Added lines #L176 - L181 were not covered by tests
product_list, "/product_list/areas/" + str(area), conf
)
logger.info("Cropping to %s", str(area))

Check warning on line 184 in trollflow2/plugins/__init__.py

View check run for this annotation

Codecov / codecov/patch

trollflow2/plugins/__init__.py#L184

Added line #L184 was not covered by tests

# Load composites before cropping, otherwise cropping fails for composites
scn.load(scn.wishlist, generate=True)

Check warning on line 187 in trollflow2/plugins/__init__.py

View check run for this annotation

Codecov / codecov/patch

trollflow2/plugins/__init__.py#L187

Added line #L187 was not covered by tests
# If area is none, no cropping is done.
if area != "None":
logger.debug("area: %s, area_conf: %s", area, str(area_conf))
job["resampled_scenes"][area] = scn.crop(area)

Check warning on line 191 in trollflow2/plugins/__init__.py

View check run for this annotation

Codecov / codecov/patch

trollflow2/plugins/__init__.py#L189-L191

Added lines #L189 - L191 were not covered by tests

# Datasets saving

Expand Down
Loading