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

Combine low level moisture with a cloud mask #3022

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 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
54 changes: 54 additions & 0 deletions satpy/etc/composites/fci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,57 @@ composites:
- name: ir_38
modifiers: [nir_reflectance]
standard_name: snow

masked_colorized_low_level_moisture:
compositor: !!python/name:satpy.composites.MaskingCompositor
standard_name: masked_essl_colorized_low_level_moisture
prerequisites:
- essl_colorized_low_level_moisture
- cloud_state
conditions:
- method: equal
value: Not processed (no or corrupt data)
transparency: 100
- method: equal
value: Cloud free (no cloud, snow or ice)
transparency: 0
- method: equal
value: Cloud contaminated (partial or semitransparent cloud)
transparency: 100
- method: equal
value: Cloud filled (opaque cloud filled)
transparency: 100
- method: equal
value: Dust contaminated
transparency: 100
- method: equal
value: Dust filled (opaque)
transparency: 100
- method: equal
value: Ash contaminated
transparency: 100
- method: equal
value: Ash filled (opaque)
transparency: 100
- method: equal
value: Snow or ice contaminated
transparency: 0
- method: equal
value: Undefined
transparency: 0
mode: LA

colorized_low_level_moisture_with_vis06:
compositor: !!python/name:satpy.composites.BackgroundCompositor
standard_name: image_ready
prerequisites:
- masked_colorized_low_level_moisture
- name: vis_06
modifiers: [effective_solar_pathlength_corrected]

colorized_low_level_moisture_with_ir105:
compositor: !!python/name:satpy.composites.BackgroundCompositor
standard_name: image_ready
prerequisites:
- masked_colorized_low_level_moisture
- night_ir105
12 changes: 6 additions & 6 deletions satpy/etc/composites/visir.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,11 @@ composites:
European Severe Storms Laboratory (ESSL). For a color version,
see essl_colorized_low_level_moisture.
compositor: !!python/name:satpy.composites.RatioCompositor
prerequisites:
- wavelength: 0.905
- wavelength: 0.86
prerequisites: &llm
- wavelength: 0.905 # workaround for https://github.com/pytroll/satpy/issues/1913
calibration: reflectance
- wavelength: 0.86
calibration: reflectance
standard_name: essl_low_level_moisture

day_essl_low_level_moisture:
Expand All @@ -625,9 +627,7 @@ composites:
European Severe Storms Laboratory (ESSL). The colorization
is still under development and may be subject to change.
compositor: !!python/name:satpy.composites.RatioCompositor
prerequisites:
- wavelength: 0.905
- wavelength: 0.86
prerequisites: *llm
standard_name: essl_colorized_low_level_moisture

day_essl_colorized_low_level_moisture:
Expand Down
8 changes: 7 additions & 1 deletion satpy/etc/enhancements/generic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1241,8 +1241,9 @@ enhancements:
operations: []

essl_colorized_low_level_moisture:
# this enhancement is only found if using name but not standard_name
name: essl_colorized_low_level_moisture
operations:
operations: &masked_llm
- name: colorize
method: !!python/name:satpy.enhancements.colorize
kwargs:
Expand Down Expand Up @@ -1352,6 +1353,11 @@ enhancements:
- [255, 249, 183]
- [255, 255, 191]

masked_essl_colorized_low_level_moisture:
# this enhancement is only found if using standard_name but not name
standard_name: masked_essl_colorized_low_level_moisture
operations: *masked_llm

rocket_plume:
standard_name: rocket_plume
operations:
Expand Down
19 changes: 10 additions & 9 deletions satpy/tests/behave/features/image_comparison.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ Feature: Image Comparison

Scenario Outline: Compare generated image with reference image
Given I have a <composite> reference image file from <satellite> resampled to <area>
When I generate a new <composite> image file from <satellite> case <case> with <reader> for <area> with clipping <clip>
When I generate a new <composite> image file from <satellite> case <case> with <reader> for <area> resampling with <resampler> with clipping <clip>
Then the generated image should be the same as the reference image

