[go: up one dir, main page]

Skip to content

Commit

Permalink
Merge pull request #980 from PCMDI/ao_update_precip_var
Browse files Browse the repository at this point in the history
Regional capabilities for precip variability
  • Loading branch information
lee1043 authored Sep 24, 2024
2 parents 04e1f76 + 04d805a commit efc2ecb
Show file tree
Hide file tree
Showing 7 changed files with 598 additions and 293 deletions.
591 changes: 348 additions & 243 deletions doc/jupyter/Demo/Demo_7_precip_variability.ipynb

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions docs/metrics_precip-variability.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ Options available to set in the parameter file include:
* **nperseg**: Length of segment in power spectra.
* **noverlap**: Length of overlap between segments in power spectra.
* **ref**: Reference data path.
* **res**: Target resolution in degrees.
* **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.
* **region_file**: Path to a shapefile containing vector region outline. Must use with **attr** and **feature** parameters.
* **attr**: Attribute used to identify region in shapefile (eg, column of attribute table). For example, "COUNTRY" in a shapefile of countries.
* **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".
* **cmec**: Set to True to output CMEC formatted JSON.

Metric
Expand Down
1 change: 1 addition & 0 deletions pcmdi_metrics/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .string_constructor import StringConstructor, fill_template # noqa # isort:skip
from . import base # noqa
from .base import MV2Json # noqa

from .xcdat_dataset_io import ( # noqa # isort:skip
da_to_ds,
get_axis_list,
Expand Down
3 changes: 2 additions & 1 deletion pcmdi_metrics/precip_variability/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
ClimAnom,
Powerspectrum,
RedNoiseSignificanceLevel,
Regrid2deg,
RegridHoriz,
CropLatLon,
lag1_autocorrelation,
prdday_to_frqidx,
precip_variability_across_timescale,
Expand Down
33 changes: 33 additions & 0 deletions pcmdi_metrics/precip_variability/lib/argparse_functions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import ast


def AddParserArgument(P):
P.add_argument(
"--mip", type=str, dest="mip", default=None, help="cmip5, cmip6 or other mip"
Expand Down Expand Up @@ -57,6 +60,21 @@ def AddParserArgument(P):
P.add_argument(
"--ref", type=str, dest="ref", default=None, help="reference data path"
)
P.add_argument(
"--res",
type=int,
dest="res",
default=2,
help="Horizontal resolution [degree] for interpolation (lon, lat)",
)
P.add_argument(
"--regions_specs",
type=ast.literal_eval,
dest="regions_specs",
help="Provide a single custom region",
default=None,
required=False,
)
P.add_argument(
"--cmec",
dest="cmec",
Expand All @@ -71,6 +89,21 @@ def AddParserArgument(P):
action="store_false",
help="Do not save CMEC format metrics JSON",
)
P.add_argument(
"--region_file",
dest="region_file",
help="File containing vector region of interest.",
default=None,
)
P.add_argument(
"--feature", dest="feature", help="Feature in vectorized region.", default=None
)
P.add_argument(
"--attr",
dest="attr",
help="Attribute containing feature in vectorized region.",
default=None,
)
P.set_defaults(cmec=False)

return P
Loading

0 comments on commit efc2ecb

Please sign in to comment.