Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ACCESS-NRI/visualisations
Browse files Browse the repository at this point in the history
  • Loading branch information
rbeucher committed Oct 23, 2024
2 parents 0843103 + 7e9a7f9 commit aa95293
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package:
version: "{{ version }}"

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

build:
noarch: python
Expand Down Expand Up @@ -39,4 +39,4 @@ about:

extra:
recipe-maintainers:
- rbeucher
- rbeucher
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ notes
build
__pycache__
vid_old
src/accessvis/data
src/accessvis.egg-info

venv/
Expand All @@ -14,7 +13,6 @@ ENV/
.env
.idea

*.png
*.jpg
*.jpeg
*.mp4
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ git tag v1.2.0
git push origin v1.2.0
```

### Config and DATA caching

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.


2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ dependencies = [
[tool.setuptools]
# If there are data files included in your packages that need to be
# installed, specify them here.
package-data = {"textures" = ["*.png"], "shaders" = ["*.frag", "*.vert"]}
package-data = {"textures" = ["data/*.png"], "shaders" = ["data/*.frag", "data/*.vert"]}

[build-system]
build-backend = "setuptools.build_meta"
Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
37 changes: 23 additions & 14 deletions src/accessvis/earth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import py360convert
from PIL import Image
import os
import sys
Image.MAX_IMAGE_PIXELS = None
from pathlib import Path
import math
import datetime
import lavavu
import gzip
Expand All @@ -18,7 +16,7 @@
import matplotlib
import quaternion as quat

from utils import is_ipython, is_notebook, download, pushd
from utils import is_notebook, download, pushd

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

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

#Where data is stored, defaults to module dir unless on gadi
INSTALL_PATH = Path(__file__).parents[0]
if 'gadi.nci.org.au' in os.getenv('HOSTNAME', ''):
DATA_PATH = Path('/g/data/nf33/public/data/accessvis')

# Default to non-headless mode
HEADLESS = False
# Check if the data directory is specified in environment variables
DATA_PATH = os.getenv("ACCESSVIS_DATA_DIR")

# Check if running on 'gadi.nci.org.au'
hostname = os.getenv('HOSTNAME', '')
if not DATA_PATH and 'gadi.nci.org.au' in hostname:
project = os.getenv("PROJECT")
user = os.getenv("USER")
DATA_PATH = Path(f'/scratch/{project}/{user}/.accessvis')
HEADLESS = True
else:
DATA_PATH = INSTALL_PATH / 'data'
HEADLESS = False
DATA_PATH = Path.home() / ".accessvis"

os.makedirs(DATA_PATH, exist_ok=True)

GEBCO_PATH = DATA_PATH / 'gebco' / 'GEBCO_2020.nc'

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

Expand Down Expand Up @@ -558,12 +567,12 @@ def plot_region(lv=None, cropbox=None, vertical_exaggeration=10, texture='bluema
'''
#TODO: wave shader etc for regional sections
if waves:
uniforms["wavetex"] = f"{settings.INSTALL_PATH}/sea-water-1024x1024_gs.png"
uniforms["wavenormal"] = f"{settings.INSTALL_PATH}/sea-water_normals.png"
uniforms["wavetex"] = f"{settings.INSTALL_PATH}/data/sea-water-1024x1024_gs.png"
uniforms["wavenormal"] = f"{settings.INSTALL_PATH}/data/sea-water_normals.png"
uniforms["waves"] = True;
if shaders is None:
shaders = [f'{settings.INSTALL_PATH}/earth_shader.vert', f'{settings.INSTALL_PATH}/earth_shader.frag']
shaders = [f'{settings.INSTALL_PATH}/data/earth_shader.vert', f'{settings.INSTALL_PATH}/data/earth_shader.frag']
'''

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

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

if shaders is None:
shaders = [f'{settings.INSTALL_PATH}/earth_shader.vert', f'{settings.INSTALL_PATH}/earth_shader.frag']
shaders = [f'{settings.INSTALL_PATH}/data/earth_shader.vert', f'{settings.INSTALL_PATH}/data/earth_shader.frag']

#Split kwargs into global props, object props and uniform values
objargs = {}
Expand Down

0 comments on commit aa95293

Please sign in to comment.