Пример #1
0
from __future__ import division

from scitbx.array_family import flex
from dials.scratch.luiso_s import model_2d, write_2d, test_compare_2d

from dials.algorithms.integration import add_2d

nrow = 10
ncol = 10

sumation = flex.double(flex.grid(21, 21))
descr = flex.double(flex.grid(1, 3))
descr[0, 0] = 0.5
descr[0, 1] = 5
descr[0, 2] = 5

ref2d = model_2d(5, 5, 2, 1, 0.2, 55, 0.5)

sumation = add_2d(descr, ref2d, sumation)
# sumation = test_compare_2d(descr, ref2d, sumation)

write_2d(sumation)
Пример #2
0
t_bbox = flex.int6(num_ref)
t_xyzobs = flex.vec3_double(num_ref)
t_xyzcal = flex.vec3_double(num_ref)

t_row = 0
for ypos in range(n_y):
    for xpos in range(n_x):
        row_str = ypos * nrow
        col_str = xpos * ncol
        dx = col_str - xmax / 2
        dy = row_str - ymax / 2

        ref_ang = float(math.atan2(dx, dy) / pi)
        i_loc = random.randint(0, 999)
        thold = i_loc / 8
        ref2d = model_2d(nrow, ncol, 5, 1, ref_ang, i_loc, 0.5)

        data2d_tmp = ref2d.as_numpy_array()
        data2d[col_str:col_str + ncol,
               row_str:row_str + nrow] += numpy.float64(data2d_tmp)
        t_bbox[t_row] = [
            col_str, col_str + ncol, row_str, row_str + nrow, 0, 1
        ]
        t_xyzobs[t_row] = [col_str + centr_col, row_str + centr_row, 0.5]

        t_xyzcal[t_row] = [col_str + centr_col, row_str + centr_row, 0.5]
        np_shoebox = numpy.copy(data2d[col_str:col_str + ncol,
                                       row_str:row_str + nrow])

        # tmp_2d_fl_shoebox = flex.double(np_shoebox)
        # tmp_2d_fl_shoebox.reshape(flex.grid(1, ncol, nrow))
Пример #3
0
nrow = 60
ncol = 60

for xpos in range(45):
  for ypos in range(25):
    row_str = ypos * 20
    col_str = xpos * 20
    ref_ang = float(ypos / 10)
    local_i = (68 - xpos - ypos) * 5
    '''
    print "xpos =", xpos
    print "ypos =", ypos
    print "local_i =", local_i
    print "____________________________"
    '''
    ref2d = model_2d(nrow, ncol, 3, 2, ref_ang, local_i, 0.5)
    data2d_tmp = ref2d.as_numpy_array()
    np_data2d[row_str:row_str + 60, col_str:col_str + 60] += numpy.float64(data2d_tmp)




big_ref2d = model_2d(550, 950, 280, 140, 1.0, 955, 0.5)
data2d_tmp = big_ref2d.as_numpy_array()
np_data2d[:, :] += numpy.float64(data2d_tmp)



#tmp='''
print "adding noise ...."
import random
Пример #4
0
from __future__ import division
from __future__ import print_function
from scitbx.array_family import flex
from dials.scratch.luiso_s import model_2d

nrow = 35
ncol = 35
ref_ang = 5
local_i = 170

data2d = model_2d(nrow, ncol, 6, 3, ref_ang, local_i, 0.5)

ext_siz = 2
mask2d = flex.int(flex.grid(nrow, ncol))
for x_loc in range(ncol):
    for y_loc in range(nrow):
        if data2d[y_loc, x_loc] > 10:
            mask2d[y_loc, x_loc] = 5
        else:
            mask2d[y_loc, x_loc] = 3

ext_siz = 1
tmp_mask = mask2d[:, :]
mask2d = mask2d.as_numpy_array()
for x_loc in range(ncol):
    for y_loc in range(nrow):
        if tmp_mask[y_loc, x_loc] == 5:
            mask2d[y_loc - ext_siz:y_loc + ext_siz,
                   x_loc - ext_siz:x_loc + ext_siz] = 5

mask2d = flex.int(mask2d)
Пример #5
0
sumation = flex.double(flex.grid(21, 21))
descr = flex.double(flex.grid(1, 3))
descr[0, 0] = .5
descr[0, 1] = 5
descr[0, 2] = 5
print "____________________________________________________________________"


for xpos in range(3):
  for ypos in range(3):
    row_str = ypos * 12
    col_str = xpos * 20
    ref_ang = float((ypos + 1) / 10)
    # flex_int model_2d(int nrow, int ncol, float a, float b,
    # float delta_ang, float imax, float asp)
    ref2d = model_2d(nrow, ncol, 2, 1, ref_ang, 55, 0.5)
    data2d_tmp = ref2d.as_numpy_array()
    data2d[row_str:row_str + nrow, col_str:col_str + ncol] += numpy.float64(data2d_tmp)

    sumation = add_2d(descr, flex.double (numpy.float64 (data2d_tmp)), sumation)
    write_2d(sumation)


