Beispiel #1
0
    def test_update_bounds_with_datapattern(self):
        patt = np.ones((100, 100))
        x = np.linspace(-2, 2, 100)
        y = np.linspace(-0.5, 3.5, 100)
        x_mesh, y_mesh = np.meshgrid(x, y)

        dp = pyfdd.DataPattern(pattern_array=patt)
        dp.set_xymesh(xmesh=x_mesh, ymesh=y_mesh)

        fp = FitParameters(n_sites=1)
        fp.update_bounds_with_datapattern(datapattern=dp)
        result_bounds = fp.get_bounds()

        # Assumes default bounds are (-3, 3)
        self.assertEqual(result_bounds['dx'], (-2, 2))
        self.assertEqual(result_bounds['dy'], (-0.5, 3))
Beispiel #2
0
    def test_get_scale_for_fit(self):
        patt = np.ones((100, 100)) * 100  # 10e6
        total_cts = patt.sum()

        dp = pyfdd.DataPattern(pattern_array=patt)

        fp = FitParameters(n_sites=1)
        fp.update_initial_values_with_datapattern(datapattern=dp)
        keys = fp.get_keys()

        scale = fp.get_scale_for_fit(cost_function='chi2')
        for k, scale_val in zip(keys, scale):
            if k == 'total_cts':
                self.assertEqual(scale_val, total_cts * FitParameters.default_scale['total_cts'])

        scale = fp.get_scale_for_fit(cost_function='ml')
        for k, scale_val in zip(keys, scale):
            if k == 'total_cts':
                self.assertEqual(scale_val, -1)
Beispiel #3
0
    def test_update_initial_values_with_datapattern(self):
        # Dummy DataPattern
        patt = np.ones((100, 100))
        x = np.linspace(-2, 2, 100)
        y = np.linspace(-2, 2, 100)
        x_mesh, y_mesh = np.meshgrid(x, y)

        dp = pyfdd.DataPattern(pattern_array=patt)
        dp.set_xymesh(xmesh=x_mesh, ymesh=y_mesh)
        dp.set_pattern_angular_pos((-0.1, 0.5), 3)

        # Test
        fitp = FitParameters(n_sites=1)
        fitp.update_initial_values_with_datapattern(datapattern=dp)
        initial_values = fitp.get_initial_values()

        self.assertEqual(initial_values['dx'], -0.1)
        self.assertEqual(initial_values['dy'], 0.5)
        self.assertEqual(initial_values['phi'], 3)
        self.assertEqual(initial_values['total_cts'], dp.pattern_matrix.sum())
Beispiel #4
0
 def make_dummy_pattern():
     pattern = np.random.poisson(1000, (22, 22))
     dp = pyfdd.DataPattern(pattern_array=pattern)
     dp.manip_create_mesh(pixel_size=1.4, distance=300)
     return dp
Beispiel #5
0
 def get_datapattern():
     print(os.getcwd())
     datapattern = pyfdd.DataPattern(
         '../../test_pyfdd/data_files/pad_dp_2M.json')
     return datapattern
Beispiel #6
0
pd.set_option('display.max_colwidth', None)

# In[2]:

filename1 = "/home/user/path/to/pattern_1.txt"
filename2 = "/home/user/path/to/pattern_2.txt"

# ## Creating the DataPattern
#
# The arguments to create a data pattern are the path to the data matrix, the number of chips (2 for the time quad 1 for the others) and the real size of the central pixels.
#
# Two DataPattern can be added together.

# In[3]:

dp1 = pyfdd.DataPattern(file_path=filename1, nChipsX=2, nChipsY=2, real_size=3)
dp2 = pyfdd.DataPattern(file_path=filename2, nChipsX=2, nChipsY=2, real_size=3)
dp = dp1 + dp2

# ## Manipulation of the data pattern

# In[4]:

# Manipulation methods

# Mask
mask = load_tpxquad_mask("/home/user/path/to/detector_mask.txt")

dp.set_mask(
    mask, expand_by=0)  # Set expand by > 0 when pixels are not added together.
# mask pixels for which its number of counts is over 4 standard deviations from averagage
Beispiel #7
0
pd.set_option('display.max_columns', 500)
pd.set_option('display.max_colwidth', None)

# In[2]:

filename = "../test_pyfdd/data_files/pad_dp_2M.txt"

# ## Creating the DataPattern
#
# The arguments to create a data pattern are the path to the data matrix, the number of chips (2 for the time quad 1 for the others) and the real size of the central pixels.
#
# Two DataPattern can be added together.

# In[3]:

dp1 = pyfdd.DataPattern(file_path=filename)
dp2 = dp1 * 1.5
dp = dp1 + dp2

# ## Manipulation of the data pattern

# In[4]:

# Manipulation methods

# Manipulation methods
# -Orient
dp.manip_orient('cw')  # PAD6 orientation
# use 'cw','cc','mh',mv' for rotate clockwise, rotate counterclockwise, mirror horizontal and mirror vertical
# in the desired order