simulariumio/filters/translate_filter.py
def apply(self, data: TrajectoryData) -> TrajectoryData:
        """
        Add the XYZ translation to all spatial coordinates
        """
        print("Filtering: translation -------------")
        # get dimensions
        total_steps = data.agent_data.times.size
        max_agents = int(np.amax(data.agent_data.n_agents))
        max_subpoints = int(np.amax(data.agent_data.n_subpoints))
        # get filtered data
        positions = np.zeros((total_steps, max_agents, 3))
        subpoints = np.zeros((total_steps, max_agents, max_subpoints, 3))
        for time_index in range(total_steps):
            for agent_index in range(int(data.agent_data.n_agents[time_index])):
                if (
                    data.agent_data.types[time_index][agent_index]
                    in self.translation_per_type
                ):
                    translation = self.translation_per_type[
                        data.agent_data.types[time_index][agent_index]
                    ]
                else:
                    translation = self.default_translation
                n_subpoints = int(data.agent_data.n_subpoints[time_index][agent_index])
                if n_subpoints > 0:
                    for subpoint_index in range(
                        int(data.agent_data.n_subpoints[time_index][agent_index])
                    ):
                        for dim in range(3):
                            subpoints[time_index][agent_index][subpoint_index][dim] = (
                                data.agent_data.subpoints[time_index][agent_index][
                                    subpoint_index
                                ][dim]
                                + translation[dim]
                            )
                else:
                    for dim in range(3):
                        positions[time_index][agent_index][dim] = (
                            data.agent_data.positions[time_index][agent_index][dim]
                            + translation[dim]
                        )
        data.agent_data.positions = positions
        data.agent_data.subpoints = subpoints
        return data

        Add the XYZ translation to all spatial coordinates
        
Add the XYZ translation to all spatial coordinates
Add the XYZ translation to all spatial coordinates
def apply(self, data: TrajectoryData) -> TrajectoryData:
        print("Filtering: translation -------------")
        total_steps = data.agent_data.times.size
        max_agents = int(np.amax(data.agent_data.n_agents))
        max_subpoints = int(np.amax(data.agent_data.n_subpoints))
        positions = np.zeros((total_steps, max_agents, 3))
        subpoints = np.zeros((total_steps, max_agents, max_subpoints, 3))
        for time_index in range(total_steps):
            for agent_index in range(int(data.agent_data.n_agents[time_index])):
                if (
                    data.agent_data.types[time_index][agent_index]
                    in self.translation_per_type
                ):
                    translation = self.translation_per_type[
                        data.agent_data.types[time_index][agent_index]
                    ]
                else:
                    translation = self.default_translation
                n_subpoints = int(data.agent_data.n_subpoints[time_index][agent_index])
                if n_subpoints > 0:
                    for subpoint_index in range(
                        int(data.agent_data.n_subpoints[time_index][agent_index])
                    ):
                        for dim in range(3):
                            subpoints[time_index][agent_index][subpoint_index][dim] = (
                                data.agent_data.subpoints[time_index][agent_index][
                                    subpoint_index
                                ][dim]
                                + translation[dim]
                            )
                else:
                    for dim in range(3):
                        positions[time_index][agent_index][dim] = (
                            data.agent_data.positions[time_index][agent_index][dim]
                            + translation[dim]
                        )
        data.agent_data.positions = positions
        data.agent_data.subpoints = subpoints
        return data
def apply ( self , data : TrajectoryData ) -> TrajectoryData : print ( "Filtering: translation -------------" ) total_steps = data . agent_data . times . size max_agents = int ( np . amax ( data . agent_data . n_agents ) ) max_subpoints = int ( np . amax ( data . agent_data . n_subpoints ) ) positions = np . zeros ( ( total_steps , max_agents , 3 ) ) subpoints = np . zeros ( ( total_steps , max_agents , max_subpoints , 3 ) ) for time_index in range ( total_steps ) : for agent_index in range ( int ( data . agent_data . n_agents [ time_index ] ) ) : if ( data . agent_data . types [ time_index ] [ agent_index ] in self . translation_per_type ) : translation = self . translation_per_type [ data . agent_data . types [ time_index ] [ agent_index ] ] else : translation = self . default_translation n_subpoints = int ( data . agent_data . n_subpoints [ time_index ] [ agent_index ] ) if n_subpoints > 0 : for subpoint_index in range ( int ( data . agent_data . n_subpoints [ time_index ] [ agent_index ] ) ) : for dim in range ( 3 ) : subpoints [ time_index ] [ agent_index ] [ subpoint_index ] [ dim ] = ( data . agent_data . subpoints [ time_index ] [ agent_index ] [ subpoint_index ] [ dim ] + translation [ dim ] ) else : for dim in range ( 3 ) : positions [ time_index ] [ agent_index ] [ dim ] = ( data . agent_data . positions [ time_index ] [ agent_index ] [ dim ] + translation [ dim ] ) data . agent_data . positions = positions data . agent_data . subpoints = subpoints return data
Add the XYZ translation to all spatial coordinates
Add the XYZ translation to all spatial coordinates
"""
        Add the XYZ translation to all spatial coordinates
        """ # get dimensions # get filtered data
self
data
TrajectoryData