SWECAST (Snow Water Equivalent Forecasting)
Micromamba environment
PyPI TensorFlow
Creating a new micromamba environment
# install micromamba
curl -L https://micro.mamba.pm/install.sh | env \
BIN_FOLDER="$HOME/local/bin" \
PREFIX_LOCATION="$HOME/opt/micromamba" \
sh
# create an alias
echo "alias mm=micromamba" >> ~/.bashrc
# source micromamba
. ~/.bashrc
mkdir -p ~/work/projects/swecast
cd ~/work/projects/swecast
git clone git@github.com:hydrocslab/swecast.git
# the latest tensorflow supports python 3.13
mm create -n swecast -y python=3.13
mm activate swecast
# add cuda lib paths to LD_LIBRARY_PATH automatically when activating the
# environment
mkdir -p $CONDA_PREFIX/etc/conda/activate.d
cat > $CONDA_PREFIX/etc/conda/activate.d/tensorflow-cuda.sh <<'EOF'
export _OLD_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$(python - <<'PY'
import site
from pathlib import Path
for sp in site.getsitepackages():
nvidia = Path(sp) / "nvidia"
if nvidia.exists():
for lib in nvidia.glob("*/lib"):
print(lib, end=":")
PY
)$LD_LIBRARY_PATH"
EOF
mkdir -p $CONDA_PREFIX/etc/conda/deactivate.d
cat > $CONDA_PREFIX/etc/conda/deactivate.d/tensorflow-cuda.sh <<'EOF'
export LD_LIBRARY_PATH="$_OLD_LD_LIBRARY_PATH"
EOF
pip install tensorflow[and-cuda] rasterio shapely xarray scipy netCDF4 matplotlib rioxarray tomli_w
. $CONDA_PREFIX/etc/conda/activate.d/tensorflow-cuda.sh
# make sure GPU is recognized
python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
mm deactivate
Running the example
mm activate swecast
cd ~/work/projects/swecast
mkdir -p runs/example
cd runs/example
python ../../swecast/example.py
mm deactivate
Installation
For now, install locally:
pip install -e .
This will change once published to PyPI.
Authentication
swecast requires access to external data services. You must set your Earthdata credentials as environment variables before running the module:
export EARTHDATA_USERNAME='your_earthdata_username'
export EARTHDATA_PASSWORD='your_earthdata_password'
Without these, data downloads will fail.
Quick start
import swecast
from datetime import date
from swecast import Manifest, build_stacks, build_swe_stacks
from swecast import fetch_stations, stations_to_csv, fill_stacks
manifest = Manifest(
start=date(2001, 1, 1),
end=date(2002, 1, 1),
bbox=(-121.9, 36.08, -109, 41.98),
)
# Build general data stacks
outputs = build_stacks(manifest, output_dir="./output")
# Build SWE stacks
swe_outputs = build_swe_stacks(manifest, output_dir="./output")
# Gap-fill SWE stacks
fill_stacks(swe_outputs)
Core concepts
Manifest
The Manifest object defines the scope of your data processing job:
- start / end: Date range for the dataset
- bbox: Geographic bounding box
(min_lon, min_lat, max_lon, max_lat)
Main functions
build_stacks(manifest, output_dir)
Builds general geospatial data stacks for the given manifest.
build_swe_stacks(manifest, output_dir)
Builds Snow Water Equivalent (SWE) stacks.
fill_stacks(stacks)
Performs gap-filling on SWE stacks to handle missing data.
fetch_stations(...)
Fetches station metadata (usage still evolving).
stations_to_csv(...)
Exports station data to CSV format.
Output
All outputs are written to the specified output_dir. The structure and formats may change as the project evolves.
Release files for swecast 0.1.0.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| swecast-0.1.0.post1.tar.gz | 40.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| swecast-0.1.0.post1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 83.7 kB
Release files / swecast-0.1.0.post1.tar.gz
| Download URL | swecast-0.1.0.post1.tar.gz |
|---|---|
| Size | 40.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1143981bcfdf1e41a1274f3e29a8712f497eb9d3b2672234e7fd30555e952162
|
|
BLAKE2b-256 checksum How to use checksums |
41f6bec634572f63d3c73cf31cb5d491aeb0551d6dc02f448325cbbcae28df35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.11
|
Release files / swecast-0.1.0.post1-py3-none-any.whl
| Download URL | swecast-0.1.0.post1-py3-none-any.whl |
|---|---|
| Size | 43.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c538666290d481a4dc704fb0777bfdee621faed3477ec9cf1f1ea4c9594fe6a
|
|
BLAKE2b-256 checksum How to use checksums |
fb3ed733aa59967718a90f0d15adb223b3e5f058aa91debf34185275db9f6434
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.11
|