Skip to content

Instantly share code, notes, and snippets.

@blaylockbk
blaylockbk / IWWG16-participants.geojson
Created May 13, 2023 00:16
16th IWWG Workshop Participants
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@blaylockbk
blaylockbk / simple_colors.py
Last active November 27, 2021 18:05
20 simple colors
# https://github.com/blaylockbk/Carpenter_Workshop/blob/main/paint/simple_colors.py
# https://github.com/blaylockbk/Carpenter_Workshop/blob/main/notebooks/demo_simple_distinct_colors.ipynb
"""
==========================
20 Simple, Distinct Colors
==========================
Cycle Sasha Trubetskoy's 20 simple colors in your Matplotlib plots
https://sashamaps.net/docs/resources/20-colors/
@blaylockbk
blaylockbk / shadded_contour.py
Created November 15, 2021 17:10
Shaded Contour Plot Matplotlib
# I COPIED THIS EXAMPLE FROM THIS FINE BOOK
# ----------------------------------------------------------------------------
# Title: Scientific Visualisation - Python & Matplotlib
# Author: Nicolas P. Rougier
# License: BSD
# ----------------------------------------------------------------------------
# Contour with drop shadows
# ----------------------------------------------------------------------------
import scipy
import numpy as np
@blaylockbk
blaylockbk / cartopy_ETOPO1.py
Last active October 18, 2021 18:55
plot terrain and bathymetry with Cartopy
# See full function at: https://github.com/blaylockbk/Carpenter_Workshop/blob/main/toolbox/cartopy_tools.py
from toolbox.cartopy_tools import common_features
ax = common_features('50m', dpi=200).BORDERS().BATHYMETRY().TERRAIN().ax
"""
Brian Blaylock
Most recent function is located here:
https://github.com/blaylockbk/Herbie/blob/master/herbie/tools.py
This function is much faster than my old `pluck_points` function found here:
https://github.com/blaylockbk/Carpenter_Workshop/blob/main/toolbox/gridded_data.py
"""
@blaylockbk
blaylockbk / pluck_points.py
Created October 8, 2021 22:45
get points nearest latitude/longitude point in xarray
'''
Brian Blaylock
Most recent function is located here:
https://github.com/blaylockbk/Carpenter_Workshop/blob/main/toolbox/gridded_data.py
But you should consider using the nearest_points() function instead, found here:
https://github.com/blaylockbk/Herbie/blob/master/herbie/tools.py
'''
@blaylockbk
blaylockbk / standalone_colorbar.py
Created October 4, 2021 17:34
sandalone matplotlib colorbar
import matplotlib.pyplot as plt
import matplotlib as mpl
fig = plt.figure()
ax = fig.add_axes([0.05, 0.80, 0.9, 0.1])
cb = mpl.colorbar.ColorbarBase(ax, orientation='horizontal',
cmap='gist_ncar',
norm=mpl.colors.Normalize(0, 10), # vmax and vmin
extend='both',
@blaylockbk
blaylockbk / full_Path_expand.py
Last active August 8, 2021 00:35
Fully Expand a pathlib.Path
# Brian Blaylock
# August 7, 2021
"""
It is often necessary to fully expand a pathlib.Path object when the
path is given a ~ or environment variables. This custom method
attachs to Path a method that fully expands these to the full path.
For example, Path('${HOME}/this/dir).expand() becomes
PosixPath('/user/name/this/dir').
"""
@blaylockbk
blaylockbk / create_default_toml.py
Last active August 8, 2021 00:52
Create/Read a default config.toml file
## Brian Blaylock
## August 7, 2021
# borrowed from Herbie package.
# use in __init__.py to create/read config.toml for package.
import toml
import os
from pathlib import Path
@blaylockbk
blaylockbk / loop_dates.sh
Created July 27, 2021 19:15
Loop over dates in a Bash script
#!/bin/bash
#=======================================================================
# Specify the "start" and "end" time.
#=======================================================================
# Use format "HH:MM YYYY-MM-DD"
start="00:00 2021-04-01"
end="00:00 2021-04-02"
increment="+1 hours"
#=======================================================================