Skip to content

Instantly share code, notes, and snippets.

View TomNicholas's full-sized avatar

Tom Nicholas TomNicholas

View GitHub Profile
@TomNicholas
TomNicholas / autostorm.py
Last active May 20, 2019 15:48
Example script to submit a BOUT++ batch job based on a configuration file
import configparser
from warnings import warn
from pathlib import Path
from collections import OrderedDict
from pprint import pprint
from datetime import timedelta
import subprocess
import git
from humanfriendly import format_timespan
@TomNicholas
TomNicholas / jexecute.py
Last active January 2, 2020 19:13
Wrapper function to execute a Jupyter notebook from python
from pathlib import Path
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor, CellExecutionError
def execute_notebook(input_notebook_file, output_notebook_file='output.ipynb',
run_path='./', timeout=600, kernel_name='', **kwargs):
"""
Executes a single jupyter notebook, and writes the results out into a
@TomNicholas
TomNicholas / mayavi_3D_plot.py
Created December 24, 2019 14:23
Fabio's implementation of 3D plotting with mayavi
from netCDF4 import Dataset
import numpy as np
import scipy.interpolate
import scipy.io
import matplotlib.pyplot as plt
import math
def extract_region(var, regions, ir, yguards=True):
"""
Extract the data from an N-dimensional (with N=2 or N=4) variable corresponding to a given region
@TomNicholas
TomNicholas / squashoutput.ipynb
Created January 6, 2020 15:57
Chronicling of various attempts to use xarray, dask & zarr to squash down many GB's of netCDF data into fewer files for xBOUT.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@TomNicholas
TomNicholas / groupby_bins_count.ipynb
Last active June 10, 2021 14:48
histogramming in xarray with numpy_groupies
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@TomNicholas
TomNicholas / profiling_xhistogram.ipynb
Last active June 14, 2021 21:56
Profiling xhistogram (+ numba)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.