Example ScriptsΒΆ
This page presents a collection of example scripts written using Mule to perform a variety of common tasks; this should highlight the intended/recommended methods for getting the most out of the API.
- Examples: Manipulating Headers
- Example 1: Change the data time in the fixed header to 12:00 01/02/03
- Example 2: Change the forecast time (lbft) in the 3rd lookup header to 12
- Example 3: Change the validity time in all lookup headers to 12:00 01/02/03
- Example 4: Round the validity time in all lookup headers to the nearest hour
- Example 5: Change the data time in all lookup headers to 12:00 01/02/03 and reset forecast hour to match
- Examples: Filtering
- Example 1: Extract theta (STASH code 4) and pressure fields (STASH code 407) into a separate fieldsfile
- Example 2: Remove all fields valid at 12Z
- Example 3: Extract field numbers 3, 5 and 8
- Example 4: Extract all 32 bit packed fields (LBPACK = 2) which have been unprocessed (LBPROC = 0)
- Example 5: Extract 38-level fields with STASH code 2, 3 and 4. The fields have to be 32 bit packed (LBPACK = 2) and unprocessed (LBPROC = 0) for STASH code 2 and 4
- Examples: Modifying data in individual fields
- Example 1: Set all real data fields to zero
- Example 2: Set level-1 u fields (STASH code 2) to their absolute values
- Example 3: Raise all fields valid at 12Z to the power 3
- Example 4: Remove negative specific humidities (STASH code 10)
- Example 5: Set all level-38 fields to -1
- Example 6: Set all level-38 32 bit packed (LBPACK 21 = 2) fields to -1
- Example 7: Add random perturbations at the level of the least significant bit to all theta fields (STASH code 4)
- Example 8: Add 1.0 to fields with Item Numbers 2 or 3, only outputting fields operated on
- Examples: Operations with multiple fields as input
- Example 1: Subtract fields in InputFile2 from corresponding fields in InputFile1
- Example 2: Add pressure (STASH code 407) and level-3 exner (STASH code 255) fields in InputFile2 to corresponding fields in InputFile1
- Example 3: Perform a weighted mean of corresponding fields in InputFile1 and InputFile2, giving double weight to the fields in InputFile1
- Example 4: Add QCF (STASH code 12), QCL (STASH code 254) and Q (STASH code 10) fields from 3 separate files