Skip to content

Instantly share code, notes, and snippets.

View scottstanie's full-sized avatar

Scott Staniewicz scottstanie

View GitHub Profile
@scottstanie
scottstanie / create-water-mask.py
Created September 23, 2025 19:19
Create a water mask in EPSG:4326 using `esa_world_cover_2021` imagery
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "tile-mate",
# "tyro",
# ]
# ///
"""Create a water mask in EPSG:4326 using `esa_world_cover_2021` imagery.
Examples
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "numpy",
# "pyproj",
# "rioxarray",
# "tyro",
# ]
# ///
"""Stand-alone plate-motion utilities and CLI.
@scottstanie
scottstanie / build_virtual_reference.py
Last active September 8, 2025 16:35
Create a reference parquet file for one OPERA DISP-S1 frame
#!/usr/bin/env python
import argparse
import multiprocessing
import warnings
import xarray as xr
from dask import compute, delayed
from dask.distributed import Client
from obstore.store import S3Store
@scottstanie
scottstanie / create-disp-s1-subset.sh
Last active June 26, 2025 22:37
Download and reformat OPERA DISP-S1 data
#!/bin/bash
set -eo pipefail
# Go to https://conda-forge.org/download/ and download mamba the installer
mamba create -n opera-utils-env pip scipy opera-utils
# (will be unnecessary once version rolls into conda-forge from pypi)
mamba run -n opera-utils-env pip install "opera-utils[disp]>=0.23.3"
# Small machine: use only 4 workers
# Large: can use more
#!/usr/bin/bash
set -e
# uv can be set up with:
# curl -LsSf https://astral.sh/uv/install.sh | sh
# Credientials must be set as AWS_* env vars, or with ~/.netrc, or with EARTHDATA_USERNAME and EARTHDATA_PASSWORD
uvx --with "rasterio,opera-utils[disp]>=0.23.1" \
@scottstanie
scottstanie / plot-disp-s1-priority-frames.ipynb
Last active April 11, 2025 17:49
Plot the DISP-S1 frame priorities
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python
# /// script
# dependencies = ["pillow", "numpy", "networkx", "scikit-image", "tyro"]
# ///
from pathlib import Path
import networkx as nx
import numpy as np
import tyro
from numpy.typing import ArrayLike
@scottstanie
scottstanie / download_s1_safe.py
Last active February 14, 2025 21:46
Download a list of specific Sentinel-1 granuale from copernicus dataspace
#!/usr/bin/env python
# /// script
# dependencies = ["requests", "tqdm"]
# ///
"""Download Sentinel-1 SAFE files from Copernicus Dataspace."""
import sys
from netrc import netrc
from pathlib import Path
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@scottstanie
scottstanie / export_to_qgis.py
Last active February 6, 2025 01:57
Export dolphin, or DISP, time series rasters to a GeoParquet format ingestible by QGIS
#!/usr/bin/env python3
# /// script
# dependencies = ["geopandas", "rioxarray", "tyro", "opera_utils"]
# ///
"""Create a GeoParquet file from multi-date InSAR displacement GeoTIFFs.
Optionally mask by similarity and coherence thresholds.
Example CLI usage (with tyro):