src/graphnet/models/detector/icecube.py
def _forward(self, data: Data) -> Data:
        """Ingests data, builds graph (connectivity/adjacency), and preprocesses features.

        Args:
            data (Data): Input graph data.

        Returns:
            Data: Connected and preprocessed graph data.
        """

        # Check(s)
        self._validate_features(data)

        # Assign pulse cluster indices to DOMs and PMTs, respectively
        data = group_pulses_to_dom(data)
        data = group_pulses_to_pmt(data)

        # Feature engineering inspired by Linea Hedemark and Tetiana Kozynets.
        xyz = torch.stack((data["dom_x"], data["dom_y"], data["dom_z"]), dim=1)
        pmt_dir = torch.stack(
            (data["pmt_dir_x"], data["pmt_dir_x"], data["pmt_dir_x"]), dim=1
        )
        charge = data["charge"].unsqueeze(dim=1)
        center_of_gravity = sum_pool_and_distribute(
            xyz * charge, data.batch
        ) / sum_pool_and_distribute(charge, data.batch)
        vector_to_center_of_gravity = center_of_gravity - xyz
        distance_to_center_of_gravity = torch.norm(
            vector_to_center_of_gravity, p=2, dim=1
        )
        unit_vector_to_center_of_gravity = vector_to_center_of_gravity / (
            distance_to_center_of_gravity.unsqueeze(dim=1) + 1e-3
        )
        cos_angle_wrt_center_of_gravity = (
            pmt_dir * unit_vector_to_center_of_gravity
        ).sum(dim=1)
        photoelectrons_on_pmt = (
            sum_pool_and_distribute(data["charge"], data.pmt_index, data.batch)
            .floor()
            .clip(1, None)
        )

        # Add new features
        data.x = torch.cat(
            (
                data.x,
                photoelectrons_on_pmt.unsqueeze(dim=1),
                distance_to_center_of_gravity.unsqueeze(dim=1),
                cos_angle_wrt_center_of_gravity.unsqueeze(dim=1),
            ),
            dim=1,
        )

        # Preprocessing
        data.x[:, 0] /= 500.0  # dom_x
        data.x[:, 1] /= 500.0  # dom_y
        data.x[:, 2] /= 500.0  # dom_z
        data.x[:, 3] /= 2e04  # dom_time
        data.x[:, 3] -= 1.0
        data.x[:, 4] = torch.log10(data.x[:, 4]) / 2.0  # charge
        # data.x[:,5] /= 1.  # rde
        data.x[:, 6] /= 0.05  # pmt_area
        data.x[:, 7] -= 50.0  # string
        data.x[:, 7] /= 50.0
        data.x[:, 8] /= 20.0  # pmt_number
        data.x[:, 9] -= 60.0  # dom_number
        data.x[:, 9] /= 60.0
        # data.x[:,10] /= 1.  # pmt_dir_x
        # data.x[:,11] /= 1.  # pmt_dir_y
        # data.x[:,12] /= 1.  # pmt_dir_z
        data.x[:, 13] /= 130.0  # dom_type

        # -- Engineered features
        data.x[:, 14] = (
            torch.log10(data.x[:, 14]) / 2.0
        )  # photoelectrons_on_pmt
        data.x[:, 15] = (
            torch.log10(1e-03 + data.x[:, 15]) / 2.0
        )  # distance_to_center_of_gravity

        return data
Ingests data, builds graph (connectivity/adjacency), and preprocesses features.

        Args:
            data (Data): Input graph data.

        Returns:
            Data: Connected and preprocessed graph data.
        
Ingests data, builds graph (connectivity/adjacency), and preprocesses features.
Ingests data builds graph ( connectivity / adjacency ) and preprocesses features .
def _forward(self, data: Data) -> Data:
        self._validate_features(data)
        data = group_pulses_to_dom(data)
        data = group_pulses_to_pmt(data)
        xyz = torch.stack((data["dom_x"], data["dom_y"], data["dom_z"]), dim=1)
        pmt_dir = torch.stack(
            (data["pmt_dir_x"], data["pmt_dir_x"], data["pmt_dir_x"]), dim=1
        )
        charge = data["charge"].unsqueeze(dim=1)
        center_of_gravity = sum_pool_and_distribute(
            xyz * charge, data.batch
        ) / sum_pool_and_distribute(charge, data.batch)
        vector_to_center_of_gravity = center_of_gravity - xyz
        distance_to_center_of_gravity = torch.norm(
            vector_to_center_of_gravity, p=2, dim=1
        )
        unit_vector_to_center_of_gravity = vector_to_center_of_gravity / (
            distance_to_center_of_gravity.unsqueeze(dim=1) + 1e-3
        )
        cos_angle_wrt_center_of_gravity = (
            pmt_dir * unit_vector_to_center_of_gravity
        ).sum(dim=1)
        photoelectrons_on_pmt = (
            sum_pool_and_distribute(data["charge"], data.pmt_index, data.batch)
            .floor()
            .clip(1, None)
        )
        data.x = torch.cat(
            (
                data.x,
                photoelectrons_on_pmt.unsqueeze(dim=1),
                distance_to_center_of_gravity.unsqueeze(dim=1),
                cos_angle_wrt_center_of_gravity.unsqueeze(dim=1),
            ),
            dim=1,
        )
        data.x[:, 0] /= 500.0  
        data.x[:, 1] /= 500.0  
        data.x[:, 2] /= 500.0  
        data.x[:, 3] /= 2e04  
        data.x[:, 3] -= 1.0
        data.x[:, 4] = torch.log10(data.x[:, 4]) / 2.0  
        data.x[:, 6] /= 0.05  
        data.x[:, 7] -= 50.0  
        data.x[:, 7] /= 50.0
        data.x[:, 8] /= 20.0  
        data.x[:, 9] -= 60.0  
        data.x[:, 9] /= 60.0
        data.x[:, 13] /= 130.0  
        data.x[:, 14] = (
            torch.log10(data.x[:, 14]) / 2.0
        )  
        data.x[:, 15] = (
            torch.log10(1e-03 + data.x[:, 15]) / 2.0
        )  
        return data
