Skip to content

Commit

Permalink
Change REF_WIDTH to REFWIDTH to fit into 8 characters for FITS, fixes c…
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe authored and nbiederbeck committed Aug 3, 2021
1 parent 59740bc commit 6484303
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ctapipe/instrument/camera/readout.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
logger = logging.getLogger(__name__)


def parse_dotted_version(version):
return tuple(map(int, version.split(".")))


class CameraReadout:
def __init__(
self,
Expand Down Expand Up @@ -133,11 +137,11 @@ def to_table(self):
names=names,
meta=dict(
TAB_TYPE="ctapipe.instrument.CameraReadout",
TAB_VER="1.0",
TAB_VER="2.0",
CAM_ID=self.camera_name,
NCHAN=n_channels,
SAMPFREQ=self.sampling_rate.to_value(u.GHz),
REF_WIDTH=self.reference_pulse_sample_width.to_value(u.ns),
REFWIDTH=self.reference_pulse_sample_width.to_value(u.ns),
),
)

Expand All @@ -162,7 +166,13 @@ def from_table(cls, url_or_table, **kwargs):
camera_name = tab.meta.get("CAM_ID", "Unknown")
n_channels = tab.meta["NCHAN"]
sampling_rate = u.Quantity(tab.meta["SAMPFREQ"], u.GHz)
reference_pulse_sample_width = u.Quantity(tab.meta["REF_WIDTH"], u.ns)

if parse_dotted_version(tab.meta["TAB_VER"]) >= (2, 0):
ref_width_key = "REFWIDTH"
else:
ref_width_key = "REF_WIDTH"

reference_pulse_sample_width = u.Quantity(tab.meta[ref_width_key], u.ns)
reference_pulse_shape = np.array(
[tab[f"reference_pulse_shape_channel{i}"] for i in range(n_channels)]
)
Expand Down

0 comments on commit 6484303

Please sign in to comment.