ascl_id stringclasses 752
values | repo_url stringclasses 737
values | file_path stringlengths 4 194 | content large_stringlengths 1 1M | language stringclasses 29
values | license_type stringclasses 24
values | size int64 1 1M |
|---|---|---|---|---|---|---|
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/estimating_lbols.ipynb | {
"cells": [
{
"cell_type": "markdown",
"id": "bfde6443",
"metadata": {},
"source": [
"# In this example I will show how you can use redback to estimate the bolometric luminosity of a transient"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "458ad56b",
"metadata": {},
... | Jupyter Notebook | Unknown | 110,511 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/MixtureModelLikelihoods.py | # This example shows how to deal with outliers in the data by using a mixture model likelhood.
# First let's fake some data.
# We are gonna keep things a bit simple here.
import numpy as np
import matplotlib.pyplot as plt
import redback
import bilby
np.random.seed(12345)
# Set some parameters
tts = np.linspace(0.1,... | Python | Unknown | 4,548 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/simulate_gamma_xray_spectra_ray.py | """
Simulate high-energy transients with photon counting statistics
This example demonstrates the SimulateHighEnergyTransient class for generating
realistic X-ray/gamma-ray observations, including:
- Time-tagged events (TTE): Individual photon arrival times and energies
- Binned photon counts: Count rates in time bins... | Python | Unknown | 8,565 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/simulate_with_cadence.py | """
Example: Using SimulateTransientWithCadence for survey planning
This demonstrates the new SimulateTransientWithCadence class that bridges
the gap between simple simulation and full survey simulation.
Perfect for:
1. Using PopulationSynthesizer parameters
2. Testing different cadence strategies
3. SNR-based detect... | Python | Unknown | 11,705 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/spectral_template_matching_example.py | """
Spectral Template Matching Example
===================================
This example demonstrates how to use the SpectralTemplateMatcher class
to match observed spectra against template libraries for supernova classification.
The default template library uses sncosmo spectral models (SALT2, SN 1998bw,
Nugent templ... | Python | Unknown | 8,086 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/calling_a_model_with_inbuilt_constraints.py | # In this example, we show how to use the csm_constraints function to apply constraints to the model.
# This works the same way for all other inbuilt constraints
import bilby.core.prior
from bilby.core.prior import Constraint
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import redback
# Imp... | Python | Unknown | 1,692 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/tde_example.py | import matplotlib.pyplot as plt
import redback
sampler = 'dynesty'
model = 'tde_analytical'
tde = "PS18kh"
data = redback.get_data.get_tidal_disruption_event_data_from_open_transient_catalog_data(tde)
tidal_disruption_event = redback.tde.TDE.from_open_access_catalogue(tde, data_mode='flux_density')
# lets make a p... | Python | Unknown | 1,436 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/simulate_basic_transient.py | # This example shows how to simulate a generic transient
# i.e., not using a pointing table to create lightcurves of a real survey but rather just random samples of a transient lightcurve.
# Since Redback models are callable functions this is easy to do yourself, but this example shows how to do it using the SimulatedG... | Python | Unknown | 1,815 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/gaussianrise_example.py | # In this example, we show how to fit the gaussian rise metzger model to a TDE.
# And show case how to use constraints.
import redback
import bilby
import numpy as np
from bilby.core.prior import LogUniform, Constraint, Uniform
# Let's load the data from the open access catalogue. Let's only fit the r band for speed.
... | Python | Unknown | 2,474 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/fit_simulated_high_energy_blackbody.py | """
End-to-end example: simulate a high-energy blackbody spectrum and recover parameters.
"""
import numpy as np
import redback.priors
from redback.simulate_transients import SimulateHighEnergyTransient
from redback.transient.spectral import CountsSpectrumTransient
from redback.sampler import fit_model
from redback.u... | Python | Unknown | 2,756 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/get_fink_data.py | #An example to get data from FINK and plot it
import redback
name = 'ZTF22abdjqlm'
data = redback.get_data.get_fink_data(transient=name, transient_type='supernova')
# FINK and OAC have the same data format, so we can just use the OAC class method to load this data
supernova = redback.supernova.Supernova.from_open_acc... | Python | Unknown | 537 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/ToOSimulations_with_redback.ipynb | {
"cells": [
{
"cell_type": "markdown",
"id": "ca02b38c",
"metadata": {},
"source": [
"## Notebook to show how to use redback to generate toO style observations for any model. \n",
"\n",
"You will need to install Redback. Instructions available at https://redback.readthedocs.io/en/latest/. I ... | Jupyter Notebook | Unknown | 9,802 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/supernova_example.py | import matplotlib.pyplot as plt
import redback
sampler = 'dynesty'
model = "arnett"
sne = "SN1998bw"
data = redback.get_data.get_supernova_data_from_open_transient_catalog_data(sne)
supernova = redback.supernova.Supernova.from_open_access_catalogue(name=sne, data_mode='flux_density', active_bands=["I", "R"])
sup... | Python | Unknown | 948 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/fit_ogip_spectrum.py | """
Fit an OGIP PHA/RMF spectrum with redback's spectral fitting API.
Uses publicly available Fermi/GBM BGO example data (simulated power-law GRB spectrum)
included in redback's example_data directory. The combined response file (.rsp) provides
the redistribution matrix and effective area in a single FITS file, as is ... | Python | Unknown | 2,939 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/creating_transient_objects.py | # In this example, we show a few of the different ways to load transient objects in redback.
# Note this example will not run unless you have run some other examples/have data downloaded.
# It is just meant to show the interface and describe the differences.
# First, we can load data downloaded from the open access ca... | Python | Unknown | 3,234 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/broadband_afterglow_private_data_example.py | # What if your data is not public, or if you simulated it yourself.
# You can fit it with redback but now by loading the transient object yourself.
# This example also shows how to fit afterglow models to broadband data.
# In particular, the afterglow of GRB170817A, the GRB that accompanied the first binary neutron sta... | Python | Unknown | 2,479 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/simulate_kilonova_population.py | # This example will show how to simulate a collection of kilonovae with Rubin
import redback
from redback.simulate_transients import SimulateOpticalTransient
import matplotlib.pyplot as plt
import bilby
import numpy as np
# We now set up the parameters for the kilonova population. An easy way to do this is to use the ... | Python | Unknown | 3,373 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/vegas_afterglow_tutorial.ipynb | {
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# VegasAfterglow Integration with Redback Tutorial\n",
"\n",
"This notebook demonstrates the full capabilities of using VegasAfterglow models within redback for GRB afterglow analysis.\n",
"\n",
"VegasAfterglow provides... | Jupyter Notebook | Unknown | 15,272 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/spectral_line_profile_models_example.py | """
Example: Using Spectral Line Profile Models and Velocity Fitting Tools
This example demonstrates how to:
1. Generate P-Cygni line profiles for supernova spectra
2. Create Voigt absorption profiles
3. Measure expansion velocities from spectral features
4. Track photospheric velocity evolution
5. Explore a SYNOW-sty... | Python | Unknown | 18,300 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/SN2011kl_sample_in_t0_example.py | import redback
from bilby.core.prior import Uniform, Gaussian
sampler = 'dynesty'
sne = "SN2011kl"
# we want to sample in t0 and with extinction so we use
model = 't0_supernova_extinction'
# we want to specify a base model for the actual physics
base_model = "arnett"
data = redback.get_data.get_supernova_data_from_o... | Python | Unknown | 2,298 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/supernova_with_unknown_explosion_date.py | from astropy.io import ascii
import bilby
import pandas as pd
from matplotlib import rcParams
import redback
from redback.model_library import all_models_dict
from redback.likelihoods import GaussianLikelihoodQuadratureNoise
from redback import filters
# Switching off latex rendering for faster and prettier ... | Python | Unknown | 8,451 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/kilonova_example.py | import matplotlib.pyplot as plt
import numpy as np
import redback
sampler = 'nestle'
# lots of different models implemented, including
# afterglow/magnetar varieties/n_dimensional_fireball/shapelets/band function/kilonova/SNe/TDE
model = 'one_component_kilonova_model'
kne = 'at2017gfo'
# gets the magnitude data for... | Python | Unknown | 1,462 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/GP_tutorial_with_redback.ipynb | {
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "037a774d",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"15:41 bilby INFO : Running bilby version: 2.3.1.dev100+g65bcde32\n",
"15:41 redback INFO : Running redba... | Jupyter Notebook | Unknown | 861,709 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/using_sncosmo_models_to_fit.py | # In this example, we show how one can use models implemented in sncosmo to fit data/or plot lightcurves.
# There is a general interface in redback that provides a redback-friendly interface to all models in sncosmo.
import bilby
import redback
import numpy as np
import matplotlib.pyplot as plt
# Let's first plot the... | Python | Unknown | 6,649 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/simulate_single_transient_in_rubin.py | # This example will show how to simulate a kilonova with the Rubin 10 year baseline survey v3.0 pointings table.
import redback
from redback.simulate_transients import SimulateOpticalTransient
import matplotlib.pyplot as plt
# We now set up the parameters for the kilonova model.
# We will use the one_component_kilonov... | Python | Unknown | 2,631 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/simulate_population_modular.py | """
Example script demonstrating the modular PopulationSynthesizer workflow
This shows how the refactored PopulationSynthesizer provides:
1. Pure parameter generation (generate_population)
2. Flexible post-processing (apply_detection_criteria)
3. Rate inference (infer_rate)
4. Integration with redback simulation tools... | Python | Unknown | 13,161 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/salt2_interface.py | import bilby
import redback
import numpy as np
import matplotlib.pyplot as plt
# redshift = 0.1
# start_time = 55570
# time = np.linspace(0.1, 65, 100) + start_time
#
# kwargs = {'frequency': 4e14, 'output_format': 'magnitude', 'bands':'ztfr'}
# outs = redback.transient_models.supernova_models.salt2(time=time, redshif... | Python | Unknown | 2,042 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/simulate_population_synthesis.py | """
Example script demonstrating the PopulationSynthesizer functionality
This shows how to:
1. Create a population synthesizer for different transient types
2. Simulate realistic populations with rate evolution
3. Apply selection effects
4. Analyze populations
5. Infer rates from observed samples
"""
import numpy as ... | Python | Unknown | 7,717 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/fit_gamma_xray_spectra.py | """
Fit a simulated gamma/X-ray count spectrum with redback's spectral fitting API.
Simulates a Band function GRB spectrum using SimulateHighEnergyTransient
(which uses the standard redback time-frequency interface), then fits the
time-integrated spectrum using band_function_high_energy directly.
"""
import numpy as ... | Python | Unknown | 2,606 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/magnetar_example.py | import redback
import bilby
# We implemented many models implemented, including
# afterglow/magnetar varieties/n_dimensional_fireball/shapelets/band function/kilonova/SNe/TDE
model = 'evolving_magnetar'
GRB = '070809'
# Flux density, flux data
redback.get_data.get_bat_xrt_afterglow_data_from_swift(grb=GRB, data_mode=... | Python | Unknown | 2,036 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/bolometric_luminosity_fitting.py | # In this example we show how to use redback to fit bolometric luminosities of different optical transients.
# Note, redback also provides functionality to build a bolometric lightcurve with/without SED corrections from the photometric data.
# Please check the other examples for more details.
# Lets import some stuff
... | Python | Unknown | 2,565 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/joint_grb_gw_example.py | # In this example, we show how redback and bilby can be used together to jointly analyse
# a GRB afterglow + GW signal from a binary neutron star merger.
# We will fix some parameters on the GRB afterglow model, with a simple tophat model
# and then use relative binning in bilby to speed up the analysis for this exampl... | Python | Unknown | 12,008 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/estimating_blackbody_properties_with_redback.ipynb | {
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "5f243c9e",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"22:04 bilby INFO : Running bilby version: 2.3.1.dev100+g65bcde32\n",
"22:04 redback INFO : Running redba... | Jupyter Notebook | Unknown | 634,983 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/fit_your_own_model_example.py | import bilby.core.prior
import redback
from bilby.core.prior import LogUniform, Uniform
# If your favourite model is not implemented in redback. You can still fit it using redback!
# Now instead of passing a string as the model. You need to pass a python function.
# let's make a simple power law. A power law model ... | Python | Unknown | 1,786 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/prompt_example.py | import redback
sampler = 'dynesty'
model = 'gaussian_prompt'
name = '910505'
data = redback.get_data.get_prompt_data_from_batse(grb=name)
prompt = redback.transient.prompt.PromptTimeSeries.from_batse_grb_name(name=name)
# use default priors
priors = redback.priors.get_priors(model=model, times=prompt.time,
... | Python | Unknown | 697 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/magnetar_boosted_example.py | import matplotlib.pyplot as plt
import redback
sampler = 'dynesty'
# lots of different models implemented, including
# afterglow/magnetar varieties/n_dimensional_fireball/shapelets/band function/kilonova/SNe/TDE
model = 'general_mergernova'
kne = 'at2017gfo'
# gets the magnitude data for AT2017gfo, the KN associate... | Python | Unknown | 1,539 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/RedbackTutorial.ipynb | {
"cells": [
{
"cell_type": "markdown",
"id": "9f292d87",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Redback: an open source bayesian inference package for fitting electromagnetic transients. \n",
"\n",
"## How redback can be useful to you.\n",
... | Jupyter Notebook | Unknown | 38,523 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/simulate_radio_xray_cadence.py | """
Example: Radio/X-ray Observations with SimulateTransientWithCadence
This demonstrates the capability to simulate radio and X-ray observations
with realistic cadences and SNR-based detection cuts using SimulateTransientWithCadence.
Perfect for:
- Radio/X-ray follow-up campaigns with some pre-defined cadence; perha... | Python | Unknown | 12,210 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/using_model_as_a_function.py | # In this example, we show how a model can be called a function.
# This is useful for plotting, or for use in setting up an analysis.
import redback
import numpy as np
import matplotlib.pyplot as plt
model = 'one_component_kilonova_model'
# use default priors
priors = redback.priors.get_priors(model=model)
priors['red... | Python | Unknown | 775 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/magnetar_example_with_gaussian_process.py | import numpy as np
import bilby
import george
import redback
# We implemented many models implemented, including
# afterglow/magnetar varieties/n_dimensional_fireball/shapelets/band function/kilonova/SNe/TDE
model = 'full_magnetar'
magmodel = bilby.likelihood.function_to_george_mean_model(redback.model_library.all_m... | Python | Unknown | 3,421 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/simulate_radio_xray.py | """
Example: Radio and X-ray Transient Simulation
This demonstrates using redback simulation tools for radio and X-ray transients,
including GRB afterglows, TDEs, and other multi-wavelength phenomena.
Keep in mind this is just an example usage; you can adapt a lot of the code below to be more specific to your needs.
L... | Python | Unknown | 12,308 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/simulate_kilonova.py | # This example will show how to simulate a kilonova with a user-generated pointings table
import redback
from redback.simulate_transients import SimulateOpticalTransient
# We first set up a table that contains the pointings of the telescope.
# This requires setting the number of observations in each filter, average ... | Python | Unknown | 3,013 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/simulate_single_transient_in_ztf.py | # This example will show how to simulate a kilonova with ZTF pointings table.
import redback
from redback.simulate_transients import SimulateOpticalTransient
import matplotlib.pyplot as plt
# We now set up the parameters for the kilonova model.
# We will use the one_component_kilonova_model implemented in redback but ... | Python | Unknown | 2,889 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/example_plugin/README.md | # Redback Example Plugin
A minimal working example of a redback plugin. It demonstrates every piece a plugin author needs to provide: model functions, prior files, a prior loader, and the `setup.py` entry points that wire them into redback automatically.
After `pip install -e .`, the plugin's models and priors are av... | Markdown | Unknown | 7,620 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/example_plugin/setup.py | """
Setup script for redback-example-plugin.
This demonstrates how to create a plugin package for Redback.
"""
from setuptools import setup, find_packages
setup(
name='redback-example-plugin',
version='0.1.0',
description='Example plugin package for Redback demonstrating the plugin system',
author='R... | Python | Unknown | 1,035 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/example_plugin/redback_example_plugin/__init__.py | """
Redback Example Plugin
This is a minimal example plugin demonstrating how to extend Redback with custom models.
"""
__version__ = '0.1.0'
| Python | Unknown | 144 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/example_plugin/redback_example_plugin/models.py | """
Example custom models for Redback.
This module demonstrates how to create models that can be registered as Redback plugins.
"""
import numpy as np
def example_exponential_model(time, amplitude, decay_time, **kwargs):
"""
Simple exponential decay model.
This is a minimal example model to demonstrate... | Python | Unknown | 1,900 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | examples/example_plugin/redback_example_plugin/priors.py | """
Prior loader for the redback example plugin.
Registered via the 'redback.model.priors' entry point group.
"""
import os
from bilby.core.prior import PriorDict
PRIOR_DIR = os.path.join(os.path.dirname(__file__), 'priors')
def get_prior(model_name):
"""
Return a PriorDict for the given model name, or Non... | Python | Unknown | 587 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | .pre-commit-hooks/check_duplicates.py | #!/usr/bin/env python3
"""
Pre-commit hook to detect duplicate class and function definitions in Python files.
"""
import ast
import sys
from collections import defaultdict
from pathlib import Path
class DuplicateChecker(ast.NodeVisitor):
"""AST visitor to find duplicate class and function definitions."""
de... | Python | Unknown | 4,739 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | .pre-commit-hooks/check_nan_comparison.py | #!/usr/bin/env python3
"""
Pre-commit hook to detect incorrect NaN comparisons in Python files.
"""
import re
import sys
def check_file(filename):
"""Check a single Python file for incorrect NaN comparisons."""
errors = []
try:
with open(filename, 'r', encoding='utf-8') as f:
lines = ... | Python | Unknown | 1,917 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | .pre-commit-hooks/README.md | # Pre-commit Hooks
This directory contains custom pre-commit hooks to maintain code quality and prevent common errors.
## Installation
To use these pre-commit hooks, first install pre-commit:
```bash
pip install pre-commit
```
Then install the git hooks:
```bash
pre-commit install
```
## Custom Hooks
### check_... | Markdown | Unknown | 1,458 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/wrappers.py | from redback.utils import logger
def cond_jit(func=None, **kwargs):
"""A conditional function wrapper for number jit functions.
Parameters
----------
func : callable, optional
The function to wrap. This is automatically passed when
the decorator has explicit arguments (e.g. no () afte... | Python | Unknown | 1,205 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/__init__.py | from redback import analysis, constants, get_data, redback_errors, priors, result, sampler, transient, \
transient_models, utils, photosphere, sed, interaction_processes, constraints, plotting, model_library, \
simulate_transients
from redback.transient import afterglow, kilonova, prompt, supernova, tde
from re... | Python | Unknown | 975 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/interaction_processes.py | # This is mostly from mosfit/transforms but rewritten to be modular
import numpy as np
from scipy.interpolate import interp1d
from redback.constants import *
class Diffusion(object):
def __init__(self, time, dense_times, luminosity, kappa, kappa_gamma, mej, vej, **kwargs):
"""
:param time: source ... | Python | Unknown | 10,123 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/photosphere.py | # This is mostly from mosfit/photospheres but rewritten considerably.
from typing import Any, Union
import numpy as np
from redback.constants import *
class CocoonPhotosphere(object):
DIFFUSION_CONSTANT = solar_mass / (4*np.pi*speed_of_light*km_cgs)
RADIUS_CONSTANT = km_cgs * day_to_s
STEF_CONSTANT = 4 *... | Python | Unknown | 11,588 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/constraints.py | import numpy as np
import redback.eos as eos
from redback.constants import *
from redback.utils import calc_tfb
from scipy.interpolate import interp1d
def slsn_constraint(parameters):
"""
Place constraints on the magnetar rotational energy being larger than the total output energy,
and the that nebula phas... | Python | Unknown | 11,365 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/redback_errors.py | class DataExists(Exception):
pass
class WebsiteExist(Exception):
pass
| Python | Unknown | 80 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/ejecta_relations.py | import numpy as np
from astropy import constants as cc
from redback.utils import citation_wrapper
class OneComponentBNSNoProjection(object):
def __init__(self, mass_1, mass_2, lambda_1, lambda_2):
"""
Relations to connect intrinsic GW parameters to extrinsic kilonova parameters from Dietrich and Uj... | Python | Unknown | 18,701 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/likelihoods.py | import numpy as np
from typing import Any, Union
import bilby
from scipy.special import gammaln, erf
from redback.utils import logger
from bilby.core.prior import DeltaFunction, Constraint
class _RedbackLikelihood(bilby.Likelihood):
def __init__(self, x: np.ndarray, y: np.ndarray, function: callable, kwargs: dic... | Python | Unknown | 50,694 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/constants.py | import astropy.constants as cc
import astropy.units as uu
ev_to_erg = 1.60218e-12
speed_of_light = cc.c.cgs.value
planck = cc.h.cgs.value
proton_mass = cc.m_p.cgs.value
electron_mass = cc.m_e.cgs.value
mev_cgs = uu.MeV.cgs.scale
qe = 4.80320425e-10
solar_mass = cc.M_sun.cgs.value
sigma_sb = cc.sigma_sb.cgs.value
sigma... | Python | Unknown | 708 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/model_library.py | from importlib.metadata import entry_points
from redback.transient_models import afterglow_models, \
extinction_models, kilonova_models, fireball_models, \
gaussianprocess_models, magnetar_models, magnetar_driven_ejecta_models, phase_models, phenomenological_models, \
prompt_models, shock_powered_models, s... | Python | Unknown | 4,134 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/utils.py | import contextlib
import logging
import os
from collections import namedtuple
from inspect import getmembers, isfunction
from pathlib import Path
from astropy.time import Time
import bilby
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy.interpolate import RegularGridInterpolator, inte... | Python | Unknown | 51,830 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/simulate_transients.py | import numpy as np
from redback.sed import RedbackTimeSeriesSource
import redback
import pandas as pd
from redback.utils import logger, calc_flux_density_error_from_monochromatic_magnitude, calc_flux_density_from_ABmag
from itertools import repeat
import astropy.units as uu
from scipy.spatial import KDTree
from scipy i... | Python | Unknown | 122,380 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/analysis.py | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from typing import Union, Optional
from pathlib import Path
import redback.model_library
from redback.utils import logger, find_nearest, bands_to_frequency
from redback.result import RedbackResult
from redback.constants import day_to_s
import matp... | Python | Unknown | 107,079 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/plotting.py | from __future__ import annotations
from os.path import join
from typing import Any, Union
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import redback
from redback.utils import KwargsAccessorWithDefault, logger
class _FilenameGetter(object):
def __init__(self, suffix: ... | Python | Unknown | 78,345 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/eos.py | import numpy as np
from redback.constants import *
from redback.utils import logger
import astropy.constants as cc
import astropy.units as uu
from scipy.interpolate import interp1d
try:
import lalsimulation as lalsim
except ModuleNotFoundError as e:
logger.warning(e)
logger.warning('lalsimulation is not in... | Python | Unknown | 6,402 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/result.py | import bilby.core.prior
import numpy as np
import os
from typing import Union
import warnings
import matplotlib
import pandas as pd
from bilby.core.result import Result
from bilby.core.result import _determine_file_name # noqa
import redback.transient.transient
from redback import model_library
from redback.transient... | Python | Unknown | 14,013 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/sed.py | from typing import Union
import numpy as np
from sncosmo import TimeSeriesSource
from redback.constants import *
from redback.utils import nu_to_lambda, bandpass_magnitude_to_flux, logger
def _bandflux_single_redback(model, band, time_or_phase):
"""
Synthetic photometry of a model through a single bandpass... | Python | Unknown | 42,127 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/filters.py | from astropy.io import ascii
from astropy import units as u
from astroquery.svo_fps import SvoFps
import numpy as np
from redback.utils import calc_effective_width_hz_from_angstrom
import redback
import sncosmo
def add_to_database(label, wavelength, zeroflux, database, plot_label, effective_width):
"""
Add a ... | Python | Unknown | 12,233 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/sampler.py | import matplotlib.pyplot as plt
import os
from pathlib import Path
from typing import Union
import bilby
import redback.get_data
from redback.likelihoods import GaussianLikelihood, PoissonLikelihood, PoissonSpectralLikelihood, \
WStatSpectralLikelihood, ChiSquareSpectralLikelihood
from redback.model_library impor... | Python | Unknown | 21,109 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/priors.py | import numpy as np
import os
import bilby.core.prior
from bilby.core.prior import PriorDict
import redback.model_library
import redback.constraints
from redback.utils import logger
_constraint_map = {
'slsn': redback.constraints.slsn_constraint,
'slsn_bolometric': redback.constraints.slsn_constraint,
}
def... | Python | Unknown | 6,051 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/spectral_models.py | import os
from functools import lru_cache
import numpy as np
from astropy.cosmology import Planck18 as cosmo
from astropy.io import fits
import redback.constants as cc
from redback.utils import lambda_to_nu, fnu_to_flambda, citation_wrapper, logger
import redback.sed as sed
import redback.transient_models.phenomenolog... | Python | Unknown | 37,410 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/shock_powered_models.py | import numpy as np
from collections import namedtuple
from scipy import special
from scipy.interpolate import interp1d
import redback.constants as cc
from astropy import units as uu
import redback.sed as sed
from redback.sed import flux_density_to_spectrum, blackbody_to_spectrum
from astropy.cosmology import Planck18 a... | Python | Unknown | 61,500 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/phase_models.py | from inspect import isfunction
import numpy as np
from astropy.time import Time
import astropy.units as uu
from redback.constants import *
from redback.transient_models import extinction_models
from redback.transient_models import integrated_flux_afterglow_models as infam
from redback.utils import calc_ABmag_from_flu... | Python | Unknown | 17,413 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/learned_models.py | """This file holds the functions to call the LearnedSurrogateModel models.
LearnedSurrogateModel are models from the redback_surrogates package that
have been trained to emulate more complex transient models and saved in ONNX format.
The workflow for these models is to load the model from an ONNX file using
the Learn... | Python | Unknown | 8,061 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/combined_models.py | import redback.transient_models.extinction_models as em
import redback.transient_models as tm
from redback.utils import nu_to_lambda
from redback.utils import lambda_to_nu
from redback.utils import day_to_s
from redback.utils import citation_wrapper
from redback.utils import calc_ABmag_from_flux_density
from redback.se... | Python | Unknown | 18,988 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/integrated_flux_afterglow_models.py | from inspect import isfunction
import numpy as np
from scipy.integrate import simpson
from redback.utils import logger, citation_wrapper
integrated_flux_base_models = ['tophat', 'cocoon', 'gaussian',
'kn_afterglow', 'cone_afterglow',
'gaussiancore', 'gaus... | Python | Unknown | 2,906 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/prompt_models.py | import numpy as np
def gaussian_prompt(times, amplitude, t_0, sigma, **kwargs):
dt = kwargs.get('dt', 1)
return amplitude * np.exp(-(times - t_0) ** 2 / (2 * sigma ** 2)) * dt
def skew_gaussian(times, amplitude, t_0, sigma_rise, sigma_fall, **kwargs):
dt = kwargs.get('dt', 1)
before_burst_indices = ... | Python | Unknown | 1,811 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/general_synchrotron_models.py | import numpy as np
from redback.transient_models.magnetar_models import magnetar_only, basic_magnetar
from redback.transient_models.magnetar_driven_ejecta_models import _ejecta_dynamics_and_interaction
from redback.transient_models.shock_powered_models import _emissivity_pl, _emissivity_thermal, _tau_nu, _c_j, _c_alpha... | Python | Unknown | 41,457 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/kilonova_models.py | import numpy as np
import pandas as pd
from astropy.table import Table, Column
from scipy.interpolate import interp1d, RegularGridInterpolator
from astropy.cosmology import Planck18 as cosmo # noqa
from scipy.integrate import cumulative_trapezoid
from collections import namedtuple
from redback.photosphere import Temp... | Python | Unknown | 110,314 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/fireball_models.py | from redback.utils import citation_wrapper
@citation_wrapper('redback')
def predeceleration(time, aa, mm, t0, **kwargs):
"""
:param time: time array in seconds
:param aa: amplitude term for powerlaw
:param mm: deceleration powerlaw gradient; typically 3 but depends on physics
:param t0: time GRB we... | Python | Unknown | 870 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/stellar_interaction_models.py | import numpy as np
from collections import namedtuple
import redback.sed as sed
from redback.sed import flux_density_to_spectrum
import redback.photosphere as photosphere
from astropy.cosmology import Planck18 as cosmo
from redback.utils import calc_kcorrected_properties, citation_wrapper, lambda_to_nu
from redback.con... | Python | Unknown | 14,620 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/__init__.py | from redback.transient_models import (afterglow_models, \
extinction_models, kilonova_models, fireball_models, \
gaussianprocess_models, magnetar_models, magnetar_driven_ejecta_models, phase_models, prompt_models, \
shock_powered_models, supernova_models, tde_models, integrated_flux_afterglow_models, phenom... | Python | Unknown | 435 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/phenomenological_models.py | import numpy as np
from redback.utils import citation_wrapper
from redback.constants import speed_of_light_si
def smooth_exponential_powerlaw(time, a_1, tpeak, alpha_1, alpha_2, smoothing_factor, **kwargs):
"""
Smoothed version of exponential power law
:param time: time array in seconds
:param a_1: e... | Python | Unknown | 40,473 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/magnetar_driven_ejecta_models.py | from redback.constants import *
from redback.transient_models.magnetar_models import magnetar_only, basic_magnetar, _evolving_gw_and_em_magnetar
import numpy as np
from astropy.cosmology import Planck18 as cosmo # noqa
from scipy.interpolate import interp1d
from collections import namedtuple
import astropy.units as uu... | Python | Unknown | 54,758 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/supernova_models.py | import numpy as np
import pandas as pd
from redback.transient_models.phenomenological_models import exponential_powerlaw, fallback_lbol
from redback.transient_models.magnetar_models import magnetar_only, basic_magnetar
from redback.transient_models.magnetar_driven_ejecta_models import _ejecta_dynamics_and_interaction
f... | Python | Unknown | 177,132 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/magnetar_models.py | import numpy as np
from astropy.cosmology import Planck18 as cosmo # noqa
import scipy.special as ss
from collections import namedtuple
from scipy.interpolate import interp1d
from scipy.integrate import quad, cumulative_trapezoid as cumtrapz
from inspect import isfunction
from redback.utils import logger, citation_wr... | Python | Unknown | 25,577 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/tde_models.py | import numpy as np
import redback.interaction_processes as ip
import redback.sed as sed
from redback.sed import flux_density_to_spectrum, blackbody_to_spectrum
import redback.photosphere as photosphere
from redback.utils import calc_kcorrected_properties, citation_wrapper, calc_tfb, lambda_to_nu, \
calc_ABmag_from_... | Python | Unknown | 89,042 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/gaussianprocess_models.py | from redback.transient_models import phenomenological_models as pm
def calculate_flux_with_labels(time, t0, tau_rise, tau_fall, labels, **kwargs):
"""
Calculate flux for multiple sets of parameters using the Bazin function,
where parameters are indexed by the provided labels.
:param time: time array i... | Python | Unknown | 1,314 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/extinction_models.py | from inspect import isfunction
import numpy as np
import redback.utils
from redback.transient_models.fireball_models import predeceleration
from redback.utils import logger, calc_ABmag_from_flux_density, citation_wrapper, lambda_to_nu
import astropy.units as uu
import redback.sed as sed
from redback.constants import da... | Python | Unknown | 27,198 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/afterglow_models/vegas_models.py | """
VegasAfterglow Models for Redback
==================================
High-performance C++ afterglow models via VegasAfterglow.
Provides millisecond-scale light curve evaluation for all jet structures.
Each model uses a unified interface supporting ISM, Wind, and Hybrid media
through lognism and loga parameters.
... | Python | Unknown | 29,394 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/afterglow_models/base_models.py | from astropy.cosmology import Planck18 as cosmo # noqa
from inspect import isfunction
from redback.utils import logger, citation_wrapper, calc_ABmag_from_flux_density, lambda_to_nu, bands_to_frequency
from redback.constants import day_to_s, speed_of_light, solar_mass, proton_mass, electron_mass, sigma_T
from redback.s... | Python | Unknown | 122,164 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient_models/afterglow_models/__init__.py | """
Afterglow Models Subpackage
============================
GRB afterglow models organized by implementation backend.
Structure:
- base_models.py: Original redback afterglow models (afterglowpy wrappers, native implementations)
- vegas_models.py: VegasAfterglow C++ high-performance models
This subpackage maintains ... | Python | Unknown | 4,604 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient/spectral.py | from __future__ import annotations
from dataclasses import dataclass
from typing import Optional
import redback
from redback.spectral.dataset import SpectralDataset
@dataclass
class CountsSpectrumTransient:
"""
High-energy spectral transient wrapper for OGIP-style data.
"""
dataset: SpectralDataset
... | Python | Unknown | 2,602 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient/__init__.py | from redback.transient import afterglow, kilonova, prompt, supernova, tde, transient, spectral
from redback.transient.afterglow import Afterglow, LGRB, SGRB
from redback.transient.kilonova import Kilonova
from redback.transient.prompt import PromptTimeSeries
from redback.transient.supernova import Supernova
from redbac... | Python | Unknown | 757 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient/afterglow.py | from __future__ import annotations
import os
from os.path import join
from typing import Union
import re
import numpy as np
import pandas as pd
from astropy.cosmology import Planck18 as cosmo # noqa
from redback.get_data.directory import afterglow_directory_structure
from redback.transient.transient import Transien... | Python | Unknown | 30,941 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient/prompt.py | from __future__ import annotations
import matplotlib.axes
import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
from typing import Union
from redback.get_data.utils import get_batse_trigger_from_grb
from redback.get_data.directory import swift_prompt_directory_structure, batse_prompt_direct... | Python | Unknown | 10,629 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient/tde.py | import numpy as np
from typing import Union
import redback.get_data.directory
from redback.transient.transient import OpticalTransient
from redback.utils import logger
class TDE(OpticalTransient):
DATA_MODES = ['flux', 'flux_density', 'magnitude', 'luminosity']
def __init__(
self, name: str, dat... | Python | Unknown | 5,298 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient/supernova.py | import numpy as np
from typing import Union
import redback.get_data.directory
from redback.transient.transient import OpticalTransient
from redback.utils import logger
class Supernova(OpticalTransient):
DATA_MODES = ['flux', 'flux_density', 'magnitude', 'luminosity']
def __init__(
self, name: st... | Python | Unknown | 5,609 |
[ascl:2406.028] | https://github.com/nikhil-sarin/redback | redback/transient/transient.py | from __future__ import annotations
from typing import Union
import matplotlib
import numpy as np
import pandas as pd
import redback
from redback.plotting import \
LuminosityPlotter, FluxDensityPlotter, IntegratedFluxPlotter, MagnitudePlotter, \
IntegratedFluxOpticalPlotter, SpectrumPlotter, LuminosityOptical... | Python | Unknown | 85,553 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.