This file contains hidden or 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
# Installing environment as ipykernel: | |
export ENV_NAME=feature_name | |
pixi add --feature $ENV_NAME ipykernel | |
pixi run -e $ENV_NAME python -m ipykernel install --user --name pixi_$ENV_NAME --display-name "$ENV_NAME (pixi)" |
This file contains hidden or 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
API_KEY=`cat ~/path/to/apikey_file` && export API_KEY |
This file contains hidden or 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
# First time cloning repo | |
git clone --branch <branch-name> <url|ssh> | |
# If already cloned | |
git fetch | |
git switch <branch-name> |
This file contains hidden or 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
## Install conda environment as Jupyter kernel using ipykernel | |
source activate {env_name} | |
conda install ipykernel -y -q | |
ipython kernel install --user --name $CONDA_DEFAULT_ENV |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 numpy | |
import xarray | |
import pandas | |
fname = "data.npy" | |
arr = numpy.load(fname) | |
df = pandas.DataFrame({"lon":arr[:,0], "lat":arr[:,1], "data":arr[:,3]}) | |
ds = df.set_index(["lat","lon"]).to_xarray() | |
ds.to_netcdf("data.nc") |
This file contains hidden or 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 numpy as np | |
def reverse_piecewise_linear_sigmoid(self, x, upper, lower): | |
''' | |
Reverse piecewise linear sigmoid function to filter a value between two thresholds in a vectorised manner according to: | |
if x <= lower: | |
y = 1 | |
else: | |
y = (upper-x)/(upper-lower) |
This file contains hidden or 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
#!/path/to/miniconda3/bin python3 | |
''' | |
A commandline tool to install all available conda environments as ipython kernels | |
- Checks for which conda envs and ipython kernels are available | |
- Installs the conda envs not yet installed as ipython kernels (including ipykernel if missing) | |
- Uninstalls ipython kernels which no longer have a corresponding conda env | |
''' | |
import jupyter_client | |
import subprocess |
This file contains hidden or 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
# (C) Crown Copyright, Met Office. All rights reserved. 2020 | |
# | |
# Python code written for demonstrative purposes only. | |
# Authored by Kevin Donkers (@kaedonkers) and Peter Killick (@DPeterK) | |
# See https://gist.github.com/DPeterK/c5061f336a91a3ce9790c206a5459b4a | |
import iris | |
import numpy as np | |
import cartopy.crs as ccrs |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder