Skip to content

moments (std_x, std_y) instead of FWHM #5

@samoylv

Description

@samoylv

(1) вдогонку - в данном конкретном случае это на результате не должно сказаться, но на будущее лучше проводить сечения для вычисления полуширины через абсолютный максимум - после прохождения через оптику центр пятна может смещаться вообще говоря и быть асимметричным

(2) for possible 'noisy' results, it is more robust to calculate peak intensity and width_x, width_y as it is done in code below and then multiply the results by dx, dy. For Gaussian xFWHM/2.35~=width_x*dx

  11    def moments(data):
  12     """Returns (height, x, y, width_x, width_y)
  13     the gaussian parameters of a 2D distribution by calculating its
  14     moments """
  15     total = data.sum()
  16     X, Y = indices(data.shape)
  17     x = (X*data).sum()/total
  18     y = (Y*data).sum()/total
  19     col = data[:, int(y)]
  20     width_x = sqrt(abs((arange(col.size)-y)**2*col).sum()/col.sum())
  21     row = data[int(x), :]
  22     width_y = sqrt(abs((arange(row.size)-x)**2*row).sum()/row.sum())
  23     height = data.max()
  24     return height, x, y, width_x, width_y

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions