Explore Module
High-level analysis and visualization tools for climate data exploration.
Overview
The climakitae.explore module provides user-friendly classes and functions for climate data analysis, including:
- Warming level analysis — Analyze data by global warming thresholds
- Time series visualization — Plot multi-model ensemble trends
- Uncertainty quantification — CMIP6 ensemble analysis
- Threshold analysis — Climate threshold and exceedance analysis
- Typical meteorological year — TMY analysis for engineering applications
- Vulnerability assessment — Climate vulnerability analysis tools
Warming Levels
A container for all of the warming levels-related functionality: - A pared-down Select panel, under "choose_data" - a "calculate" step where most of the waiting occurs - an optional "visualize" panel, as an instance of WarmingLevelVisualize - postage stamps from visualize "main" tab are accessible via "gwl_snapshots" - data sliced around gwl window retrieved from "sliced_data"
Source code in climakitae/explore/warming.py
find_warming_slice(level, gwl_times)
Find the warming slice data for the current level from the catalog data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
str
|
The warming level to find the slice for. |
required |
gwl_times
|
DataFrame
|
The DataFrame containing the warming level times. |
required |
Returns:
| Type | Description |
|---|---|
DataArray
|
The warming slice data for the specified level. |
Source code in climakitae/explore/warming.py
calculate()
Calculate the warming levels for the selected parameters.
This function retrieves the data from the catalog, slices it according to the
warming levels, and stores the results in the sliced_data and gwl_snapshots
attributes.
Source code in climakitae/explore/warming.py
Time Series Visualization
Holds the instance of TimeSeriesParameters that is used for the following purposes: 1) to display a panel that previews various time-series transforms (explore), and 2) to save the transform represented by the current state of that preview into a new variable (output_current).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Time series array with no spatial coordinates. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
choices |
TimeSeriesParameters
|
Param object containing time series data and analysis parameters. |
Source code in climakitae/explore/timeseries.py
output_current()
Output the current attributes of the class to a DataArray object. Allows the data to be easily accessed by the user after modifying the attributes directly in the explore panel, for example.
Returns:
| Type | Description |
|---|---|
DataArray
|
|
Source code in climakitae/explore/timeseries.py
Uncertainty Analysis (CMIP Ensemble Optimization)
A class for holding relevant data options for cmip preprocessing
Attributes:
| Name | Type | Description |
|---|---|---|
variable |
str
|
variable name, cf-compliant (or cmip6 variable name) |
area_subset |
str
|
geographic boundary name (states/counties) |
location |
str
|
geographic area name (name of county/state) |
timescale |
str
|
frequency of data |
area_average |
bool
|
average computed across domain |
Methods:
| Name | Description |
|---|---|
_cmip_clip |
CMIP6-specific subsetting |
Source code in climakitae/explore/uncertainty.py
Typical Meteorological Year
Encapsulate the code needed to generate Typical Meteorological Year (TMY) files.
Uses WRF hourly data to produce TMYs. User provides the start and end years along with location to generate file.
How to set location: The location can either be provided as latitude and
longitude coordinates or as the name of a HadISD station in California. Do not set
latitude and longitude if using a HadISD station. If latitude and longitude
are set along with a custom value for station_name (NOT a HadISD station), the
custom station name will be used in file headers where appropriate.
How to set time period: The time period can either be set with a time approach using
start_year and end_year or with a warming level approach using warming_level.
If the warming level approach is used, a 30-year period is obtained centered around
the given warming level and the start and end years are taken for that warming level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_year
|
str
|
Initial year of TMY period (time approach) |
UNSET
|
end_year
|
str
|
Final year of TMY period (time approach) |
UNSET
|
warming_level
|
float | int
|
Desired warming level (warming level approach) |
UNSET
|
station_name
|
str
|
Long name of desired station |
UNSET
|
latitude
|
float | int(optional)
|
Latitude for TMY data if station_name not set |
UNSET
|
longitude
|
float | int(optional)
|
Longitude for TMY data if station_name not set |
UNSET
|
verbose
|
bool
|
True to increase verbosity |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
start_year |
str
|
Initial year of TMY period |
end_year |
str
|
Final year of TMY period |
warming_level |
float | int
|
Warming level value |
lat_range |
tuple
|
Pair of latitudes that bracket |
lon_range |
tuple
|
Pair of longitudes that bracket |
simulations |
list[str]
|
List of included simulations |
scenario |
list[str]
|
List of scenarios |
vars_and_units |
dict[str, str]
|
Dictionary of all required variables and units |
verbose |
bool
|
True to increase verbosity |
cdf_climatology |
Dataset
|
CDF climatology data |
cdf_monthly |
Dataset
|
CDF monthly data by model |
weighted_fs_sum |
Dataset
|
Weighted F-S statistic results |
top_months |
DataFrame
|
Table of top months by model |
all_vars |
Dataset
|
All loaded variables for TMY |
tmy_data_to_export |
dict[Dataframe]
|
Dictionary of TMY results by simulation |
_skip_last |
bool
|
Internal flag to track last year for warming level approach |
Source code in climakitae/explore/typical_meteorological_year.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 | |
load_all_variables()
Load hourly TMY variables and derive daily statistics for CDF/F-S.
Fetches hourly raw variables via ClimateData for the 8760 profile assembly, then derives ALL daily statistics from the hourly data in local time. This matches the original TMY code's approach and avoids two problems with fetching daily catalog variables directly:
- UTC vs local time: Catalog daily variables are pre-aggregated over UTC day boundaries, which differ from local-time days by the station's UTC offset (e.g., 8 hours for California).
- Non-determinism: With a Dask distributed client active, lazy
reductions (
.resample().sum()) can produce slightly different floating-point results on each run due to non-deterministic task ordering. Computing hourly data eagerly to numpy before resampling guarantees deterministic daily statistics.
Source code in climakitae/explore/typical_meteorological_year.py
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 | |
set_cdf_climatology()
Calculate the long-term climatology for each index for each month so we can establish the baseline pattern.
Source code in climakitae/explore/typical_meteorological_year.py
set_cdf_monthly()
Get CDF for each month and variable.
Source code in climakitae/explore/typical_meteorological_year.py
set_weighted_statistic()
Calculate the weighted F-S statistic.
Source code in climakitae/explore/typical_meteorological_year.py
set_top_months()
Calculate top months dataframe.
Source code in climakitae/explore/typical_meteorological_year.py
show_tmy_data_to_export(simulation)
Show line plots of TMY data for single model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation
|
str
|
Simulation to display. |
required |
Source code in climakitae/explore/typical_meteorological_year.py
run_tmy_analysis()
Generate typical meteorological year data.
Output will be a list of dataframes per simulation. Print statements throughout the function indicate progress.
Notes
Results are saved to the class variable tmy_data_to_export.
Source code in climakitae/explore/typical_meteorological_year.py
export_tmy_data(extension='epw')
Write TMY data to EPW file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extension
|
str
|
Desired file extension ('tmy','epw', or 'csv') |
'epw'
|
Source code in climakitae/explore/typical_meteorological_year.py
get_candidate_months()
Run CDF functions to get top candidates.
This function can be used to view the candidate months without running the entire TMY workflow.
Source code in climakitae/explore/typical_meteorological_year.py
generate_tmy()
Run the whole TMY workflow.
Source code in climakitae/explore/typical_meteorological_year.py
Climate Vulnerability Assessment
Bases: Parameterized
Climate Analysis and Vulnerability Assessment Parameters Class.
This class defines and validates parameters for climate vulnerability analysis, supporting various climate variables, metrics, and analysis approaches.
Attributes:
| Name | Type | Description |
|---|---|---|
input_locations |
DataFrame
|
Input coordinates that must have 'lat' and 'lon' columns with numeric data. |
time_start_year |
int, default=1981
|
Start year for the analysis period. Must be between 1900 and 2100. |
time_end_year |
int, default=2010
|
End year for the analysis period. Must be between 1900 and 2100. |
units |
str, default="Celsius"
|
Units for temperature measurement. |
variable |
str, default="Air Temperature at 2m"
|
Climate variable to analyze. Options include "Air Temperature at 2m", "Precipitation (total)", "NOAA Heat Index", "Effective Temperature". |
metric_calc |
str, default="max"
|
Statistical metric calculation method. Options: "min", "max", "mean", "median". |
percentile |
float or None, default=None
|
Percentile value for calculation. Must be between 0 and 100 if specified. |
heat_idx_threshold |
float or None, default=None
|
Threshold value for heat index calculations. |
one_in_x |
int, float, list or None, default=None
|
Return period(s) for extreme event analysis (e.g., 1-in-100 year event). Can be a single value or list of values. |
season |
str, default="all"
|
Season to analyze. Options: "summer", "winter", "all". |
downscaling_method |
str, default="Dynamical"
|
Climate model downscaling method. Options: "Dynamical", "Statistical". |
approach |
str, default="Time"
|
Analysis approach. Options: "Time" (time period), "Warming Level" (temperature target). |
warming_level |
float, default=1.0
|
Global warming level in degrees Celsius. Must be between 0 and 7. |
wrf_bias_adjust |
bool, default=True
|
Whether to apply bias adjustment to WRF model data. |
historical_data |
str, default="Historical Climate"
|
Type of historical data. Options: "Historical Climate", "Historical Reconstruction". |
ssp_data |
list, default=["SSP 3-7.0"]
|
Shared Socioeconomic Pathway scenarios to use. Options: "SSP 2-4.5", "SSP 3-7.0", "SSP 5-8.5". |
export_method |
str, default="both"
|
Data export method. Options: "raw", "calculate", "both", "None". |
separate_files |
bool, default=False
|
Whether to save climate variables in separate files. |
file_format |
str, default="NetCDF"
|
Output file format. |
batch_mode |
bool, default=False
|
Whether to run in batch processing mode. |
distr |
str, default="gev"
|
Statistical distribution for extreme value analysis. Options: "gev" (Generalized Extreme Value), "genpareto" (Generalized Pareto), "gamma". |
duration |
tuple, default=UNSET
|
Length of extreme event, specified as (4, 'hour'). Only implemented for hourly data. |
groupby |
tuple, default=(1, "day")
|
Group over which to look for max occurrence, specified as (1, 'day'). Only 'day' groupings supported. |
grouped_duration |
tuple, default=UNSET
|
Length of event after grouping, specified as (5, 'day'). Requires groupby to be set. |
file_name |
str
|
Base name for output files, no extension (e.g., "output", not "output.nc"). |
Methods:
| Name | Description |
|---|---|
validate_params |
Validate all parameters for consistency and compatibility. |
get_names |
Generate standardized names and metadata for data processing. If parameter validation fails. Common validation errors include: - Missing or non-numeric lat/lon columns in input_locations - Invalid time range (start year > end year) - Incompatible parameter combinations (e.g., multiple threshold parameters) - Unsupported variable-downscaling method combinations - Invalid approach-data type combinations |
Notes
The class enforces several validation rules: - Only one threshold parameter (heat_idx_threshold, percentile, or one_in_x) can be specified - Historical Reconstruction data requires time-based approach and end year <= 2022 - NOAA Heat Index and Effective Temperature cannot use Statistical downscaling - Dynamical downscaling with time-based approach only supports SSP 3-7.0 - duration only supports "hour" units; groupby and grouped_duration only support "day" units
Examples:
>>> import pandas as pd
>>> locations = pd.DataFrame({'lat': [34.05, 36.17], 'lon': [-118.25, -115.14]})
>>> params = CavaParams(
... input_locations=locations,
... time_start_year=2020,
... time_end_year=2050,
... variable="Air Temperature at 2m",
... percentile=95,
... metric_calc="max"
... )
Source code in climakitae/explore/vulnerability.py
validate_params()
Validate the parameters for vulnerability analysis.
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If any validation check fails. The error message lists all validation failures found during the validation process. |
Notes
The method validates the following conditions: - Input locations DataFrame contains required 'lat' and 'lon' columns with numeric data types (float64 or int64) - Time range validity (start year must be <= end year) - Historical reconstruction data constraints: - End year must be <= 2022 - Only time-based approach is supported - Mutual exclusivity of threshold parameters (only one of heat_idx_threshold, percentile, or one_in_x can be specified) - At least one threshold parameter must be specified - Metric calculation ('min' or 'max') compatibility with percentile calculations - Variable and downscaling method compatibility (NOAA Heat Index and Effective Temperature cannot use Statistical downscaling) - SSP data constraints for WRF/Dynamical downscaling (only SSP 3-7.0 allowed for time-based approach)
Side Effects
Converts self.one_in_x to a list if it's not None and not already a list.
Source code in climakitae/explore/vulnerability.py
724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 | |
get_names()
Generate names and metadata for climate data processing.
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary containing the following keys: ssp_selected : str or list The SSP (Shared Socioeconomic Pathway) data selected for analysis. variable : str The climate variable being analyzed, potentially adjusted based on downscaling method and metric calculation. variable_type : str Type of variable, either "Variable" for raw climate variables or "Derived Index" for calculated indices. var_name : str Human-readable description of the calculation being performed, including variable, metric, time period/warming level, and season. raw_name : str Standardized name for raw data storage. calc_name : str Standardized name for calculated data storage. |
Notes
The function handles three main calculation types based on instance attributes: - Percentile calculations (when self.percentile is not None) - Heat index threshold calculations (when self.heat_idx_threshold is not None) - Return period calculations (when self.one_in_x is not None) For LOCA2 statistical downscaling with air temperature, the variable name is adjusted based on whether maximum or minimum metric calculation is selected. The approach can be either "Time" (using start/end years) or "Warming Level" (using a specific warming level in degrees Celsius).
Raises:
| Type | Description |
|---|---|
ValueError
|
If metric_calc is not "max" or "min" for LOCA2 air temperature data. |
ValueError
|
If approach is not "Time" or "Warming Level". |
ValueError
|
If an unsupported variable is used for 1-in-X calculations. |
Source code in climakitae/explore/vulnerability.py
885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | |
Threshold Tools
Helper functions for performing analyses related to thresholds
calculate_ess(data, nlags=UNSET)
Function for calculating the effective sample size (ESS) of the provided data using the autocorrelation of the data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Input array is assumed to be timeseries data with potential autocorrelation. |
required |
nlags
|
int
|
Number of lags to use in the autocorrelation function, defaults to the length of the timeseries. |
UNSET
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Effective sample size. Returned as a DataArray object so it can be utilized by xr.groupby and xr.resample. |
References
Zwiers, F. W., and H. von Storch, 1995: Taking Serial Correlation into Account in Tests of the Mean. J. Climate, 8, 336–351, https://doi.org/10.1175/1520-0442(1995)008<0336:TSCIAI>2.0.CO;2.
Source code in climakitae/explore/threshold_tools.py
get_block_maxima(da_series, extremes_type='max', duration=UNSET, groupby=UNSET, grouped_duration=UNSET, check_ess=True, block_size=1, rolling_agg='sustained')
Convert a timeseries into block extrema (maxima or minima), defaulting to annual block size.
Resamples the input array by taking the most extreme value in each block.
Optional arguments duration, groupby, and grouped_duration define the
type of compound event to extract extrema from, corresponding to the event types
used in get_exceedance_count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
da_series
|
DataArray
|
Input timeseries from which block extrema are extracted. |
required |
extremes_type
|
(max, min)
|
Whether to extract block maxima or minima. Default is |
"max"
|
duration
|
tuple[int, str]
|
Length of the extreme event, specified as |
UNSET
|
groupby
|
tuple[int, str]
|
Temporal grouping applied before computing block extrema, specified as
|
UNSET
|
grouped_duration
|
tuple[int, str]
|
Rolling window applied after |
UNSET
|
check_ess
|
bool
|
If |
True
|
block_size
|
int
|
Block size in years over which to take the extremum. Default is |
1
|
rolling_agg
|
(sustained, cumulative, average)
|
Aggregation method applied during rolling windows ( |
"sustained"
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Block extrema series with the same non-time dimensions as |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
ValueError
|
If |
ValueError
|
If |
ValueError
|
If |
ValueError
|
If |
ValueError
|
If all block values are NaN (i.e. the input contains no valid observations for this variable). |
Source code in climakitae/explore/threshold_tools.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
get_ks_stat(bms, distr='gev', multiple_points=True)
Function to perform kstest on input DataArray
Creates a dataset of ks test d-statistics and p-values from an inputed maximum series.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bms
|
DataArray
|
Block maximum series, can be output from the function get_block_maxima() |
required |
distr
|
str
|
name of distribution to use |
'gev'
|
multiple_points
|
boolean
|
Whether or not the data contains multiple points (has x, y dimensions) |
True
|
Returns:
| Type | Description |
|---|---|
Dataset
|
|
Source code in climakitae/explore/threshold_tools.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | |
get_return_value(bms, return_period=10, distr='gev', bootstrap_runs=100, conf_int_lower_bound=2.5, conf_int_upper_bound=97.5, multiple_points=True, extremes_type='max', dropna_time=False, dim_to_fit='time')
Creates xarray Dataset with return values and confidence intervals from maximum series.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bms
|
DataArray
|
Block maximum series, can be output from the function get_block_maxima() |
required |
return_period
|
float
|
The recurrence interval (in years) for which to calculate the return value |
10
|
distr
|
str
|
The type of extreme value distribution to fit |
'gev'
|
bootstrap_runs
|
int
|
Number of bootstrap samples |
100
|
conf_int_lower_bound
|
float
|
Confidence interval lower bound |
2.5
|
conf_int_upper_bound
|
float
|
Confidence interval upper bound |
97.5
|
multiple_points
|
boolean
|
Whether or not the data contains multiple points (has x, y dimensions) |
True
|
extremes_type
|
str
|
Whether to compute max ('max') or min ('min') extremes, by default 'max'. |
'max'
|
dropna_time
|
bool
|
Whether to drop NaNs along the time axis |
False
|
dim_to_fit
|
str
|
Name of the dimension that the distribution is going to be fit on. |
'time'
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset with return values and confidence intervals |
Notes
This function calls _get_return_variable, which will attempt to use the block_size attribute from the BMS to get the block size. If the block_size attribute is not found, an default of 1 will be used. The block size is used to get the annual probability of the desired event when the block size is > 1 year.
Source code in climakitae/explore/threshold_tools.py
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 | |
get_return_prob(bms, threshold, distr='gev', bootstrap_runs=100, conf_int_lower_bound=2.5, conf_int_upper_bound=97.5, multiple_points=True, extremes_type='max', dropna_time=False, dim_to_fit='time')
Creates xarray Dataset with return probabilities and confidence intervals from maximum series.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bms
|
DataArray
|
Block maximum series, can be output from the function get_block_maxima() |
required |
threshold
|
float
|
The threshold value for which to calculate the probability of exceedance |
required |
distr
|
str
|
The type of extreme value distribution to fit |
'gev'
|
bootstrap_runs
|
int
|
Number of bootstrap samples |
100
|
conf_int_lower_bound
|
float
|
Confidence interval lower bound |
2.5
|
conf_int_upper_bound
|
float
|
Confidence interval upper bound |
97.5
|
multiple_points
|
boolean
|
Whether or not the data contains multiple points (has x, y dimensions) |
True
|
extremes_type
|
str
|
Whether to compute max ('max') or min ('min') extremes, by default 'max'. |
'max'
|
dropna_time
|
bool
|
Whether to drop NaNs along the time axis |
False
|
dim_to_fit
|
str
|
Name of the dimension that the distribution is going to be fit on. |
'time'
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset with return probabilities and confidence intervals |
Notes
This function calls _get_return_variable, which will attempt to use the block_size attribute from the BMS to get the block size. If the block_size attribute is not found, an default of 1 will be used. The block size is used to get the annual probability of the desired event when the block size is > 1 year.
Source code in climakitae/explore/threshold_tools.py
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 | |
get_return_period(bms, return_value, distr='gev', bootstrap_runs=100, conf_int_lower_bound=2.5, conf_int_upper_bound=97.5, multiple_points=True, extremes_type='max', dropna_time=False, dim_to_fit='time')
Creates xarray Dataset with return periods and confidence intervals from maximum series.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bms
|
DataArray
|
Block maximum series, can be output from the function get_block_maxima() |
required |
return_value
|
float
|
The threshold value for which to calculate the return period of occurance |
required |
distr
|
str
|
The type of extreme value distribution to fit |
'gev'
|
bootstrap_runs
|
int
|
Number of bootstrap samples |
100
|
conf_int_lower_bound
|
float
|
Confidence interval lower bound |
2.5
|
conf_int_upper_bound
|
float
|
Confidence interval upper bound |
97.5
|
multiple_points
|
boolean
|
Whether or not the data contains multiple points (has x, y dimensions) |
True
|
extremes_type
|
str
|
Whether to compute max ('max') or min ('min') extremes, by default 'max'. |
'max'
|
dropna_time
|
bool
|
Whether to drop NaNs along the time axis |
False
|
dim_to_fit
|
str
|
Name of the dimension that the distribution is going to be fit on. |
'time'
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset with return periods and confidence intervals |
Notes
This function calls _get_return_variable, which will attempt to use the block_size attribute from the BMS to get the block size. If the block_size attribute is not found, an default of 1 will be used. The block size is used to get the annual probability of the desired event when the block size is > 1 year.
Source code in climakitae/explore/threshold_tools.py
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 | |
get_exceedance_count(da, threshold_value, duration1=UNSET, period=(1, 'year'), threshold_direction='above', duration2=UNSET, groupby=UNSET, smoothing=UNSET)
Calculate the number of occurances of exceeding the specified threshold within each period.
Returns an xarray.DataArray with the same coordinates as the input data except for the time dimension, which will be collapsed to one value per period (equal to the number of event occurances in each period).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
da
|
DataArray
|
array of some climate variable. Can have multiple scenarios, simulations, or x and y coordinates. |
required |
threshold_value
|
float
|
value against which to test exceedance |
required |
duration1
|
tuple[int, str]
|
length of exceedance in order to qualify as an event (before grouping) |
UNSET
|
period
|
tuple[int, str]
|
amount of time across which to sum the number of occurances, default is (1, "year"). Specified as a tuple: (x, time) where x is an integer, and time is one of: ["day", "month", "year"] |
(1, 'year')
|
threshold_direction
|
str
|
either "above" or "below", default is above. |
'above'
|
duration2
|
tuple[int, str]
|
length of exceedance in order to qualify as an event (after grouping) |
UNSET
|
groupby
|
tuple[int, str]
|
see examples for explanation. Typical grouping could be (1, "day") |
UNSET
|
smoothing
|
int
|
option to average the result across multiple periods with a rolling average; value is either UNSET or the number of timesteps to use as the window size |
UNSET
|
Returns:
| Type | Description |
|---|---|
DataArray
|
|
Source code in climakitae/explore/threshold_tools.py
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 | |
exceedance_plot_title(exceedance_count)
Function to build title for exceedance plots
Helper function for making the title for exceedance plots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exceedance_count
|
DataArray
|
|
required |
Returns:
| Type | Description |
|---|---|
string
|
|
Examples:
'Air Temperatue at 2m: events above 35C'
'Preciptation (total): events below 10mm'
Source code in climakitae/explore/threshold_tools.py
exceedance_plot_subtitle(exceedance_count)
Function of build exceedance plot subtitle
Helper function for making the subtile for exceedance plots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exceedance_count
|
DataArray
|
|
required |
Returns:
| Type | Description |
|---|---|
string
|
|
Examples:
'Number of hours per year'
'Number of 4-hour events per 3-months'
'Number of days per year with conditions lasting at least 4-hours'
Source code in climakitae/explore/threshold_tools.py
Thresholds
get_threshold_data(selections)
This function pulls data from the catalog and reads it into memory
Arguments
selections : DataParameters object holding user's selections
Returns:
| Name | Type | Description |
|---|---|---|
data |
DataArray
|
data to use for creating postage stamp data |
Source code in climakitae/explore/thresholds.py
Vulnerability Tables
create_vul_table(example_loc, percentile, heat_idx_threshold, one_in_x)
Creates a vulnerability assessment table and exports the table to CSV.