def read(self, real): import bigfile if self.comm.rank == 0: self.logger.info("Reading from Nmesh = %d to Nmesh = %d" % (self.Nmesh, real.Nmesh[0])) if any(real.Nmesh != self.Nmesh): pmread = ParticleMesh(BoxSize=real.BoxSize, Nmesh=(self.Nmesh, self.Nmesh, self.Nmesh), dtype='f4', comm=self.comm) else: pmread = real.pm f = bigfile.BigFileMPI(self.comm, self.path) with f[self.dataset] as ds: if self.isfourier: if self.comm.rank == 0: self.logger.info("reading complex field") complex2 = ComplexField(pmread) assert self.comm.allreduce(complex2.size) == ds.size start = sum( self.comm.allgather(complex2.size)[:self.comm.rank]) end = start + complex2.size complex2.unsort(ds[start:end]) complex2.resample(real) else: if self.comm.rank == 0: self.logger.info("reading real field") real2 = RealField(pmread) start = sum(self.comm.allgather(real2.size)[:self.comm.rank]) end = start + real2.size real2.unsort(ds[start:end]) real2.resample(real)
def to_real_field(self): """ Return the RealField stored on disk. .. note:: The mesh stored on disk must be stored with ``mode=real`` Returns ------- real : pmesh.pm.RealField an array-like object holding the mesh loaded from disk in configuration space """ if self.isfourier: return NotImplemented # the real field to paint to pmread = self.pm with BigFileMPI(comm=self.comm, filename=self.path)[self.dataset] as ds: if self.comm.rank == 0: self.logger.info("reading real field from %s" % self.path) real2 = RealField(pmread) start = sum(self.comm.allgather(real2.size)[:self.comm.rank]) end = start + real2.size real2.unsort(ds[start:end]) return real2
def read(self, real): import bigfile if self.comm.rank == 0: self.logger.info("Reading from Nmesh = %d to Nmesh = %d" %(self.Nmesh, real.Nmesh[0])) if any(real.Nmesh != self.Nmesh): pmread = ParticleMesh(BoxSize=real.BoxSize, Nmesh=(self.Nmesh, self.Nmesh, self.Nmesh), dtype='f4', comm=self.comm) else: pmread = real.pm f = bigfile.BigFileMPI(self.comm, self.path) with f[self.dataset] as ds: if self.isfourier: if self.comm.rank == 0: self.logger.info("reading complex field") complex2 = ComplexField(pmread) assert self.comm.allreduce(complex2.size) == ds.size start = sum(self.comm.allgather(complex2.size)[:self.comm.rank]) end = start + complex2.size complex2.unsort(ds[start:end]) complex2.resample(real) else: if self.comm.rank == 0: self.logger.info("reading real field") real2 = RealField(pmread) start = sum(self.comm.allgather(real2.size)[:self.comm.rank]) end = start + real2.size real2.unsort(ds[start:end]) real2.resample(real)