redback 1.0.1__py3-none-any.whl → 1.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- redback/__init__.py +4 -0
- redback/constraints.py +46 -25
- redback/eos.py +1 -0
- redback/get_data/fink.py +1 -1
- redback/get_data/lasair.py +3 -4
- redback/get_data/swift.py +7 -7
- redback/interaction_processes.py +1 -4
- redback/likelihoods.py +207 -21
- redback/model_library.py +2 -2
- redback/plotting.py +10 -10
- redback/priors/bazin_sne.prior +5 -0
- redback/priors/csm_interaction.prior +6 -7
- redback/priors/csm_nickel.prior +3 -3
- redback/priors/csm_shock_and_arnett.prior +11 -0
- redback/priors/csm_shock_and_arnett_bolometric.prior +10 -0
- redback/priors/csm_shock_breakout.prior +7 -0
- redback/priors/nicholl_bns.prior +2 -1
- redback/priors/one_comp_kne_rosswog_heatingrate.prior +5 -0
- redback/priors/pwn.prior +7 -0
- redback/priors/shocked_cocoon.prior +6 -6
- redback/priors/sn_fallback.prior +8 -0
- redback/priors/stream_stream_tde.prior +10 -0
- redback/priors/stream_stream_tde_bolometric.prior +9 -0
- redback/priors/tde_analytical.prior +5 -5
- redback/priors/tde_analytical_bolometric.prior +6 -4
- redback/priors/tde_fallback.prior +9 -0
- redback/priors/tde_fallback_bolometric.prior +6 -0
- redback/priors/tde_synchrotron.prior +6 -0
- redback/priors/tophat_from_emulator.prior +9 -0
- redback/priors/two_comp_kne_rosswog_heatingrate.prior +9 -0
- redback/priors/two_layer_stratified_kilonova.prior +1 -1
- redback/priors/villar_sne.prior +7 -0
- redback/priors.py +12 -1
- redback/sed.py +194 -2
- redback/simulate_transients.py +71 -35
- redback/tables/GRBs_w_redshift.txt +430 -413
- redback/tables/LGRB_table.txt +70 -6
- redback/tables/SGRB_table.txt +139 -135
- redback/tables/filters.csv +14 -0
- redback/tables/qdot_rosswogkorobkin24.pck +0 -0
- redback/tables/ztf.tar.gz +0 -0
- redback/transient/afterglow.py +17 -7
- redback/transient/kilonova.py +6 -3
- redback/transient/prompt.py +14 -4
- redback/transient/supernova.py +7 -3
- redback/transient/tde.py +6 -3
- redback/transient/transient.py +29 -12
- redback/transient_models/afterglow_models.py +152 -146
- redback/transient_models/combined_models.py +69 -48
- redback/transient_models/extinction_models.py +6 -6
- redback/transient_models/general_synchrotron_models.py +518 -0
- redback/transient_models/integrated_flux_afterglow_models.py +2 -2
- redback/transient_models/kilonova_models.py +310 -61
- redback/transient_models/magnetar_driven_ejecta_models.py +2 -2
- redback/transient_models/magnetar_models.py +1 -1
- redback/transient_models/phenomenological_models.py +69 -1
- redback/transient_models/shock_powered_models.py +159 -110
- redback/transient_models/supernova_models.py +211 -43
- redback/transient_models/tde_models.py +975 -5
- redback/utils.py +309 -16
- {redback-1.0.1.dist-info → redback-1.0.3.dist-info}/METADATA +46 -6
- {redback-1.0.1.dist-info → redback-1.0.3.dist-info}/RECORD +65 -49
- {redback-1.0.1.dist-info → redback-1.0.3.dist-info}/WHEEL +1 -1
- redback/tables/ztf_obslog.csv +0 -106649
- {redback-1.0.1.dist-info → redback-1.0.3.dist-info}/LICENCE.md +0 -0
- {redback-1.0.1.dist-info → redback-1.0.3.dist-info}/top_level.txt +0 -0
redback/transient/afterglow.py
CHANGED
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import os
|
|
4
4
|
from os.path import join
|
|
5
5
|
from typing import Union
|
|
6
|
+
import re
|
|
6
7
|
|
|
7
8
|
import numpy as np
|
|
8
9
|
import pandas as pd
|
|
@@ -26,7 +27,8 @@ class Afterglow(Transient):
|
|
|
26
27
|
flux_density_err: np.ndarray = None, magnitude: np.ndarray = None, magnitude_err: np.ndarray = None,
|
|
27
28
|
redshift: float = np.nan, photon_index: float = np.nan, frequency: np.ndarray = None,
|
|
28
29
|
bands: np.ndarray = None, system: np.ndarray = None, active_bands: Union[np.ndarray, str] = 'all',
|
|
29
|
-
|
|
30
|
+
plotting_order: Union[np.ndarray, str] = None, use_phase_model: bool = False,
|
|
31
|
+
optical_data: bool = False, **kwargs: None) -> None:
|
|
30
32
|
|
|
31
33
|
"""
|
|
32
34
|
This is a general constructor for the Afterglow class. Note that you only need to give data corresponding to
|
|
@@ -57,7 +59,7 @@ class Afterglow(Transient):
|
|
|
57
59
|
:type flux: np.ndarray, optional
|
|
58
60
|
:type flux_err: np.ndarray, optional
|
|
59
61
|
:param flux_err: Flux error values.
|
|
60
|
-
:param flux_density:Flux density values.
|
|
62
|
+
:param flux_density: Flux density values.
|
|
61
63
|
:type flux_density: np.ndarray, optional
|
|
62
64
|
:param flux_density_err: Flux density error values.
|
|
63
65
|
:type flux_density_err: np.ndarray, optional
|
|
@@ -81,6 +83,8 @@ class Afterglow(Transient):
|
|
|
81
83
|
:type bands: np.ndarray, optional
|
|
82
84
|
:param active_bands: List or array of active bands to be used in the analysis. Use all available bands if 'all' is given.
|
|
83
85
|
:type active_bands: Union[list, np.ndarray]
|
|
86
|
+
:param plotting_order: Order in which to plot the bands/and how unique bands are stored.
|
|
87
|
+
:type plotting_order: Union[np.ndarray, str], optional
|
|
84
88
|
:param kwargs:
|
|
85
89
|
Additional classes that can be customised to fulfil the truncation on flux to luminosity conversion:
|
|
86
90
|
FluxToLuminosityConverter: Conversion class to convert fluxes to luminosities.
|
|
@@ -99,7 +103,8 @@ class Afterglow(Transient):
|
|
|
99
103
|
Lum50=Lum50, Lum50_err=Lum50_err, flux=flux, flux_err=flux_err, flux_density=flux_density,
|
|
100
104
|
flux_density_err=flux_density_err, use_phase_model=use_phase_model, optical_data=optical_data,
|
|
101
105
|
magnitude=magnitude, magnitude_err=magnitude_err, frequency=frequency, redshift=redshift,
|
|
102
|
-
photon_index=photon_index, system=system, bands=bands, active_bands=active_bands,
|
|
106
|
+
photon_index=photon_index, system=system, bands=bands, active_bands=active_bands,
|
|
107
|
+
plotting_order=plotting_order, **kwargs)
|
|
103
108
|
self._set_data()
|
|
104
109
|
self._set_photon_index()
|
|
105
110
|
self._set_t90()
|
|
@@ -244,7 +249,8 @@ class Afterglow(Transient):
|
|
|
244
249
|
'BAT Photon Index (15-150 keV) (PL = simple power-law, CPL = cutoff power-law)'].fillna(0)
|
|
245
250
|
self.meta_data = meta_data
|
|
246
251
|
except FileNotFoundError:
|
|
247
|
-
logger.
|
|
252
|
+
logger.info("Metadata does not exist for this event.")
|
|
253
|
+
logger.info("Setting metadata to None. This is not an error, but a warning that no metadata could be found online.")
|
|
248
254
|
self.meta_data = None
|
|
249
255
|
|
|
250
256
|
def _set_photon_index(self) -> None:
|
|
@@ -305,9 +311,13 @@ class Afterglow(Transient):
|
|
|
305
311
|
:return: The cleaned string converted into a float.
|
|
306
312
|
:rtype: float
|
|
307
313
|
"""
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
314
|
+
try:
|
|
315
|
+
for r in ["PL", "CPL", ",", "C", "~", " ", 'Gemini:emission', '()']:
|
|
316
|
+
string = string.replace(r, "")
|
|
317
|
+
new_float = float(string)
|
|
318
|
+
except ValueError:
|
|
319
|
+
new_float = float(re.findall("\d+\.\d+", string)[0])
|
|
320
|
+
return new_float
|
|
311
321
|
|
|
312
322
|
def analytical_flux_to_luminosity(self) -> None:
|
|
313
323
|
"""Converts flux to luminosity using the analytical method."""
|
redback/transient/kilonova.py
CHANGED
|
@@ -20,7 +20,8 @@ class Kilonova(OpticalTransient):
|
|
|
20
20
|
flux_density: np.ndarray = None, flux_density_err: np.ndarray = None, magnitude: np.ndarray = None,
|
|
21
21
|
magnitude_err: np.ndarray = None, redshift: float = np.nan, photon_index: float = np.nan,
|
|
22
22
|
bands: np.ndarray = None, system: np.ndarray = None, active_bands: Union[np.ndarray, str] = 'all',
|
|
23
|
-
|
|
23
|
+
plotting_order: Union[np.ndarray, str] = None, use_phase_model: bool = False,
|
|
24
|
+
optical_data: bool = True, **kwargs: None) -> None:
|
|
24
25
|
"""This is a general constructor for the Kilonova class. Note that you only need to give data corresponding to
|
|
25
26
|
the data mode you are using. For luminosity data provide times in the rest frame, if using a phase model
|
|
26
27
|
provide time in MJD, else use the default time (observer frame).
|
|
@@ -50,7 +51,7 @@ class Kilonova(OpticalTransient):
|
|
|
50
51
|
:type flux: np.ndarray, optional
|
|
51
52
|
:type flux_err: np.ndarray, optional
|
|
52
53
|
:param flux_err: Flux error values.
|
|
53
|
-
:param flux_density:Flux density values.
|
|
54
|
+
:param flux_density: Flux density values.
|
|
54
55
|
:type flux_density: np.ndarray, optional
|
|
55
56
|
:param flux_density_err: Flux density error values.
|
|
56
57
|
:type flux_density_err: np.ndarray, optional
|
|
@@ -74,6 +75,8 @@ class Kilonova(OpticalTransient):
|
|
|
74
75
|
:type bands: np.ndarray, optional
|
|
75
76
|
:param active_bands: List or array of active bands to be used in the analysis. Use all available bands if 'all' is given.
|
|
76
77
|
:type active_bands: Union[list, np.ndarray]
|
|
78
|
+
:param plotting_order: Order in which to plot the bands/and how unique bands are stored.
|
|
79
|
+
:type plotting_order: Union[np.ndarray, str], optional
|
|
77
80
|
:param kwargs: Additional callables:
|
|
78
81
|
bands_to_frequency: Conversion function to convert a list of bands to frequencies. Use
|
|
79
82
|
redback.utils.bands_to_frequency if not given.
|
|
@@ -85,7 +88,7 @@ class Kilonova(OpticalTransient):
|
|
|
85
88
|
Lum50_err=Lum50_err, flux_density=flux_density, flux_density_err=flux_density_err,
|
|
86
89
|
magnitude=magnitude, magnitude_err=magnitude_err, data_mode=data_mode, name=name, bands=bands,
|
|
87
90
|
system=system, active_bands=active_bands, use_phase_model=use_phase_model, redshift=redshift,
|
|
88
|
-
photon_index=photon_index, optical_data=optical_data, **kwargs)
|
|
91
|
+
photon_index=photon_index, optical_data=optical_data, plotting_order=plotting_order, **kwargs)
|
|
89
92
|
self.directory_structure = redback.get_data.directory.open_access_directory_structure(
|
|
90
93
|
transient=name, transient_type="kilonova")
|
|
91
94
|
self._set_data()
|
redback/transient/prompt.py
CHANGED
|
@@ -8,7 +8,7 @@ import pandas as pd
|
|
|
8
8
|
from typing import Union
|
|
9
9
|
|
|
10
10
|
from redback.get_data.utils import get_batse_trigger_from_grb
|
|
11
|
-
from redback.get_data.directory import swift_prompt_directory_structure
|
|
11
|
+
from redback.get_data.directory import swift_prompt_directory_structure, batse_prompt_directory_structure
|
|
12
12
|
from redback.transient.transient import Transient
|
|
13
13
|
|
|
14
14
|
dirname = os.path.dirname(__file__)
|
|
@@ -61,7 +61,12 @@ class PromptTimeSeries(Transient):
|
|
|
61
61
|
self.channels = channels
|
|
62
62
|
self.instrument = instrument
|
|
63
63
|
self._set_data()
|
|
64
|
-
self.
|
|
64
|
+
if self.instrument == "batse":
|
|
65
|
+
self.directory_structure = batse_prompt_directory_structure(grb=self.name)
|
|
66
|
+
elif self.instrument == "swift":
|
|
67
|
+
self.directory_structure = swift_prompt_directory_structure(grb=self.name, bin_size=self.bin_size)
|
|
68
|
+
else:
|
|
69
|
+
raise ValueError("Instrument must be either 'batse' or 'swift'.")
|
|
65
70
|
|
|
66
71
|
@classmethod
|
|
67
72
|
def from_batse_grb_name(
|
|
@@ -95,8 +100,9 @@ class PromptTimeSeries(Transient):
|
|
|
95
100
|
:rtype tuple:
|
|
96
101
|
"""
|
|
97
102
|
name = f"GRB{name.lstrip('GRB')}"
|
|
98
|
-
directory_structure =
|
|
99
|
-
|
|
103
|
+
directory_structure = batse_prompt_directory_structure(grb=name)
|
|
104
|
+
path = directory_structure.directory_path + name.lstrip('GRB') + '_BATSE_lc.csv'
|
|
105
|
+
_time_series_data = np.genfromtxt(path, delimiter=",")[1:]
|
|
100
106
|
|
|
101
107
|
bin_left = _time_series_data[:, 0]
|
|
102
108
|
bin_right = _time_series_data[:, 1]
|
|
@@ -150,6 +156,8 @@ class PromptTimeSeries(Transient):
|
|
|
150
156
|
:type kwargs: None
|
|
151
157
|
"""
|
|
152
158
|
plt.step(self.time, self.counts / self.bin_size)
|
|
159
|
+
plt.ylabel('Counts')
|
|
160
|
+
plt.xlabel('Time')
|
|
153
161
|
plt.show()
|
|
154
162
|
plt.clf()
|
|
155
163
|
|
|
@@ -177,6 +185,8 @@ class PromptTimeSeries(Transient):
|
|
|
177
185
|
plt.clf()
|
|
178
186
|
plt.step(self.time, self.counts / self.bin_size)
|
|
179
187
|
plt.plot(self.time, model(self.time, **dict(posterior.iloc[-1])))
|
|
188
|
+
plt.ylabel('Counts')
|
|
189
|
+
plt.xlabel('Time')
|
|
180
190
|
plt.show()
|
|
181
191
|
plt.clf()
|
|
182
192
|
|
redback/transient/supernova.py
CHANGED
|
@@ -15,7 +15,8 @@ class Supernova(OpticalTransient):
|
|
|
15
15
|
flux_density: np.ndarray = None, flux_density_err: np.ndarray = None, magnitude: np.ndarray = None,
|
|
16
16
|
magnitude_err: np.ndarray = None, redshift: float = np.nan, photon_index: float = np.nan,
|
|
17
17
|
bands: np.ndarray = None, system: np.ndarray = None, active_bands: Union[np.ndarray, str] = 'all',
|
|
18
|
-
|
|
18
|
+
plotting_order: Union[np.ndarray, str] = None, use_phase_model: bool = False,
|
|
19
|
+
optical_data:bool = True, **kwargs: None) -> None:
|
|
19
20
|
"""
|
|
20
21
|
This is a general constructor for the Supernova class. Note that you only need to give data corresponding to
|
|
21
22
|
the data mode you are using. For luminosity data provide times in the rest frame, if using a phase model
|
|
@@ -45,7 +46,7 @@ class Supernova(OpticalTransient):
|
|
|
45
46
|
:type flux: np.ndarray, optional
|
|
46
47
|
:type flux_err: np.ndarray, optional
|
|
47
48
|
:param flux_err: Flux error values.
|
|
48
|
-
:param flux_density:Flux density values.
|
|
49
|
+
:param flux_density: Flux density values.
|
|
49
50
|
:type flux_density: np.ndarray, optional
|
|
50
51
|
:param flux_density_err: Flux density error values.
|
|
51
52
|
:type flux_density_err: np.ndarray, optional
|
|
@@ -69,6 +70,8 @@ class Supernova(OpticalTransient):
|
|
|
69
70
|
:type bands: np.ndarray, optional
|
|
70
71
|
:param active_bands: List or array of active bands to be used in the analysis. Use all available bands if 'all' is given.
|
|
71
72
|
:type active_bands: Union[list, np.ndarray]
|
|
73
|
+
:param plotting_order: Order in which to plot the bands/and how unique bands are stored.
|
|
74
|
+
:type plotting_order: Union[np.ndarray, str], optional
|
|
72
75
|
:param kwargs: Additional callables:
|
|
73
76
|
bands_to_frequency: Conversion function to convert a list of bands to frequencies. Use
|
|
74
77
|
redback.utils.bands_to_frequency if not given.
|
|
@@ -80,7 +83,8 @@ class Supernova(OpticalTransient):
|
|
|
80
83
|
Lum50_err=Lum50_err, flux_density=flux_density, flux_density_err=flux_density_err,
|
|
81
84
|
magnitude=magnitude, magnitude_err=magnitude_err, data_mode=data_mode, name=name,
|
|
82
85
|
use_phase_model=use_phase_model, bands=bands, system=system, active_bands=active_bands,
|
|
83
|
-
redshift=redshift, photon_index=photon_index,
|
|
86
|
+
redshift=redshift, photon_index=photon_index, optical_data=optical_data,
|
|
87
|
+
plotting_order=plotting_order, **kwargs)
|
|
84
88
|
self.directory_structure = redback.get_data.directory.open_access_directory_structure(
|
|
85
89
|
transient=name, transient_type="supernova")
|
|
86
90
|
self._set_data()
|
redback/transient/tde.py
CHANGED
|
@@ -15,7 +15,8 @@ class TDE(OpticalTransient):
|
|
|
15
15
|
flux_density: np.ndarray = None, flux_density_err: np.ndarray = None, magnitude: np.ndarray = None,
|
|
16
16
|
magnitude_err: np.ndarray = None, redshift: float = np.nan, photon_index: float = np.nan,
|
|
17
17
|
bands: np.ndarray = None, system: np.ndarray = None, active_bands: Union[np.ndarray, str] = 'all',
|
|
18
|
-
|
|
18
|
+
plotting_order: Union[np.ndarray, str] = None, use_phase_model: bool = False,
|
|
19
|
+
optical_data:bool = True, **kwargs: None) -> None:
|
|
19
20
|
"""
|
|
20
21
|
|
|
21
22
|
:param name: Name of the transient.
|
|
@@ -42,7 +43,7 @@ class TDE(OpticalTransient):
|
|
|
42
43
|
:type flux: np.ndarray, optional
|
|
43
44
|
:type flux_err: np.ndarray, optional
|
|
44
45
|
:param flux_err: Flux error values.
|
|
45
|
-
:param flux_density:Flux density values.
|
|
46
|
+
:param flux_density: Flux density values.
|
|
46
47
|
:type flux_density: np.ndarray, optional
|
|
47
48
|
:param flux_density_err: Flux density error values.
|
|
48
49
|
:type flux_density_err: np.ndarray, optional
|
|
@@ -66,6 +67,8 @@ class TDE(OpticalTransient):
|
|
|
66
67
|
:type bands: np.ndarray, optional
|
|
67
68
|
:param active_bands: List or array of active bands to be used in the analysis. Use all available bands if 'all' is given.
|
|
68
69
|
:type active_bands: Union[list, np.ndarray]
|
|
70
|
+
:param plotting_order: Order in which to plot the bands/and how unique bands are stored.
|
|
71
|
+
:type plotting_order: Union[np.ndarray, str], optional
|
|
69
72
|
:param kwargs: Additional callables:
|
|
70
73
|
bands_to_frequency: Conversion function to convert a list of bands to frequencies. Use
|
|
71
74
|
redback.utils.bands_to_frequency if not given.
|
|
@@ -77,7 +80,7 @@ class TDE(OpticalTransient):
|
|
|
77
80
|
magnitude=magnitude, magnitude_err=magnitude_err, data_mode=data_mode, name=name,
|
|
78
81
|
use_phase_model=use_phase_model, optical_data=optical_data, bands=bands,
|
|
79
82
|
system=system, active_bands=active_bands,redshift=redshift,
|
|
80
|
-
photon_index=photon_index, **kwargs)
|
|
83
|
+
photon_index=photon_index, plotting_order=plotting_order, **kwargs)
|
|
81
84
|
self.directory_structure = redback.get_data.directory.open_access_directory_structure(
|
|
82
85
|
transient=self.name, transient_type="tidal_disruption_event")
|
|
83
86
|
self._set_data()
|
redback/transient/transient.py
CHANGED
|
@@ -38,7 +38,7 @@ class Transient(object):
|
|
|
38
38
|
ttes: np.ndarray = None, bin_size: float = None, redshift: float = np.nan, data_mode: str = None,
|
|
39
39
|
name: str = '', photon_index: float = np.nan, use_phase_model: bool = False,
|
|
40
40
|
optical_data: bool = False, frequency: np.ndarray = None, system: np.ndarray = None, bands: np.ndarray = None,
|
|
41
|
-
active_bands: Union[np.ndarray, str] = None, **kwargs: None) -> None:
|
|
41
|
+
active_bands: Union[np.ndarray, str] = None, plotting_order: Union[np.ndarray, str] = None, **kwargs: None) -> None:
|
|
42
42
|
"""This is a general constructor for the Transient class. Note that you only need to give data corresponding to
|
|
43
43
|
the data mode you are using. For luminosity data provide times in the rest frame, if using a phase model
|
|
44
44
|
provide time in MJD, else use the default time (observer frame).
|
|
@@ -98,6 +98,8 @@ class Transient(object):
|
|
|
98
98
|
:param active_bands: List or array of active bands to be used in the analysis.
|
|
99
99
|
Use all available bands if 'all' is given.
|
|
100
100
|
:type active_bands: Union[list, np.ndarray], optional
|
|
101
|
+
:param plotting_order: Order in which to plot the bands/and how unique bands are stored.
|
|
102
|
+
:type plotting_order: Union[np.ndarray, str], optional
|
|
101
103
|
:param kwargs: Additional callables:
|
|
102
104
|
bands_to_frequency: Conversion function to convert a list of bands to frequencies.
|
|
103
105
|
Use redback.utils.bands_to_frequency if not given.
|
|
@@ -137,11 +139,12 @@ class Transient(object):
|
|
|
137
139
|
self.system = system
|
|
138
140
|
self.data_mode = data_mode
|
|
139
141
|
self.active_bands = active_bands
|
|
140
|
-
self.sncosmo_bands = redback.utils.sncosmo_bandname_from_band(self.bands
|
|
142
|
+
self.sncosmo_bands = redback.utils.sncosmo_bandname_from_band(self.bands)
|
|
141
143
|
self.redshift = redshift
|
|
142
144
|
self.name = name
|
|
143
145
|
self.use_phase_model = use_phase_model
|
|
144
146
|
self.optical_data = optical_data
|
|
147
|
+
self.plotting_order = plotting_order
|
|
145
148
|
|
|
146
149
|
self.meta_data = None
|
|
147
150
|
self.photon_index = photon_index
|
|
@@ -179,7 +182,7 @@ class Transient(object):
|
|
|
179
182
|
@classmethod
|
|
180
183
|
def from_lasair_data(
|
|
181
184
|
cls, name: str, data_mode: str = "magnitude", active_bands: Union[np.ndarray, str] = 'all',
|
|
182
|
-
use_phase_model: bool = False) -> Transient:
|
|
185
|
+
use_phase_model: bool = False, plotting_order: Union[np.ndarray, str] = None) -> Transient:
|
|
183
186
|
"""Constructor method to built object from LASAIR data.
|
|
184
187
|
|
|
185
188
|
:param name: Name of the transient.
|
|
@@ -189,6 +192,8 @@ class Transient(object):
|
|
|
189
192
|
:param active_bands: Sets active bands based on array given.
|
|
190
193
|
If argument is 'all', all unique bands in `self.bands` will be used.
|
|
191
194
|
:type active_bands: Union[np.ndarray, str]
|
|
195
|
+
:param plotting_order: Order in which to plot the bands/and how unique bands are stored.
|
|
196
|
+
:type plotting_order: Union[np.ndarray, str], optional
|
|
192
197
|
:param use_phase_model: Whether to use a phase model.
|
|
193
198
|
:type use_phase_model: bool, optional
|
|
194
199
|
|
|
@@ -214,12 +219,12 @@ class Transient(object):
|
|
|
214
219
|
return cls(name=name, data_mode=data_mode, time=time_days, time_err=None, time_mjd=time_mjd,
|
|
215
220
|
flux_density=flux_density, flux_density_err=flux_density_err, magnitude=magnitude,
|
|
216
221
|
magnitude_err=magnitude_err, flux=flux, flux_err=flux_err, bands=bands, active_bands=active_bands,
|
|
217
|
-
use_phase_model=use_phase_model, optical_data=True)
|
|
222
|
+
use_phase_model=use_phase_model, optical_data=True, plotting_order=plotting_order)
|
|
218
223
|
|
|
219
224
|
@classmethod
|
|
220
225
|
def from_simulated_optical_data(
|
|
221
226
|
cls, name: str, data_mode: str = "magnitude", active_bands: Union[np.ndarray, str] = 'all',
|
|
222
|
-
use_phase_model: bool = False) -> Transient:
|
|
227
|
+
plotting_order: Union[np.ndarray, str] = None, use_phase_model: bool = False) -> Transient:
|
|
223
228
|
"""Constructor method to built object from SimulatedOpticalTransient.
|
|
224
229
|
|
|
225
230
|
:param name: Name of the transient.
|
|
@@ -229,6 +234,8 @@ class Transient(object):
|
|
|
229
234
|
:param active_bands: Sets active bands based on array given.
|
|
230
235
|
If argument is 'all', all unique bands in `self.bands` will be used.
|
|
231
236
|
:type active_bands: Union[np.ndarray, str]
|
|
237
|
+
:param plotting_order: Order in which to plot the bands/and how unique bands are stored.
|
|
238
|
+
:type plotting_order: Union[np.ndarray, str], optional
|
|
232
239
|
:param use_phase_model: Whether to use a phase model.
|
|
233
240
|
:type use_phase_model: bool, optional
|
|
234
241
|
|
|
@@ -250,7 +257,7 @@ class Transient(object):
|
|
|
250
257
|
return cls(name=name, data_mode=data_mode, time=time_days, time_err=None, time_mjd=time_mjd,
|
|
251
258
|
flux_density=flux_density, flux_density_err=flux_density_err, magnitude=magnitude,
|
|
252
259
|
magnitude_err=magnitude_err, flux=flux, flux_err=flux_err, bands=bands, active_bands=active_bands,
|
|
253
|
-
use_phase_model=use_phase_model, optical_data=True)
|
|
260
|
+
use_phase_model=use_phase_model, optical_data=True, plotting_order=plotting_order)
|
|
254
261
|
|
|
255
262
|
@property
|
|
256
263
|
def _time_attribute_name(self) -> str:
|
|
@@ -501,7 +508,10 @@ class Transient(object):
|
|
|
501
508
|
:return: All bands that we get from the data, eliminating all duplicates.
|
|
502
509
|
:rtype: np.ndarray
|
|
503
510
|
"""
|
|
504
|
-
|
|
511
|
+
if self.plotting_order is not None:
|
|
512
|
+
return self.plotting_order
|
|
513
|
+
else:
|
|
514
|
+
return np.unique(self.bands)
|
|
505
515
|
|
|
506
516
|
@property
|
|
507
517
|
def unique_frequencies(self) -> np.ndarray:
|
|
@@ -789,7 +799,8 @@ class OpticalTransient(Transient):
|
|
|
789
799
|
flux_density_err: np.ndarray = None, magnitude: np.ndarray = None, magnitude_err: np.ndarray = None,
|
|
790
800
|
redshift: float = np.nan, photon_index: float = np.nan, frequency: np.ndarray = None,
|
|
791
801
|
bands: np.ndarray = None, system: np.ndarray = None, active_bands: Union[np.ndarray, str] = 'all',
|
|
792
|
-
|
|
802
|
+
plotting_order: Union[np.ndarray, str] = None, use_phase_model: bool = False,
|
|
803
|
+
optical_data:bool = True, **kwargs: None) -> None:
|
|
793
804
|
"""This is a general constructor for the Transient class. Note that you only need to give data corresponding to
|
|
794
805
|
the data mode you are using. For luminosity data provide times in the rest frame, if using a phase model
|
|
795
806
|
provide time in MJD, else use the default time (observer frame).
|
|
@@ -839,6 +850,8 @@ class OpticalTransient(Transient):
|
|
|
839
850
|
:param active_bands: List or array of active bands to be used in the analysis.
|
|
840
851
|
Use all available bands if 'all' is given.
|
|
841
852
|
:type active_bands: Union[list, np.ndarray], optional
|
|
853
|
+
:param plotting_order: Order in which to plot the bands/and how unique bands are stored.
|
|
854
|
+
:type plotting_order: Union[np.ndarray, str], optional
|
|
842
855
|
:param use_phase_model: Whether we are using a phase model.
|
|
843
856
|
:type use_phase_model: bool, optional
|
|
844
857
|
:param optical_data: Whether we are fitting optical data, useful for plotting.
|
|
@@ -855,14 +868,15 @@ class OpticalTransient(Transient):
|
|
|
855
868
|
flux=flux, flux_err=flux_err, redshift=redshift, photon_index=photon_index,
|
|
856
869
|
flux_density=flux_density, flux_density_err=flux_density_err, magnitude=magnitude,
|
|
857
870
|
magnitude_err=magnitude_err, data_mode=data_mode, name=name,
|
|
858
|
-
use_phase_model=use_phase_model, optical_data=optical_data,
|
|
871
|
+
use_phase_model=use_phase_model, optical_data=optical_data,
|
|
872
|
+
system=system, bands=bands, plotting_order=plotting_order,
|
|
859
873
|
active_bands=active_bands, **kwargs)
|
|
860
874
|
self.directory_structure = None
|
|
861
875
|
|
|
862
876
|
@classmethod
|
|
863
877
|
def from_open_access_catalogue(
|
|
864
878
|
cls, name: str, data_mode: str = "magnitude", active_bands: Union[np.ndarray, str] = 'all',
|
|
865
|
-
use_phase_model: bool = False) -> OpticalTransient:
|
|
879
|
+
plotting_order: Union[np.ndarray, str] = None, use_phase_model: bool = False) -> OpticalTransient:
|
|
866
880
|
"""Constructor method to built object from Open Access Catalogue
|
|
867
881
|
|
|
868
882
|
:param name: Name of the transient.
|
|
@@ -873,6 +887,8 @@ class OpticalTransient(Transient):
|
|
|
873
887
|
Sets active bands based on array given.
|
|
874
888
|
If argument is 'all', all unique bands in `self.bands` will be used.
|
|
875
889
|
:type active_bands: Union[np.ndarray, str]
|
|
890
|
+
:param plotting_order: Order in which to plot the bands/and how unique bands are stored.
|
|
891
|
+
:type plotting_order: Union[np.ndarray, str], optional
|
|
876
892
|
:param use_phase_model: Whether to use a phase model.
|
|
877
893
|
:type use_phase_model: bool, optional
|
|
878
894
|
|
|
@@ -890,7 +906,8 @@ class OpticalTransient(Transient):
|
|
|
890
906
|
return cls(name=name, data_mode=data_mode, time=time_days, time_err=None, time_mjd=time_mjd,
|
|
891
907
|
flux_density=flux_density, flux_density_err=flux_density_err, magnitude=magnitude,
|
|
892
908
|
magnitude_err=magnitude_err, bands=bands, system=system, active_bands=active_bands,
|
|
893
|
-
use_phase_model=use_phase_model, optical_data=True, flux=flux, flux_err=flux_err
|
|
909
|
+
use_phase_model=use_phase_model, optical_data=True, flux=flux, flux_err=flux_err,
|
|
910
|
+
plotting_order=plotting_order)
|
|
894
911
|
|
|
895
912
|
@property
|
|
896
913
|
def event_table(self) -> str:
|
|
@@ -906,7 +923,7 @@ class OpticalTransient(Transient):
|
|
|
906
923
|
meta_data = pd.read_csv(self.event_table, on_bad_lines='skip', delimiter=',', dtype='str')
|
|
907
924
|
except FileNotFoundError as e:
|
|
908
925
|
redback.utils.logger.warning(e)
|
|
909
|
-
redback.utils.logger.warning("Setting metadata to None")
|
|
926
|
+
redback.utils.logger.warning("Setting metadata to None. This is not an error, but a warning that no metadata could be found online.")
|
|
910
927
|
meta_data = None
|
|
911
928
|
self.meta_data = meta_data
|
|
912
929
|
|