Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ requirements:
- xarray
- tqdm
- netcdf4
- lavavu
- lavavu-osmesa
- moderngl


Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ jobs:

- name: Run tests
shell: bash -l {0}
env:
LV_CONTEXT: moderngl
LV_ECHO_FAIL: 1
LV_ARGS: -v
run: python -m pytest -s .

- name: Upload code coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.codecov_token }}
files: ./coverage.xml
files: ./coverage.xml
3 changes: 2 additions & 1 deletion .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ jobs:
LV_CONTEXT: moderngl
LV_ECHO_FAIL: 1
LV_ARGS: -v
ACCESSVIS_DATA_DIR: /media/data/accessvis
run: |
python -m pip install moderngl freezegun
git clone -b tests --depth 1 https://github.com/ACCESS-NRI/ACCESS-Visualisation-Recipes.git
git clone --depth 1 https://github.com/ACCESS-NRI/ACCESS-Visualisation-Recipes.git
cd ACCESS-Visualisation-Recipes/tests
python tests.py thumbs

3 changes: 2 additions & 1 deletion ci/environment-3.11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies:
- xarray
- pip
- pip:
- lavavu
- lavavu-osmesa
- moderngl
- codecov
- pytest-cov
3 changes: 2 additions & 1 deletion ci/environment-3.12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies:
- xarray
- pip
- pip:
- lavavu
- lavavu-osmesa
- moderngl
- codecov
- pytest-cov
3 changes: 2 additions & 1 deletion ci/environment-3.13.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies:
- xarray
- pip
- pip:
- lavavu
- lavavu-osmesa
- moderngl
- codecov
- pytest-cov
8 changes: 4 additions & 4 deletions src/accessvis/earth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import py360convert
import quaternion as quat
import xarray as xr
from PIL import Image, ImageFile
from PIL import Image

from .utils import download, is_notebook, pushd

Expand Down Expand Up @@ -426,7 +426,7 @@ def crop_img_uv(img, cropbox):

return arr

elif isinstance(img, ImageFile.ImageFile):
elif isinstance(img, Image.Image):
crop_regions = []
if u0 < 0: # wraps around the left side
crop_regions.append(
Expand Down Expand Up @@ -1419,7 +1419,7 @@ def vec_rotate(v, theta, axis):
v : list/numpy.ndarray
The 3 component vector
theta : float
Angle in degrees
Angle in radians
axis : list/numpy.ndarray
The 3 component axis of rotation

Expand Down Expand Up @@ -2418,7 +2418,7 @@ def plot_vectors_xr(
alt = max_alt

# Basis vector directions, on the 3d model.
normal = latlon_normal_vector(lat, lon)
normal = latlon_normal_vector(lat=lat, lon=lon)
east = latlon_vector_to_east(lat=lat, lon=lon)
north = latlon_vector_to_north(lat=lat, lon=lon)

Expand Down
9 changes: 7 additions & 2 deletions src/accessvis/widgets/calendar_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def _make_mpl(self):
ax.set_xticklabels(MONTH, size=20)
ax.spines["polar"].set_color(self.text_colour)

ax.set_ylim([0, 10])

# Make Colours:
ax.bar(x=0, height=10, width=np.pi * 2, color="black")
for i in range(12):
Expand Down Expand Up @@ -90,7 +92,7 @@ def _update_mpl(self, fig, ax, date: datetime.datetime = None, show_year=True):
position,
0,
0,
8.5,
7.5,
facecolor="#fff",
width=0.1,
head_length=2,
Expand All @@ -103,4 +105,7 @@ def _reset_mpl(self, fig, ax, **kwargs):
"""
fig.suptitle("")
if self.arrow is not None:
self.arrow.remove()
try:
self.arrow.remove()
except ValueError:
pass # already removed
11 changes: 9 additions & 2 deletions src/accessvis/widgets/season_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def _make_mpl(self):
ax.set_xticklabels(MONTH, size=20)
ax.spines["polar"].set_color(self.text_colour)

ax.set_ylim([0, 10])

# Colour background based on time of year:
dec22_doy = datetime.date(2001, 12, 22).timetuple().tm_yday - 1
dec22 = np.pi * 2.0 * dec22_doy / 365 # summer solstice
Expand All @@ -76,6 +78,8 @@ def _make_mpl(self):
R, T = np.meshgrid(r, theta)
ax.pcolormesh(T, R, T, cmap=cmap, shading="gouraud")

self._update_mpl(fig=fig, ax=ax)

return fig, ax

def _update_mpl(self, fig, ax, date: datetime.datetime = None, show_year=True):
Expand Down Expand Up @@ -106,7 +110,7 @@ def _update_mpl(self, fig, ax, date: datetime.datetime = None, show_year=True):
position,
0,
0,
8.5,
7.5, # length of arrow
facecolor="#fff",
width=0.1,
head_length=2,
Expand All @@ -119,4 +123,7 @@ def _reset_mpl(self, fig, ax, **kwargs):
"""
fig.suptitle("")
if self.arrow is not None:
self.arrow.remove()
try:
self.arrow.remove()
except ValueError:
pass # already removed
11 changes: 9 additions & 2 deletions src/accessvis/widgets/widget_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _make_pixels(self, **kwargs):

canvas = self.fig.canvas
canvas.draw()
pixels = np.asarray(canvas.buffer_rgba())
pixels = np.asarray(canvas.buffer_rgba(), copy=True)

self._reset_mpl(fig=self.fig, ax=self.ax, **kwargs)

Expand All @@ -218,4 +218,11 @@ def list_widgets():
-------
List[String]: The name of the classes.
"""
return [cls.__name__ for cls in Widget.__subclasses__()]

def get_subclasses(cls):
# From https://stackoverflow.com/questions/3862310/how-to-find-all-the-subclasses-of-a-class-given-its-name
for subclass in cls.__subclasses__():
yield from get_subclasses(subclass)
yield subclass.__name__

return [Widget.__name__] + list(get_subclasses(Widget))
Loading
Loading