diff --git a/airshower_template_generator/bins.py b/airshower_template_generator/bins.py index a52fe7a..00a540c 100644 --- a/airshower_template_generator/bins.py +++ b/airshower_template_generator/bins.py @@ -68,7 +68,6 @@ def full_coverage_xy_supports_on_observationlevel(binning): for azi, azi_center_deg in enumerate(eb["azimuth_deg"]["supports"]): for rad, r_m in enumerate(eb["radius_m"]["supports"]): - azi_circumference_m = 2.0 * np.pi * r_m azi_arc_length_m = ( azi_circumference_m / binning["azimuth_deg"]["num_bins"] diff --git a/airshower_template_generator/input_output.py b/airshower_template_generator/input_output.py index 0342397..e70043a 100644 --- a/airshower_template_generator/input_output.py +++ b/airshower_template_generator/input_output.py @@ -83,7 +83,9 @@ def write_raw(raw_look_up, path): _tar_append( tar_obj=tar_obj, name="airshower.histogram.ene_alt.int64.gz", - payload_bytes=gzip.compress(data=num.tobytes(order="c"),), + payload_bytes=gzip.compress( + data=num.tobytes(order="c"), + ), ) _tar_append( tar_obj=tar_obj, @@ -170,9 +172,10 @@ def write_map_result( _tar_append( tar_obj=tar_obj, name="job.json", - payload_bytes=json_utils.dumps(job, indent=4,).encode( - encoding="ascii" - ), + payload_bytes=json_utils.dumps( + job, + indent=4, + ).encode(encoding="ascii"), ) _tar_append( tar_obj=tar_obj, @@ -212,7 +215,6 @@ def write_map_result( def read_map_result(path): out = {} with tarfile.TarFile(path, "r") as tar_obj: - tinfo = tar_obj.next() assert tinfo.name == "job.json" out["job"] = json_utils.loads(tar_obj.extractfile(tinfo).read()) diff --git a/airshower_template_generator/model.py b/airshower_template_generator/model.py index 52c26e8..ca7c9cf 100644 --- a/airshower_template_generator/model.py +++ b/airshower_template_generator/model.py @@ -11,15 +11,17 @@ def gaussian_bell_1d(c_deg, peak_deg, width_deg): def gaussian_bell_1d_max_one(c_deg, peak_deg, width_deg): - return np.exp(-0.5 * (c_deg - peak_deg) ** 2 / width_deg ** 2) + return np.exp(-0.5 * (c_deg - peak_deg) ** 2 / width_deg**2) def lorentz_transversal(c_deg, peak_deg, width_deg): - return width_deg / (np.pi * (width_deg ** 2 + (c_deg - peak_deg) ** 2)) + return width_deg / (np.pi * (width_deg**2 + (c_deg - peak_deg) ** 2)) def lorentz_moyal_longitidinal( - c_deg, peak_deg, width_deg, + c_deg, + peak_deg, + width_deg, ): lam = (c_deg - peak_deg) / width_deg return ( @@ -29,9 +31,13 @@ def lorentz_moyal_longitidinal( def my_moyal_model(c_deg, moyal_peak_deg, tail_direction, width_deg): moyal_density = (1.0 - tail_direction) * lorentz_moyal_longitidinal( - c_deg=c_deg, peak_deg=moyal_peak_deg, width_deg=width_deg, + c_deg=c_deg, + peak_deg=moyal_peak_deg, + width_deg=width_deg, ) gaussian_density = tail_direction * lorentz_moyal_longitidinal( - c_deg=-c_deg, peak_deg=-moyal_peak_deg, width_deg=width_deg, + c_deg=-c_deg, + peak_deg=-moyal_peak_deg, + width_deg=width_deg, ) return moyal_density + gaussian_density diff --git a/airshower_template_generator/plot.py b/airshower_template_generator/plot.py index 265e4f3..30531e6 100644 --- a/airshower_template_generator/plot.py +++ b/airshower_template_generator/plot.py @@ -216,28 +216,32 @@ def write_view(path, energy_GeV, altitude_m, azimuth_deg, radius_m, lut): 0.1, 0.3, "azimuth-bin [{: 3d}, {: 3d}]".format( - b["azimuth_deg"][0]["bin"], b["azimuth_deg"][1]["bin"], + b["azimuth_deg"][0]["bin"], + b["azimuth_deg"][1]["bin"], ), ) ax_ap_text.text( 0.1, 0.2, "radius-bin [{: 3d}, {: 3d}]".format( - b["radius_m"][0]["bin"], b["radius_m"][1]["bin"], + b["radius_m"][0]["bin"], + b["radius_m"][1]["bin"], ), ) ax_ap_text.text( 0.1, 0.1, "energy-bin [{: 3d}, {: 3d}]".format( - b["energy_GeV"][0]["bin"], b["energy_GeV"][1]["bin"], + b["energy_GeV"][0]["bin"], + b["energy_GeV"][1]["bin"], ), ) ax_ap_text.text( 0.1, 0.0, "altitude-bin [{: 3d}, {: 3d}]".format( - b["altitude_m"][0]["bin"], b["altitude_m"][1]["bin"], + b["altitude_m"][0]["bin"], + b["altitude_m"][1]["bin"], ), ) diff --git a/airshower_template_generator/production.py b/airshower_template_generator/production.py index f86b8b0..8d24aa7 100644 --- a/airshower_template_generator/production.py +++ b/airshower_template_generator/production.py @@ -82,7 +82,7 @@ def area_of_aperture_m2(binning): def solid_angle_of_pixel_sr(binning): assert image_pixels_are_square(binning=binning) pixel_edge_rad = parallel_pixel_width_rad(binning=binning) - return pixel_edge_rad ** 2 + return pixel_edge_rad**2 def time_slice_duration_s(binning): @@ -138,7 +138,8 @@ def image_pixels_are_square(binning): def zeros(binning, keys=[], dtype=np.float32): return np.zeros( - shape=[binning[key]["num_bins"] for key in keys], dtype=dtype, + shape=[binning[key]["num_bins"] for key in keys], + dtype=dtype, ) @@ -277,11 +278,9 @@ def run_job(job): for azi in range(job["binning"]["azimuth_deg"]["num_bins"]): for rad in range(job["binning"]["radius_m"]["num_bins"]): - num_probing_apertures = len(xy_supports[azi][rad]) probing_aperture_weight = 1.0 / num_probing_apertures for probe in range(num_probing_apertures): - meets = xy_tree.query_ball_point( x=xy_supports[azi][rad][probe], r=job["binning"]["aperture_radius_m"], @@ -299,7 +298,6 @@ def run_job(job): ) if num_cherenkov_photons_in_surrounding > 0: - med_time_ns = np.median( cherenkov_bunches[ surround_meets, cpw.I.BUNCH.TIME_NS @@ -393,7 +391,6 @@ def reduce(work_dir): for site_key in sites: for particle_key in particles: - cer = zeros( keys=[ "energy_GeV", @@ -491,7 +488,12 @@ def reduce(work_dir): print("estimate leakage") leakage_mask = zeros( - keys=["energy_GeV", "azimuth_deg", "radius_m", "altitude_m",], + keys=[ + "energy_GeV", + "azimuth_deg", + "radius_m", + "altitude_m", + ], binning=binning, dtype=np.uint8, ) @@ -499,7 +501,6 @@ def reduce(work_dir): for azi in range(binning["azimuth_deg"]["num_bins"]): for rad in range(binning["radius_m"]["num_bins"]): for alt in range(binning["altitude_m"]["num_bins"]): - leak = quality.estimate_leakage( image=cer[ene, azi, rad, alt], num_pixel_outer_rim=1, diff --git a/airshower_template_generator/tests/test_bin_edges.py b/airshower_template_generator/tests/test_bin_edges.py index 375dfea..b77848f 100644 --- a/airshower_template_generator/tests/test_bin_edges.py +++ b/airshower_template_generator/tests/test_bin_edges.py @@ -7,7 +7,11 @@ binning = { - "energy_GeV": {"start_support": 1e0, "stop_support": 1e3, "num_bins": 3,}, + "energy_GeV": { + "start_support": 1e0, + "stop_support": 1e3, + "num_bins": 3, + }, "azimuth_deg": {"num_bins": 3}, "radius_m": {"start_support": 0.0, "stop_support": 3.0, "num_bins": 4}, "altitude_m": {"start_edge": 0, "stop_edge": 30e3, "num_bins": 3}, @@ -21,7 +25,11 @@ "stop_edge": 0.5, "num_bins": 32, }, - "time_s": {"start_edge": -32e-9, "stop_edge": 32e-9, "num_bins": 16,}, + "time_s": { + "start_edge": -32e-9, + "stop_edge": 32e-9, + "num_bins": 16, + }, "aperture_radius_m": 5.0, } diff --git a/airshower_template_generator/tests/test_projection.py b/airshower_template_generator/tests/test_projection.py index fd906a4..06f008e 100644 --- a/airshower_template_generator/tests/test_projection.py +++ b/airshower_template_generator/tests/test_projection.py @@ -63,15 +63,15 @@ def test_core_xy_does_not_matter_when_pointing_to_zero(): def test_parallel_on_x_axis(): """ - cY, c_perpendicular - ^ - -----|------------ - | | | - | | | - -------0-----------------------> cX, c_parallel - | | - | | - ------------------ + cY, c_perpendicular + ^ + -----|------------ + | | | + | | | + -------0-----------------------> cX, c_parallel + | | + | | + ------------------ """ for cer_cx in np.linspace(-0.1, 0.1, 10): for cer_cy in np.linspace(-0.1, 0.1, 10): @@ -94,17 +94,17 @@ def test_parallel_on_x_axis(): def test_parallel_on_y_axis(): """ - c_perpendicular - ^ - -----|------------ - | | | - | | | - -------0-----------------------> cY, c_parallel - | | | - | | | - -----|------------ - V - cX + c_perpendicular + ^ + -----|------------ + | | | + | | | + -------0-----------------------> cY, c_parallel + | | | + | | | + -----|------------ + V + cX """ offset_y = 1.0 for cer_cx in np.linspace(-0.1, 0.1, 10): diff --git a/airshower_template_generator/version.py b/airshower_template_generator/version.py index 334b899..a8d4557 100644 --- a/airshower_template_generator/version.py +++ b/airshower_template_generator/version.py @@ -1 +1 @@ -__version__ = "0.3.4" +__version__ = "0.3.5" diff --git a/setup.py b/setup.py index 6e9c83d..c94719a 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,9 @@ url="https://github.com/cherenkov-plenoscope/airshower_template_generator.git", author="Sebastian Achim Mueller", author_email="sebastian-achim.mueller@mpi-hd.mpg.de", - packages=["airshower_template_generator",], + packages=[ + "airshower_template_generator", + ], package_data={"airshower_template_generator": []}, install_requires=[ "json_utils_sebastian-achim-mueller",