Example #1
0
 def D(self, h_and_edges):
     h, edges = h_and_edges
     d = density.Density(h,
                         edges,
                         parameters={'isDensity': False},
                         units={'length': 'A'})
     d.make_density()
     return d
Example #2
0
    def check_density_from_Universe(self, atomselection, ref_meandensity,
                                    universe, tmpdir, **kwargs):
        with tmpdir.as_cwd():
            D = density.density_from_Universe(universe,
                                              select=atomselection,
                                              delta=self.delta,
                                              **kwargs)
            assert_almost_equal(D.grid.mean(),
                                ref_meandensity,
                                err_msg="mean density does not match")

            D.export(self.outfile)

            D2 = density.Density(self.outfile)
            assert_almost_equal(
                D.grid,
                D2.grid,
                decimal=self.precision,
                err_msg="DX export failed: different grid sizes")
Example #3
0
 def _conclude(self):
     self._grid = self._results[:].sum(axis=0)
     self._grid /= float(self.n_frames)
     metadata = self._metadata if self._metadata is not None else {}
     metadata['psf'] = self._atomgroup.universe.filename
     metadata['dcd'] = self._trajectory.filename
     metadata['atomselection'] = self._atomselection
     metadata['n_frames'] = self.n_frames
     metadata['totaltime'] = self._atomgroup.universe.trajectory.totaltime
     metadata['dt'] = self._trajectory.dt
     metadata['time_unit'] = "ps"
     parameters = self._parameters if self._parameters is not None else {}
     parameters['isDensity'] = False  # must override
     density = serial_density.Density(
         grid=self._grid, edges=self._edges,
         units={'length': "Angstrom"},
         parameters=parameters,
         metadata=metadata)
     density.make_density()
     self.density = density
Example #4
0
    def check_DensityAnalysis(self,
                              ag,
                              ref_meandensity,
                              tmpdir,
                              runargs=None,
                              **kwargs):
        runargs = runargs if runargs else {}
        with tmpdir.as_cwd():
            D = density.DensityAnalysis(ag, delta=self.delta,
                                        **kwargs).run(**runargs)
            assert_almost_equal(D.density.grid.mean(),
                                ref_meandensity,
                                err_msg="mean density does not match")
            D.density.export(self.outfile)

            D2 = density.Density(self.outfile)
            assert_almost_equal(
                D.density.grid,
                D2.grid,
                decimal=self.precision,
                err_msg="DX export failed: different grid sizes")
Example #5
0
#add up slices
#make sure you can graph density over z so you can look at it.

u=mda.Universe(SPH,topology_format='PDB')

interp_values=np.zeros(len(u.atoms))
cylinder_height=np.abs(u.atoms.positions[0][2]-u.atoms.positions[1][2])
spacing=0.2
stride=np.int(np.round(spacing/cylinder_height))
stride=1
cylinder_height=stride*cylinder_height
stride_pos=u.atoms.positions[0:-1:stride]
stride_rad=u.atoms.tempfactors[0:-1:stride]
big_sample=np.zeros(len(stride_pos))

x=de.Density(DX)
y=(x.centers())

for i in range(len(u.atoms)):
    pos=u.atoms.positions[i]
    rad=u.atoms.tempfactors[i]
    interp_values[i]=(x.interpolated(pos[0],pos[1],pos[2]))



for i in range(len(stride_pos)):

    pos=stride_pos[i]
    rad=stride_rad[i]

    grid_sample_values=np.zeros(num_sample_points)