simulariumio/md/md_converter.py
def _read_universe(
        input_data: MdData,
    ) -> AgentData:
        """
        Use a MD Universe to get AgentData
        """
        dimensions = MdConverter._read_universe_dimensions(input_data)
        result = AgentData.from_dimensions(dimensions)
        get_type_name_func = np.frompyfunc(MdConverter._get_type_name, 2, 1)
        unique_raw_type_names = set([])
        time_index = 0
        for frame in input_data.md_universe.trajectory[
            :: input_data.nth_timestep_to_read
        ]:
            result.times[time_index] = input_data.md_universe.trajectory.time
            atom_positions = input_data.md_universe.atoms.positions
            result.n_agents[time_index] = atom_positions.shape[0]
            result.unique_ids[time_index] = np.arange(atom_positions.shape[0])
            unique_raw_type_names.update(list(input_data.md_universe.atoms.names))
            result.types[time_index] = get_type_name_func(
                input_data.md_universe.atoms.names, input_data
            )
            result.positions[time_index] = (
                input_data.meta_data.scale_factor * atom_positions
            )
            result.radii[time_index] = input_data.meta_data.scale_factor * np.array(
                [
                    MdConverter._get_radius(type_name, input_data)
                    for type_name in input_data.md_universe.atoms.names
                ]
            )
            time_index += 1
        result.n_timesteps = dimensions.total_steps
        result.display_data = MdConverter._get_display_data_mapping(
            unique_raw_type_names, input_data
        )
        return result

        Use a MD Universe to get AgentData
        
Use a MD Universe to get AgentData
Use a MD Universe to get AgentData
def _read_universe(
        input_data: MdData,
    ) -> AgentData:
        dimensions = MdConverter._read_universe_dimensions(input_data)
        result = AgentData.from_dimensions(dimensions)
        get_type_name_func = np.frompyfunc(MdConverter._get_type_name, 2, 1)
        unique_raw_type_names = set([])
        time_index = 0
        for frame in input_data.md_universe.trajectory[
            :: input_data.nth_timestep_to_read
        ]:
            result.times[time_index] = input_data.md_universe.trajectory.time
            atom_positions = input_data.md_universe.atoms.positions
            result.n_agents[time_index] = atom_positions.shape[0]
            result.unique_ids[time_index] = np.arange(atom_positions.shape[0])
            unique_raw_type_names.update(list(input_data.md_universe.atoms.names))
            result.types[time_index] = get_type_name_func(
                input_data.md_universe.atoms.names, input_data
            )
            result.positions[time_index] = (
                input_data.meta_data.scale_factor * atom_positions
            )
            result.radii[time_index] = input_data.meta_data.scale_factor * np.array(
                [
                    MdConverter._get_radius(type_name, input_data)
                    for type_name in input_data.md_universe.atoms.names
                ]
            )
            time_index += 1
        result.n_timesteps = dimensions.total_steps
        result.display_data = MdConverter._get_display_data_mapping(
            unique_raw_type_names, input_data
        )
        return result
def _read_universe ( input_data : MdData , ) -> AgentData : dimensions = MdConverter . _read_universe_dimensions ( input_data ) result = AgentData . from_dimensions ( dimensions ) get_type_name_func = np . frompyfunc ( MdConverter . _get_type_name , 2 , 1 ) unique_raw_type_names = set ( [ ] ) time_index = 0 for frame in input_data . md_universe . trajectory [ : : input_data . nth_timestep_to_read ] : result . times [ time_index ] = input_data . md_universe . trajectory . time atom_positions = input_data . md_universe . atoms . positions result . n_agents [ time_index ] = atom_positions . shape [ 0 ] result . unique_ids [ time_index ] = np . arange ( atom_positions . shape [ 0 ] ) unique_raw_type_names . update ( list ( input_data . md_universe . atoms . names ) ) result . types [ time_index ] = get_type_name_func ( input_data . md_universe . atoms . names , input_data ) result . positions [ time_index ] = ( input_data . meta_data . scale_factor * atom_positions ) result . radii [ time_index ] = input_data . meta_data . scale_factor * np . array ( [ MdConverter . _get_radius ( type_name , input_data ) for type_name in input_data . md_universe . atoms . names ] ) time_index += 1 result . n_timesteps = dimensions . total_steps result . display_data = MdConverter . _get_display_data_mapping ( unique_raw_type_names , input_data ) return result
Use a MD Universe to get AgentData
Use a MD Universe to get AgentData
"""
        Use a MD Universe to get AgentData
        """
input_data
MdData