def test_psf_2D_dy(): # 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_2d.spline") with open(spline_filename, "rb") as fp: spline_data = pickle.load(fp) py_spline = spline2D.Spline2D(spline_data["spline"], spline_data["coeff"]) c_spline = cubicSplineC.CSpline2D(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) #print("{0:.3f} {1:.3f}".format(py_spline.dyf(x, y), c_spline.dyf(x, y))) assert (abs(py_spline.dyf(x, y) - c_spline.dyf(x, y)) < 1.0e-6)
def __init__(self, spline_file = None, **kwds): super(SplineToPSF2D, 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!" # These are used when we check the starting z-value(s) # provided by the user, if any. self.zmin = -1.0 self.zmax = 1.0 # The Python representation of the spline. self.spline = spline2D.Spline2D(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.CSpline2D(self.spline)