Skip to content

Instantly share code, notes, and snippets.

View tommylees112's full-sized avatar
🐘

Tommy Lees tommylees112

🐘
  • University of Oxford
  • Oxford
View GitHub Profile
@tommylees112
tommylees112 / save_load_scaler.py
Created July 29, 2021 10:44
Save load pandas / xarray objects
frmo typing import Dict, Union
import xarray as xr
import pandas as pd
from pathlib import Path
def save_scaler(scaler: Dict[str, Union[xr.Dataset, pd.DataFrame]], run_dir: Path) -> None:
"""Save scaler to disk as separate netcdf files"""
scaler_dir = run_dir / "train_data"
for k, v in scaler.items():
@tommylees112
tommylees112 / env_0721.sh
Created July 28, 2021 12:29
Environment for July 2021 [07/21]
conda create -n env_0721 --yes
conda activate env_0721
conda install -c conda-forge xarray=0.18.2 pandas=1.1.4 numpy=1.20.2
conda install pytorch torchvision -c pytorch --yes
conda install -c conda-forge seaborn=0.11 --yes
conda install -c conda-forge netcdf4 numba tqdm jupyterlab tensorboard ipython pip ruamel.yaml descartes statsmodels scikit-learn black mypy --yes
pip install geopandas
ipython --pdb -c "import torch; assert torch.cuda.is_available(); print(torch.backends.cudnn.version()); print(torch.cuda.device_count());"
@tommylees112
tommylees112 / old_ml.sh
Created July 28, 2021 12:23
Create an old_ml environment that works with previously run versions of neuralhydrology [01/01/2021]
conda create -n old_ml
conda activate old_ml
conda install -c conda-forge xarray=0.16.2 pandas=1.2.4 numpy=1.19.2 --yes
conda install pytorch torchvision -c pytorch --yes
conda install -c conda-forge seaborn=0.11 --yes
conda install -c conda-forge netcdf4 numba tqdm jupyterlab tensorboard ipython pip ruamel.yaml descartes statsmodels scikit-learn black mypy --yes
pip install geopandas
ipython --pdb -c "import torch; assert torch.cuda.is_available(); print(torch.backends.cudnn.version()); print(torch.cuda.device_count());"
@tommylees112
tommylees112 / xesmf_env.sh
Last active July 23, 2021 13:00
Environment with Xesmf (Python 3.7)
# conda xesmf
conda create -n xesmf python=3.7 --yes
conda activate xesmf
conda install -c conda-forge xesmf rasterio --yes
conda install -c anaconda boto3 --yes
conda install pytorch torchvision -c pytorch --yes
conda install -c conda-forge dask netcdf4 numba tqdm jupyterlab ipython pip ruamel.yaml descartes scikit-learn black mypy --yes
@tommylees112
tommylees112 / install_cdo.sh
Last active February 1, 2024 06:09
Script to install cdo on a linux machine
#!/bin/bash
# Institut für Wetter- und Klimakommunikation GmbH / Qmet
# O. Maywald <[email protected]>
# This should install CDO with grib2, netcdf and HDF5 support. Note that the binaries are in ~/cdo_install/bin.
# For further information look:
# http://www.studytrails.com/blog/install-climate-data-operator-cdo-with-netcdf-grib2-and-hdf5-support/
# docker-command
@tommylees112
tommylees112 / wave2web_env.sh
Last active October 28, 2021 15:09
Environment with rasterio, skimage, pytorch, xarray, networkx
conda create -n w2w python=3.8 --yes
conda activate w2w
conda install -c conda-forge pytorch xarray=0.16 pytorch torchvision cudatoolkit --yes
conda install dask --yes
conda install -c conda-forge rasterio scikit-image --yes
conda install -c conda-forge seaborn=0.11 --yes
conda install -c anaconda networkx --yes
conda install -c conda-forge zarr gcsfs netcdf4 numba tqdm jupyterlab tensorboard ipython pip ruamel.yaml descartes statsmodels scikit-learn black mypy --yes
conda install -c conda-forge geopandas --yes
conda install -c conda-forge cdsapi --yes
# https://serverfault.com/a/241593
ssh-keygen -t rsa -b 2048
# copy keys to target server
ssh-copy-id username@server_address
# check login
ssh username@server_address
@tommylees112
tommylees112 / cuda_toolkit.md
Last active June 29, 2021 20:47
Getting up and running on virtual machine with cuda

# list all PCI devices lspci

# Find the nvidia package

$ whereis nvidia
nvidia: /usr/lib/nvidia /usr/share/nvidia

# download nvidia-smi

@tommylees112
tommylees112 / xarray_env.sh
Last active June 28, 2021 13:33
xarray version 0.16 environment
conda create -n xr python=3.8 --yes
conda activate xr
conda install -c conda-forge pytorch xarray=0.16 pytorch torchvision cudatoolkit --yes
conda install -c conda-forge seaborn=0.11 --yes
conda install -c conda-forge netcdf4 numba tqdm jupyterlab tensorboard ipython pip ruamel.yaml descartes statsmodels scikit-learn black mypy --yes
pip install geopandas
@tommylees112
tommylees112 / cwatm_env.sh
Last active June 24, 2021 10:59
Make python environment for running cwatm
conda create -n cwat --yes
conda activate cwat
conda install -c conda-forge gdal --yes
conda install -c conda-forge pyflow --yes
conda install -c conda-forge seaborn scipy netcdf4 numba tqdm jupyterlab tensorboard ipython pip ruamel.yaml xarray descartes scikit-learn black mypy --yes
pip install geopandas
ipython --pdb -c "from osgeo import gdal; from osgeo import osr; import scipy; import xarray as xr"