Skip to content

Instantly share code, notes, and snippets.

@moble
moble / CompareSquads.ipynb
Last active May 30, 2023 19:52
Compare quaternion interpolation methods
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.
# 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
Loading
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
Loading
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 December 13, 2023 14:22
Speed up execution of `@everywhere` in julia

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). Just submit precompile.jl as a batch job (adjusting the SBATCH directives as needed), and it should create a sysimage that you can use to run future batch jobs. Check end of the log of the Slurm job to see exactly how to use the sysimage.

Note that both the original julia process and all processes created with addprocs should use the --sysimage=/path/to/sys_everywhere.so argument. Doing so reduces the time taken to execute the first @everywhere sta

@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 / memory.ipynb
Last active December 18, 2020 15:13
Notebook demonstrating the use of sxs memory functions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moble
moble / unique_gene_id.py
Last active October 11, 2023 02:33
Ensure GTF-format files have `gene_id` fields unique to each `gene_name` or `transcript_id`
#!/usr/bin/env python
# Copyright (c) 2020, Michael Boyle
#
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell