Skip to content
Snippets Groups Projects
Commit 291e12d6 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

still debugging field I/O

i removed the symmetrize, and now "test_field_class" gives sane results.
the problem may be with the symmetrization.
parent 4c2154ae
No related branches found
No related tags found
2 merge requests!21Bugfix/nansampling,!3Bugfix/event manager show html
......@@ -237,8 +237,6 @@ int field<rnumber, be, fc>::io(
memshape[i] = this->rmemlayout->subsizes[i];
memoffset[i] = 0;
}
mspace = H5Screate_simple(ndim(fc), memshape, NULL);
H5Sselect_hyperslab(mspace, H5S_SELECT_SET, memoffset, NULL, count, NULL);
}
else
{
......@@ -249,10 +247,12 @@ int field<rnumber, be, fc>::io(
dims [i] = this->clayout->sizes[i];
memshape [i] = count[i];
memoffset[i] = 0;
DEBUG_MSG("%d %d %d %d\n",
count[i], offset[i], dims[i], memshape[i]);
}
}
mspace = H5Screate_simple(ndim(fc), memshape, NULL);
H5Sselect_hyperslab(mspace, H5S_SELECT_SET, memoffset, NULL, count, NULL);
}
/* open/create data set */
if (read)
......@@ -335,7 +335,7 @@ int field<rnumber, be, fc>::io(
std::fill_n(this->data, this->clayout->local_size*2, 0);
H5Dread(dset_id, this->cnumber_H5T, mspace, fspace, H5P_DEFAULT, this->data);
//DEBUG_MSG("%g %g\n", this->cval(2, 0, 0), this->cval(2, 0, 1));
this->symmetrize();
//this->symmetrize();
//this->ift();
//this->dft();
//this->normalize();
......
......@@ -101,7 +101,7 @@ class TestField(_fluid_particle_base):
return None
def main():
n = 128
n = 32
kdata = pyfftw.n_byte_align_empty(
(n, n, n//2 + 1),
pyfftw.simd_alignment,
......@@ -142,35 +142,60 @@ def main():
'--ncpu', '2'])
f = h5py.File('field.h5', 'r')
err0 = np.max(np.abs(f['data_tmp/real/0'].value - rdata)) / np.mean(np.abs(rdata))
err1 = np.max(np.abs(f['data/real/0'].value/(n**3) - rdata)) / np.mean(np.abs(rdata))
err2 = np.max(np.abs(f['data_tmp/complex/0'].value/(n**3) - cdata)) / np.mean(np.abs(cdata))
print(err0, err1, err2)
assert(err0 < 1e-5)
assert(err1 < 1e-5)
assert(err2 < 1e-4)
### compare
#fig = plt.figure(figsize=(12, 6))
#a = fig.add_subplot(121)
#a.set_axis_off()
#a.imshow(rdata[0, :, :], interpolation = 'none')
#a = fig.add_subplot(122)
#a.set_axis_off()
#a.imshow(f['rdata_tmp'][0, 0, :, :], interpolation = 'none')
#err0 = np.max(np.abs(f['scal_tmp/real/0'].value - rdata)) / np.mean(np.abs(rdata))
#err1 = np.max(np.abs(f['scal/real/0'].value/(n**3) - rdata)) / np.mean(np.abs(rdata))
#err2 = np.max(np.abs(f['scal_tmp/complex/0'].value/(n**3) - cdata)) / np.mean(np.abs(cdata))
#print(err0, err1, err2)
#assert(err0 < 1e-5)
#assert(err1 < 1e-5)
#assert(err2 < 1e-4)
## compare
fig = plt.figure(figsize=(18, 6))
a = fig.add_subplot(131)
a.set_axis_off()
v0 = f['vec/complex/0'][:, :, 0, 0]
v1 = f['vec_tmp/complex/0'][:, :, 0, 0]
a.imshow(np.log(np.abs(v0 - v1)),
interpolation = 'none')
a = fig.add_subplot(132)
a.set_axis_off()
a.imshow(np.log(np.abs(v0)),
interpolation = 'none')
a = fig.add_subplot(133)
a.set_axis_off()
a.imshow(np.log(np.abs(v1)),
interpolation = 'none')
fig.tight_layout()
fig.savefig('tst_fields.pdf')
fig = plt.figure(figsize=(18, 6))
a = fig.add_subplot(131)
a.set_axis_off()
v0 = f['scal/complex/0'][:, :, 0]
v1 = f['scal_tmp/complex/0'][:, :, 0]
a.imshow(np.log(np.abs(v0 - v1)),
interpolation = 'none')
a = fig.add_subplot(132)
a.set_axis_off()
a.imshow(np.log(np.abs(v0)),
interpolation = 'none')
a = fig.add_subplot(133)
a.set_axis_off()
a.imshow(np.log(np.abs(v1)),
interpolation = 'none')
fig.tight_layout()
fig.savefig('tst_sfields.pdf')
# look at moments and histogram
#print('moments are ', f['moments/scal'][0])
#fig = plt.figure(figsize=(6,6))
#a = fig.add_subplot(211)
#a.plot(f['histograms/scal'][0])
#a.set_yscale('log')
#a = fig.add_subplot(212)
#a.plot(f['spectra/scal'][0])
#a.set_xscale('log')
#a.set_yscale('log')
#fig.tight_layout()
#fig.savefig('tst.pdf')
# look at moments and histogram
print('moments are ', f['moments/scal'][0])
fig = plt.figure(figsize=(6,6))
a = fig.add_subplot(211)
a.plot(f['histograms/scal'][0])
a.set_yscale('log')
a = fig.add_subplot(212)
a.plot(f['spectra/scal'][0])
a.set_xscale('log')
a.set_yscale('log')
fig.tight_layout()
fig.savefig('tst.pdf')
return None
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment