Skip to content

Instantly share code, notes, and snippets.

View xylar's full-sized avatar

Xylar Asay-Davis xylar

View GitHub Profile
@xylar
xylar / isomip_plus_base_mesh.py
Created September 26, 2023 14:26
Make an ISOMIP+ base mesh
#!/usr/bin/env python3
import numpy as np
from mpas_tools.io import write_netcdf
from mpas_tools.planar_hex import make_planar_hex_mesh
from mpas_tools.translate import translate
def main():
"""
@xylar
xylar / grayskull_autoupdate.py
Last active October 31, 2023 10:08
A script for automatically updating dependencies in conda-forge bot branches using grayskull and pypi
#!/usr/bin/env python
import argparse
import os
import shutil
import subprocess
import packaging.version
import grayskull.strategy
from importlib.resources import open_binary
import yaml
#!/usr/bin/env python
import subprocess
import os
subdir = 'linux-64'
specs = ['python=3.9',
#'qt=5.12.9',',
'dbus >=1.13.6,<2.0a0',
'expat >=2.2.10,<3.0.0a0',
@xylar
xylar / add_feedstock.bash
Created September 29, 2021 20:05
A script for adding a conda-forge feedstock
#!/bin/bash
set -e
feedstock="$1"-feedstock
mkdir -p "${feedstock}"
cd "${feedstock}"
git clone git@github.com:conda-forge/"${feedstock}".git
@xylar
xylar / conda_first_failure.py
Last active October 4, 2021 17:59
A hacky script for using mamba to determin the first conda package that leads to an unsolvable environment
#!/usr/bin/env python
import subprocess
import os
subdir = 'osx-64'
specs = ['python=3.9.*',
'setuptools',
'cython',
'libcdms',
@xylar
xylar / create_env_and_plot.bash
Created September 15, 2021 13:28
A script for plotting Bedmap2 Antarctic bathymetry and ice topography
#!/usr/bin/env bash
conda create -y -n plot_topo_env -c conda-forge python=3.9 cartopy matplotlib xarray numpy progressbar2 requests cmocean
conda activate plot_topo_env
./plot_bedmap2_topo.py
#!/usr/bin/env python
from make_vertical_grid_xsad import create_vertical_grid
# Standard 64 layer vertical grid
create_vertical_grid(bottom_depth=5500, nz=64, dz1_in=2., dz2_in=200.,
plot_vertical_grid=True, outFile= 'vertical_grid_xsad.nc')
@xylar
xylar / fit_smoothing_width.py
Created March 24, 2020 21:26
Multivariate power-law fit to the smoothing width based on number of iterations and nearest-neighbor weighting coefficient
#!/usr/bin/env python
import numpy
import matplotlib.pyplot as plt
from scipy.ndimage.filters import convolve1d
from pandas import DataFrame
from sklearn import linear_model
nx = 2001
x = numpy.linspace(-10., 10., nx)
@xylar
xylar / high_res_region.geojson
Last active March 14, 2020 20:49
Test region
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
"""
This script creates MOCBasinRegionGroup, which includes five regions used for
computing the meridional overturning circulation (MOC) and meridional heat
transport (MHT)
"""
# stuff to make scipts work for python 2 and python 3
from __future__ import absolute_import, division, print_function, \
unicode_literals