Skip to content

Instantly share code, notes, and snippets.

@michael-petersen
michael-petersen / BenchmarkingEXP.md
Last active August 25, 2023 07:03
Run Plummer models on cuillin as an EXP benchmark

Benchmarking EXP

For use with computing time proposals

@michael-petersen
michael-petersen / BrownianNoise.md
Last active June 14, 2023 15:07
Notes and code for Stobie talk, 2 June 2023

Brownian Noise

identification in the wild

I spend a lot of time sitting in these sound isolating phone booths. And one of the early things you might notice while sitting in them is that there is quite a bit of noise. And let's be honest, I don't pay attention during all of the calls, so when my mind wandered, it drifted towards some projects I've been working on...

I've been wondering about whether the booths are purposely trying to get me to focus. There were quite a few articles this past autumn about broadband noise with the goal of focusing your mind. In particular, brownian (or red) noise as all the rage, see WaPo, NYT, Guardian coverage. And when I read the articles, I wondered: is the booth pumping focusing

@michael-petersen
michael-petersen / CompilationNotes.md
Last active December 26, 2024 19:30
Useful tidbits when compiling a heavily GNU-developed package on a Mac machine.

Making GNU and Apple play nice

Congratulations! You have now committed to turning your arm64 machine into a GNU development device. This is not trivial, but we seem to have solved the bulk of the issues. These notes are mainly relevant for installing EXP, although how to install Gadget-4 basically happens for free.

As of right now (2-May-2023), you must install the main branch of EXP in order to compile on arm64 machines.

A few guiding points:

  • Don't forget to git submodule update --init --recursive!
  • If you think it's a bug, it more likely is a path issue.
  • clang is pretty finicky with warnings; most are no cause for panic.
@michael-petersen
michael-petersen / FourierDrawings.py
Last active September 8, 2022 08:40
Expanding line drawings as a Fourier series: an introduction to basis function expansions.
# standard python modules
import numpy as np
# plotting utilities
import matplotlib.pyplot as plt
def trace_points(x,y,startpoint=0):
"""trace_points
starting from a defined point in a set, find the next closest point, to make a continous line
"""
@michael-petersen
michael-petersen / TiltedDisc.py
Last active January 5, 2024 20:18
Generate points for an exponential disc and (optionally) tilt them to match observations.
import matplotlib.pyplot as plt
# the code in rotation.py
from rotation import *
# the code in flatdisc.py
from flatdisc import *
N = 10000
x,y,z,u,v,w = generate_basic_disc_points(N)
@michael-petersen
michael-petersen / timing_with_constants.jl
Last active August 4, 2022 17:48
Comparing timing tests in Julia using constants: both need to be run interactively (e.g. line by line from a Julia prompt, not as scripts).
"""
This version uses constants:
ugly from an object-oriented standpoint, but fast.
"""
using BenchmarkTools
"""
Follow along
https://docs.juliahub.com/BenchmarkTools/ZXPQo/1.0.0/
"""
@michael-petersen
michael-petersen / Cuomo2020TableA1.csv
Last active November 21, 2022 10:22
Data looking at the length of bars in the literature, compiled in Cuomo+ (2020)
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 22 columns, instead of 3 in line 9.
Galaxy,Morph.Type,z,M_r,Rbar,Rbarh,Rbarl,Sbar,Omega,eOmega,Rcr,Rcrh,Rcrl,R,Rl,Rh,B/T(Ref.),Ref.,FinalSample,Rnew,Rnewl,Rnewh
ESO 139-G09 , SAB0^0(rs) ,0.018,-21.2,6.41,2.41,-1.13,0.44,56.7,15.4,5.54,1.96,-1.17,0.8,0.3,-0.2, ... ,1, yes,,,
ESO 281-G31 , SB0^0(rs) ,0.018,-21.22,4.04,0.37,-0.37,,28.6,11.2,7.35,4.41,-1.47,1.8,1.1,-0.4, ... ,2, yes,,,
IC 874 , SB0^0(rs) ,0.008,-20.57,3.65,0.94,-0.9,0.57,38.2,13.1,4.93,2.4,-1.25,1.4,0.7,-0.4, ... ,1, yes,,,
NGC 271 , (R’)SBab(rs) ,0.014,-21.81,7.7,0.27,-0.27,0.63,29.5,16,11.69,7.97,-4.25,1.5,1,-0.5, ... ,2, no,,,
NGC 936 , SB0^+(rs) ,0.005,-20.71,4.16,,,0.55,56.8,13.2,5.74,1.25,-1.25,1.4,0.5,-0.4, 0.20 (1) ,3, yes,,,
NGC 1023 , SB0^-(rs) ,0.002,-21.39,3.94,0.29,-0.29,0.48,89.2,31.5,3.03,0.34,-0.34,0.8,0.5,-0.3, ... ,4, yes,,,
NGC 1308 , SB0/a(r) ,0.021,-21.71,5.36,0.78,-1.47,0.5,91.8,32.1,3.85,1.95,-0.99,0.8,0.4,-0.2, ... ,1, yes,,,
NGC 1358 , SAB0/a(r) ,0.013,-21.09,5.16,0.81,-0.81,,34.4,16.6,6.24,5.16,-1.9,1.2,1,-0.4, ... ,2, yes,,,
NGC 1440 , (R')SB0^0 ,0.005
@michael-petersen
michael-petersen / launch_all_lmaxnmax.sh
Last active May 11, 2024 09:53
PBS script to run EXP on infinity, including a template YAML file, and a driver file.
#!/bin/sh
# we want to create a grid of simulations, from
# lmax \in [2,4,6,8,12,16,24,32,64]
# nmax \in [2,4,8,16,24,32,48,64,128]
# for an ensemble of 10 simulations, e.g.
# run in run1a run1b run1c run1d run1e run1f run1g run1h run1i run1j
for run in run2a run2b run2c run2d run2e run2f
@michael-petersen
michael-petersen / GenerateSphereSurface.py
Last active August 10, 2022 00:42
How would a oblate ellipsoid of points look if projected on a sphere? How does the inclusion of spherical harmonic deformations affect originally spherical equipotential surfaces?
import numpy as np
def gen_sphere_surface(npoints):
"""generate a sphere of stars, evenly spaced on the surface of a sphere"""
npoint = 0
points = np.zeros([npoints,3])
a = 4*np.pi/npoints
d = np.sqrt(a)
Mtheta = np.floor(np.pi/d).astype('int')
dtheta = np.pi/Mtheta
@michael-petersen
michael-petersen / density_binner.py
Last active May 20, 2022 19:01
A basic particle density binning technique in Python.
import numpy as np
def return_density(logr,weights=1.,rangevals=[-2, 6],bins=500,d2=False):
"""return_density
simple binned density using logarithmically spaced bins
inputs
---------
logr : (array) log radii of particles to bin