Skip to content

Commit 2c28e96

Browse files
committed
Use geoviews everywhere + use pn.State for caching
This commit is quite messy, but we are still at an early stage of the development and the API is not set yet. Anyhow, it mostly addresses the remarks made by @jbednar at: #16 (comment) In a nutshell: - We follow the recommendation of the [FAQ](https://holoviews.org/FAQ.html) and we stop mixing holoviews and geoviews objects. - We use `pn.State` in order to cache the `xr.Dataset` objects among different requests. - We fix cartopy to < 0.20 since we are affected by this issue: holoviz/geoviews#529
1 parent ac150c6 commit 2c28e96

11 files changed

+268
-6397
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ cython_debug/
145145

146146
#data folder
147147
data/
148+
data.bak/
148149
data_/
149150

150151
.config_jupyter/

README.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,24 @@ You will need some data to visualize. If you don't have any you can download a s
99
created with [pyposeidon](https://github.com/ec-jrc/pyPoseidon/):
1010

1111
```
12-
mkdir data
13-
wget -O data/dataset.nc https://static.techrad.eu/thalassa/dataset.nc
12+
mkdir ./data
13+
wget -O data/dataset.nc https://static.techrad.eu/thalassa/dataset.nc
1414
```
1515

1616
## Deploying on a server
1717

18-
1. Install the dependencies with
18+
1. Install the binary dependencies:
19+
20+
- `python 3.9`
21+
- `proj < 8`
22+
23+
2. Install the python dependencies with
1924

2025
```
2126
pip install -r requirements/requirements.txt
2227
```
2328

24-
2. Run the panel server with:
29+
3. Run the panel server with:
2530

2631
```
2732
panel serve ./thalassa

Thalassa.ipynb

+11-6,101
Large diffs are not rendered by default.

poetry.lock

+112-209
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ bokeh = "^2.2"
4545
panel = "^0.12"
4646
xarray = "^0.19"
4747
netCDF4 = "^1.5"
48-
geoviews = "^1.8"
4948
datashader = "^0.13"
5049
ruyaml = "^0.20.0"
50+
geoviews = "^1.9.2"
51+
Cartopy = "<0.20" # due to https://github.com/holoviz/geoviews/issues/529
5152

5253
[tool.poetry.group.dev.dependencies]
5354
black = "^21.9b0"
@@ -58,12 +59,14 @@ mypy = "^0.910"
5859
prospector = "^1.5"
5960
pre-commit = "^2.15.0"
6061

62+
6163
[tool.poetry.group.vim]
6264
optional = true
6365

6466
[tool.poetry.group.vim.dependencies]
6567
jupyterlab-vim = "^0.14"
6668

69+
6770
[tool.black]
6871
line-length = 109
6972
target-version = ['py39']

requirements/requirements-dev.txt

+16-18
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
anyio==3.3.2; python_full_version >= "3.6.2" and python_version >= "3.6"
1+
anyio==3.3.3; python_full_version >= "3.6.2" and python_version >= "3.6"
22
appnope==0.1.2; sys_platform == "darwin" and python_version >= "3.7" or platform_system == "Darwin" and python_version >= "3.7"
33
argon2-cffi==21.1.0; python_version >= "3.6"
4-
astroid==2.8.0; python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.1"
4+
astroid==2.8.2; python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.1"
55
attrs==21.2.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
66
babel==2.9.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
77
backcall==0.2.0; python_version >= "3.7"
88
backports.entry-points-selectable==1.1.0; python_version >= "2.7" and python_full_version >= "3.6.1"
99
black==21.9b0; python_full_version >= "3.6.2"
1010
bleach==4.1.0; python_version >= "3.6"
1111
bokeh==2.4.0; python_version >= "3.7"
12-
cartopy==0.20.0; python_version >= "3.7"
13-
certifi==2021.5.30; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6" or python_version >= "3.7"
12+
cartopy==0.19.0.post1; python_version >= "3.5"
13+
certifi==2021.10.8; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6" or python_version >= "3.7"
1414
cffi==1.14.6; implementation_name == "pypy" and python_version >= "3.6" or python_version >= "3.6"
1515
cfgv==3.3.1; python_full_version >= "3.6.1"
1616
cftime==1.5.1
17-
charset-normalizer==2.0.6; python_full_version >= "3.6.0" and python_version >= "3.6"
18-
click==8.0.1; python_version >= "3.6" and python_full_version >= "3.6.2" or python_version >= "3.7"
17+
charset-normalizer==2.0.7; python_full_version >= "3.6.0" and python_version >= "3.6"
18+
click==8.0.3; python_version >= "3.6" and python_full_version >= "3.6.2" or python_version >= "3.7"
1919
cloudpickle==2.0.0; python_version >= "3.7" or python_version >= "3.7"
2020
colorama==0.4.4; python_version >= "3.6" and python_full_version < "3.0.0" and platform_system == "Windows" or python_full_version >= "3.5.0" and python_version >= "3.6" and platform_system == "Windows" or python_version >= "3.6" and python_full_version >= "3.6.2" and platform_system == "Windows" or python_version >= "3.7" and python_full_version < "3.0.0" and sys_platform == "win32" or sys_platform == "win32" and python_version >= "3.7" and python_full_version >= "3.5.0" or python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.1" and sys_platform == "win32"
2121
colorcet==2.0.6; python_version >= "2.7"
22-
cycler==0.10.0; python_version >= "3.7"
2322
dask==2021.9.1; python_version >= "3.7" or python_version >= "3.7"
2423
datashader==0.13.0; python_version >= "2.7"
2524
datashape==0.5.2; python_version >= "2.7"
@@ -33,35 +32,33 @@ dodgy==0.2.1; python_full_version >= "3.6.1" and python_version < "4.0"
3332
entrypoints==0.3; python_full_version >= "3.6.1" and python_version >= "3.6" or python_version >= "3.6"
3433
filelock==3.3.0; python_version >= "3.6" and python_full_version >= "3.6.1"
3534
flake8-polyfill==1.0.2; python_full_version >= "3.6.1" and python_version < "4.0"
36-
flake8==3.9.2; python_full_version >= "3.6.1" and python_version < "4.0"
35+
flake8==2.3.0; python_full_version >= "3.6.1" and python_version < "4.0"
3736
fsspec==2021.10.0; python_version >= "3.7"
3837
geoviews==1.9.2; python_version >= "3.7"
3938
heapdict==1.0.1; python_version >= "3.7"
4039
holoviews==1.14.6; python_version >= "2.7"
4140
identify==2.3.0; python_full_version >= "3.6.1"
42-
idna==3.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6" or python_full_version >= "3.6.2" and python_version >= "3.6"
41+
idna==3.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6" or python_full_version >= "3.6.2" and python_version >= "3.6"
4342
ipykernel==6.4.1; python_version >= "3.7"
4443
ipython-genutils==0.2.0; python_version >= "3.6"
4544
ipython==7.28.0; python_version >= "3.7"
4645
isort==5.9.3; python_full_version >= "3.6.1" and python_version < "4.0" and python_version >= "3.6"
4746
jedi==0.18.0; python_version >= "3.7"
4847
jinja2==3.0.2; python_version >= "3.7" or python_version >= "3.6"
4948
json5==0.9.6; python_version >= "3.6"
50-
jsonschema==4.0.1; python_version >= "3.7"
49+
jsonschema==4.1.0; python_version >= "3.7"
5150
jupyter-client==7.0.6; python_full_version >= "3.6.1" and python_version >= "3.6" or python_full_version >= "3.6.1" and python_version >= "3.7"
5251
jupyter-core==4.8.1; python_full_version >= "3.6.1" and python_version >= "3.6" or python_version >= "3.6"
5352
jupyter-server==1.11.1; python_version >= "3.6"
5453
jupyterlab-pygments==0.1.2; python_version >= "3.7"
5554
jupyterlab-server==2.8.2; python_version >= "3.6"
56-
jupyterlab==3.1.17; python_version >= "3.6"
57-
kiwisolver==1.3.2; python_version >= "3.7"
55+
jupyterlab==3.1.18; python_version >= "3.6"
5856
lazy-object-proxy==1.6.0; python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.1"
5957
llvmlite==0.36.0; python_version >= "3.6" and python_version < "3.10"
6058
locket==0.2.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7"
6159
markdown==3.3.4; python_version >= "3.6"
6260
markupsafe==2.0.1; python_version >= "3.7"
6361
matplotlib-inline==0.1.3; python_version >= "3.7"
64-
matplotlib==3.4.3; python_version >= "3.7"
6562
mccabe==0.6.1; python_full_version >= "3.6.1" and python_version < "4.0" or python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.1"
6663
mistune==0.8.4; python_version >= "3.7"
6764
msgpack==1.0.2; python_version >= "3.7"
@@ -87,6 +84,7 @@ parso==0.8.2; python_version >= "3.7"
8784
partd==1.2.0; python_version >= "3.7"
8885
pathspec==0.9.0; python_full_version >= "3.6.2"
8986
pep8-naming==0.10.0; python_full_version >= "3.6.1" and python_version < "4.0"
87+
pep8==1.7.1; python_full_version >= "3.6.1" and python_version < "4.0"
9088
pexpect==4.8.0; sys_platform != "win32" and python_version >= "3.7"
9189
pickleshare==0.7.5; python_version >= "3.7"
9290
pillow==8.3.2; python_version >= "3.6"
@@ -98,7 +96,7 @@ prospector==1.5.1; python_full_version >= "3.6.1" and python_version < "4.0"
9896
psutil==5.8.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.4.0"
9997
ptyprocess==0.7.0; sys_platform != "win32" and python_version >= "3.7" or os_name != "nt" and python_version >= "3.6"
10098
py==1.10.0; python_version >= "3.6" and python_full_version < "3.0.0" and implementation_name == "pypy" or implementation_name == "pypy" and python_version >= "3.6" and python_full_version >= "3.4.0"
101-
pycodestyle==2.7.0; python_full_version >= "3.6.1" and python_version < "4.0"
99+
pycodestyle==2.8.0; python_full_version >= "3.6.1" and python_version < "4.0"
102100
pycparser==2.20; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
103101
pyct==0.4.8; python_version >= "2.7"
104102
pydocstyle==6.1.1; python_full_version >= "3.6.1" and python_version < "4.0" and python_version >= "3.6"
@@ -113,14 +111,14 @@ pyparsing==2.4.7; python_version >= "3.7" and python_full_version < "3.0.0" or p
113111
pyproj==3.2.1; python_version >= "3.7"
114112
pyrsistent==0.18.0; python_version >= "3.7"
115113
pyshp==2.1.3; python_version >= "3.7"
116-
python-dateutil==2.8.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "2.7" or python_full_version >= "3.7.1" and python_version >= "2.7" or python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7" or python_full_version >= "3.6.1" and python_version >= "3.6"
114+
python-dateutil==2.8.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "2.7" or python_full_version >= "3.7.1" and python_version >= "2.7" or python_full_version >= "3.6.1" and python_version >= "3.6"
117115
pytz==2021.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" or python_full_version >= "3.7.1" and python_version >= "2.7"
118116
pyviz-comms==2.1.0
119-
pywin32==301; sys_platform == "win32" and platform_python_implementation != "PyPy" and python_version >= "3.6"
117+
pywin32==302; sys_platform == "win32" and platform_python_implementation != "PyPy" and python_version >= "3.6"
120118
pywinpty==1.1.4; os_name == "nt" and python_version >= "3.6"
121119
pyyaml==5.4.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.7" or python_full_version >= "3.6.1" and python_version < "4.0" or python_full_version >= "3.6.1"
122120
pyzmq==22.3.0; python_full_version >= "3.6.1" and python_version >= "3.6" or python_version >= "3.6"
123-
regex==2021.9.30; python_full_version >= "3.6.2"
121+
regex==2021.10.8; python_full_version >= "3.6.2"
124122
requests-unixsocket==0.2.0; python_version >= "3.6"
125123
requests==2.26.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6"
126124
requirements-detector==0.7; python_full_version >= "3.6.1" and python_version < "4.0"
@@ -130,7 +128,7 @@ send2trash==1.8.0; python_version >= "3.6"
130128
setoptconf-tmp==0.3.1; python_full_version >= "3.6.1" and python_version < "4.0"
131129
setuptools==58.2.0; python_version >= "3.6" and python_version < "3.10" or python_version >= "3.6" or python_version >= "3.7" or python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.1"
132130
shapely==1.7.1; python_version >= "3.7"
133-
six==1.16.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6" or python_full_version >= "3.7.1" and python_version >= "2.7" or python_full_version >= "3.6.1" or python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "2.7" or python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7"
131+
six==1.16.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6" or python_full_version >= "3.7.1" and python_version >= "2.7" or python_full_version >= "3.6.1" or python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "2.7"
134132
sniffio==1.2.0; python_full_version >= "3.6.2" and python_version >= "3.6"
135133
snowballstemmer==2.1.0; python_full_version >= "3.6.1" and python_version < "4.0" and python_version >= "3.6"
136134
sortedcontainers==2.4.0; python_version >= "3.7"

requirements/requirements.txt

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
bleach==4.1.0; python_version >= "3.6"
22
bokeh==2.4.0; python_version >= "3.7"
3-
cartopy==0.20.0; python_version >= "3.7"
4-
certifi==2021.5.30; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6" or python_version >= "3.7"
3+
cartopy==0.19.0.post1; python_version >= "3.5"
4+
certifi==2021.10.8; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6" or python_version >= "3.7"
55
cftime==1.5.1
6-
charset-normalizer==2.0.6; python_full_version >= "3.6.0" and python_version >= "3.6"
7-
click==8.0.1; python_version >= "3.7"
6+
charset-normalizer==2.0.7; python_full_version >= "3.6.0" and python_version >= "3.6"
7+
click==8.0.3; python_version >= "3.7"
88
cloudpickle==2.0.0; python_version >= "3.7" or python_version >= "3.7"
99
colorama==0.4.4; python_version >= "3.6" and python_full_version < "3.0.0" and platform_system == "Windows" or python_full_version >= "3.5.0" and python_version >= "3.6" and platform_system == "Windows" or python_version >= "3.7" and python_full_version < "3.0.0" and platform_system == "Windows" or python_version >= "3.7" and platform_system == "Windows" and python_full_version >= "3.5.0"
1010
colorcet==2.0.6; python_version >= "2.7"
11-
cycler==0.10.0; python_version >= "3.7"
1211
dask==2021.9.1; python_version >= "3.7" or python_version >= "3.7"
1312
datashader==0.13.0; python_version >= "2.7"
1413
datashape==0.5.2; python_version >= "2.7"
@@ -18,14 +17,12 @@ fsspec==2021.10.0; python_version >= "3.7"
1817
geoviews==1.9.2; python_version >= "3.7"
1918
heapdict==1.0.1; python_version >= "3.7"
2019
holoviews==1.14.6; python_version >= "2.7"
21-
idna==3.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6"
20+
idna==3.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6"
2221
jinja2==3.0.2; python_version >= "3.7" or python_version >= "3.7"
23-
kiwisolver==1.3.2; python_version >= "3.7"
2422
llvmlite==0.36.0; python_version >= "3.6" and python_version < "3.10"
2523
locket==0.2.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7"
2624
markdown==3.3.4; python_version >= "3.6"
2725
markupsafe==2.0.1; python_version >= "3.7"
28-
matplotlib==3.4.3; python_version >= "3.7"
2926
msgpack==1.0.2; python_version >= "3.7"
3027
multipledispatch==0.6.0; python_version >= "2.7"
3128
netcdf4==1.5.7
@@ -42,7 +39,7 @@ pyct==0.4.8; python_version >= "2.7"
4239
pyparsing==2.4.7; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7"
4340
pyproj==3.2.1; python_version >= "3.7"
4441
pyshp==2.1.3; python_version >= "3.7"
45-
python-dateutil==2.8.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "2.7" or python_full_version >= "3.7.1" and python_version >= "2.7" or python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7"
42+
python-dateutil==2.8.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "2.7" or python_full_version >= "3.7.1" and python_version >= "2.7"
4643
pytz==2021.3; python_full_version >= "3.7.1" and python_version >= "2.7"
4744
pyviz-comms==2.1.0; python_version >= "2.7"
4845
pyyaml==5.4.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.7"
@@ -51,7 +48,7 @@ ruyaml==0.20.0; python_version >= "3.6"
5148
scipy==1.7.1; python_version >= "3.7" and python_version < "3.10"
5249
setuptools==58.2.0; python_version >= "3.6" and python_version < "3.10" or python_version >= "3.6" or python_version >= "3.7"
5350
shapely==1.7.1; python_version >= "3.7"
54-
six==1.16.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6" or python_full_version >= "3.7.1" and python_version >= "2.7" or python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "2.7" or python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7"
51+
six==1.16.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6" or python_full_version >= "3.7.1" and python_version >= "2.7" or python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "2.7"
5552
sortedcontainers==2.4.0; python_version >= "3.7"
5653
tblib==1.7.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.5.0"
5754
toolz==0.11.1; python_version >= "3.7" or python_version >= "3.7"

thalassa/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
from .utils import open_dataset
44
from .utils import reload
5+
from .visuals import get_max_elevation
6+
from .visuals import get_tiles
57
from .visuals import get_trimesh
6-
from .visuals import get_wireframe_and_max_elevation
8+
from .visuals import get_wireframe
79

810

911
__all__: list[str] = [
1012
"open_dataset",
1113
"reload",
1214
"get_trimesh",
13-
"get_wireframe_and_max_elevation",
15+
"get_tiles",
16+
"get_wireframe",
17+
"get_max_elevation",
1418
]

thalassa/utils.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
logger = logging.getLogger(__name__)
1313

1414

15-
def open_dataset(path: str | pathlib.Path) -> xr.Dataset:
15+
def open_dataset(path: str | pathlib.Path, load: bool = False) -> xr.Dataset:
1616
path = pathlib.Path(path)
1717
if path.suffix == ".nc":
1818
ds = xr.open_dataset(path, mask_and_scale=True)
@@ -21,6 +21,9 @@ def open_dataset(path: str | pathlib.Path) -> xr.Dataset:
2121
# TODO: extend with GeoTiff, Grib etc
2222
else:
2323
raise ValueError(f"Don't know how to handle this: {path}")
24+
if load:
25+
# load dataset to memory
26+
ds.load()
2427
return ds
2528

2629

0 commit comments

Comments
 (0)