Skip to content

Instantly share code, notes, and snippets.

View tspriggs's full-sized avatar

Thomas Spriggs tspriggs

View GitHub Profile
def minicube_extractor(x, y, n_pix, data):
"""Extract a PNe minicube from a given MUSE residual cube.
Parameters
----------
x : [float]
x coordinate
y : [float]
y coordinate
logger.info(f"N fitted PNe: {}")
logger.info(f"PNLF N: {}")
logger.info(f"Bolometric luminosity: {}")
logger.info(f"L_bol error: {} {}")
logger.info(f"Rmag: {}")
logger.info(f"Vmag: {}")
logger.info(f"Distance (Mpc) +/-: {} {}")
logger.info(f"dM +/-: {} {}")
logging.basicConfig(filename=f"{EXPORT_DIR}{galaxy_name}_{loc}_log.log", level=logging.INFO, format="%(asctime)s -%(message)s", datefmt="%d-%b-%y %H:%M:%S")
@tspriggs
tspriggs / example_dual_peak_astropy_model.py
Created December 14, 2019 14:14
example of my older astropy dual peak fitting class
# Define custom two peak Gaussian model using Astropy class type.
class Gaussian1D_OIII(Fittable1DModel):
amplitude = Parameter()
mean = Parameter()
stddev = Parameter()
a = Parameter()
b = Parameter()
# evaluate the model. This is composued using the Fittable1DModel class from Astropy.
@staticmethod
@tspriggs
tspriggs / gist:989b57a495ab2831a021fb376e18fabc
Last active March 14, 2018 17:23
custom model to fit a 2D moffat model to data, equate that to F_OIII_xy, then pass it to a 1D custom Gaussian equation to get a model spectrum. The idea is to have x, y and l (wavelength) as inputs, then the amplitude is fixed as it is calculated. When I run it I normally get mismatched dimension errors: wavelength is a 271 long list, and then x…
def Moffat_3d_test(x, mean, stddev, Gauss_bkg, Gauss_grad,
Moffat_amplitude, x_0, y_0, gamma, alpha, Moffat_bkg):
# Moffat
rr_gg = ((x_fit - x_0)**2 + (y_fit - y_0)**2) / gamma**2
F_OIII_xy = Moffat_amplitude * (1 + rr_gg)**(-alpha) + Moffat_bkg
# Prep for Gauss 1D
Gauss_std = np.sqrt(stddev**2 + std_MUSE**2)
A_OIII_xy = F_OIII_xy / (np.sqrt(2*np.pi) * Gauss_std)
check_1.append(A_OIII_xy)
model_spectra = []