This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from abc import ABC, abstractmethod | |
from matplotlib import pyplot as plt, path as mpath | |
import functools | |
import cartopy | |
import cartopy.crs | |
import cartopy.mpl.geoaxes | |
import numpy as np | |
def register_geoaxes_accessor(accessor_name): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
url = "https://github.com/IPCC-WG1/colormaps/blob/master/CMIP6_color.xlsx?raw=true" | |
df = pd.read_excel(url, index_col=[0]) | |
cmip6_colors = {i:k.values for (i,k) in df.iterrows()} | |
# or as one-liner | |
# cmip6_colors = {i:k.values for (i,k) in pd.read_excel("https://github.com/IPCC-WG1/colormaps/blob/master/CMIP6_color.xlsx?raw=true", index_col=[0]).iterrows()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pdftk in.pdf output - uncompress | sed '/^\/Annots/d' | pdftk - output out.pdf compress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# following https://stackoverflow.com/a/25864063/5925453 | |
git config --add oh-my-zsh.hide-status 1 | |
git config --add oh-my-zsh.hide-dirty 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conda list -n env1 --export > env1-packages.txt | |
conda list -n env2 --export > env2-packages.txt | |
diff env1-packages.txt env2-packages.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -name *.txt -type f -exec sed -i 's/string-to-replace/replacement-string/g' {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
canonical_path() { | |
perl -mCwd -le ' print Cwd::abs_path $ARGV[0] ' -- "$1" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from psutil import virtual_memory | |
mem = virtual_memory() | |
print(mem.total) # in bytes | |
print(mem.total / 1024**3) # in giga bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xarray as xr | |
ds = xr.open_dataset('data.nc') | |
# find temporal breaks that are larger than a given threshold | |
thrsh = 300 # threshold in seconds | |
interval_ends = ds.time.diff('time').dt.seconds > thrsh # gives a boolean array with True at the end of each interval longer than the threshold | |
# plot the intervals | |
import matplotlib.pyplot as plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# according to https://sriramjaju.github.io/2018-05-30-2-minute-recipe-how-to-rollback-your-conda-environment/ | |
conda list --revisions # List the history of each change to the current environment | |
conda install --revision 2 # Restore environment to a previous revision |
NewerOlder