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
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Update example Miniforge version to 25.3.0-3
- Update example Miniforge version to 25.3.1-0
- Update example Python version to 3.13
- Re-enable `basemap` installation by default
- This is now possible as `basemap` has been updated to support `numpy` v2
- Rename `always_circular_stereo.py` to `cartopy_example.py`
- Enable TensorFlow installation for Python 3.13
- This is now possible as TensorFlow has been updated to support Python 3.13
- Moved `rasterio` to be a Conda package instead of Pip
- This is because `contextily` (a Conda package) depends on `rasterio` and it is better to have both installed via the same package manager

### Added

- Explicit Conda Packages
- contextily
- Explicit Pip Packages
- nco
- cdo
- ecmwf-opendata
- Add new pytorch test

### Removed

- Removed `sqlite` fix as it doesn't seem needed anymore for `ipython`

### Deprecated

## [24.11.3] - 2025-03-03
Expand Down
16 changes: 5 additions & 11 deletions install_miniforge.bash
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fi
# -----

EXAMPLE_PY_VERSION="3.13"
EXAMPLE_MINI_VERSION="25.3.0-3"
EXAMPLE_MINI_VERSION="25.3.1-0"
EXAMPLE_INSTALLDIR="/opt/GEOSpyD"
EXAMPLE_DATE=$(date +%F)
usage() {
Expand Down Expand Up @@ -603,9 +603,7 @@ $PACKAGE_INSTALL earthaccess

$PACKAGE_INSTALL uxarray

# We seem to need to require sqlite 3.48.0 *exactly* for ipython3
# NOTE: This might need to be revisited in the next version
$PACKAGE_INSTALL sqlite"==3.48.0"
$PACKAGE_INSTALL rasterio contextily

# Only install pythran on linux. On mac it brings in an old clang
if [[ $MINIFORGE_ARCH == Linux ]]
Expand Down Expand Up @@ -649,16 +647,11 @@ $PACKAGE_INSTALL -c conda-forge/label/renamed nc_time_axis
PIP_INSTALL="$MINIFORGE_ENVDIR/bin/$PYTHON_EXEC -m pip install"
PIP_UNINSTALL="$MINIFORGE_ENVDIR/bin/$PYTHON_EXEC -m pip uninstall -y"

$PIP_INSTALL PyRTF3 pipenv pymp-pypi rasterio h5py
$PIP_INSTALL PyRTF3 pipenv pymp-pypi h5py
$PIP_INSTALL pycircleci metpy siphon questionary xgrads
$PIP_INSTALL ruamel.yaml
$PIP_INSTALL xgboost
# At the moment tensorflow does not support Python 3.13
# See https://github.com/tensorflow/tensorflow/issues/78774
if [[ $PYTHON_VER_WITHOUT_DOT -lt 313 ]]
then
$PIP_INSTALL tensorflow evidential-deep-learning silence_tensorflow
fi
$PIP_INSTALL tensorflow evidential-deep-learning silence_tensorflow
$PIP_INSTALL torch
$PIP_INSTALL yaplon
$PIP_INSTALL lxml
Expand All @@ -671,6 +664,7 @@ $PIP_INSTALL Flask
$PIP_INSTALL goes2go
$PIP_INSTALL nco
$PIP_INSTALL cdo
$PIP_INSTALL ecmwf-opendata

# some packages require a Fortran compiler. This sometimes isn't available
# on macs (though usually is)
Expand Down
45 changes: 45 additions & 0 deletions tests/torch_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-

import torch
import math


dtype = torch.float
device = torch.device("cpu")
# device = torch.device("cuda:0") # Uncomment this to run on GPU

# Create random input and output data
x = torch.linspace(-math.pi, math.pi, 2000, device=device, dtype=dtype)
y = torch.sin(x)

# Randomly initialize weights
a = torch.randn((), device=device, dtype=dtype)
b = torch.randn((), device=device, dtype=dtype)
c = torch.randn((), device=device, dtype=dtype)
d = torch.randn((), device=device, dtype=dtype)

learning_rate = 1e-6
for t in range(2000):
# Forward pass: compute predicted y
y_pred = a + b * x + c * x ** 2 + d * x ** 3

# Compute and print loss
loss = (y_pred - y).pow(2).sum().item()
if t % 100 == 99:
print(t, loss)

# Backprop to compute gradients of a, b, c, d with respect to loss
grad_y_pred = 2.0 * (y_pred - y)
grad_a = grad_y_pred.sum()
grad_b = (grad_y_pred * x).sum()
grad_c = (grad_y_pred * x ** 2).sum()
grad_d = (grad_y_pred * x ** 3).sum()

# Update weights using gradient descent
a -= learning_rate * grad_a
b -= learning_rate * grad_b
c -= learning_rate * grad_c
d -= learning_rate * grad_d


print(f'Result: y = {a.item()} + {b.item()} x + {c.item()} x^2 + {d.item()} x^3')