Skip to content
Snippets Groups Projects

Dom wise graph representation

Closed Jorge Prado requested to merge github/fork/RasmusOrsoe/dom_wise-graph-representation into main
1 unresolved thread

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

Approval is optional

Closed by Jorge PradoJorge Prado 2 years ago (May 12, 2022 11:29am UTC)

Merge details

  • The changes were not merged into main.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
19 19 truth_table: str = 'truth',
20 20 selection: Optional[List[int]] = None,
21 21 dtype: torch.dtype = torch.float32,
22 node_representation = 'pulse',
  • Created by: asogaard

    This would probably be best suited for an "enum" or similar type of structure (i.e., to have a fixed set of options), but this is perfectly fine for now.

  • Created by: asogaard

    If you stick to strings, though, I would add a assert node_representation in ['pulse', 'node'] check in the constructor (see also comment below).

  • Jorge Prado
    Jorge Prado @jprado started a thread on commit b7420b81
  • 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: asogaard

      This loop-based implement could likely be optimised for speed, but if it works and you haven't been impeded by the speed I am happy to included it and open an issue for future improvement.

    • 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.

  • Jorge Prado
  • Jorge Prado
    Jorge Prado @jprado started a thread on commit b7420b81
  • 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)
  • Jorge Prado
    Jorge Prado @jprado started a thread on commit b7420b81
  • 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
  • Jorge Prado
  • Jorge Prado
    Jorge Prado @jprado started a thread on commit b7420b81
  • 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
  • Jorge Prado
    Jorge Prado @jprado started a thread on commit b7420b81
  • 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
  • Jorge Prado
    Jorge Prado @jprado started a thread on commit b7420b81
  • 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
    • Created by: asogaard

      These do not seems to align with the 8 features being output from _make_dom_wise_representation above?

    • Created by: RasmusOrsoe

      The graph.x has 14 columns, not 8. Not sure what you mean?

  • Jorge Prado
    Jorge Prado @jprado started a thread on commit b7420b81
  • 3 3
    • Created by: asogaard

      The changes to this file seem to be accidental? Perhaps they should be reverted?

    • Created by: RasmusOrsoe

      I do not understand what this comment refers to @asogaard - Could you help me out?

    • 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.

  • Created by: asogaard

    Review: Changes requested

    Hi @RasmusOrsoe,

    I have gone through the PR now and added a few comment! :)

  • Jorge Prado mentioned in merge request !196 (merged)

    mentioned in merge request !196 (merged)

  • Created by: asogaard

    NB: Have opened #196 as an alternative implementation.

  • Created by: asogaard

    @RasmusOrsoe I figure this can be closed following #196?

  • assigned to @jprado

  • closed

  • Please register or sign in to reply
    Loading