Skip to content

Instantly share code, notes, and snippets.

@mtrebitsch
mtrebitsch / subplot_mosaic.py
Created August 19, 2021 15:03
Testing the subplot_mosaic feature from matplotlib 3.3
import matplotlib.pyplot as plt
import numpy as np
# Helper function used for visualization in the following examples
def identify_axes(ax_dict, fontsize=48):
"""
Helper to identify the Axes in the examples below.
Draws the label in a large font in the center of the Axes.
@mtrebitsch
mtrebitsch / blend.sh
Created February 12, 2020 16:21
Not very clean script to merge images with ImageMagick
# Define the maps I will use
TEMPERATURE="BASE/Obelisk_00194_Projection_y_temperature_density.png"
GAMMA="BASE/Obelisk_00194_Projection_y_Gamma_HI_density.png"
DENSITY="BASE/Obelisk_00194_Projection_y_H_nuclei_density.png"
DM="BASE/Obelisk_00194_Projection_y_DM_density.png"
STARS="BASE/Obelisk_00194_Projection_y_star_density.png"
SIZE=$(convert $TEMPERATURE -ping -format "%w" info:)
HALF=$(echo "scale=0;$SIZE / 2" | bc -l)
ONETHIRD=$(echo "scale=0; $SIZE / 3" | bc -l)
@mtrebitsch
mtrebitsch / chladni.py
Created March 28, 2018 15:34
Quick and dirty script to generate Chladni patterns from a square plate, inspired from https://twitter.com/mcnees/status/978996740438315008
def chladni(n, m, N=100):
x = np.linspace(-1,1,N)
y = np.linspace(-1,1,N)
xx, yy = np.meshgrid(x, y)
sgn = -1 if n>m else 1
return np.cos(n*np.pi*xx/2.)*np.cos(m*np.pi*yy/2.) + sgn*np.cos(m*np.pi*xx/2.)*np.cos(n*np.pi*yy/2.)
def all_chladni(nr=10, mr=10):
fig, ax = plt.subplots(nr, mr, figsize=(nr+2.5,mr+2.5), sharex=True, sharey=True)
for n in range(nr):