Skip to content

Instantly share code, notes, and snippets.

#%%
"""
This script shows how to load CCE data into a `scri.AsymptoticBondiData` object
and evaluate a set of constraints that should be satisfied involving the strain
and the Newman-Penrose quantities (assuming the waveform is in Bondi gauge).
These constraints are listed in the plot legend (see below) as equations to be
satisfied at each instant. The violation is just one side minus the other, and
the norm is that difference squared integrated over the sphere (and
square-rooted).
"""
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.
@moble
moble / WhitespaceCleanup.sh
Created March 20, 2014 19:08
Use Emacs to clean up whitespace in a whole bunch of files
# Remove trailing whitespace, and replace tabs with the appropriate number of spaces
for file in `find . -name "*.?pp"`; do
echo "$file"; /usr/local/bin/emacs --batch "$file" \
--eval '(setq-default indent-tabs-mode nil)' \
--eval '(whitespace-cleanup)' \
-f 'save-buffer'
done
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moble
moble / doi2bibtex.sh
Created December 13, 2023 17:13
doi2bibtex
# This bash/zsh function queries for the input DOI's bibtex entry. When the DOI points
# to a journal article, this usually resolves to the journal's own bibtex output.
doi2bibtex () {
curl -fsSLH "Accept: application/x-bibtex" "https://doi.org/$1" | sed -e 's|%2F|/|g'
}
@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 / 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
@moble
moble / make_plots.out
Last active June 9, 2023 19:45
Compare results of `to_coprecessing_frame` before and after CoM correction with old and new versions of scri/sxs/...
=======================================
Running in CoprecessingFrameTransients1
=======================================
/Users/boyle/.continuum/mambaforge/envs/CoprecessingFrameTransients1/lib/python3.9/site-packages/quaternion/calculus.py:310: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
def fd_indefinite_integral(f, t):
python.__version__ = 3.9.16 | packaged by conda-forge | (main, Feb 1 2023, 21:42:20)
[Clang 14.0.6 ]
numpy.__version__ = 1.21.0
scipy.__version__ = 1.7.0
@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.