Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 14 additions & 11 deletions src/pybkgmodel/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,17 @@ def is_compatible(cls, file_name):
True if fits file according to file extension
"""

ext = Path(file_name).suffixes
compatible = ".fits" in ext
ext = Path(file_name)

print("PATH", ext)

try:
with fits.open(ext) as file:
pass
compatible = True
except OSError:
compatible = False

return compatible

@classmethod
Expand Down Expand Up @@ -654,25 +662,20 @@ def load_events(cls, file_name):
event_data[name] *= u.one

# Event times need to be converted from Instrument reference epoch
ref_epoch = astropy.time.Time(evt_head['MJDREFI']+evt_head['MJDREFF'], format='mjd')
ref_epoch = astropy.time.Time(evt_head['MJDREFI'], evt_head['MJDREFF'], format='mjd')

event_data['mjd'] = astropy.time.Time((evt_data['TIME'].to_numpy()
+ ref_epoch.unix),
scale='utc',
format='unix'
event_data['mjd'] = astropy.time.Time((evt_data['TIME'].quantity
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The outer time here is unnecessary.

The result of ref_epoch + evt_data["TIME"].quantity is a time, you are just making a copy again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

+ ref_epoch)
).mjd * u.d

# Adapt
evt_time = astropy.time.Time(event_data['mjd'], format='mjd')

# TODO: current observatory location only La Palma, no mandatory header keyword
obs_loc = EarthLocation(lat=28.761758*u.deg,
lon=-17.890659*u.deg,
height=2200*u.m)

if evt_head['OBS_MODE'] in ('POINTING', 'WOBBLE'):

alt_az_frame = AltAz(obstime=evt_time,
alt_az_frame = AltAz(obstime=event_data['mjd'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can pass a raw mjd value to AltAz(obstime=), this needs to be a Time instance.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, corrected.

location=obs_loc)

coords = SkyCoord(evt_head['RA_PNT'] *u.deg,
Expand Down
32 changes: 24 additions & 8 deletions src/pybkgmodel/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,15 @@ def __init__(self,
pointing_delta=self.pointing_delta
)

@BkgMakerBase.bkg_map_maker.setter
@property
def bkg_map_maker(self):
return self.__bkg_map_maker

@bkg_map_maker.setter
def bkg_map_maker(self, maker):
if not isinstance(maker, WobbleMap):
raise TypeError(f"Maker must be of type {WobbleMap}")
BkgMakerBase.bkg_map_maker.fset(self, maker)
self.__bkg_map_maker = maker

class StackedWobbleMap(Stacked):
"""
Expand Down Expand Up @@ -642,11 +646,15 @@ def __init__(self,
pointing_delta=self.pointing_delta
)

@BkgMakerBase.bkg_map_maker.setter
@property
def bkg_map_maker(self):
return self.__bkg_map_maker

@bkg_map_maker.setter
def bkg_map_maker(self, maker):
if not isinstance(maker, WobbleMap):
raise TypeError(f"Maker must be of type {WobbleMap}")
BkgMakerBase.bkg_map_maker.fset(self, maker)
self.__bkg_map_maker = maker

class RunwiseExclusionMap(Runwise):
"""
Expand Down Expand Up @@ -778,11 +786,15 @@ def __init__(self,
pointing_delta=self.pointing_delta
)

@BkgMakerBase.bkg_map_maker.setter
@property
def bkg_map_maker(self):
return self.__bkg_map_maker

@bkg_map_maker.setter
def bkg_map_maker(self, maker):
if not isinstance(maker, ExclusionMap):
raise TypeError(f"Maker must be of type {ExclusionMap}")
BkgMakerBase.bkg_map_maker.fset(self, maker)
self.__bkg_map_maker = maker

class StackedExclusionMap(Stacked):
"""
Expand Down Expand Up @@ -914,8 +926,12 @@ def __init__(self,
pointing_delta=self.pointing_delta
)

@BkgMakerBase.bkg_map_maker.setter
@property
def bkg_map_maker(self):
return self.__bkg_map_maker

@bkg_map_maker.setter
def bkg_map_maker(self, maker):
if not isinstance(maker, ExclusionMap):
raise TypeError(f"Maker must be of type {ExclusionMap}")
BkgMakerBase.bkg_map_maker.fset(self, maker)
self.__bkg_map_maker = maker