def __init__(self, spline_file = None, **kwds): super(SplineToPSF3D, self).__init__(**kwds) spline_data = self.loadSplineFile(spline_file) # Check that this is not an old spline, which will be transposed. assert("version" in spline_data), "v0 spline file detected! Please re-measure!" assert(spline_data["version"] >= 2.0), "v0/v1 spline file detected! Please re-measure!" self.zmin = spline_data["zmin"] self.zmax = spline_data["zmax"] # The Python representation of the spline. self.spline = spline3D.Spline3D(spline_data["spline"], spline_data["coeff"]) self.spline_size = self.spline.getSize() # The C representation of the spline. This class does not use # this, but it keeps track of it for the C fitting library. self.c_spline = cubicSplineC.CSpline3D(self.spline)
def test_psf_3D_f(): # Only test for Python3 due to pickle incompatibility issues. if (sys.version_info < (3, 0)): return spline_filename = storm_analysis.getData( "test/data/test_spliner_psf.spline") with open(spline_filename, "rb") as fp: spline_data = pickle.load(fp) py_spline = spline3D.Spline3D(spline_data["spline"], spline_data["coeff"]) c_spline = cubicSplineC.CSpline3D(py_spline) size = py_spline.getSize() - 1.0e-6 for i in range(reps): x = random.uniform(1.0e-6, size) y = random.uniform(1.0e-6, size) z = random.uniform(1.0e-6, size) #print("{0:.3f} {1:.3f}".format(py_spline.f(x, y), c_spline.f(x, y))) assert (abs(py_spline.f(x, y, z) - c_spline.f(x, y, z)) < 1.0e-6)