Skip to content

Instantly share code, notes, and snippets.

View giacomov's full-sized avatar

Giacomo Vianello giacomov

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@giacomov
giacomov / my_model.py
Created January 12, 2018 22:26
A custom model in astromodels
from astromodels.functions.function import Function1D, FunctionMeta
class MyCustomModel(Function1D):
r"""
description :
A custom power law model
latex : $ 10^{K}~\frac{x}{piv}^{index} $
parameters :
K :
desc : Normalization (log of differential flux at the pivot value)
rsps = []
phas = []
baks = []
for interval in intervals:
this_rsp = my_instrument_response_set.weight_by_counts(...)
this_pha = [this is what you are doing]
this_bak = [this is what you are doing]
# LAT light curve fit
one = LATLike(...)
two = LATLike(...)
three = LATLike(...)
data = DataList(one, two, three)
model = Model(...)
@giacomov
giacomov / EventList.py
Last active September 3, 2016 15:26
A generic EventList class
import numpy as np
class EventList(object):
def __init__(self, arrival_times, energies, ra=None, dec=None):
self._arrival_times = np.asarray(arrival_times)
self._energies = np.asarray(energies)
assert self._arrival_times.shape[0] == self._energies.shape[0]
electrons (particle source):
spectrum:
main:
log_parabola:
K: {value: 1.0000000000000002e+38, desc: Normalization, min_value: null, max_value: null,
source_1 (point source):
position:
ra: {value: 125.6, desc: Right Ascension, min_value: 0.0, max_value: 360.0, unit: deg,
delta: 37.68, free: false}
dec: {value: -75.3, desc: Declination, min_value: -90.0, max_value: 90.0, unit: deg,
@giacomov
giacomov / create_file_spectrum.py
Created March 28, 2016 23:53
FileSpectrum in pyLikelihood
import FuncFactory
# Create the text file with the energies and the fluxes (which can be whatever at this stage)
source_name = 'a'
tempName = "__%s.txt" % source_name
with open(tempName, "w+") as f:
@giacomov
giacomov / sherpa_astropy_astromodels.ipynb
Last active February 23, 2016 00:07
Speed comparison between models in Sherpa, Astropy and astromodels
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.