Skip to content

Commit efc2ecb

Browse files
authored
Merge pull request #980 from PCMDI/ao_update_precip_var
Regional capabilities for precip variability
2 parents 04e1f76 + 04d805a commit efc2ecb

File tree

7 files changed

+598
-293
lines changed

7 files changed

+598
-293
lines changed

doc/jupyter/Demo/Demo_7_precip_variability.ipynb

Lines changed: 348 additions & 243 deletions
Large diffs are not rendered by default.

docs/metrics_precip-variability.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ Options available to set in the parameter file include:
6262
* **nperseg**: Length of segment in power spectra.
6363
* **noverlap**: Length of overlap between segments in power spectra.
6464
* **ref**: Reference data path.
65+
* **res**: Target resolution in degrees.
66+
* **regions_specs**: Dictionary containing region bounding box. Uses format {"your region name": {"domain": {"latitude": (min, max), "longitude": (min, max)}}}. Min and max should be replaced with the values that define the region.
67+
* **region_file**: Path to a shapefile containing vector region outline. Must use with **attr** and **feature** parameters.
68+
* **attr**: Attribute used to identify region in shapefile (eg, column of attribute table). For example, "COUNTRY" in a shapefile of countries.
69+
* **feature**: Unique feature value of the region that occurs in the attribute given by "--attr". Must match only one geometry in the shapefile. An example is a feature called "USA" under the attribute "COUNTRY".
6570
* **cmec**: Set to True to output CMEC formatted JSON.
6671

6772
Metric

pcmdi_metrics/io/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .string_constructor import StringConstructor, fill_template # noqa # isort:skip
44
from . import base # noqa
55
from .base import MV2Json # noqa
6+
67
from .xcdat_dataset_io import ( # noqa # isort:skip
78
da_to_ds,
89
get_axis_list,

pcmdi_metrics/precip_variability/lib/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
ClimAnom,
55
Powerspectrum,
66
RedNoiseSignificanceLevel,
7-
Regrid2deg,
7+
RegridHoriz,
8+
CropLatLon,
89
lag1_autocorrelation,
910
prdday_to_frqidx,
1011
precip_variability_across_timescale,

pcmdi_metrics/precip_variability/lib/argparse_functions.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import ast
2+
3+
14
def AddParserArgument(P):
25
P.add_argument(
36
"--mip", type=str, dest="mip", default=None, help="cmip5, cmip6 or other mip"
@@ -57,6 +60,21 @@ def AddParserArgument(P):
5760
P.add_argument(
5861
"--ref", type=str, dest="ref", default=None, help="reference data path"
5962
)
63+
P.add_argument(
64+
"--res",
65+
type=int,
66+
dest="res",
67+
default=2,
68+
help="Horizontal resolution [degree] for interpolation (lon, lat)",
69+
)
70+
P.add_argument(
71+
"--regions_specs",
72+
type=ast.literal_eval,
73+
dest="regions_specs",
74+
help="Provide a single custom region",
75+
default=None,
76+
required=False,
77+
)
6078
P.add_argument(
6179
"--cmec",
6280
dest="cmec",
@@ -71,6 +89,21 @@ def AddParserArgument(P):
7189
action="store_false",
7290
help="Do not save CMEC format metrics JSON",
7391
)
92+
P.add_argument(
93+
"--region_file",
94+
dest="region_file",
95+
help="File containing vector region of interest.",
96+
default=None,
97+
)
98+
P.add_argument(
99+
"--feature", dest="feature", help="Feature in vectorized region.", default=None
100+
)
101+
P.add_argument(
102+
"--attr",
103+
dest="attr",
104+
help="Attribute containing feature in vectorized region.",
105+
default=None,
106+
)
74107
P.set_defaults(cmec=False)
75108

76109
return P

0 commit comments

Comments
 (0)