Dom wise graph representation
Created by: RasmusOrsoe
Adds additional functionality to the sqlite dataset class that lets the user specify the "node representation" in graphs. The node representation defaults to "pulse" - our current choice.
When node_representation = "dom", the SQLite dataset class groups same-pmt pulses to the same node, and aggregate the pulse information by taking min, max, mean and std of the pulse time and charge.
Rasmus
Merge request reports
Activity
requested review from @jprado
19 19 truth_table: str = 'truth', 20 20 selection: Optional[List[int]] = None, 21 21 dtype: torch.dtype = torch.float32, 22 node_representation = 'pulse', 118 120 except: 119 121 return -1 120 122 123 def _get_unique_positions(self, tensor): 124 return torch.unique(tensor, return_counts = True, return_inverse=True, dim=0) 125 126 def _make_dom_wise_representation(self,data): Created by: RasmusOrsoe
It's fairly performant, but it is slower than the pulse representation. I agree with your suggestion and would welcome input on how to vectorize this. I thought about it a bit and sought inspiration from your upgrade code, but I could not see a direct application for this. So I'd be quite interested to see the solution.
193 graph = Data( 194 x=x, 195 edge_index= None 196 ) 197 elif self._node_representation.lower() == 'dom': 198 x = torch.tensor(data, dtype=self._dtype) 199 n_pulses = torch.tensor(len(x), dtype=torch.int32) 200 graph = Data( 201 x=x, 202 edge_index= None 203 ) 204 graph = self._make_dom_wise_representation(graph) 205 else: 206 print('WARNING: node representation %s not recognized!'%self._node_representation) 207 208 Created by: asogaard
DRY. Also, the check for
node_representation in ['pulse', 'node']
should probably be done in the constructor, such that we can assume that it has a standard value in all other methods. I'll assume that here to simplify.x = torch.tensor(data, dtype=self._dtype) n_pulses = torch.tensor(len(x), dtype=torch.int32) graph = Data( x=x, edge_index= None ) if self._node_representation == 'dom': graph = self._make_dom_wise_representation(graph)
63 Data: Connected and preprocessed graph data. 64 """ 65 66 # Check(s) 67 self._validate_features(data) 68 69 #pulse_statistics[count,0] = torch.min(time) 70 #pulse_statistics[count,1] = torch.mean(time) 71 #pulse_statistics[count,2] = torch.max(time) 72 #pulse_statistics[count,3] = torch.std(time) 73 #pulse_statistics[count,4] = torch.min(charge) 74 #pulse_statistics[count,5] = torch.mean(charge) 75 #pulse_statistics[count,6] = torch.max(charge) 76 #pulse_statistics[count,7] = torch.std(charge) 77 #unique_doms, n_pulses_pr_dom.unsqueeze(1), pulse_statistics 78 40 40 41 41 return data 42 42 43 class IceCube86_v2(Detector): 44 """`Detector` class for IceCube-86 with nodes as doms.""" 45 46 # Implementing abstract class attribute 47 features = FEATURES.ICECUBE86 48 49 @property 50 def nb_inputs(self) -> int: 51 return len(self.features) + 7 Created by: RasmusOrsoe
Yes. These are the aggregated pulse information. See https://github.com/icecube/graphnet/blob/b7420b8163c8eb4f30a4dd0b3784582fe4dcb974/src/graphnet/data/sqlite_dataset.py#L132
40 40 41 41 return data 42 42 43 class IceCube86_DOM(Detector): 44 """`Detector` class for IceCube-86 with nodes as doms.""" 45 46 # Implementing abstract class attribute 47 features = FEATURES.ICECUBE86 48 49 @property 50 def nb_inputs(self) -> int: 51 return len(self.features) + 7 52 53 @property 54 def nb_outputs(self): 55 return self.nb_inputs 95 data.x[:,7] /= 1.05e+04 # dom_time 96 data.x[:,7] -= 1. 97 data.x[:,7] *= 20 98 99 data.x[:,8] /= 1.05e+04 # dom_time 100 data.x[:,8] -= 1. 101 data.x[:,8] *= 20 102 103 data.x[:,9] /= 1.05e+04 # dom_time 104 data.x[:,9] -= 1. 105 data.x[:,9] *= 20 106 107 data.x[:,10] /= 1. # charge 108 data.x[:,11] /= 1. # charge 109 data.x[:,12] /= 1. # charge 110 data.x[:,13] /= 1. # charge 3 3 Created by: asogaard
It's just that the only changes to this file seem to be whitespace changes and adding a few imports that are not used? (E.g.,
from graphnet.components.pool import group_identical
) If these are indeed unintentional, I was just asking if it would be better to just not modify this file at all in this PR.
mentioned in merge request !196 (merged)
assigned to @jprado