Skip to content

Commit

Permalink
in tar_append now
Browse files Browse the repository at this point in the history
  • Loading branch information
relleums committed Dec 16, 2023
1 parent d6ca97c commit 631030e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
7 changes: 4 additions & 3 deletions plenoirf/instrument_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 0 additions & 9 deletions plenoirf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import binning_utils
import datetime
import io
import tarfile
import scipy.interpolate
import json_utils
import warnings
Expand All @@ -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(
Expand Down

0 comments on commit 631030e

Please sign in to comment.