From 9b7afdbd1ed53bf4923675eb704fb86efa2463f0 Mon Sep 17 00:00:00 2001 From: daflack Date: Mon, 9 Dec 2024 14:48:42 +0000 Subject: [PATCH] adds example recipes --- src/CSET/recipes/combined_mask_addition.yaml | 48 +++++++++++++++++++ .../recipes/combined_mask_multiplication.yaml | 48 +++++++++++++++++++ src/CSET/recipes/simple_mask.yaml | 36 ++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 src/CSET/recipes/combined_mask_addition.yaml create mode 100644 src/CSET/recipes/combined_mask_multiplication.yaml create mode 100644 src/CSET/recipes/simple_mask.yaml diff --git a/src/CSET/recipes/combined_mask_addition.yaml b/src/CSET/recipes/combined_mask_addition.yaml new file mode 100644 index 000000000..32b903c51 --- /dev/null +++ b/src/CSET/recipes/combined_mask_addition.yaml @@ -0,0 +1,48 @@ +category: Quick Look +title: Example adding masks for 'OR' or "between" type filters +description: | + Generates and applies two masks, and adds them together for more complex 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: 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 diff --git a/src/CSET/recipes/combined_mask_multiplication.yaml b/src/CSET/recipes/combined_mask_multiplication.yaml new file mode 100644 index 000000000..53da3c316 --- /dev/null +++ b/src/CSET/recipes/combined_mask_multiplication.yaml @@ -0,0 +1,48 @@ +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. + +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 diff --git a/src/CSET/recipes/simple_mask.yaml b/src/CSET/recipes/simple_mask.yaml new file mode 100644 index 000000000..d39d8d683 --- /dev/null +++ b/src/CSET/recipes/simple_mask.yaml @@ -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