cavapy 0.1.2__py3-none-any.whl → 0.1.3__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.

Potentially problematic release.


This version of cavapy might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: cavapy
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: CAVA Python package. Retrive and analyze climate data.
5
5
  Home-page: https://github.com/Risk-Team/cavapy
6
6
  License: MIT
@@ -0,0 +1,5 @@
1
+ cavapy.py,sha256=i9ULBOrL4NrtG13KFl7g9JEytsXJkF0Vepudebw7MEY,24377
2
+ cavapy-0.1.3.dist-info/LICENSE,sha256=1etyG4_n-Tb3yoNMwQ38g_WxXFQ4E_ZCjZc-AGYPc9U,1151
3
+ cavapy-0.1.3.dist-info/METADATA,sha256=M2KwoqRuQFd7SAubXRnwFKSJaVci1HfU1Q-BwOoT9Vo,6002
4
+ cavapy-0.1.3.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
5
+ cavapy-0.1.3.dist-info/RECORD,,
cavapy.py CHANGED
@@ -461,10 +461,14 @@ def _climate_data_for_variable(
461
461
  filtered_data["models"] = downloaded_models
462
462
 
463
463
  if historical or bias_correction:
464
- hist = filtered_data[filtered_data["experiment"] == "historical"]["models"].iloc[0].interpolate_na(dim="time", method="linear")
465
- proj = filtered_data[filtered_data["experiment"] == rcp]["models"].iloc[0].interpolate_na(dim="time", method="linear")
464
+ hist = filtered_data[filtered_data["experiment"] == "historical"]["models"].iloc[0]
465
+ proj = filtered_data[filtered_data["experiment"] == rcp]["models"].iloc[0]
466
+
467
+ hist = hist.interpolate_na(dim="time", method="linear")
468
+ proj = proj.interpolate_na(dim="time", method="linear")
466
469
  else:
467
- proj = filtered_data["models"].iloc[0].interpolate_na(dim="time", method="linear")
470
+ proj = filtered_data["models"].iloc[0]
471
+ proj = proj.interpolate_na(dim="time", method="linear")
468
472
 
469
473
  if bias_correction and historical:
470
474
  # Load observations for bias correction
@@ -587,6 +591,14 @@ def _download_data(
587
591
  else:
588
592
  log.info(f"Establishing connection to CORDEX data for {variable}")
589
593
  ds_var = xr.open_dataset(url)[variable]
594
+
595
+ # Check if time dimension has a prefix, indicating variable is not available
596
+ time_dims = [dim for dim in ds_var.dims if dim.startswith('time_')]
597
+ if time_dims:
598
+ msg = f"Variable {variable} is not available for this model: {url}"
599
+ log.exception(msg)
600
+ raise ValueError(msg)
601
+
590
602
  log.info(f"Connection to CORDEX data for {variable} has been established")
591
603
  ds_cropped = ds_var.sel(
592
604
  longitude=slice(bbox["xlim"][0], bbox["xlim"][1]),
@@ -642,14 +654,15 @@ def _download_data(
642
654
 
643
655
  if __name__ == "__main__":
644
656
  data = get_climate_data(
645
- country="Zambia",
657
+ country="Togo",
658
+ variables=["hurs"],
646
659
  cordex_domain="AFR-22",
647
660
  rcp="rcp26",
648
661
  gcm="MPI",
649
- rcm="REMO",
662
+ rcm="Reg",
650
663
  years_up_to=2030,
651
664
  obs=False,
652
- bias_correction=True,
665
+ bias_correction=False,
653
666
  historical=False,
654
667
  )
655
668
  print(data)
@@ -1,5 +0,0 @@
1
- cavapy.py,sha256=hie9HYVNepHlAiUF7zT0I1Y6Yghf-8WiVm2LLKddeB0,23903
2
- cavapy-0.1.2.dist-info/LICENSE,sha256=1etyG4_n-Tb3yoNMwQ38g_WxXFQ4E_ZCjZc-AGYPc9U,1151
3
- cavapy-0.1.2.dist-info/METADATA,sha256=zig0HriF0p6YpEAOAyy07vOCD33lt7sv9ZRUSzVQJ_0,6002
4
- cavapy-0.1.2.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
5
- cavapy-0.1.2.dist-info/RECORD,,
File without changes