Skip to content

Instantly share code, notes, and snippets.

View bamford's full-sized avatar

Steven Bamford bamford

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bamford
bamford / sersic_lum.py
Created October 18, 2023 08:13
Luminosity of Sérsic function in annulus
from numpy import pi, exp
from scipy.special import gamma, gammaincinv, gammainc
# Normalisation constant
def b(n):
return gammaincinv(2*n, 0.5)
# Total luminosity of a 2D Sérsic profile
def sersic_total_lum(Ie, re, n):
bn = b(n)
@bamford
bamford / Format forum posts.ipynb
Created October 13, 2022 13:51
Formatting Moodle forum posts from html export
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bamford
bamford / setup_tensorflow.py
Created April 12, 2022 14:55
This function initialises TensorFlow to work in a friendly way in a shared, multi-GPU environment. It identifies the GPU with the most free RAM, selects it for use and sets TF to only claim the amount of RAM actually required to run the model, so other jobs can run on the same GPU. Uses `nvsmi`, which can be installed using pip.
import numpy as np
import tensorflow as tf
from tensorflow.config import list_logical_devices, list_physical_devices, set_visible_devices
from tensorflow.config.experimental import set_memory_growth
def setup_tensorflow(seed=None):
try:
import nvsmi
@bamford
bamford / get_yolo_classes.ipynb
Created February 14, 2022 16:12
Get YOLO classes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bamford
bamford / test_rebinning.ipynb
Last active March 23, 2021 23:09
Test how to rebin contents of an image, without changing the image size
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bamford
bamford / test_stack_convolution.ipynb
Last active March 23, 2021 16:42
Test application of a 2D convolution to a stack of multi-channel images
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bamford
bamford / sersic_gals_asym.ipynb
Created February 1, 2021 14:12
Create asymmetric Sersic gals
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bamford
bamford / sersic_gals.ipynb
Last active February 1, 2021 14:13
Create Sersic gals
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bamford
bamford / gmm_tests.ipynb
Created January 28, 2021 09:38
Testing that the likelihood of a GMM doesn't depend on the number of components
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.