Skip to content

Instantly share code, notes, and snippets.

View aphearin's full-sized avatar

Andrew Hearin aphearin

  • Argonne National Lab
View GitHub Profile
@aphearin
aphearin / demo_kde_loss_double_gaussian.ipynb
Created February 28, 2024 19:25
Demonstrate optimization of a two-component Gaussian model using a loss function based on Gaussian KDE PDF estimation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aphearin
aphearin / met_weights_age_dep.py
Last active January 29, 2024 08:47
DSPS calculation of the restframe SED of a galaxy with different metallicity in young and old stars
"""
"""
from dsps.sed.metallicity_weights import calc_lgmet_weights_from_lognormal_mdf
from dsps.sed.ssp_weights import SSPWeights
from dsps.sed.stellar_age_weights import calc_age_weights_from_sfh_table
from dsps.sed.stellar_sed import RestSED
from dsps.utils import _tw_sigmoid, cumulative_mstar_formed
from jax import jit as jjit
from jax import numpy as jnp
from jax import vmap
@aphearin
aphearin / jax_demo_diffmah.ipynb
Created February 15, 2023 19:53
Intro to JAX based on the Diffmah model of dark matter halo mass assembly history
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aphearin
aphearin / jax_overview.ipynb
Created February 15, 2023 19:42
Quick overview of JAX
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aphearin
aphearin / demo_mpi4py.py
Created January 19, 2023 20:25
Example pattern for a simple script parallelized with mpi4py using JAX-generated randoms
"""mpiexec -n 2 python demo_mpi4py.py
"""
from mpi4py import MPI
import argparse
from jax import random as jran
import numpy as np
OUTPAT = "results_rank_{0}.dat"
@aphearin
aphearin / demo_toy_model.ipynb
Created April 14, 2022 15:58
Demonstration of fitting a toy model for subhalo mass loss to itself
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aphearin
aphearin / jax_odeint_demo.ipynb
Created November 30, 2021 16:39
Demo of using JAX to solve an ODE and differentiate through the solution
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aphearin
aphearin / dev_latin_hypercube_integration.ipynb
Created July 30, 2021 22:06
Calculate the integral of a 2d Gaussian using Latin Hypercube sampling
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aphearin
aphearin / eigenbasis_covariance.ipynb
Created June 28, 2021 20:04
Calculate the change-of-basis matrix defined by the covariance of a dataset
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aphearin
aphearin / jax_differentiability_pattern_halo_mass_assembly.ipynb
Last active May 26, 2021 14:49
Basic demo of how to implement a physical model for dark matter halo mass assembly in JAX
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.