Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Code freeze date: YYYY-MM-DD
Removed:

- `pandas-datareader`
- `fiona`

### Added
- Added optional parameter to `geo_im_from_array`, `plot_from_gdf`, `plot_rp_imp`, `plot_rp_intensity`,
Expand All @@ -24,6 +25,7 @@ Removed:
- `Hazard.local_exceedance_intensity`, `Hazard.local_return_period` and `Impact.local_exceedance_impact`, `Impact.local_return_period`, using the `climada.util.interpolation` module: New default (no binning), binning on decimals, and faster implementation [#1012](https://github.com/CLIMADA-project/climada_python/pull/1012)
- World Bank indicator data is now downloaded directly from their API via the function `download_world_bank_indicator`, instead of relying on the `pandas-datareader` package [#1033](https://github.com/CLIMADA-project/climada_python/pull/1033)
- `Exposures.write_hdf5` pickles geometry data in WKB format, which is faster and more sustainable. [#1051](https://github.com/CLIMADA-project/climada_python/pull/1051)
- CLIMADA does not make explicit use of `fiona` anymore [#1057](https://github.com/CLIMADA-project/climada_python/pull/1057)

### Fixed

Expand Down
11 changes: 5 additions & 6 deletions climada/engine/test/test_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import unittest
from pathlib import Path

import fiona
import geopandas as gpd
import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -147,12 +146,12 @@ def test_Forecast_plot(self):
adm1_shape_file = shapereader.natural_earth(
resolution="10m", category="cultural", name="admin_1_states_provinces"
)

if not cantons_file.exists():
with fiona.open(adm1_shape_file, "r") as source:
with fiona.open(cantons_file, "w", **source.meta) as sink:
for f in source:
if f["properties"]["adm0_a3"] == "CHE":
sink.write(f)
source = gpd.read_file(adm1_shape_file)
cantons_data = source[source["adm0_a3"] == "CHE"]
cantons_data.to_file(cantons_file)

## test plotting functions
# should save plot without failing
forecast.plot_imp_map(
Expand Down
4 changes: 2 additions & 2 deletions climada/hazard/centroids/centr.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,12 @@

@classmethod
def from_vector_file(cls, file_name, dst_crs=None):
"""Create Centroids object from vector file (any format supported by fiona).
"""Create Centroids object from vector file (any format supported by GeoPandas).

Parameters
----------
file_name : str
vector file with format supported by fiona and 'geometry' field.
vector file with format supported by GeoPandas and 'geometry' field.
dst_crs : crs, optional
reproject to given crs
If no crs is given in the file, simply sets the crs.
Expand Down Expand Up @@ -1046,7 +1046,7 @@
-------
df : DataFrame
"""
df = pd.DataFrame(self.gdf)

Check warning on line 1049 in climada/hazard/centroids/centr.py

View check run for this annotation

Jenkins - WCR / Pylint

invalid-name

LOW: Variable name "df" doesn't conform to '(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$' pattern
Raw output
Used when the name doesn't match the regular expression associated to its type(constant, variable, class...).
df["lon"] = self.gdf["geometry"].x
df["lat"] = self.gdf["geometry"].y
df["crs"] = CRS.from_user_input(self.crs).to_wkt()
Expand Down
8 changes: 0 additions & 8 deletions climada/util/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@

import matplotlib as mpl

# pylint: disable=unused-import
# without importing numpy ahead of fiona the debugger may run into an error
import numpy
from fiona.crs import from_epsg

from .config import CONFIG

SYSTEM_DIR = CONFIG.local_data.system.dir(create=False)
Expand Down Expand Up @@ -212,9 +207,6 @@
DEF_CRS = f"EPSG:{DEF_EPSG}"
"""Default coordinate reference system WGS 84, str, for pyproj and rasterio CRS.from_string()"""

DEF_CRS_FIONA = from_epsg(DEF_EPSG)
"""Default coordinate reference system WGS 84, dict, for fiona interface"""

cm_data1 = [
[0.00000000, 0.00000000, 0.00000000],
[0.00032031, 0.00020876, 0.00015576],
Expand Down
4 changes: 2 additions & 2 deletions climada/util/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2635,12 +2635,12 @@ def refine_raster_data(data, transform, res, method="linear", fill_value=0):


def read_vector(file_name, field_name, dst_crs=None):
"""Read vector file format supported by fiona.
"""Read vector file format supported by GeoPandas.

Parameters
----------
file_name : str
vector file with format supported by fiona and 'geometry' field.
vector file with format supported by GeoPandas and 'geometry' field.
field_name : list(str)
list of names of the columns with values.
dst_crs : crs, optional
Expand Down
1 change: 0 additions & 1 deletion doc/guide/Guide_Euler.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
"```bash\n",
"pip install \\\n",
" dask[dataframe] \\\n",
" fiona==1.9 \\\n",
" gdal==3.6 \\\n",
" netcdf4==1.6.2 \\\n",
" rasterio==1.4 \\\n",
Expand Down
25 changes: 11 additions & 14 deletions doc/tutorial/climada_engine_Forecast.ipynb

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions doc/tutorial/climada_entity_Exposures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1657,18 +1657,15 @@
"\n",
"## Write (Save) Exposures\n",
"\n",
"Exposures can be saved in any format available for `GeoDataFrame` (see fiona.supported_drivers) and `DataFrame` ([pandas IO tools](https://pandas.pydata.org/pandas-docs/stable/io.html)). Take into account that in many of these formats the metadata (e.g. variables `ref_year` and `value_unit`) will not be saved. Use instead the format hdf5 provided by `Exposures` methods `write_hdf5()` and `from_hdf5()` to handle all the data."
"Exposures can be saved in any format available for `GeoDataFrame` and `DataFrame` ([pandas IO tools](https://pandas.pydata.org/pandas-docs/stable/io.html)). Take into account that in many of these formats the metadata (e.g. variables `ref_year` and `value_unit`) will not be saved. Use instead the format hdf5 provided by `Exposures` methods `write_hdf5()` and `from_hdf5()` to handle all the data."
]
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import fiona\n",
"\n",
"fiona.supported_drivers\n",
"from climada import CONFIG\n",
"\n",
"results = CONFIG.local_data.save_dir.dir()\n",
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/climada_hazard_Hazard.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
"\n",
"- excel: Hazards can be read from Excel files following the template in `climada_python/climada/data/system/hazard_template.xlsx` using the `from_excel()` method. \n",
"- MATLAB: Hazards generated with CLIMADA's MATLAB version (.mat format) can be read using `from_mat()`.\n",
"- vector data: Use `Hazard`'s `from_vector`-constructor to read shape data (all formats supported by [fiona](https://fiona.readthedocs.io/en/latest/manual.html)).\n",
"- vector data: Use `Hazard`'s `from_vector`-constructor to read shape data (all formats supported by GeoPandas).\n",
"- hdf5: Hazards generated with the CLIMADA in Python (.h5 format) can be read using `from_hdf5()`.\n"
]
},
Expand Down
3 changes: 2 additions & 1 deletion requirements/env_climada.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ dependencies:
- contextily>=1.6
- dask>=2025.2
- eccodes>=2.40
- fiona>=1.10
- gdal>=3.10
- geopandas>=0.14,<1.0 # geopandas 1.0 does not depend on fiona anymore, hence fiona would need to be added as dependency
- geopandas>=0.14
- h5py>=3.12
- haversine>=2.9
- matplotlib-base>=3.10
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"contextily",
"dask",
"deprecation",
"fiona",
"geopandas",
"h5py",
"haversine",
Expand Down
Loading