@@ -51,7 +51,7 @@ class Settings:
51
51
if envdir :
52
52
DATA_PATH = Path (envdir )
53
53
else :
54
- # Check if running on ' gadi.nci.org.au'
54
+ # Check if running on " gadi.nci.org.au"
55
55
if gadi :
56
56
# Use public shared data cache on gadi
57
57
DATA_PATH = Path ("/g/data/xp65/public/apps/access-vis-data" )
@@ -94,6 +94,11 @@ def get_viewer(*args, **kwargs):
94
94
# headless not required because always in headless mode
95
95
metadata .metadata ("lavavu" )
96
96
# Requires moderngl for EGL headless context
97
+ import moderngl
98
+
99
+ print (
100
+ moderngl .__file__
101
+ ) # If we don't use it the pre-commit will delete above
97
102
except (ImportError , metadata .PackageNotFoundError ):
98
103
settings .HEADLESS = False
99
104
@@ -216,7 +221,7 @@ def paste_image(fn, xpos, ypos, out):
216
221
# print(fn, col.shape)
217
222
xoff = xpos * col .shape [0 ]
218
223
yoff = ypos * col .shape [1 ]
219
- # print(f' {yoff}:{yoff+col.shape[1]}, {xoff}:{xoff+col.shape[0]}' )
224
+ # print(f" {yoff}:{yoff+col.shape[1]}, {xoff}:{xoff+col.shape[0]}" )
220
225
out [yoff : yoff + col .shape [1 ], xoff : xoff + col .shape [0 ]] = col
221
226
222
227
@@ -473,12 +478,12 @@ def cubemap_sphere_vertices(
473
478
and save the data for next time
474
479
hemisphere: str
475
480
Crop the data to show a single hemisphere
476
- 'N' = North polar
477
- 'S' = South polar
478
- 'EW' = Antimeridian at centre (Oceania/Pacific)
479
- 'WE' = Prime meridian at centre (Africa/Europe)
480
- 'E' = Eastern hemisphere - prime meridian to antimeridian (Indian ocean)
481
- 'W' = Western hemisphere - antimeridian to prime meridian (Americas)
481
+ "N" = North polar
482
+ "S" = South polar
483
+ "EW" = Antimeridian at centre (Oceania/Pacific)
484
+ "WE" = Prime meridian at centre (Africa/Europe)
485
+ "E" = Eastern hemisphere - prime meridian to antimeridian (Indian ocean)
486
+ "W" = Western hemisphere - antimeridian to prime meridian (Americas)
482
487
"""
483
488
if resolution is None :
484
489
resolution = settings .GRIDRES
@@ -592,12 +597,12 @@ def load_topography_cubemap(
592
597
Radius of the sphere, defaults to 6.371 Earth's approx radius in Mm
593
598
hemisphere: str
594
599
Crop the data to show a single hemisphere
595
- 'N' = North polar
596
- 'S' = South polar
597
- 'EW' = Antimeridian at centre (Oceania/Pacific)
598
- 'WE' = Prime meridian at centre (Africa/Europe)
599
- 'E' = Eastern hemisphere - prime meridian to antimeridian (Indian ocean)
600
- 'W' = Western hemisphere - antimeridian to prime meridian (Americas)
600
+ "N" = North polar
601
+ "S" = South polar
602
+ "EW" = Antimeridian at centre (Oceania/Pacific)
603
+ "WE" = Prime meridian at centre (Africa/Europe)
604
+ "E" = Eastern hemisphere - prime meridian to antimeridian (Indian ocean)
605
+ "W" = Western hemisphere - antimeridian to prime meridian (Americas)
601
606
"""
602
607
# Load detailed topo data
603
608
if resolution is None :
@@ -717,7 +722,7 @@ def plot_region(
717
722
uniforms["waves"] = True
718
723
719
724
if shaders is None:
720
- shaders = [f' {settings.INSTALL_PATH}/data/earth_shader.vert' , f' {settings.INSTALL_PATH}/data/earth_shader.frag' ]
725
+ shaders = [f" {settings.INSTALL_PATH}/data/earth_shader.vert" , f" {settings.INSTALL_PATH}/data/earth_shader.frag" ]
721
726
"""
722
727
723
728
# Split kwargs into global props, object props and uniform values
@@ -750,9 +755,9 @@ def plot_region(
750
755
# TODO: support cropping tiled high res blue marble textures
751
756
# Also download relief textures if not found or call process_bluemarble
752
757
# TODO2: write a process_relief function for splitting/downloading relief from Earth_Model.ipynb
753
- # colour_tex = f' {settings.DATA_PATH}/relief/4_no_ice_clouds_mts_16k.jpg'
758
+ # colour_tex = f" {settings.DATA_PATH}/relief/4_no_ice_clouds_mts_16k.jpg"
754
759
colour_tex = f"{ settings .DATA_PATH } /bluemarble/source_full/world.200412.3x21600x10800.jpg"
755
- # colour_tex = f' {settings.DATA_PATH}/landmask/world.oceanmask.21600x10800.png'
760
+ # colour_tex = f" {settings.DATA_PATH}/landmask/world.oceanmask.21600x10800.png"
756
761
uniforms ["bluemarble" ] = True
757
762
elif texture == "relief" :
758
763
colour_tex = f"{ settings .DATA_PATH } /relief/4_no_ice_clouds_mts_16k.jpg"
@@ -801,15 +806,15 @@ def plot_earth(
801
806
----------
802
807
texture: str
803
808
Path to textures, face label and texres will be applied with .format(), eg:
804
- texture=' path/{face}_mytexture_{texres}.png'
805
- with: texture.format(face='F' , texres=settings.TEXRES)
806
- to:' path/F_mytexture_1024.png'
809
+ texture=" path/{face}_mytexture_{texres}.png"
810
+ with: texture.format(face="F" , texres=settings.TEXRES)
811
+ to:" path/F_mytexture_1024.png"
807
812
radius: float
808
813
Radius of the sphere, defaults to 6.371 Earth's approx radius in Mm
809
814
vertical_exaggeration: number
810
815
Multiplier to topography/bathymetry height
811
816
texture: str
812
- Texture set to use, ' bluemarble' for the 2004 NASA satellite data, ' relief' for a basic relief map
817
+ Texture set to use, " bluemarble" for the 2004 NASA satellite data, " relief" for a basic relief map
813
818
or provide a custom set of textures using a filename template with the following variables, only face is required
814
819
{face} (F/R/B/L/U/D) {month} (name of month, capitialised) {texres} (2048/4096/8192/16384)
815
820
lighting: bool
@@ -818,9 +823,9 @@ def plot_earth(
818
823
Provide a datetime object to set the month for texture sets that vary over the year and time for
819
824
position of sun and rotation of earth when calculating sun light position
820
825
hour: int
821
- If not providing ' when' datetime, provide just the hour and minute
826
+ If not providing " when" datetime, provide just the hour and minute
822
827
minute: int
823
- If not providing ' when' datetime, provide just the hour and minute
828
+ If not providing " when" datetime, provide just the hour and minute
824
829
waves: bool
825
830
When plotting ocean as surface, set this to true to render waves
826
831
sunlight: bool
@@ -834,17 +839,17 @@ def plot_earth(
834
839
uniforms: dict
835
840
Provide a set of uniform variables, these can be used to pass data to a custom shader
836
841
shaders: list
837
- Provide a list of two custom shader file paths eg: [' vertex_shader.glsl', ' fragment_shader.glsl' ]
842
+ Provide a list of two custom shader file paths eg: [" vertex_shader.glsl", " fragment_shader.glsl" ]
838
843
background: str
839
844
Provide a background colour string, X11 colour name or hex RGB
840
845
hemisphere: str
841
846
Crop the data to show a single hemisphere
842
- 'N' = North polar
843
- 'S' = South polar
844
- 'EW' = Antimeridian at centre (Oceania/Pacific)
845
- 'WE' = Prime meridian at centre (Africa/Europe)
846
- 'E' = Eastern hemisphere - prime meridian to antimeridian (Indian ocean)
847
- 'W' = Western hemisphere - antimeridian to prime meridian (Americas)
847
+ "N" = North polar
848
+ "S" = South polar
849
+ "EW" = Antimeridian at centre (Oceania/Pacific)
850
+ "WE" = Prime meridian at centre (Africa/Europe)
851
+ "E" = Eastern hemisphere - prime meridian to antimeridian (Indian ocean)
852
+ "W" = Western hemisphere - antimeridian to prime meridian (Americas)
848
853
"""
849
854
if lv is None :
850
855
lv = get_viewer (
@@ -1027,7 +1032,7 @@ def update_earth_datetime(
1027
1032
obj = lv .objects [o ]
1028
1033
uniforms = obj ["uniforms" ]
1029
1034
1030
- # if not ' blendTex' in uniforms or uniforms[' blendTex' ] != texfn2:
1035
+ # if not " blendTex" in uniforms or uniforms[" blendTex" ] != texfn2:
1031
1036
if obj ["texture" ] != texfn :
1032
1037
obj ["texture" ] = texfn # Not needed, but set so can be checked above
1033
1038
obj .texture (texfn , flip = False )
@@ -1090,8 +1095,6 @@ def update_earth_values(lv, name="", flip=False, *args, **kwargs):
1090
1095
1091
1096
lv .render () # Required to render a frame which fixes texture glitch
1092
1097
1093
- # Load the texture arrays
1094
-
1095
1098
1096
1099
def vec_rotate (v , theta , axis ):
1097
1100
"""
@@ -1110,7 +1113,6 @@ def vec_rotate(v, theta, axis):
1110
1113
-------
1111
1114
numpy.ndarray: rotated 3d vector
1112
1115
"""
1113
- np .array ([0.0 ] + v )
1114
1116
rot_axis = np .array ([0.0 ] + axis )
1115
1117
axis_angle = (theta * 0.5 ) * rot_axis / np .linalg .norm (rot_axis )
1116
1118
@@ -1497,27 +1499,20 @@ def load_mask(res_y=None, masktype="watermask", cropbox=None):
1497
1499
https://neo.gsfc.nasa.gov/archive/bluemarble/bmng/landmask_new/
1498
1500
https://neo.gsfc.nasa.gov/archive/bluemarble/bmng/landmask/world.watermask.21600x21600.A1.png
1499
1501
1500
- masktype = ' oceanmask' / ' watermask'
1502
+ masktype = " oceanmask" / " watermask"
1501
1503
"""
1502
1504
if res_y is None :
1503
1505
res_y = settings .FULL_RES_Y
1504
1506
# Get the tiled high res images
1505
1507
os .makedirs (settings .DATA_PATH / "landmask/source_tiled" , exist_ok = True )
1506
- if (
1507
- len (
1508
- glob .glob (
1509
- f"{ settings .DATA_PATH } /landmask/source_tiled/world.{ masktype } .21600x21600.*.tif.gz"
1510
- )
1511
- )
1512
- < 8
1513
- ):
1508
+ filespec = f"{ settings .DATA_PATH } /landmask/source_tiled/world.{ masktype } .21600x21600.*.tif.gz"
1509
+ if len (glob .glob (filespec )) < 8 :
1514
1510
# Download tiles
1515
1511
for t in bm_tiles :
1516
1512
# https://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73967/world.200402.3x21600x21600.A1.jpg
1517
1513
url = f"https://neo.gsfc.nasa.gov/archive/bluemarble/bmng/landmask_new/world.{ masktype } .21600x21600.{ t } .tif.gz"
1518
1514
# print(url)
1519
1515
download (url , f"{ settings .DATA_PATH } /landmask/source_tiled" )
1520
- # print(filename)
1521
1516
1522
1517
# Calculate full image res to use for specified TEXRES
1523
1518
ffn = f"{ settings .DATA_PATH } /landmask/world.{ masktype } .{ 2 * res_y } x{ res_y } .png"
@@ -1529,12 +1524,8 @@ def load_mask(res_y=None, masktype="watermask", cropbox=None):
1529
1524
for t in bm_tiles :
1530
1525
x = ord (t [0 ]) - ord ("A" )
1531
1526
y = 1 if int (t [1 ]) == 2 else 0
1532
- paste_image (
1533
- f"{ settings .DATA_PATH } /landmask/source_tiled/world.{ masktype } .21600x21600.{ t } .tif.gz" ,
1534
- x ,
1535
- y ,
1536
- mask ,
1537
- )
1527
+ filespec = f"{ settings .DATA_PATH } /landmask/source_tiled/world.{ masktype } .21600x21600.{ t } .tif.gz"
1528
+ paste_image (filespec , x , y , mask )
1538
1529
1539
1530
# Save full mask in various resolutions
1540
1531
for res in [(86400 , 43200 ), (43200 , 21600 ), (21600 , 10800 )]:
@@ -1782,7 +1773,7 @@ def process_gebco(overwrite=False, redownload=False):
1782
1773
#TODO2: move subsampling and export functions from GEBCO.ipynb to this module
1783
1774
url = f"https://github.com/ACCESS-NRI/visualisations/releases/download/v0.0.1/gebco_cubemap_{settings.GRIDRES}.npz"
1784
1775
raise(Exception("TODO: upload gebco cubemap data to github releases!"))
1785
- filename = utils.download(url, ' ./data/gebco' )
1776
+ filename = utils.download(url, " ./data/gebco" )
1786
1777
"""
1787
1778
1788
1779
# Attempt to load full GEBCO
0 commit comments