Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions astropix_analysis/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from astropix_analysis import logger, LOGGING_LEVELS, DEFAULT_LOGGING_LEVEL, \
reset_logger, start_message
from astropix_analysis import fmt
from astropix_analysis import sock


Expand Down Expand Up @@ -123,6 +124,13 @@ def add_multicast(self) -> None:
group.add_argument('--port', type=int, default=sock.DEFAULT_PORT,
help='multicast port')

def add_readout_class(self) -> None:
"""Add the --readout option
"""
self.add_argument('--readout', type=str, choices=fmt.supported_readout_names(),
required=True,
help='name of the readout class in the target file')

def add_refresh(self, default: float) -> None:
"""Add the refresh argument (interval in s).
"""
Expand Down
525 changes: 304 additions & 221 deletions astropix_analysis/fmt.py

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions astropix_analysis/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

from astropix_analysis import logger
from astropix_analysis.fileio import apx_open, FileHeader, sanitize_path
from astropix_analysis.fmt import AstroPix4Readout


class LogFileHeader(dict):
Expand Down Expand Up @@ -158,7 +157,7 @@ def __next__(self) -> typing.Tuple[int, str]:
return readout_id, readout_data


def log_to_apx(input_file_path: str, readout_class: type = AstroPix4Readout,
def log_to_apx(input_file_path: str, readout_class: type,
output_file_path: str = None) -> str:
"""Convert a .log (text) file to a .apx (binary) file.
"""
Expand Down Expand Up @@ -187,7 +186,7 @@ def log_to_apx(input_file_path: str, readout_class: type = AstroPix4Readout,
except ValueError as exception:
logger.warning(f'{exception} for readout {readout_id}')
continue
readout = AstroPix4Readout(readout_data, readout_id, timestamp=0)
readout = readout_class(readout_data, readout_id, wall_timestamp=0)
readout.write(output_file)
num_readouts += 1
if num_readouts == 0:
Expand Down
5 changes: 4 additions & 1 deletion bin/apx_log2apx.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import argparse

from astropix_analysis.cli import ArgumentParser
from astropix_analysis.fmt import name_to_readout_class
from astropix_analysis.legacy import log_to_apx


Expand All @@ -33,11 +34,13 @@
def main(args: argparse.Namespace) -> None:
"""Actual conversion function.
"""
readout_class = name_to_readout_class(args.readout)
for file_path in args.infiles:
log_to_apx(file_path)
log_to_apx(file_path, readout_class)


if __name__ == "__main__":
parser = ArgumentParser(description=_DESCRIPTION)
parser.add_infiles()
parser.add_readout_class()
main(parser.parse_args())
2 changes: 1 addition & 1 deletion tests/data/20250723_092534/20250723_092534_data.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#{"readout_uid": 4000, "configuration": [{"thpmos": 0, "cardConf2": 0, "vcasc2": 1.1, "BL": 1, "cardConf5": 0, "cardConf6": 0, "vminuspix": 0.8, "thpix": 1.1}, {"interrupt_pushpull": 0, "clkmux": 0, "timerend": 0, "slowdownldpix": 0, "slowdownldcol": 0, "maxcyc": 63, "resetckdiv": 15, "nu1": 0, "tdacmux": 0, "Reset": 0, "PCH": 0, "enRamPCH": 1, "nu2": 0, "enLVDSterm": 1, "enPLL": 1, "enLVDS": 0, "nu3": 0}, {"DisHiDR": 0, "q01": 0, "qon0": 0, "qon1": 1, "qon2": 0, "qon3": 1}, {"blres": 0, "vpdac": 0, "vn1": 20, "vnfb": 1, "vnfoll": 2, "nu5": 0, "vndel": 30, "incp": 10, "ipvco": 0, "vn2": 0, "vnfoll2": 1, "vnbias": 10, "vpload": 5, "nu13": 0, "vncomp": 2, "vpfoll": 10, "nu16": 0, "vprec": 10, "vnrec": 10}, {"blpix": 568, "thpix": 610, "vcasc2": 625, "vtest": 682, "vinj": 142}, {"col0": 68719476735, "col1": 68719476734, "col2": 68719476734, "col3": 68719476734, "col4": 68719476734, "col5": 68719476734, "col6": 68719476734, "col7": 68719476734, "col8": 68719476734, "col9": 274877906940, "col10": 68719476734, "col11": 68719476734, "col12": 68719476734, "col13": 68719476734, "col14": 68719476734, "col15": 68719476734}], "args": {"outdir": "E:\\data\\astropix-output", "yaml": "config_v4_none", "prescale": 25, "saveascsv": false, "inject": [0, 9], "vinj": 250.0, "analog": 9, "threshold": 100.0, "maxruns": null, "maxtime": 1.0, "loglevel": "I"}}
chip_id,payload,readout_id,timestamp,decoding_order,row,column,ts_neg1,ts_coarse1,ts_fine1,ts_tdc1,ts_neg2,ts_coarse2,ts_fine2,ts_tdc2,ts_dec1,ts_dec2,tot_us
chip_id,payload,readout_id,wall_timestamp,decoding_order,row,column,ts_neg1,ts_coarse1,ts_fine1,ts_tdc1,ts_neg2,ts_coarse2,ts_fine2,ts_tdc2,ts_dec1,ts_dec2,tot_us
0,7,0,1753255536707629800,0,0,9,1,12395,3,0,0,13123,0,0,66157,70639,224.1
0,7,1,1753255536785609300,0,0,9,1,6699,7,0,1,7480,2,0,40554,45436,244.1
0,7,2,1753255536861580900,0,0,9,1,1258,7,0,0,3428,0,0,14949,19904,247.75
Expand Down
4 changes: 2 additions & 2 deletions tests/data/20250723_092534/20250723_092534_data.ecsv
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# - {name: chip_id, datatype: uint8}
# - {name: payload, datatype: uint8}
# - {name: readout_id, datatype: uint32}
# - {name: timestamp, datatype: uint64}
# - {name: wall_timestamp, datatype: uint64}
# - {name: decoding_order, datatype: uint8}
# - {name: row, datatype: uint8}
# - {name: column, datatype: uint8}
Expand Down Expand Up @@ -32,7 +32,7 @@
# "yaml": "config_v4_none", "prescale": 25, "saveascsv": false, "inject": [0, 9], "vinj": 250.0, "analog": 9, "threshold": 100.0,
# "maxruns": null, "maxtime": 1.0, "loglevel": "I"}}']
# schema: astropy-2.0
chip_id payload readout_id timestamp decoding_order row column ts_neg1 ts_coarse1 ts_fine1 ts_tdc1 ts_neg2 ts_coarse2 ts_fine2 ts_tdc2 ts_dec1 ts_dec2 tot_us
chip_id payload readout_id wall_timestamp decoding_order row column ts_neg1 ts_coarse1 ts_fine1 ts_tdc1 ts_neg2 ts_coarse2 ts_fine2 ts_tdc2 ts_dec1 ts_dec2 tot_us
0 7 0 1753255536707629800 0 0 9 1 12395 3 0 0 13123 0 0 66157 70639 224.1
0 7 1 1753255536785609300 0 0 9 1 6699 7 0 1 7480 2 0 40554 45436 244.1
0 7 2 1753255536861580900 0 0 9 1 1258 7 0 0 3428 0 0 14949 19904 247.75
Expand Down
2 changes: 1 addition & 1 deletion tests/data/20250723_092534/20250723_092534_data.fits

Large diffs are not rendered by default.

Binary file modified tests/data/20250723_092534/20250723_092534_data.hdf5
Binary file not shown.
Binary file not shown.
Loading