Skip to content

Instantly share code, notes, and snippets.

@alexander0042
alexander0042 / AJMR_colormapsJGR.m
Last active July 19, 2023 13:55
Handy Colormaps
# A list of handy colormaps used in my JGR paper
# Alexander Rey
: mail@alexanderrey.ca
# https://agupubs.onlinelibrary.wiley.com/doi/full/10.1029/2020JC016489
# Cmocean Colormaps
# https://matplotlib.org/cmocean/
# MatPlotLib Colormaps
# https://www.mathworks.com/matlabcentral/fileexchange/51986-perceptually-uniform-colormaps
@alexander0042
alexander0042 / MapboxBasemap.py
Created September 24, 2021 14:09
Mapbox Python Code
#%% Import
import contextily as ctx
import matplotlib.pyplot as plt
#%% Import
mapbox = 'https://api.mapbox.com/styles/v1/alexander0042/ckemxgtk51fgp19nybfmdcb1e/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYWxleGFuZGVyMDA0MiIsImEiOiJjazVmdG4zbncwMHY4M2VrcThwZGUzZDFhIn0.w6oDHoo1eCeRlSBpwzwVtw'
fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(10, 6))
@alexander0042
alexander0042 / closestPoints.py
Created June 9, 2021 17:11
Closest Points Python
abslat = np.abs(lats-stn_lat)
abslon= np.abs(lons-stn_lon)
c = np.maximum(abslon,abslat)
latlon_idx = np.argpartition(-c.flatten(), -4)[-4:]
x, y = np.unravel_index(latlon_idx,c.shape)
latlon_dist = c[x, y]
# Avoid divide by zero if exactly on point
latlon_dist=np.maximum(latlon_dist, 0.000001)