Skip to content

Commit 55f751b

Browse files
authored
Merge pull request #147 from VERITAS-Observatory/trans_finder
Trans_finder
2 parents 7b75715 + 58687d7 commit 55f751b

File tree

5 files changed

+52
-19
lines changed

5 files changed

+52
-19
lines changed

download_data_for_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
set -e
44

5-
wget --no-verbose https://syncandshare.desy.de/index.php/s/FFqtMQ93PZEHiaj/download/github-CI.tar.gz
5+
wget --no-verbose https://syncandshare.desy.de/index.php/s/JRez6MJCFiEGenc/download/github-CI.tar.gz
66
tar -xvzf github-CI.tar.gz

pyV2DL3/eventdisplay/EventDisplayDataSource.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def __fill_response__(self, **kwargs):
4444
" ze={1:.2f} deg,"
4545
" pedvar={2:.1f}"
4646
).format(
47-
self.__azimuth__, self.__zenith__, self.__pedvar__,
47+
self.__azimuth__,
48+
self.__zenith__,
49+
self.__pedvar__,
4850
)
4951
)
5052

@@ -54,5 +56,6 @@ def __fill_response__(self, **kwargs):
5456
self.__azimuth__,
5557
self.__zenith__,
5658
self.__pedvar__,
57-
self.__irf_to_store__, **kwargs
59+
self.__irf_to_store__,
60+
**kwargs
5861
)

pyV2DL3/eventdisplay/fillEVENTS.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def __fillEVENTS__(edFileIO, select=None):
9292
altArr = DL3EventTree["El"][mask]
9393
energyArr = DL3EventTree["Energy"][mask]
9494
nTelArr = DL3EventTree["NImages"][mask]
95+
Xoff = DL3EventTree["Xoff"][mask]
96+
Yoff = DL3EventTree["Yoff"][mask]
97+
9598
try:
9699
# Test if anasum file was created using the all events option.
97100
# In this case write out the additional output.
@@ -157,6 +160,8 @@ def __fillEVENTS__(edFileIO, select=None):
157160
evt_dict["GEOLON"] = VTS_REFERENCE_LON
158161
evt_dict["GEOLAT"] = VTS_REFERENCE_LAT
159162
evt_dict["ALTITUDE"] = VTS_REFERENCE_HEIGHT
163+
evt_dict["Xoff"] = Xoff
164+
evt_dict["Yoff"] = Yoff
160165

161166
# Read evndispLog which is stored as TMacro in anasum root file (ED >= 486)
162167
try:

pyV2DL3/fillEVENTS.py

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,30 @@
66
import pyV2DL3.constant as constant
77

88

9-
def fillEVENTS(datasource, save_multiplicity=False, instrument_epoch=None):
9+
def add_existing_column(columns, evt_dict, name, format, unit=None):
10+
"""
11+
Test if key `name` exists in `evt_dict`. If `true` add a new column to columns inplace.
12+
13+
Parameters
14+
----------
15+
columns: list
16+
evt_dict: dict
17+
name: str
18+
Used as name for the new column and key in evt_dict.
19+
format: str
20+
unit: str or None
21+
22+
Returns
23+
-------
24+
"""
25+
26+
if name in evt_dict:
27+
columns.append(
28+
fits.Column(name=name, format=format, array=evt_dict[name], unit=unit)
29+
)
30+
1031

32+
def fillEVENTS(datasource, save_multiplicity=False, instrument_epoch=None):
1133
logging.debug("Create EVENT HDU")
1234
evt_dict = datasource.get_evt_data()
1335

@@ -19,14 +41,15 @@ def fillEVENTS(datasource, save_multiplicity=False, instrument_epoch=None):
1941
fits.Column(name="DEC", format="1E", array=evt_dict["DEC"], unit="deg"),
2042
fits.Column(name="ENERGY", format="1E", array=evt_dict["ENERGY"], unit="TeV"),
2143
]
22-
try:
23-
columns.append(fits.Column("IS_GAMMA", format="1L", array=evt_dict["IS_GAMMA"]))
24-
columns.append(
25-
fits.Column("BDT_SCORE", format="1E", array=evt_dict["BDT_SCORE"])
26-
)
27-
logging.debug("Found BDT variables in event list")
28-
except KeyError:
29-
logging.debug("No BDT variables in event list")
44+
45+
# Test if key exists in evt_dict. If yes, add these columns.
46+
add_existing_column(columns, evt_dict, name="ALT", format="1E", unit="deg")
47+
add_existing_column(columns, evt_dict, name="AZ", format="1E", unit="deg")
48+
add_existing_column(columns, evt_dict, name="Xoff", format="1E")
49+
add_existing_column(columns, evt_dict, name="Yoff", format="1E")
50+
add_existing_column(columns, evt_dict, name="IS_GAMMA", format="1L")
51+
add_existing_column(columns, evt_dict, name="BDT_SCORE", format="1E")
52+
3053
# Number of triggered telescope if necessary
3154
if save_multiplicity:
3255
columns.append(
@@ -45,9 +68,7 @@ def fillEVENTS(datasource, save_multiplicity=False, instrument_epoch=None):
4568
hdu1.header.set("EQUINOX", constant.EQUINOX, "base equinox")
4669
hdu1.header.set(
4770
"CREATOR",
48-
"pyV2DL3 v{}::{}".format(
49-
constant.VERSION, datasource.get_source_name()
50-
),
71+
"pyV2DL3 v{}::{}".format(constant.VERSION, datasource.get_source_name()),
5172
)
5273
hdu1.header.set("ORIGIN", "VERITAS Collaboration", "Data from VERITAS")
5374
hdu1.header.set("TELESCOP", "VERITAS")
@@ -119,6 +140,13 @@ def fillEVENTS(datasource, save_multiplicity=False, instrument_epoch=None):
119140
"altitude of array center [m]",
120141
)
121142

143+
if hasattr(datasource, "__pedvar__"):
144+
hdu1.header.set(
145+
"PED_VAR",
146+
datasource.__pedvar__,
147+
"average pedestal variance",
148+
)
149+
122150
try:
123151
hdu1.header.set(
124152
"QUALITY",

pyV2DL3/script/v2dl3.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33

44
def main():
5-
logging.basicConfig(
6-
format="%(levelname)s: %(message)s",
7-
level=logging.INFO
8-
)
5+
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.INFO)
96
logging.info(
107
"""
118
Run V2DL3 for VEGAS (.stage5) or EventDisplay (.anasum):

0 commit comments

Comments
 (0)