Examples:
|satellite | case | composite | reader | area | clip |
|Meteosat-12 | scan_night | cloudtop | fci_l1c_nc | sve | True |
|Meteosat-12 | scan_night | night_microphysics | fci_l1c_nc | sve | True |
|Meteosat-12 | mali_day | essl_colorized_low_level_moisture | fci_l1c_nc | mali | False |
|GOES17 | americas_night | airmass | abi_l1b | null | null |
|GOES16 | americas_night | airmass | abi_l1b | null | null |
|GOES16 | americas_night | ash | abi_l1b | null | null |
|GOES17 | americas_night | ash | abi_l1b | null | null |
|satellite | case | composite | reader | area | resampler | clip |
|Meteosat-12 | scan_night | cloudtop | fci_l1c_nc | sve | gradient_search | True |
|Meteosat-12 | scan_night | night_microphysics | fci_l1c_nc | sve | gradient_search | True |
|Meteosat-12 | mali_day | essl_colorized_low_level_moisture | fci_l1c_nc | mali | gradient_search | False |
|Meteosat-12 | spain_day | colorized_low_level_moisture_with_vis06 | fci_l1c_nc,fci_l2_nc | spain | nearest | False |
|GOES17 | americas_night | airmass | abi_l1b | null | null | null |
|GOES16 | americas_night | airmass | abi_l1b | null | null | null |
|GOES16 | americas_night | ash | abi_l1b | null | null | null |
|GOES17 | americas_night | ash | abi_l1b | null | null | null |
17 changes: 9 additions & 8 deletions satpy/tests/behave/features/steps/image_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import numpy as np
from behave import given, then, when

import satpy
from satpy import Scene

ext_data_path = "/app/ext_data"
Expand Down Expand Up @@ -64,28 +65,28 @@


@when("I generate a new {composite} image file from {satellite} case {case} "
"with {reader} for {area} with clipping {clip}")
def step_when_generate_image(context, composite, satellite, case, reader, area, clip):
"with {reader} for {area} resampling with {resampler} with clipping {clip}")
def step_when_generate_image(context, composite, satellite, case, reader, area, resampler, clip):
"""Generate test images."""
os.environ["OMP_NUM_THREADS"] = os.environ["MKL_NUM_THREADS"] = "2"
os.environ["PYTROLL_CHUNK_SIZE"] = "1024"
warnings.simplefilter("ignore")
dask.config.set(scheduler="threads", num_workers=4)

# Get the list of satellite files to open
filenames = glob(f"{ext_data_path}/satellite_data/{satellite}/{case}/*.nc")

reader_kwargs = {}
if clip != "null":
reader_kwargs["clip_negative_radiances"] = clip
scn = Scene(reader=reader, filenames=filenames, reader_kwargs=reader_kwargs)

scn.load([composite])
if "," in reader:
reader = reader.split(",")
with satpy.config.set({"readers.clip_negative_radiances": False if clip == "null" else clip}):
scn = Scene(reader=reader, filenames=filenames)
scn.load([composite])

if area == "null":
ls = scn
else:
ls = scn.resample(area, resampler="gradient_search")
ls = scn.resample(area, resampler=resampler)

Check notice on line 89 in satpy/tests/behave/features/steps/image_comparison.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

step_when_generate_image increases from 7 to 8 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.

# Save the generated image in the generated folder
generated_image_path = os.path.join(context.test_results_dir, "generated",
Expand Down
2 changes: 2 additions & 0 deletions satpy/tests/etc/readers/fake1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ datasets:
ds8:
name: ds8
wavelength: [0.7, 0.8, 0.9]
calibration: "reflectance"
file_type: fake_file1
coordinates: [lons, lats]
ds9_fail_load:
Expand All @@ -70,6 +71,7 @@ datasets:
ds10:
name: ds10
wavelength: [0.75, 0.85, 0.95]
calibration: "reflectance"
file_type: fake_file1
coordinates: [lons, lats]
ds11:
Expand Down
12 changes: 9 additions & 3 deletions utils/create_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ def generate_images(props):
filenames = (props.basedir / "satellite_data" / props.satellite /
props.case).glob("*")

scn = Scene(reader=props.reader, filenames=filenames)
if "," in props.reader:
reader = props.reader.split(",")
resampler = "nearest" # use nearest when combining with cloud mask
else:
reader = props.reader
resampler = "gradient_search"
scn = Scene(reader=reader, filenames=filenames)

scn.load(props.composites)
if props.area == "native":
ls = scn.resample(resampler="native")
elif props.area is not None:
ls = scn.resample(props.area, resampler="gradient_search")
ls = scn.resample(props.area, resampler=resampler)
else:
ls = scn

Expand All @@ -74,7 +80,7 @@ def get_parser():

parser.add_argument(
"reader", action="store", type=str,
help="Reader name.")
help="Reader name. Multiple readers (if needed) can be comma-seperated.")

parser.add_argument(
"case", help="case to generate", type=str)
Expand Down
Loading