Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
corentincarton committed Nov 15, 2023
1 parent 81f777e commit 5377c31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 80 deletions.
6 changes: 3 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ name: hat
channels:
- conda-forge
dependencies:
- python=3.10
- python<=3.10
- netCDF4
- eccodes
- cfgrib
- cftime
- geopandas
- xarray
- plotly
Expand All @@ -15,8 +14,9 @@ dependencies:
- tqdm
- typer
- humanize
- folium
- typer
- ipyleaflet
- ipywidgets
- pip
# - pytest
# - mkdocs
Expand Down
77 changes: 0 additions & 77 deletions hat/hydrostats.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
"""high level python api for hydrological statistics"""
from typing import List

import folium
import geopandas as gpd
import numpy as np
import xarray as xr
from branca.colormap import linear
from folium.plugins import Fullscreen

from hat import hydrostats_functions

Expand Down Expand Up @@ -48,76 +44,3 @@ def run_analysis(
ds[name] = xr.DataArray(statistics, coords={"station": stations})

return ds


def display_map(ds: xr.Dataset, name: str, minv: float = 0, maxv: float = 1):
# xarray to geopandas
gdf = gpd.GeoDataFrame(
ds.to_dataframe(),
geometry=gpd.points_from_xy(ds["longitude"], ds["latitude"]),
crs="epsg:4326",
)
gdf["station_id"] = gdf.index
gdf = gdf[~gdf[name].isnull()]

# Create a color map
colormap = linear.Blues_09.scale(minv, maxv)

# Define style function
def style_function(feature):
property = feature["properties"][name]
return {"fillOpacity": 0.7, "weight": 0, "fillColor": colormap(property)}

m = folium.Map(location=[48, 5], zoom_start=5, prefer_canvas=True, tiles=None)
_ = folium.GeoJson(
gdf,
marker=folium.CircleMarker(fillColor="white", fillOpacity=0.5, radius=5),
name=name,
style_function=style_function,
tooltip=folium.GeoJsonTooltip(fields=["station_id", name]),
popup=folium.GeoJsonPopup(fields=["station_id", name]),
).add_to(m)

# Add the CartoDB Positron tileset as a layer
cartodb_positron = folium.TileLayer(
tiles="CartoDB Dark_Matter",
name="Dark",
overlay=False,
control=True,
)
cartodb_positron.add_to(m)

# Add the CartoDB Positron tileset as a layer
cartodb_positron = folium.TileLayer(
tiles="CartoDB Positron",
name="Light",
overlay=False,
control=True,
)
cartodb_positron.add_to(m)

# Add OpenStreetMap layer
open_street_map = folium.TileLayer(
tiles="OpenStreetMap",
name="Open Street Map",
overlay=False,
control=True,
)
open_street_map.add_to(m)

# Add the satellite layer
esri_satellite = folium.TileLayer(
tiles="""https://server.arcgisonline.com/ArcGIS/rest/services/
World_Imagery/MapServer/tile/{z}/{y}/{x}""",
attr="Esri",
name="Satellite",
overlay=False,
control=True,
)
esri_satellite.add_to(m)

# add controls
folium.LayerControl().add_to(m)
Fullscreen().add_to(m)

return m

0 comments on commit 5377c31

Please sign in to comment.