def _forward ( self , data : Data ) -> Data : self . _validate_features ( data ) data = group_pulses_to_dom ( data ) data = group_pulses_to_pmt ( data ) xyz = torch . stack ( ( data [ "dom_x" ] , data [ "dom_y" ] , data [ "dom_z" ] ) , dim = 1 ) pmt_dir = torch . stack ( ( data [ "pmt_dir_x" ] , data [ "pmt_dir_x" ] , data [ "pmt_dir_x" ] ) , dim = 1 ) charge = data [ "charge" ] . unsqueeze ( dim = 1 ) center_of_gravity = sum_pool_and_distribute ( xyz * charge , data . batch ) / sum_pool_and_distribute ( charge , data . batch ) vector_to_center_of_gravity = center_of_gravity - xyz distance_to_center_of_gravity = torch . norm ( vector_to_center_of_gravity , p = 2 , dim = 1 ) unit_vector_to_center_of_gravity = vector_to_center_of_gravity / ( distance_to_center_of_gravity . unsqueeze ( dim = 1 ) + 1e-3 ) cos_angle_wrt_center_of_gravity = ( pmt_dir * unit_vector_to_center_of_gravity ) . sum ( dim = 1 ) photoelectrons_on_pmt = ( sum_pool_and_distribute ( data [ "charge" ] , data . pmt_index , data . batch ) . floor ( ) . clip ( 1 , None ) ) data . x = torch . cat ( ( data . x , photoelectrons_on_pmt . unsqueeze ( dim = 1 ) , distance_to_center_of_gravity . unsqueeze ( dim = 1 ) , cos_angle_wrt_center_of_gravity . unsqueeze ( dim = 1 ) , ) , dim = 1 , ) data . x [ : , 0 ] /= 500.0 data . x [ : , 1 ] /= 500.0 data . x [ : , 2 ] /= 500.0 data . x [ : , 3 ] /= 2e04 data . x [ : , 3 ] -= 1.0 data . x [ : , 4 ] = torch . log10 ( data . x [ : , 4 ] ) / 2.0 data . x [ : , 6 ] /= 0.05 data . x [ : , 7 ] -= 50.0 data . x [ : , 7 ] /= 50.0 data . x [ : , 8 ] /= 20.0 data . x [ : , 9 ] -= 60.0 data . x [ : , 9 ] /= 60.0 data . x [ : , 13 ] /= 130.0 data . x [ : , 14 ] = ( torch . log10 ( data . x [ : , 14 ] ) / 2.0 ) data . x [ : , 15 ] = ( torch . log10 ( 1e-03 + data . x [ : , 15 ] ) / 2.0 ) return data
Ingests data, builds graph (connectivity/adjacency), and preprocesses features.
Ingests data builds graph ( connectivity / adjacency ) and preprocesses features .
"""Ingests data, builds graph (connectivity/adjacency), and preprocesses features.

        Args:
            data (Data): Input graph data.

        Returns:
            Data: Connected and preprocessed graph data.
        """ # Check(s) # Assign pulse cluster indices to DOMs and PMTs, respectively # Feature engineering inspired by Linea Hedemark and Tetiana Kozynets. # Add new features # Preprocessing # dom_x # dom_y # dom_z # dom_time # charge # data.x[:,5] /= 1.  # rde # pmt_area # string # pmt_number # dom_number # data.x[:,10] /= 1.  # pmt_dir_x # data.x[:,11] /= 1.  # pmt_dir_y # data.x[:,12] /= 1.  # pmt_dir_z # dom_type # -- Engineered features # photoelectrons_on_pmt # distance_to_center_of_gravity
Connected and preprocessed graph data.
Connected and preprocessed graph data .
Data
self
data
Data
Input graph data.
Input graph data .