Skip to content

Instantly share code, notes, and snippets.

@jbwhit
jbwhit / example-ruff-formatting.ipynb
Last active April 19, 2024 14:36
Steps to use `ruff` in JupyterLab with the `jupyterlab_code_formatter` plugin.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jbwhit
jbwhit / Brewfile
Last active February 21, 2024 08:12
My default Brewfile.
tap "homebrew/bundle"
tap "homebrew/cask-fonts"
tap "homebrew/cask-versions"
tap "jesseduffield/lazygit"
tap "textualize/rich"
# set arguments for all 'brew install --cask' commands
cask_args appdir: "~/Applications", require_sha: true
# brew "awscli"
@jbwhit
jbwhit / Automatic Voigt Profile Fitting.ipynb
Last active January 15, 2024 07:14
My attempt to create an automatic Voigt Profile Fitting program using PyMC and barak python libraries.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jbwhit
jbwhit / Resources.md
Last active January 8, 2024 21:16
Jonathan Whitmore's resource links for AAS 2024 talk
@jbwhit
jbwhit / post-save-hook.py
Last active September 21, 2023 04:50
Saves Jupyter Notebooks as .py and .html files automatically. Add to the ipython_notebook_config.py file of your associated profile.
import os
from subprocess import check_call
def post_save(model, os_path, contents_manager):
"""post-save hook for converting notebooks to .py and .html files."""
if model['type'] != 'notebook':
return # only do this for notebooks
d, fname = os.path.split(os_path)
check_call(['jupyter', 'nbconvert', '--to', 'script', fname], cwd=d)
check_call(['jupyter', 'nbconvert', '--to', 'html', fname], cwd=d)
@jbwhit
jbwhit / PlanetAnimation3.py
Last active August 10, 2023 09:47
Plotting Separation between prediction and observation
%%manim -qm PlanetAnimation3
df2 = pd.read_csv(
"https://gist.githubusercontent.com/jbwhit/8c745f8e6d814651a2254b3509e3d17c/raw/2e2457ee96dd8268f419fd842cdfb6e345b8ed22/uranus-example.csv"
)
class PlanetAnimation3(Scene):
def construct(self):
times = np.array(df2["date_frac"].values)
uranus_positions_1 = np.hstack(
df = pd.read_parquet("plotme.parquet")
class PlanetAnimation2(Scene):
def construct(self):
my_template = TexTemplate()
my_template.add_to_preamble(r"\usepackage{mathabx}")
Tex.set_default(tex_template=my_template)
scale = 12
shift = np.array([-4, -1])
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.
@jbwhit
jbwhit / scene.py
Last active June 8, 2023 17:20
This code creates this video here: https://youtu.be/g5QsoVxFSx0
import numpy as np
import pandas as pd
from manim import *
class SolarSystem(ThreeDScene):
def construct(self):
# Set the initial camera position
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
colors = {