Skip to content

Instantly share code, notes, and snippets.

@spencerkclark
spencerkclark / regressions.py
Created March 26, 2021 10:47
Code for computing regressions of variables with an arbitrary number of dimensions against a 1D index
import dask.array as darray
import numpy as np
import xarray as xr
from collections import defaultdict
def _matmul(arr1, arr2):
if isinstance(arr1, darray.core.Array):
return darray.matmul(arr1, arr2)
@spencerkclark
spencerkclark / README.md
Last active July 12, 2020 18:49
example-lag-regression-sequence

Example analysis script

This gist contains an example analysis script, along with a list of dependencies. It uses data from a simulation I ran for Clark et al. (2020) and shows how one might compute and plot a lag-regression sequence of precipitation for South Asian monsoon low pressure systems.

Instructions

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

xspharm

Yet another wrapper for pyspharm...

Existing wrappers, windspharm and animal-spharm, lack dask support to parallelize operations. This wrapper enables use of dask at least for a subset of functions provided by pyspharm needed for computing closed tracer budgets following the methods of

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@spencerkclark
spencerkclark / test_first_items_current.out
Last active December 30, 2018 00:54
Tests of first items
============================= test session starts ==============================
platform darwin -- Python 3.6.6, pytest-3.10.1, py-1.7.0, pluggy-0.8.0 -- //anaconda/envs/xarray-dev-37/bin/python
cachedir: .pytest_cache
rootdir: /Users/spencerclark/cftime-resample-simplifications, inifile:
collecting ... collected 64 items
test_first_items_current.py::test_first_items[downsampling-0-left-left-11M] PASSED [ 1%]
test_first_items_current.py::test_first_items[downsampling-0-left-left-8001H] PASSED [ 3%]
test_first_items_current.py::test_first_items[downsampling-0-left-left-600003T] PASSED [ 4%]
test_first_items_current.py::test_first_items[downsampling-0-left-left-3MS] PASSED [ 6%]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.