print "Plotting data2d"
plt.imshow(data2d, interpolation = "nearest")
plt.show()

print "Plotting reslt"
img_suma = sumation.as_numpy_array()
plt.imshow(img_suma, interpolation = "nearest")
plt.show()
Пример #6
0
from __future__ import division

from scitbx.array_family import flex
from dials.scratch.luiso_s import model_2d, write_2d, test_compare_2d

from dials.algorithms.integration import add_2d

nrow = 10
ncol = 10

sumation = flex.double(flex.grid(21, 21))
descr = flex.double(flex.grid(1, 3))
descr[0, 0] = .5
descr[0, 1] = 5
descr[0, 2] = 5

ref2d = model_2d(5, 5, 2, 1, 0.2, 55, 0.5)

sumation = add_2d(descr, ref2d, sumation)
#sumation = test_compare_2d(descr, ref2d, sumation)

write_2d(sumation)

Пример #7
0
        col_str = xpos * ncol
        dx = col_str - 1200
        dy = row_str - 1300

        if dx < 0 and dy < 0:
            ref_ang = 0.25
        elif dx > 0 and dy < 0:
            ref_ang = 0.75
        elif dx < 0 and dy > 0:
            ref_ang = 0.75
        else:
            ref_ang = 0.20
        ref_ang = float(math.atan2(dx, dy) / pi)
        i_loc = random.randint(0, 999)
        thold = i_loc / 20
        ref2d = model_2d(nrow, ncol, 5, 1, ref_ang, i_loc, 0.5)

        data2d_tmp = ref2d.as_numpy_array()
        data2d[col_str : col_str + ncol, row_str : row_str + nrow] += numpy.float64(data2d_tmp)

        # new_r = Reflection()

        # new_r.bounding_box = [col_str, col_str + ncol, row_str, row_str + nrow, 0, 1]
        t_bbox[t_row] = [col_str, col_str + ncol, row_str, row_str + nrow, 0, 1]

        # new_r.centroid_position = [col_str + 14.5, row_str + 14.5, 0.5]
        t_xyzobs[t_row] = [col_str + 14.5, row_str + 14.5, 0.5]

        t_xyzcal[t_row] = [col_str + 14.5, row_str + 14.5, 0.5]
        # new_r.image_coord_px = [col_str + 14.5, row_str + 14.5]
Пример #8
0
from __future__ import division
from scitbx.array_family import flex
from dials.scratch.luiso_s import model_2d

nrow = 35
ncol = 35
ref_ang = 5
local_i = 170

data2d = model_2d(nrow, ncol, 6, 3, ref_ang, local_i, 0.5)

ext_siz = 2
mask2d = flex.int(flex.grid(nrow, ncol))
for x_loc in range(ncol):
  for y_loc in range(nrow):
    if( data2d[y_loc, x_loc] > 10):
      mask2d[y_loc, x_loc] = 5
    else:
      mask2d[y_loc, x_loc] = 3

ext_siz = 1
tmp_mask = mask2d[:,:]
mask2d = mask2d.as_numpy_array()
for x_loc in range(ncol):
  for y_loc in range(nrow):
    if( tmp_mask[y_loc, x_loc] == 5):
      mask2d[y_loc - ext_siz:y_loc + ext_siz \
      , x_loc - ext_siz : x_loc + ext_siz] = 5

mask2d = flex.int(mask2d)
print "adding noise ...."
Пример #9
0
sumation = flex.double(flex.grid(21, 21))
descr = flex.double(flex.grid(1, 3))
descr[0, 0] = 0.5
descr[0, 1] = 5
descr[0, 2] = 5
print("____________________________________________________________________")

for xpos in range(3):
    for ypos in range(3):
        row_str = ypos * 12
        col_str = xpos * 20
        ref_ang = float((ypos + 1) / 10)
        # flex_int model_2d(int nrow, int ncol, float a, float b,
        # float delta_ang, float imax, float asp)
        ref2d = model_2d(nrow, ncol, 2, 1, ref_ang, 55, 0.5)
        data2d_tmp = ref2d.as_numpy_array()
        data2d[row_str:row_str + nrow,
               col_str:col_str + ncol] += numpy.float64(data2d_tmp)

        sumation = add_2d(descr, flex.double(numpy.float64(data2d_tmp)),
                          sumation)
        write_2d(sumation)

