29 When we extract the fine grid patches, we rely on a
30 patch overlap. With floating point precision which is
31 often smaller then IEEE single (for a lot of vis tools
32 or formats, respectively), I try to be rather careful
33 with throwing away patches - otherwise, you quickly end
34 up with vis where small pieces are missing.
36 I therefore introduce an expansion factor. I throw away
37 patches if they overlap. So to be more pessimistic, the
38 expansion has to be set negative.
40 a: tarch.plotter.api.Patch
42 b: tarch.plotter.api.Patch
47 Expansion = -0.1 * min(
48 a.size[0], b.size[0], a.size[1], b.size[1], a.size[2], b.size[2]
51 a.offset[0] + a.size[0] + Expansion > b.offset[0]
52 and a.offset[1] + a.size[1] + Expansion > b.offset[1]
53 and a.offset[2] + a.size[2] + Expansion > b.offset[2]
54 and a.offset[0] < b.offset[0] + b.size[0] + Expansion
55 and a.offset[1] < b.offset[1] + b.size[1] + Expansion
56 and a.offset[2] < b.offset[2] + b.size[2] + Expansion
59 Expansion = -0.1 * min(a.size[0], b.size[0], a.size[1], b.size[1])
61 a.offset[0] + a.size[0] + Expansion > b.offset[0]
62 and a.offset[1] + a.size[1] + Expansion > b.offset[1]
63 and a.offset[0] < b.offset[0] + b.size[0] + Expansion
64 and a.offset[1] < b.offset[1] + b.size[1] + Expansion
75 is_data_associated_to_cell,
80 Overwrite this one for the particular filter.
82 We create an empty result array. Then we run over the input sequence
83 of cell_data. Per element, we check if a cell_data to the right within
84 this input sequence overlaps.
86 List operations are very expensive in Python. I therefore implement a
87 two-pass strategy, where I first sort the patches according to their
88 size. Actually, I sort them according to their inverted size, i.e.
89 big entries come first.
97 "Sort input data to optimise algorithmic efficiency. Small patches come first"
99 cell_data.sort(reverse=
False, key=sort_key)
102 new_cell_data = [
None for _
in range(len(cell_data))]
106 "Build up auxiliary data structures over "
107 + str(len(cell_data))
111 new_cell_data[0] = cell_data[0]
112 current_index_in_cell_data = 1
113 current_index_in_new_cell_data = 0
117 min_size = cell_data[current_index_in_cell_data].size[0]
119 ratio_of_last_progress_print = 10
121 while current_index_in_cell_data < len(cell_data):
123 cell_data[current_index_in_cell_data - 1].size[0]
124 <= cell_data[current_index_in_cell_data].size[0]
127 if cell_data[current_index_in_cell_data].size[0] == min_size:
128 current_index_in_new_cell_data += 1
129 new_cell_data[current_index_in_new_cell_data] = cell_data[
130 current_index_in_cell_data
132 current_index_in_cell_data += 1
136 while not overlaps
and check_index < current_index_in_new_cell_data:
138 new_cell_data[check_index],
139 cell_data[current_index_in_cell_data],
144 current_index_in_cell_data += 1
146 current_index_in_new_cell_data += 1
147 new_cell_data[current_index_in_new_cell_data] = cell_data[
148 current_index_in_cell_data
150 current_index_in_cell_data += 1
152 if current_index_in_cell_data > ratio_of_last_progress_print / 100 * len(
156 print(
"... {}%".format(ratio_of_last_progress_print))
157 ratio_of_last_progress_print += 10
159 current_index_in_new_cell_data += 1
163 + str(current_index_in_new_cell_data)
165 + str(len(cell_data))
168 new_cell_data = new_cell_data[0:current_index_in_new_cell_data]
175 is_data_associated_to_cell,