Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
change-fesom-mesh-binder
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Gierz
change-fesom-mesh-binder
Commits
dcb3a00a
Commit
dcb3a00a
authored
2 years ago
by
Paul Gierz
Browse files
Options
Downloads
Patches
Plain Diff
fix: forgot the src folder for offloaded code
parent
e344fd41
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+2
-0
2 additions, 0 deletions
.gitignore
src/__init__.py
+67
-0
67 additions, 0 deletions
src/__init__.py
with
69 additions
and
0 deletions
.gitignore
+
2
−
0
View file @
dcb3a00a
# data downloads
data/
# Direnv
.envrc
.direnv/
...
...
This diff is collapsed.
Click to expand it.
src/__init__.py
0 → 100644
+
67
−
0
View file @
dcb3a00a
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment