set MC_ID in .sample_sources() amd .sample.background()
@@ -88,6 +88,8 @@ class MapDatasetEventSampler:
table = self._sample_coord_time(npred, temporal_model, dataset.gti)
if len(table) > 0:
table["MC_ID"] = idx + 1
+ table.meta["MID{:05d}".format(idx + 1)] = idx + 1
+ table.meta["MMN{:05d}".format(idx + 1)] = dataset.models[idx].name
else:
mcid = table.Column(name="MC_ID", length=0, dtype=int)
table.add_column(mcid)
@@ -119,6 +121,12 @@ class MapDatasetEventSampler:
table["RA"] = table["RA_TRUE"]
table["DEC"] = table["DEC_TRUE"]
+ for i, mod in enumerate(dataset.models):
+ if mod.tag[0] == "FoVBackgroundModel":
+ break
+ table.meta["MID{:05d}".format(0)] = 0
+ table.meta["MMN{:05d}".format(0)] = dataset.models[i].name
+
return EventList(table)
def sample_edisp(self, edisp_map, events):
@@ -294,9 +302,6 @@ class MapDatasetEventSampler:
meta["CONV_RA"] = 0
meta["CONV_DEC"] = 0
- for idx, model in enumerate(dataset.models):
- meta["MID{:05d}".format(idx)] = idx
- meta["MMN{:05d}".format(idx)] = model.name
meta["NMCIDS"] = len(dataset.models)
# Necessary for DataStore, but they should be ALT and AZ instead!
@@ -351,16 +356,6 @@ class MapDatasetEventSampler:
Event list.
"""
if len(dataset.models) > 1:
- for i, mod in enumerate(dataset.models):
- if mod.tag[0] == "FoVBackgroundModel":
- break
-
- sky_model = np.delete(dataset.models, i, 0)
- fov_bkg = dataset.models[i]
- model_new = Models([fov_bkg])
- model_new.extend(sky_model)
- dataset.models = model_new
-
events_src = self.sample_sources(dataset)
if len(events_src.table) > 0:
@@ -387,7 +382,7 @@ class MapDatasetEventSampler:
events = self.event_det_coords(observation, events)
events.table["EVENT_ID"] = np.arange(len(events.table))
- events.table.meta = self.event_list_meta(dataset, observation)
+ events.table.meta.update(self.event_list_meta(dataset, observation))
geom = dataset._geom
selection = geom.contains(events.map_coord(geom))
