Skip to content

Commit aa95293

Browse files
committed
Merge branch 'main' of github.com:ACCESS-NRI/visualisations
2 parents 0843103 + 7e9a7f9 commit aa95293

10 files changed

+30
-19
lines changed

.conda/meta.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package:
66
version: "{{ version }}"
77

88
source:
9-
#url: "https://pypi.io/packages/source/a/access-nri-intake/accessvis-{{ version }}.tar.gz"
9+
url: "https://pypi.io/packages/source/a/accessvis/accessvis-{{ version }}.tar.gz"
1010

1111
build:
1212
noarch: python
@@ -39,4 +39,4 @@ about:
3939

4040
extra:
4141
recipe-maintainers:
42-
- rbeucher
42+
- rbeucher

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ notes
55
build
66
__pycache__
77
vid_old
8-
src/accessvis/data
98
src/accessvis.egg-info
109

1110
venv/
@@ -14,7 +13,6 @@ ENV/
1413
.env
1514
.idea
1615

17-
*.png
1816
*.jpg
1917
*.jpeg
2018
*.mp4

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ git tag v1.2.0
3333
git push origin v1.2.0
3434
```
3535

36+
### Config and DATA caching
37+
38+
By default, `ACCESS-Vis` caches its data in different locations depending on the platform. On NCI Gadi, data are stored in `/scratch/$PROJECT/$USER/.accessvis`, while on other platforms, the data are cached in `$HOME/.accessvis`. However, users can customize this path by setting the `ACCESSVIS_DATA_DIR` environment variable to a directory of their choice.
39+
3640

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ dependencies = [
101101
[tool.setuptools]
102102
# If there are data files included in your packages that need to be
103103
# installed, specify them here.
104-
package-data = {"textures" = ["*.png"], "shaders" = ["*.frag", "*.vert"]}
104+
package-data = {"textures" = ["data/*.png"], "shaders" = ["data/*.frag", "data/*.vert"]}
105105

106106
[build-system]
107107
build-backend = "setuptools.build_meta"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/accessvis/earth.py

+23-14
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
import py360convert
55
from PIL import Image
66
import os
7-
import sys
87
Image.MAX_IMAGE_PIXELS = None
98
from pathlib import Path
10-
import math
119
import datetime
1210
import lavavu
1311
import gzip
@@ -18,7 +16,7 @@
1816
import matplotlib
1917
import quaternion as quat
2018

21-
from utils import is_ipython, is_notebook, download, pushd
19+
from utils import is_notebook, download, pushd
2220

2321
MtoLL = 1.0/111133 #Rough conversion from metres to lat/lon units
2422

@@ -34,13 +32,24 @@ class Settings():
3432

3533
#Where data is stored, defaults to module dir unless on gadi
3634
INSTALL_PATH = Path(__file__).parents[0]
37-
if 'gadi.nci.org.au' in os.getenv('HOSTNAME', ''):
38-
DATA_PATH = Path('/g/data/nf33/public/data/accessvis')
35+
36+
# Default to non-headless mode
37+
HEADLESS = False
38+
# Check if the data directory is specified in environment variables
39+
DATA_PATH = os.getenv("ACCESSVIS_DATA_DIR")
40+
41+
# Check if running on 'gadi.nci.org.au'
42+
hostname = os.getenv('HOSTNAME', '')
43+
if not DATA_PATH and 'gadi.nci.org.au' in hostname:
44+
project = os.getenv("PROJECT")
45+
user = os.getenv("USER")
46+
DATA_PATH = Path(f'/scratch/{project}/{user}/.accessvis')
3947
HEADLESS = True
4048
else:
41-
DATA_PATH = INSTALL_PATH / 'data'
42-
HEADLESS = False
49+
DATA_PATH = Path.home() / ".accessvis"
4350

51+
os.makedirs(DATA_PATH, exist_ok=True)
52+
4453
GEBCO_PATH = DATA_PATH / 'gebco' / 'GEBCO_2020.nc'
4554

4655
def __repr__(self):
@@ -310,7 +319,7 @@ def sphere_mesh(radius=1.0, quality=256, cache=True):
310319
lv = get_viewer()
311320
tris0 = lv.spheres("sphere", scaling=radius, segments=quality, colour="grey", vertices=[0,0,0], fliptexture=False)
312321
tris0['rotate'] = [0,-90,0] #This rotates the sphere coords to align with [0,360] longitude texture
313-
tris0['texture'] = 'blank.png' #Need an initial texture or texcoords will not be generated
322+
tris0['texture'] = 'data/blank.png' #Need an initial texture or texcoords will not be generated
314323
tris0['renderer'] = 'sortedtriangles'
315324
lv.render()
316325

@@ -558,12 +567,12 @@ def plot_region(lv=None, cropbox=None, vertical_exaggeration=10, texture='bluema
558567
'''
559568
#TODO: wave shader etc for regional sections
560569
if waves:
561-
uniforms["wavetex"] = f"{settings.INSTALL_PATH}/sea-water-1024x1024_gs.png"
562-
uniforms["wavenormal"] = f"{settings.INSTALL_PATH}/sea-water_normals.png"
570+
uniforms["wavetex"] = f"{settings.INSTALL_PATH}/data/sea-water-1024x1024_gs.png"
571+
uniforms["wavenormal"] = f"{settings.INSTALL_PATH}/data/sea-water_normals.png"
563572
uniforms["waves"] = True;
564573
565574
if shaders is None:
566-
shaders = [f'{settings.INSTALL_PATH}/earth_shader.vert', f'{settings.INSTALL_PATH}/earth_shader.frag']
575+
shaders = [f'{settings.INSTALL_PATH}/data/earth_shader.vert', f'{settings.INSTALL_PATH}/data/earth_shader.frag']
567576
'''
568577

569578
#Split kwargs into global props, object props and uniform values
@@ -691,8 +700,8 @@ def plot_earth(lv=None, radius=6.371, vertical_exaggeration=10, texture='bluemar
691700
texture = '{basedir}/relief/cubemap_{texres}/{face}_relief_{texres}.png'
692701

693702
#Waves - load textures as shared
694-
lv.texture("wavetex", f"{settings.INSTALL_PATH}/sea-water-1024x1024_gs.png")
695-
lv.texture("wavenormal", f"{settings.INSTALL_PATH}/sea-water_normals.png")
703+
lv.texture("wavetex", f"{settings.INSTALL_PATH}/data/sea-water-1024x1024_gs.png")
704+
lv.texture("wavenormal", f"{settings.INSTALL_PATH}/data/sea-water_normals.png")
696705
#Need to set the property too or will not know to load the texture
697706
if waves is None: waves = False
698707
uniforms["wavetex"] = ""
@@ -707,7 +716,7 @@ def plot_earth(lv=None, radius=6.371, vertical_exaggeration=10, texture='bluemar
707716
uniforms["heightmax"] = hrange[1];
708717

709718
if shaders is None:
710-
shaders = [f'{settings.INSTALL_PATH}/earth_shader.vert', f'{settings.INSTALL_PATH}/earth_shader.frag']
719+
shaders = [f'{settings.INSTALL_PATH}/data/earth_shader.vert', f'{settings.INSTALL_PATH}/data/earth_shader.frag']
711720

712721
#Split kwargs into global props, object props and uniform values
713722
objargs = {}

0 commit comments

Comments
 (0)