Skip to content

Commit 571ccf2

Browse files
authored
Merge pull request #52 from VERITAS-Observatory/0.5.0-dev3
0.5.0 dev3
2 parents b998ebf + 10aad62 commit 571ccf2

File tree

7 files changed

+36
-16
lines changed

7 files changed

+36
-16
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2023, 2024, 2025 Gernot Maier
3+
Copyright (c) 2023-2025 Gernot Maier
44

55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are met:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Reflected region analysis using gammapy:
5353
```console
5454
python v2dl5/scripts/reflected_region_analysis.py \
5555
--run_list my_output_dir/runlist.txt \
56-
--config examples/reflected_region_analysis.yml \
56+
--config examples/reflected_region.yml \
5757
--output_dir my_output_dir
5858
```
5959

examples/reflected_region.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ datasets:
3434
background:
3535
method: reflected
3636
fit:
37-
fit_range: {min: 0.1 TeV, max: 20 TeV}
3837
model: pl
3938
index: 2.5
4039
reference_energy: 1 TeV
4140

4241
flux_points:
4342
energy: {min: 0.1 TeV, max: 20 TeV, nbins: 10}
43+
flux: {min: 1.e-15, max: 1.e-9}
4444

4545
light_curve:
4646
energy: {min: 1. TeV, max: 100 TeV}

v2dl5/analysis.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ def plot(self):
8686
plotter.plot_spectra(
8787
flux_points=self.flux_points,
8888
model=self.spectral_model,
89+
y_min=self.args_dict["flux_points"].get("flux", {}).get("min"),
90+
y_max=self.args_dict["flux_points"].get("flux", {}).get("max"),
8991
)
9092
else:
9193
self._logger.warning("Skipping spectral plots because fit failed")

v2dl5/data.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Data:
1414
Data class holding data store and observations.
1515
1616
Allows to select data from run list or based on
17-
target coordinates (and observation cone).
17+
target coordinates and observation cone.
1818
1919
Parameters
2020
----------
@@ -33,7 +33,7 @@ def __init__(self, args_dict, target=None):
3333
"""
3434
Initialize Data object.
3535
36-
Uses run_list if not set to None, otherwise selects data
36+
Uses 'run_list' from args_dict if not set to None, otherwise selects data
3737
according to target coordinates and observation cone.
3838
3939
"""
@@ -84,7 +84,7 @@ def get_observations(self, reflected_region=True, skip_missing=False):
8484

8585
def _from_run_list(self, run_list):
8686
"""
87-
Read run_list from file and select data.
87+
Read run list from file and select data.
8888
8989
Parameters
9090
----------
@@ -140,15 +140,15 @@ def get_on_region_radius(self):
140140
try:
141141
rad_max = {obs.rad_max.data[0][0] for obs in observations}
142142
except IndexError:
143-
self._logger.error("Rad max not found in observations.")
143+
self._logger.error("On region radius not found in observations.")
144144
raise
145145

146146
if len(rad_max) > 1:
147-
self._logger.error("Rad max is not the same for all observations.")
147+
self._logger.error("On region radius not the same for all observations.")
148148
raise ValueError
149149

150150
on_region = rad_max.pop() * u.deg
151-
self._logger.info(f"On region size: {on_region}")
151+
self._logger.info(f"On region radius: {on_region}")
152152

153153
return on_region
154154

@@ -166,7 +166,7 @@ def get_max_wobble_distance(self, fov=3.5 * u.deg):
166166
Returns
167167
-------
168168
max_offset : astropy.units.Quantity
169-
Maximum offset.
169+
Maximum offset (radius of FoV).
170170
171171
"""
172172
woff = np.array(

v2dl5/plot.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,30 @@ def plot_maps(self, exclusion_mask=None):
4444
self.plot_regions(exclusion_mask=exclusion_mask)
4545
self.plot_theta2()
4646

47-
def plot_spectra(self, flux_points=None, model=None):
48-
"""Spectrum related plots."""
47+
def plot_spectra(self, flux_points=None, model=None, y_min=None, y_max=None):
48+
"""
49+
Spectrum related plots.
50+
51+
Parameters
52+
----------
53+
flux_points : `~gammapy.datasets.FluxPointsDataset`
54+
Flux points dataset to plot
55+
model : `~gammapy.modeling.models.Model`
56+
Model to plot
57+
y_min : float, optional
58+
Minimum y-axis value for the SED plot
59+
y_max : float, optional
60+
Maximum y-axis value for the SED plot
61+
62+
63+
"""
4964
for dataset in self.data_set:
5065
self.plot_fit(dataset)
5166

5267
self.plot_flux_points(flux_points)
5368
self.plot_sed(
5469
FluxPointsDataset(data=flux_points, models=model.copy()),
70+
y_min=y_min, y_max=y_max,
5571
)
5672

5773
def plot_light_curves(self, light_curves):
@@ -124,6 +140,7 @@ def plot_fit(self, data_set):
124140
ax_spectrum, _ = data_set.plot_fit()
125141
except ValueError:
126142
return
143+
# TODO: Adjust axis limits and add any necessary labels or annotations to improve plot clarity.
127144
ax_spectrum.set_ylim(0.1, 40)
128145
data_set.plot_masks(ax=ax_spectrum)
129146
try:
@@ -141,11 +158,13 @@ def plot_flux_points(self, flux_point_dataset):
141158
flux_point_dataset.plot_ts_profiles(ax=ax, sed_type="dnde")
142159
self._plot(plot_name="flux_points", output_dir=self.output_dir)
143160

144-
def plot_sed(self, flux_point_dataset):
161+
def plot_sed(self, flux_point_dataset, y_min=None, y_max=None):
145162
"""Plot spectral energy distribution."""
146163
kwargs_model = {"color": "grey", "ls": "--", "sed_type": "dnde"}
147164
kwargs_fp = {"color": "black", "marker": "o", "sed_type": "dnde"}
148-
flux_point_dataset.plot_spectrum(kwargs_fp=kwargs_fp, kwargs_model=kwargs_model)
165+
ax = flux_point_dataset.plot_spectrum(kwargs_fp=kwargs_fp, kwargs_model=kwargs_model)
166+
if y_min is not None and y_max is not None:
167+
ax.set_ylim(y_min, y_max)
149168
self._plot(plot_name="spectrum", output_dir=self.output_dir)
150169
try:
151170
flux_point_dataset.plot_residuals(method="diff/model")

v2dl5/sky_regions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ def get_target(self, sky_coord=None, print_target_info=True):
5252
5353
"""
5454
target = None
55-
lon = sky_coord.get("lon", None)
56-
lat = sky_coord.get("lat", None)
55+
lon, lat = sky_coord.get("lon", None), sky_coord.get("lat", None)
5756
if lon is not None and lat is not None:
5857
if sky_coord.get("frame", None) == "icrs":
5958
target = SkyCoord(

0 commit comments

Comments
 (0)