print("Plotting data2d")
plt.imshow(data2d, interpolation="nearest")
plt.show()

print("Plotting reslt")
img_suma = sumation.as_numpy_array()
plt.imshow(img_suma, interpolation="nearest")
Пример #10
0
from __future__ import print_function
from dials.algorithms.integration import add_2d
from scitbx.array_family import flex
from dials.scratch.luiso_s import model_2d

nrow = ncol = 25

ref2d_01 = model_2d(nrow, ncol, 3, 6, 0.2, 85, 0.5)
ref2d_02 = model_2d(nrow + 1, ncol + 1, 3, 6, 0.8, 85, 0.5)
descr = flex.double(flex.grid(1, 3))
descr[0, 0] = 12.5
descr[0, 1] = 12.5
descr[0, 2] = 2.5
# tmp_ref01 = ref2d_01[:,:]
# tmp_ref02 = ref2d_02[:,:]
print(id(ref2d_01))
print(id(ref2d_02))
print()
sumation = add_2d(descr, ref2d_01, ref2d_02)
# sumation = add_2d(descr, tmp_ref01, tmp_ref02)
print()
print(id(ref2d_01))
print(id(ref2d_02))
print(id(sumation))

from matplotlib import pyplot as plt

plt.imshow(ref2d_01.as_numpy_array(), interpolation="nearest")
plt.show()
plt.imshow(ref2d_02.as_numpy_array(), interpolation="nearest")
plt.show()
Пример #11
0
import numpy

data2d = numpy.zeros((550, 950), dtype = numpy.float64)
nrow = 60
ncol = 60



for xpos in range(10):
  for ypos in range(10):
    row_str = ypos * 50
    col_str = xpos * 90
    ref_ang = float(ypos / 10)
    '''flex_int model_2d(int nrow, int ncol, float a, float b,
    float delta_ang, float imax, float asp)'''
    ref2d = model_2d(nrow, ncol, 3, 2, ref_ang, 955, 0.5)
    data2d_tmp = ref2d.as_numpy_array()
    data2d[row_str:row_str + 60, col_str:col_str + 60] += numpy.float64(data2d_tmp)


ref2d = model_2d(550, 950, 280, 140, 1.0, 955, 0.5)
data2d_tmp = ref2d.as_numpy_array()
data2d[:, :] += numpy.float64(data2d_tmp)


#n = write_2d(flex.double(data2d))


from matplotlib import pyplot as plt
print "Plotting data2d"
plt.imshow(data2d, interpolation = "nearest")
Пример #12
0
from dials.algorithms.integration import add_2d
from scitbx.array_family import flex
from dials.scratch.luiso_s import model_2d

nrow = ncol = 25

ref2d_01 = model_2d(nrow, ncol, 3, 6, 0.2, 85, 0.5)
ref2d_02 = model_2d(nrow+1, ncol+1, 3, 6, 0.8, 85, 0.5)
descr = flex.double(flex.grid(1, 3))
descr[0, 0] = 12.5
descr[0, 1] = 12.5
descr[0, 2] = 2.5
#tmp_ref01 = ref2d_01[:,:]
#tmp_ref02 = ref2d_02[:,:]
print id(ref2d_01)
print id(ref2d_02)
print
sumation = add_2d(descr, ref2d_01, ref2d_02)
#sumation = add_2d(descr, tmp_ref01, tmp_ref02)
print
print id(ref2d_01)
print id(ref2d_02)
print id(sumation)


from matplotlib import pyplot as plt

plt.imshow(ref2d_01.as_numpy_array(), interpolation = "nearest")
plt.show()
plt.imshow(ref2d_02.as_numpy_array(), interpolation = "nearest")
plt.show()
Пример #13
0
nrow = 60
ncol = 60

for xpos in range(45):
    for ypos in range(25):
        row_str = ypos * 20
        col_str = xpos * 20
        ref_ang = float(ypos / 10)
        local_i = (68 - xpos - ypos) * 5
        """
    print "xpos =", xpos
    print "ypos =", ypos
    print "local_i =", local_i
    print "____________________________"
    """
        ref2d = model_2d(nrow, ncol, 3, 2, ref_ang, local_i, 0.5)
        data2d_tmp = ref2d.as_numpy_array()
        np_data2d[row_str:row_str + 60,
                  col_str:col_str + 60] += numpy.float64(data2d_tmp)

big_ref2d = model_2d(550, 950, 280, 140, 1.0, 955, 0.5)
data2d_tmp = big_ref2d.as_numpy_array()
np_data2d[:, :] += numpy.float64(data2d_tmp)

# tmp='''
print("adding noise ....")
import random

for x_loc in range(950):
    for y_loc in range(550):
        roll_the_dice = random.randint(1, 50)