Skip to content

Commit

Permalink
Adapt core
Browse files Browse the repository at this point in the history
  • Loading branch information
MRegeard committed Apr 5, 2024
1 parent 81bbe90 commit 36cb4e1
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions gammapy/catalog/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def _make_source_object(self, index):

try:
idx = self._lookup_additional_table(
self.spectral_table[self._source_name_key]
self.spectral_table[self._get_source_name_key]
)[name_spectral]
data_spectral = table_row_to_dict(self.spectral_table[idx])
except (KeyError, AttributeError):
Expand All @@ -291,6 +291,10 @@ def _make_source_object(self, index):
source = self.source_object_class(data, data_extended, data_spectral)
return source

@property
def _get_source_name_key(self):
return self._source_name_key

def _get_name_spectral(self, data):
if "Source_name" in data:
name_spectral = data["Source_name"].strip()
Expand All @@ -304,25 +308,6 @@ def _lookup_additional_table(self, selected_table):
idx = range(len(names))
return dict(zip(names, idx))

@lazyproperty
def _lookup_spectral_source_idx(self):
"""Return a dictionary of names-idx pairs corresponding to the
entry of the spectral table (for Fermi-LAT pulsar catalogs).
"""
source_name_key = self._get_spectral_table_source_name_key()
names = [_.strip() for _ in self.spectral_table[source_name_key]]
idx = range(len(names))
return dict(zip(names, idx))

@lazyproperty
def _lookup_extended_source_idx(self):
"""Return a dictionary of names-idx pairs corresponding to the
entry of the extended table (for Fermi-LAT catalogs).
"""
names = [_.strip() for _ in self.extended_sources_table[self._source_name_key]]
idx = range(len(names))
return dict(zip(names, idx))

@property
def positions(self):
"""Source positions as a `~astropy.coordinates.SkyCoord` object."""
Expand Down

0 comments on commit 36cb4e1

Please sign in to comment.