climate-toolkit 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- climate_toolkit/__init__.py +109 -0
- climate_toolkit/_resources.py +45 -0
- climate_toolkit/calculate_hazards/__init__.py +14 -0
- climate_toolkit/calculate_hazards/crop_water_balance_params.json +58 -0
- climate_toolkit/calculate_hazards/ensemble_hazards.py +1317 -0
- climate_toolkit/calculate_hazards/hazards.py +3272 -0
- climate_toolkit/cli.py +89 -0
- climate_toolkit/climate_statistics/__init__.py +14 -0
- climate_toolkit/climate_statistics/ensemble_statistics.py +1065 -0
- climate_toolkit/climate_statistics/statistics.py +3375 -0
- climate_toolkit/climatology/__init__.py +104 -0
- climate_toolkit/climatology/_cli_common.py +172 -0
- climate_toolkit/climatology/heat_stress.py +675 -0
- climate_toolkit/climatology/human_heat_stress.py +389 -0
- climate_toolkit/climatology/long_term_climatology.py +1939 -0
- climate_toolkit/climatology/spei.py +745 -0
- climate_toolkit/climatology/vpd.py +246 -0
- climate_toolkit/climatology/xclim_reference.py +988 -0
- climate_toolkit/compare_datasets/__init__.py +14 -0
- climate_toolkit/compare_datasets/compare_datasets.py +1070 -0
- climate_toolkit/compare_periods/__init__.py +14 -0
- climate_toolkit/compare_periods/ensemble_periods.py +2899 -0
- climate_toolkit/compare_periods/periods.py +1892 -0
- climate_toolkit/crop_calendar/__init__.py +94 -0
- climate_toolkit/crop_calendar/ggcmi.py +198 -0
- climate_toolkit/crop_calendar/registry.py +102 -0
- climate_toolkit/data/__init__.py +1 -0
- climate_toolkit/data/ggcmi_phase3/__init__.py +1 -0
- climate_toolkit/data/ggcmi_phase3/crop_calendar.parquet +0 -0
- climate_toolkit/data/ggcmi_phase3/crop_calendar_manifest.json +42 -0
- climate_toolkit/fetch_data/__init__.py +61 -0
- climate_toolkit/fetch_data/cache_inventory.py +378 -0
- climate_toolkit/fetch_data/fetch_data.py +645 -0
- climate_toolkit/fetch_data/gee_xee_batch.py +1133 -0
- climate_toolkit/fetch_data/multi_site.py +220 -0
- climate_toolkit/fetch_data/nex_gddp_batch.py +1017 -0
- climate_toolkit/fetch_data/preprocess_data/__init__.py +18 -0
- climate_toolkit/fetch_data/preprocess_data/preprocess_data.py +332 -0
- climate_toolkit/fetch_data/runtime_notes.py +80 -0
- climate_toolkit/fetch_data/source_data/__init__.py +15 -0
- climate_toolkit/fetch_data/source_data/source_data.py +398 -0
- climate_toolkit/fetch_data/source_data/sources/agera_5.py +15 -0
- climate_toolkit/fetch_data/source_data/sources/chirps.py +63 -0
- climate_toolkit/fetch_data/source_data/sources/chirts.py +63 -0
- climate_toolkit/fetch_data/source_data/sources/era_5.py +15 -0
- climate_toolkit/fetch_data/source_data/sources/gee.py +999 -0
- climate_toolkit/fetch_data/source_data/sources/gee_xee.py +107 -0
- climate_toolkit/fetch_data/source_data/sources/ghcn_daily.py +87 -0
- climate_toolkit/fetch_data/source_data/sources/gsod.py +87 -0
- climate_toolkit/fetch_data/source_data/sources/imerg.py +106 -0
- climate_toolkit/fetch_data/source_data/sources/nasa_power.py +414 -0
- climate_toolkit/fetch_data/source_data/sources/nex_gddp.py +357 -0
- climate_toolkit/fetch_data/source_data/sources/nex_gddp_xee.py +1062 -0
- climate_toolkit/fetch_data/source_data/sources/soil_grid.py +58 -0
- climate_toolkit/fetch_data/source_data/sources/tamsat.py +647 -0
- climate_toolkit/fetch_data/source_data/sources/terraclimate.py +96 -0
- climate_toolkit/fetch_data/source_data/sources/utils/__init__.py +177 -0
- climate_toolkit/fetch_data/source_data/sources/utils/config.yaml +227 -0
- climate_toolkit/fetch_data/source_data/sources/utils/models.py +539 -0
- climate_toolkit/fetch_data/source_data/sources/utils/settings.py +206 -0
- climate_toolkit/fetch_data/source_data/sources/xee_common.py +221 -0
- climate_toolkit/fetch_data/transform_data/__init__.py +20 -0
- climate_toolkit/fetch_data/transform_data/data_dictionary.yaml +96 -0
- climate_toolkit/fetch_data/transform_data/transform_data.py +343 -0
- climate_toolkit/gee_check.py +280 -0
- climate_toolkit/pipeline.py +307 -0
- climate_toolkit/season_analysis/__init__.py +24 -0
- climate_toolkit/season_analysis/ensemble.py +1016 -0
- climate_toolkit/season_analysis/season_identity.py +58 -0
- climate_toolkit/season_analysis/seasons.py +1817 -0
- climate_toolkit/weather_station/__init__.py +73 -0
- climate_toolkit/weather_station/compare.py +3236 -0
- climate_toolkit/weather_station/custom_station.py +464 -0
- climate_toolkit/weather_station/dem.py +153 -0
- climate_toolkit/weather_station/download.py +1440 -0
- climate_toolkit/weather_station/ghcn_daily.py +832 -0
- climate_toolkit/weather_station/gsod.py +835 -0
- climate_toolkit/weather_station/overrides.py +174 -0
- climate_toolkit/weather_station/station_selector.py +607 -0
- climate_toolkit-0.1.0.dist-info/METADATA +1548 -0
- climate_toolkit-0.1.0.dist-info/RECORD +85 -0
- climate_toolkit-0.1.0.dist-info/WHEEL +5 -0
- climate_toolkit-0.1.0.dist-info/entry_points.txt +18 -0
- climate_toolkit-0.1.0.dist-info/licenses/LICENSE +21 -0
- climate_toolkit-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, Optional
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def build_season_identity(
|
|
9
|
+
onset: Any,
|
|
10
|
+
cessation: Any,
|
|
11
|
+
*,
|
|
12
|
+
length_days: Optional[int] = None,
|
|
13
|
+
regime: Optional[str] = None,
|
|
14
|
+
season_number: Optional[int] = None,
|
|
15
|
+
total_seasons_per_year: Optional[int] = None,
|
|
16
|
+
) -> Dict[str, Any]:
|
|
17
|
+
onset_ts = pd.to_datetime(onset)
|
|
18
|
+
cess_ts = pd.to_datetime(cessation)
|
|
19
|
+
midpoint_ts = onset_ts + (cess_ts - onset_ts) / 2
|
|
20
|
+
duration = (
|
|
21
|
+
int(length_days)
|
|
22
|
+
if length_days is not None
|
|
23
|
+
else int((cess_ts - onset_ts).days + 1)
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
onset_month = int(onset_ts.month)
|
|
27
|
+
cess_month = int(cess_ts.month)
|
|
28
|
+
regime_name = regime or "unknown"
|
|
29
|
+
|
|
30
|
+
alignment_candidates = [
|
|
31
|
+
f"onset_month:{onset_month:02d}",
|
|
32
|
+
f"month_pair:{onset_month:02d}-{cess_month:02d}",
|
|
33
|
+
f"regime:{regime_name}|onset_month:{onset_month:02d}",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
"onset_date": onset_ts.strftime("%Y-%m-%d"),
|
|
38
|
+
"cessation_date": cess_ts.strftime("%Y-%m-%d"),
|
|
39
|
+
"midpoint_date": midpoint_ts.strftime("%Y-%m-%d"),
|
|
40
|
+
"onset_month": onset_month,
|
|
41
|
+
"cessation_month": cess_month,
|
|
42
|
+
"midpoint_month": int(midpoint_ts.month),
|
|
43
|
+
"onset_doy": int(onset_ts.dayofyear),
|
|
44
|
+
"cessation_doy": int(cess_ts.dayofyear),
|
|
45
|
+
"midpoint_doy": int(midpoint_ts.dayofyear),
|
|
46
|
+
"length_days": duration,
|
|
47
|
+
"crosses_year_boundary": bool(cess_ts.year > onset_ts.year),
|
|
48
|
+
"regime": regime_name,
|
|
49
|
+
"season_number": season_number,
|
|
50
|
+
"total_seasons_per_year": total_seasons_per_year,
|
|
51
|
+
"slot_label": (
|
|
52
|
+
f"season_{season_number}_of_{total_seasons_per_year}"
|
|
53
|
+
if season_number is not None and total_seasons_per_year is not None
|
|
54
|
+
else None
|
|
55
|
+
),
|
|
56
|
+
"candidate_alignment_keys": alignment_candidates,
|
|
57
|
+
"experimental_alignment_key": alignment_candidates[-1],
|
|
58
|
+
}
|