From 631030e3d273861739595e0dd24379f426187f4d Mon Sep 17 00:00:00 2001 From: Sebastian Achim Mueller Date: Sat, 16 Dec 2023 21:32:06 +0100 Subject: [PATCH] in tar_append now --- plenoirf/instrument_response.py | 7 ++++--- plenoirf/utils.py | 9 --------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/plenoirf/instrument_response.py b/plenoirf/instrument_response.py index c55baf7..b015125 100644 --- a/plenoirf/instrument_response.py +++ b/plenoirf/instrument_response.py @@ -5,6 +5,7 @@ from . import analysis from . import reconstruction from . import outer_telescope_array +from . import tar_append import sys import numpy as np @@ -432,7 +433,7 @@ def _run_corsika_and_grid_and_output_to_tmp_dir( bin_idxs_limitation=grid_bin_idxs_limitation, ) if event_idx % GRID_SKIP == 0: - utils.tar_append( + tar_append.tar_append( tarout=imgtar, file_name=uid_str + ".f4.gz", file_bytes=atmospheric_cherenkov_response.grid.histogram_to_bytes( @@ -495,7 +496,7 @@ def _run_corsika_and_grid_and_output_to_tmp_dir( rcor["core_y_m"] = reuse_event["core_y_m"] tabrec["core"].append(rcor) - utils.tar_append( + tar_append.tar_append( tarout=imgroitar, file_name=uid_str + ".f4.gz", file_bytes=atmospheric_cherenkov_response.grid.serialization.histogram_to_bytes( @@ -972,7 +973,7 @@ def _export_grid_region_of_interest_if_passed_loose_trigger( if idx in pasttrigger_set: bimg = itar.extractfile(tarinfo).read() filename = unique.UID_FOTMAT_STR.format(idx) + ".f4.gz" - utils.tar_append( + tar_append.tar_append( tarout=otar, file_name=filename, file_bytes=bimg, diff --git a/plenoirf/utils.py b/plenoirf/utils.py index 38d3661..3c6bb72 100644 --- a/plenoirf/utils.py +++ b/plenoirf/utils.py @@ -3,7 +3,6 @@ import binning_utils import datetime import io -import tarfile import scipy.interpolate import json_utils import warnings @@ -16,14 +15,6 @@ def contains_same_bytes(path_a, path_b): return a_bytes == b_bytes -def tar_append(tarout, file_name, file_bytes): - with io.BytesIO() as buff: - info = tarfile.TarInfo(file_name) - info.size = buff.write(file_bytes) - buff.seek(0) - tarout.addfile(info, buff) - - def power10space_bin_edges(binning, fine): assert fine > 0 space = binning_utils.power10.space(