forked from metoppv/improver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into im1787
* upstream/master: Fix to the wind vertical displacement adjustment implementation (metoppv#1927) Add function which normalises input cubes according to a reference (metoppv#1919) Skip ECC bounds usage when converting probabilities to percentiles (metoppv#1926) Add CLIs to support rescaling of the forecast based on altitude difference (metoppv#1917) Changes to the modal code to increase the percentage to 30% and change the groupings to provide a more representative daily summary symbol. (metoppv#1925) Add plugins to support rescaling of the forecast based on altitude difference (metoppv#1916) Support conversion from percentiles to probabilities (metoppv#1924) Correct handling of reference time in weather_code plugin (metoppv#1920) Add CLI for clipping cubes (metoppv#1918) Update cbh ecc name (metoppv#1922) Updates Broadcast and expand_bounds in Combine Plugin (metoppv#1914) Mobt515 cloud base height spot extraction (metoppv#1911) MOBT-494: Cube title setting in weather symbol code (metoppv#1912) MOBT512-masking percentiles for cloud base height (metoppv#1908) Mobt 496 enforce forecast between references (metoppv#1907)
- Loading branch information
Showing
57 changed files
with
4,493 additions
and
827 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,88 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# ----------------------------------------------------------------------------- | ||
# (C) British Crown copyright. The Met Office. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# * Redistributions of source code must retain the above copyright notice, this | ||
# list of conditions and the following disclaimer. | ||
# | ||
# * Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# * Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
"""Script to apply height adjustments to spot data.""" | ||
|
||
from improver import cli | ||
|
||
|
||
@cli.clizefy | ||
@cli.with_output | ||
def process( | ||
spot_cube: cli.inputcube, | ||
neighbour: cli.inputcube, | ||
*, | ||
land_constraint: bool = False, | ||
similar_altitude: bool = False, | ||
): | ||
"""Apply height adjustment to account for the difference between site altitude and | ||
grid square orography. The spot forecast contains information representative of the | ||
associated grid point. This needs to be adjusted to reflect the true site altitude. | ||
Args: | ||
spot_cube (iris.cube.Cube): | ||
A cube of spot forecasts. If this is a cube of probabilities | ||
then the units of the threshold coordinate must be convertible to | ||
metres as this is expected to represent a vertical coordinate. | ||
If this is a cube of percentiles or realizations then the | ||
units of the cube must be convertible to metres as the cube is | ||
expected to represent a vertical profile. | ||
neighbour (iris.cube.Cube): | ||
A cube containing information about spot-data neighbours and | ||
the spot site information. | ||
land_constraint (bool): | ||
Use to select the nearest-with-land-constraint neighbour-selection | ||
method from the neighbour_cube. This means that the grid points | ||
should be land points except for sites where none were found within | ||
the search radius when the neighbour cube was created. May be used | ||
with similar_altitude. | ||
similar_altitude (bool): | ||
Use to select the nearest-with-height-constraint | ||
neighbour-selection method from the neighbour_cube. These are grid | ||
points that were found to be the closest in altitude to the spot | ||
site within the search radius defined when the neighbour cube was | ||
created. May be used with land_constraint. | ||
Returns: | ||
iris.cube.Cube: | ||
A cube of spot data values with the same metadata as spot_cube but with data | ||
adjusted to be relative to site height rather than orography grid square | ||
height | ||
""" | ||
from improver.spotdata.height_adjustment import SpotHeightAdjustment | ||
from improver.spotdata.neighbour_finding import NeighbourSelection | ||
|
||
neighbour_selection_method = NeighbourSelection( | ||
land_constraint=land_constraint, minimum_dz=similar_altitude | ||
).neighbour_finding_method_name() | ||
|
||
result = SpotHeightAdjustment(neighbour_selection_method)(spot_cube, neighbour) | ||
return result |
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,64 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# ----------------------------------------------------------------------------- | ||
# (C) British Crown copyright. The Met Office. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# * Redistributions of source code must retain the above copyright notice, this | ||
# list of conditions and the following disclaimer. | ||
# | ||
# * Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# * Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
"""Script to clip the input cube's data to be between the specified values""" | ||
|
||
from improver import cli | ||
|
||
|
||
@cli.clizefy | ||
@cli.with_output | ||
def process( | ||
cube: cli.inputcube, *, min_value: float = None, max_value: float = None, | ||
): | ||
"""Clip the data in the input cube such that any data above max_value is set equal to | ||
max_value and any data below min_value is set equal to min_value. | ||
Args: | ||
cube (iris.cube.Cube): | ||
A Cube whose data will be clipped. This can be a cube of spot or gridded data. | ||
max_value (float): | ||
If specified any data in cube that is above max_value will be set equal to | ||
max_value. | ||
min_value (float): | ||
If specified any data in cube that is below min_value will be set equal to | ||
min_value. | ||
Returns: | ||
iris.cube.Cube: | ||
A cube with the same metadata as the input cube but with the data clipped such | ||
that any data above max_value is set equal to max_value and any data below | ||
min_value is set equal to min_value. | ||
""" | ||
from numpy import clip | ||
|
||
cube.data = clip(cube.data, min_value, max_value) | ||
|
||
return cube |
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
Oops, something went wrong.