-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #967 from MetOffice/221_mask_operator
Add mask operators
- Loading branch information
Showing
6 changed files
with
371 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
category: Quick Look | ||
title: Example adding masks for 'OR' type filters | ||
description: | | ||
Generates and applies two masks, and adds them together for more complex stratified analysis. | ||
Examples would include masking for variables outside a range, e.g. temperature < 273 K or temperature | ||
> 313 K. Addition of masks would be akin to finding a probability of two events happening at the same time in different places. | ||
steps: | ||
- operator: read.read_cubes | ||
|
||
- operator: filters.apply_mask | ||
original_field: | ||
operator: filters.filter_cubes | ||
constraint: | ||
operator: constraints.combine_constraints | ||
variable_constraint: | ||
operator: constraints.generate_var_constraint | ||
varname: surface_air_temperature | ||
cell_method_constraint: | ||
operator: constraints.generate_cell_methods_constraint | ||
cell_methods: [] | ||
masks: | ||
operator: misc.addition | ||
addend_1: | ||
operator: filters.generate_mask | ||
mask_field: | ||
operator: filters.filter_cubes | ||
constraint: | ||
operator: constraints.generate_var_constraint | ||
varname: surface_altitude | ||
condition: '<' | ||
value: 500 | ||
addend_2: | ||
operator: filters.generate_mask | ||
mask_field: | ||
operator: filters.filter_cubes | ||
constraint: | ||
operator: constraints.generate_var_constraint | ||
varname: surface_altitude | ||
condition: '>' | ||
value: 200 | ||
|
||
- operator: collapse.collapse | ||
coordinate: [grid_latitude, grid_longitude] | ||
method: MEAN | ||
|
||
- operator: write.write_cube_to_nc | ||
overwrite: True | ||
|
||
- operator: plot.plot_line_series |
50 changes: 50 additions & 0 deletions
50
src/CSET/recipes/example_combined_mask_multiplication.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
category: Quick Look | ||
title: Example adding masks for 'AND' type filters | ||
description: | | ||
Generates and applies two masks, and multiplies them together for more complex stratified analysis. | ||
Examples would include masking for temperature > 273 K and orography > 500 m. Multiplication of masks | ||
would be akin to finding a probability of two events happening at the same time in the same place. | ||
steps: | ||
- operator: read.read_cubes | ||
|
||
- operator: filters.apply_mask | ||
original_field: | ||
operator: filters.filter_cubes | ||
constraint: | ||
operator: constraints.combine_constraints | ||
variable_constraint: | ||
operator: constraints.generate_var_constraint | ||
varname: surface_air_temperature | ||
cell_method_constraint: | ||
operator: constraints.generate_cell_methods_constraint | ||
cell_methods: [] | ||
masks: | ||
operator: misc.multiplication | ||
multiplicand: | ||
operator: filters.generate_mask | ||
mask_field: | ||
operator: filters.filter_cubes | ||
constraint: | ||
operator: constraints.generate_var_constraint | ||
varname: surface_altitude | ||
condition: '>' | ||
value: 500 | ||
multiplier: | ||
operator: filters.generate_mask | ||
mask_field: | ||
operator: filters.filter_cubes | ||
constraint: | ||
operator: constraints.generate_var_constraint | ||
varname: surface_air_temperature | ||
condition: '<=' | ||
value: 273 | ||
|
||
- operator: collapse.collapse | ||
coordinate: [grid_latitude, grid_longitude] | ||
method: MEAN | ||
|
||
- operator: write.write_cube_to_nc | ||
overwrite: True | ||
|
||
- operator: plot.plot_line_series |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
category: Quick Look | ||
title: Example simple mask application | ||
description: Generates and applies a simple mask to a field for stratified analysis. | ||
|
||
steps: | ||
- operator: read.read_cubes | ||
|
||
- operator: filters.apply_mask | ||
original_field: | ||
operator: filters.filter_cubes | ||
constraint: | ||
operator: constraints.combine_constraints | ||
variable_constraint: | ||
operator: constraints.generate_var_constraint | ||
varname: surface_air_temperature | ||
cell_method_constraint: | ||
operator: constraints.generate_cell_methods_constraint | ||
cell_methods: [] | ||
masks: | ||
operator: filters.generate_mask | ||
mask_field: | ||
operator: filters.filter_cubes | ||
constraint: | ||
operator: constraints.generate_var_constraint | ||
varname: surface_altitude | ||
condition: '>=' | ||
value: 500 | ||
|
||
- operator: collapse.collapse | ||
coordinate: [grid_latitude, grid_longitude] | ||
method: MEAN | ||
|
||
- operator: write.write_cube_to_nc | ||
overwrite: True | ||
|
||
- operator: plot.plot_line_series |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
category: Surface Spatial Plot | ||
title: Example plot of a mask | ||
description: | | ||
Generates a mask and then provides a spatial map of the mask. | ||
steps: | ||
- operator: read.read_cubes | ||
|
||
- operator: filters.generate_mask | ||
mask_field: | ||
operator: filters.filter_cubes | ||
constraint: | ||
operator: constraints.generate_var_constraint | ||
varname: surface_altitude | ||
condition: '>=' | ||
value: 500 | ||
|
||
- operator: plot.spatial_pcolormesh_plot | ||
|
||
- operator: write.write_cube_to_nc | ||
overwrite: True |
Oops, something went wrong.