Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MAGIC+LST-1 performance #28

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/changes/28.added.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added support for MAGIC+LST-1 performance estimation.
12 changes: 12 additions & 0 deletions src/iact_estimator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,15 @@
)
"""`~astropy.table.QTable` with energy bins, rate of gammas and background for
mid zenith performance (30 to 45 degrees)."""

MAGIC_LST1_LOW_ZENITH_PERFORMANCE = QTable.read(
RESOURCES_PATH / Path("MAGIC_LST1_low_zenith_performance.ecsv")
)
"""`~astropy.table.QTable` with energy bins, rate of gammas and background for
low zenith performance (0 to 30 degrees)."""

MAGIC_LST1_MID_ZENITH_PERFORMANCE = QTable.read(
RESOURCES_PATH / Path("MAGIC_LST1_mid_zenith_performance.ecsv")
)
"""`~astropy.table.QTable` with energy bins, rate of gammas and background for
mid zenith performance (30 to 45 degrees)."""
21 changes: 17 additions & 4 deletions src/iact_estimator/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from . import (
LOW_ZENITH_PERFORMANCE,
MID_ZENITH_PERFORMANCE,
MAGIC_LST1_LOW_ZENITH_PERFORMANCE,
MAGIC_LST1_MID_ZENITH_PERFORMANCE,
)
from .io import load_ebl
from .spectral import crab_nebula_spectrum
Expand Down Expand Up @@ -338,19 +340,30 @@ def prepare_data(config):
performance_data = {
"low": LOW_ZENITH_PERFORMANCE,
"mid": MID_ZENITH_PERFORMANCE,
"magic_lst1_low": MAGIC_LST1_LOW_ZENITH_PERFORMANCE,
"magic_lst1_mid": MAGIC_LST1_MID_ZENITH_PERFORMANCE,
}

if config["sum_trigger"] and config["magic_lst1"]:
message = "LST-1 is not compatible with the MAGIC SUM trigger."
" is not currently available."
logger.critical(message)
raise NotImplementedError(message)

if config["sum_trigger"] and config["zenith_performance"] == "low":
message = "Low zenith performance with the SUM trigger"
" is not currently available."
logger.critical(message)
raise NotImplementedError(message)

min_energy = performance_data[config["zenith_performance"]]["min_energy"]
max_energy = performance_data[config["zenith_performance"]]["max_energy"]
magic_lst1 = "magic_lst1_" if config["magic_lst1"] else ""
dataset = f"{magic_lst1}{config['zenith_performance']}"

min_energy = performance_data[dataset]["min_energy"]
max_energy = performance_data[dataset]["max_energy"]
energy_bins = np.append(min_energy.value, max_energy[-1].value) * min_energy.unit
gamma_rate = performance_data[config["zenith_performance"]]["gamma_rate"]
background_rate = performance_data[config["zenith_performance"]]["background_rate"]
gamma_rate = performance_data[dataset]["gamma_rate"]
background_rate = performance_data[dataset]["background_rate"]

return energy_bins, gamma_rate, background_rate

