Skip to content
Snippets Groups Projects
Commit dcb3a00a authored by Paul Gierz's avatar Paul Gierz
Browse files

fix: forgot the src folder for offloaded code

parent e344fd41
No related branches found
No related tags found
No related merge requests found
# data downloads
data/
# Direnv
.envrc
.direnv/
......
import requests
from tqdm.auto import tqdm
import zipfile
import io
import pyfesom2 as pf2
import cartopy.crs as ccrs
import numpy as np
import geoviews as gv
from holoviews.operation.datashader import datashade, shade, dynspread, spread, rasterize
import datashader as ds
import pandas as pd
import panel as pn
import colorcet
import holoviews as hv
def download_pangaea_zip(url, fname):
resp = requests.get(url, stream=True)
total = int(resp.headers.get('content-length', 0))
# Can also replace 'file' with a io.BytesIO object
zip_buffer = io.BytesIO()
with io.BytesIO() as zip_buffer, tqdm(
desc=fname,
total=total,
unit='iB',
unit_scale=True,
unit_divisor=1024,
) as bar:
for data in resp.iter_content(chunk_size=1024):
size = zip_buffer.write(data)
bar.update(size)
zipfile.ZipFile(zip_buffer).extractall(fname)
def plot_fesom_mesh_depth(mesh):
if mesh.topo.max() >= 0:
mesh.topo *= -1
topo_mean = mesh.topo.take(mesh.elem[mesh.no_cyclic_elem], axis=-1).mean(axis=1)
node_ids_and_area = np.concatenate([mesh.elem[mesh.no_cyclic_elem], np.expand_dims(topo_mean, axis=-1)], axis=1)
df = pd.DataFrame(node_ids_and_area) #
df.index.name = "Element ID"
df.columns = ["Node 1", "Node 2", "Node 3", "Depth"]
nodes = gv.Points((mesh.x2, mesh.y2))
trimesh = gv.TriMesh((df, nodes)).redim(
x="Longitude (˚E)", y="Latitude (˚N)", z="Depth (m)"
)
projection = ccrs.PlateCarree()
projected_trimesh = gv.project(trimesh, projection=projection)
FESOM_depth = rasterize(projected_trimesh).opts(
cmap="ocean",
height=600,
width=900,
projection=projection,
colorbar=True,
colorbar_position="bottom",
tools=["hover"],
clabel="Average Element Depth (m)",
bgcolor="darkgray",
color_levels=20,
clim=(-5000, 0),
cformatter="%.0f",
)
return FESOM_depth
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment