Skip to content

Instantly share code, notes, and snippets.

@moble
moble / CompareSquads.ipynb
Last active May 30, 2023 19:52
Compare quaternion interpolation methods
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# The vector method is roughly 2.5x than the existing code with a
# sorted t′, and about 15% slower with a worst-case-disordered t′.
using BenchmarkTools
using DataInterpolations
shuffle(v) = collect(Iterators.flatten(zip(v[begin:length(v)÷2], v[length(v)÷2+1:end])))
function inplace(u, interp, t)
@assert length(u) == length(t)
@moble
moble / X2D.py
Last active September 28, 2022 15:43
"""Convert RPXMB files to RPDMB
This file can be run either as a script, or by calling its functions. To run as a script, do
something like this:
python X2D.py Strain_N2.h5 Strain_N3.h5 Strain_N4.h5 ExtraWaveforms.h5
To call the functions, and assuming that this file is in the same directory as the script using it,
do something like this:
@moble
moble / ComparingIntegrationMethods.ipynb
Last active February 23, 2022 16:30
Notebooks related to 'The integration of angular velocity' https://arxiv.org/abs/1604.08139
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moble
moble / rpxmb.ipynb
Last active September 9, 2021 16:29
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moble
moble / README.md
Last active August 17, 2021 03:34
Speed up execution of `@everywhere` in julia
NOTE: A somewhat streamlined version of this approach can be found in this other gist, which involves only one simple script. You could still use the timing files from this gist if you want to check the details.

As described in detail here, julia can take really excessive amounts of time to execute the first @everywhere statement on many processes — around 1 hour for thousands of processes — even if the actual code being executed everywhere is trivial. Basically, the Distributed functions need to be precompiled to make this happen quickly.

This gist provides a simple way to do so — at least on Slurm clusters (though the same principles should apply elsewhere). The key file is organizer.jl; just submit it as a batch job (adjusting the SBATCH directives as needed), and it should create a sysimage that you can use to run futur

@moble
moble / NumbaODEExample.ipynb
Last active July 6, 2021 18:32
Show how to speed up scipy.integrate.odeint simply by decorating the right-hand side with numba's jit function
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moble
moble / memory.ipynb
Last active December 18, 2020 15:13
Notebook demonstrating the use of sxs memory functions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moble
moble / show_dimensions.tex
Last active September 4, 2020 16:44
Get latex to tell you its sizes, then use those sizes in matplotlib to create plots that will fit perfectly in your latex file
% Anywhere you want to see the dimensions latex is using, just place
% this command in the tex file itself, run latex, and look for these
% items in the compilation output. For example, to see these numbers
% as latex uses them within the text, just put this command in the
% main text. To see them in a figure caption, just put this command
% where you write the caption text. Note that the standard
% points-per-inch ratio is 72.27.
\makeatletter