Expand Down
5 changes: 4 additions & 1 deletion src/iact_estimator/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ def plot_sed(
np.log10(max_energy.to_value(energy_unit)),
50,
) * u.Unit(energy_unit)
labeltext = rf"Expected SED ($T_{{obs}}$ = {config['observation_time']})"
performance_name = f"{'MAGIC+LST-1' if config['magic_lst1'] else 'MAGIC'} ({config['zenith_performance']} zenith)"
labeltext = (
rf"{performance_name} Expected SED ($T_{{obs}}$ = {config['observation_time']})"
)
plt.plot(
energy,
energy * energy * crab_nebula_spectrum()(energy),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# %ECSV 1.0
# ---
# datatype:
# - {name: min_energy, unit: GeV, datatype: float64}
# - {name: max_energy, unit: GeV, datatype: float64}
# - {name: gamma_rate, unit: 1 / min, datatype: float64}
# - {name: background_rate, unit: 1 / min, datatype: float64}
# meta:
# __serialized_columns__:
# background_rate:
# __class__: astropy.units.quantity.Quantity
# unit: !astropy.units.Unit {unit: 1 / min}
# value: !astropy.table.SerializedColumn {name: background_rate}
# gamma_rate:
# __class__: astropy.units.quantity.Quantity
# unit: !astropy.units.Unit {unit: 1 / min}
# value: !astropy.table.SerializedColumn {name: gamma_rate}
# max_energy:
# __class__: astropy.units.quantity.Quantity
# unit: &id001 !astropy.units.Unit {unit: GeV}
# value: !astropy.table.SerializedColumn {name: max_energy}
# min_energy:
# __class__: astropy.units.quantity.Quantity
# unit: *id001
# value: !astropy.table.SerializedColumn {name: min_energy}
# name: MAGIC_LST1_low_zenith
# schema: astropy-2.0
min_energy max_energy gamma_rate background_rate
39.81071705534972 63.09573444801933 0.3795 0.8887
63.09573444801933 100.0 2.5808 1.6505
100.0 158.48931924611136 2.8257 0.57688
158.48931924611136 251.188643150958 1.6654 0.050804
251.188643150958 398.1071705534973 1.3289 0.020521
398.1071705534973 630.9573444801933 1.2871 0.021718
630.9573444801933 1000.0 0.8834 0.0056106
1000.0 1584.8931924611143 0.7045 0.0039491
1584.8931924611143 2511.886431509581 0.3908 0.0032053
2511.886431509581 3981.0717055349733 0.1963 0.0018074
3981.0717055349733 6309.573444801933 0.089 0.00073253
6309.573444801933 10000.0 0.0368 1.1352e-05
10000.0 15848.931924611143 0.0 0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# %ECSV 1.0
# ---
# datatype:
# - {name: min_energy, unit: GeV, datatype: float64}
# - {name: max_energy, unit: GeV, datatype: float64}
# - {name: gamma_rate, unit: 1 / min, datatype: float64}
# - {name: background_rate, unit: 1 / min, datatype: float64}
# meta:
# __serialized_columns__:
# background_rate:
# __class__: astropy.units.quantity.Quantity
# unit: !astropy.units.Unit {unit: 1 / min}
# value: !astropy.table.SerializedColumn {name: background_rate}
# gamma_rate:
# __class__: astropy.units.quantity.Quantity
# unit: !astropy.units.Unit {unit: 1 / min}
# value: !astropy.table.SerializedColumn {name: gamma_rate}
# max_energy:
# __class__: astropy.units.quantity.Quantity
# unit: &id001 !astropy.units.Unit {unit: GeV}
# value: !astropy.table.SerializedColumn {name: max_energy}
# min_energy:
# __class__: astropy.units.quantity.Quantity
# unit: *id001
# value: !astropy.table.SerializedColumn {name: min_energy}
# name: MAGIC_LST1_mid_zenith
# schema: astropy-2.0
min_energy max_energy gamma_rate background_rate
39.81071705534972 63.09573444801933 0.0 0.0
63.09573444801933 100.0 0.59 0.715
100.0 158.48931924611136 2.43 1.42
158.48931924611136 251.188643150958 2.65 0.307
251.188643150958 398.1071705534973 2.03 0.093
398.1071705534973 630.9573444801933 1.171 0.0229
630.9573444801933 1000.0 0.899 0.0093
1000.0 1584.8931924611143 0.806 0.0096
1584.8931924611143 2511.886431509581 0.319 0.00264
2511.886431509581 3981.0717055349733 0.185 0.0007
3981.0717055349733 6309.573444801933 0.113 0.00138
6309.573444801933 10000.0 0.084 0.00148
10000.0 15848.931924611143 0.0 0.0
1 change: 1 addition & 0 deletions src/iact_estimator/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extension: 0.0 deg
redshift: -1 # redshift of the source (for the EBL absorption), if -1 then no absorption
sum_trigger: False
zenith_performance: "low" # "low"=0-30deg, "mid"=30-45deg
magic_lst1: True
# you can check visibility of your source e.g. here: http://www.magic.iac.es/scheduler/

ebl_file_path:
Expand Down
Loading