Skip to content

Commit

Permalink
fix constants class attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
TjarkMiener committed Feb 6, 2025
1 parent 8587449 commit 4b854bd
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions dl1_data_handler/image_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ def __init__(
self.geometry.rotate(self.geometry.pix_rotation)

self.pix_x = np.around(
self.geometry.pix_x.value, decimals=constants.decimal_precision
self.geometry.pix_x.value, decimals=self.constants.decimal_precision
)
self.pix_y = np.around(
self.geometry.pix_y.value, decimals=constants.decimal_precision
self.geometry.pix_y.value, decimals=self.constants.decimal_precision
)

self.x_ticks = np.unique(self.pix_x).tolist()
Expand Down Expand Up @@ -164,10 +164,10 @@ def _create_virtual_hex_pixels(
):
"""Create virtual hexagonal pixels outside of the camera."""
dist_first = np.around(
abs(first_ticks[0] - first_ticks[1]), decimals=constants.decimal_precision
abs(first_ticks[0] - first_ticks[1]), decimals=self.constants.decimal_precision
)
dist_second = np.around(
abs(second_ticks[0] - second_ticks[1]), decimals=constants.decimal_precision
abs(second_ticks[0] - second_ticks[1]), decimals=self.constants.decimal_precision
)

tick_diff = len(first_ticks) * 2 - len(second_ticks)
Expand All @@ -178,14 +178,14 @@ def _create_virtual_hex_pixels(
[
np.around(
second_ticks[0] - dist_second,
decimals=constants.decimal_precision,
decimals=self.constants.decimal_precision,
)
]
+ second_ticks
+ [
np.around(
second_ticks[-1] + dist_second,
decimals=constants.decimal_precision,
decimals=self.constants.decimal_precision,
)
]
)
Expand All @@ -195,14 +195,14 @@ def _create_virtual_hex_pixels(
[
np.around(
first_ticks[0] - dist_first,
decimals=constants.decimal_precision,
decimals=self.constants.decimal_precision,
)
]
+ first_ticks
+ [
np.around(
first_ticks[-1] + dist_first,
decimals=constants.decimal_precision,
decimals=self.constants.decimal_precision,
)
]
)
Expand All @@ -211,7 +211,7 @@ def _create_virtual_hex_pixels(
second_ticks.insert(
0,
np.around(
second_ticks[0] - dist_second, decimals=constants.decimal_precision
second_ticks[0] - dist_second, decimals=self.constants.decimal_precision
),
)

Expand Down Expand Up @@ -345,14 +345,14 @@ def _get_grids_for_oversampling(
[
np.around(
grid_second[0] - dist_second,
decimals=constants.decimal_precision,
decimals=self.constants.decimal_precision,
)
]
+ grid_second
+ [
np.around(
grid_second[-1] + dist_second,
decimals=constants.decimal_precision,
decimals=self.constants.decimal_precision,
)
]
)
Expand All @@ -362,7 +362,7 @@ def _get_grids_for_oversampling(
grid_second.insert(
0,
np.around(
grid_second[0] - dist_second, decimals=constants.decimal_precision
grid_second[0] - dist_second, decimals=self.constants.decimal_precision
),
)

Expand Down Expand Up @@ -426,7 +426,7 @@ def _smooth_ticks(self, pix_pos, ticks):
"""Smooth the ticks needed for the 'DigiCam' and 'CHEC' cameras."""
remove_val, change_val = [], []
for i in range(len(ticks) - 1):
if abs(ticks[i] - ticks[i + 1]) <= constants.tick_interval_limit:
if abs(ticks[i] - ticks[i + 1]) <= self.constants.tick_interval_limit:
remove_val.append(ticks[i])
change_val.append(ticks[i + 1])

Expand Down Expand Up @@ -580,18 +580,18 @@ def _get_grids(
)

dist_first = np.around(
abs(first_ticks[0] - first_ticks[1]), decimals=constants.decimal_precision
abs(first_ticks[0] - first_ticks[1]), decimals=self.constants.decimal_precision
)
dist_second = np.around(
abs(second_ticks[0] - second_ticks[1]), decimals=constants.decimal_precision
abs(second_ticks[0] - second_ticks[1]), decimals=self.constants.decimal_precision
)

# manipulate y ticks with extra ticks
num_extra_ticks = len(self.y_ticks)
for i in np.arange(num_extra_ticks):
second_ticks.append(
np.around(
second_ticks[-1] + dist_second, decimals=constants.decimal_precision
second_ticks[-1] + dist_second, decimals=self.constants.decimal_precision
)
)
first_ticks = reversed(first_ticks)
Expand All @@ -611,15 +611,15 @@ def _get_grids(
grid_second.append(
np.around(
grid_second[-1] + dist_second,
decimals=constants.decimal_precision,
decimals=self.constants.decimal_precision,
)
)
elif len(grid_first) < len(grid_second):
for i in np.arange(len(grid_second) - len(grid_first)):
grid_first.append(
np.around(
grid_first[-1] + dist_first,
decimals=constants.decimal_precision,
decimals=self.constants.decimal_precision,
)
)

Expand Down Expand Up @@ -719,21 +719,21 @@ def _get_grids(
for _ in np.arange(tick_diff_each_side):
second_ticks.append(
np.around(
second_ticks[-1] + dist_second, decimals=constants.decimal_precision
second_ticks[-1] + dist_second, decimals=self.constants.decimal_precision
)
)
second_ticks.insert(
0,
np.around(
second_ticks[0] - dist_second, decimals=constants.decimal_precision
second_ticks[0] - dist_second, decimals=self.constants.decimal_precision
),
)
# If tick_diff is odd, add one more tick to the beginning
if tick_diff % 2 != 0:
second_ticks.insert(
0,
np.around(
second_ticks[0] - dist_second, decimals=constants.decimal_precision
second_ticks[0] - dist_second, decimals=self.constants.decimal_precision
),
)
# Create the input and output grid
Expand Down

0 comments on commit 4b854bd

Please sign in to comment.