SWECAST (Snow Water Equivalent Forecasting)
- Micromamba environment
- Installation
- Authentication
- Quick start
- Core concepts
- Main functions
- Output
- Development notes
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.
Development notes
- This project is actively under development
- Interfaces are not yet stable
Release files for swecast 0.1.0
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.tar.gz | 63.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| swecast-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 106.9 kB
Release files / swecast-0.1.0.tar.gz
| Download URL | swecast-0.1.0.tar.gz |
|---|---|
| Size | 63.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92ba9e07fe7b957bb8bf30412c7826915d19e591fd5222c44b1b79a123893ae7
|
|
BLAKE2b-256 checksum How to use checksums |
608b5946e1b0b96b3583a758671d0030692374966da93eb355f04dff8ab9447c
|
| 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-py3-none-any.whl
| Download URL | swecast-0.1.0-py3-none-any.whl |
|---|---|
| Size | 43.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8cfc6cc252bf55d68e7b71254ca2fdd0115fdc9ef675c0d3d9e1b7e792dc4ce
|
|
BLAKE2b-256 checksum How to use checksums |
bb72f5f031c81c8c7fe9f1729b3a6aa6e1fe391b5025ad3ca9bb1e9c61c2593a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.11
|