Skip to content

Instantly share code, notes, and snippets.

@abkfenris
abkfenris / xarray_pointwise_indexing.ipynb
Created September 19, 2023 18:00
Pointwise Indexing with Xarray
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abkfenris
abkfenris / xarray-fmrc.md
Last active January 4, 2023 04:35
Xarray-FMRC

Xarray-FMRC

Xarray-FMCR uses Xarray datatrees to provide a standard in-memory and storage representation of Forecast Model Run Collections that can then be access via the various forecast views (best estimate/constant offset/constant time/model run).

def from_model_runs(datasets: dict[str | datetime.datetime | pd.Timestamp, xr.Dataset] | Iterable[xr.dataset]) -> datatree.DataTree:
    """
    From a collection of xarray datasets, assemble a datatree of forecasts

    If datasets contain a single length dimension of `forecast_reference_time`, or an attribute as such, they can be passed in as an `Iterable`, otherwise a dictionary mapping `forecast_reference_time` to datasets can be passed in. Dimensions other than time are expected to match.
@abkfenris
abkfenris / Dockerfile
Created April 27, 2022 19:36
Dockerfile with buildkit cache
#syntax=docker/dockerfile:1.3
FROM mambaorg/micromamba:0.21.2@sha256:27cc1034175f16df27d48a3fff8e3beab87b1c22a9c4e369a05a9125e993404b
ENV PYTHON_USER neracoos
ENV HOME /home/${PYTHON_USER}
RUN mkdir ${HOME}
WORKDIR ${HOME}
@abkfenris
abkfenris / dynamic_xpublish.py
Created April 26, 2022 22:25
Dynamic xpublish
import fsspec
import requests
import xarray as xr
import xpublish
from xpublish import rest
recipe_runs_url = "https://api.pangeo-forge.org/recipe_runs/"
@abkfenris
abkfenris / fsspec_resource.py
Created April 6, 2022 14:37
Fsspec context manager and dagster resource
import os
from tempfile import TemporaryDirectory
from dagster import (
resource,
EventMetadata,
EventMetadataEntry,
Field,
Noneable,
)
pandas
xarray
censusdata
@abkfenris
abkfenris / smalls_flows.ipynb
Created February 8, 2021 20:30
Smalls to the Wall flows
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abkfenris
abkfenris / run3.ipynb
Last active October 18, 2019 19:05
ROMS exploration
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abkfenris
abkfenris / MiddleForkLotteryStats.ipynb
Created January 29, 2018 23:14
Middle Fork Lottery Stats
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.