# Path: imgProcessor/equations/numbaGaussian2d.py
# @njit
# def numbaGaussian2d(psf, sy, sx):
#     '''
#     2d Gaussian to be used in numba code
#     '''
#     ps0, ps1 = psf.shape
#     c0,c1 = ps0//2, ps1//2
#     ssx = 2*sx**2
#     ssy = 2*sy**2
#     for i in range(ps0):
#         for j in range(ps1):
#             psf[i,j]=exp( -( (i-c0)**2/ssy
#                             +(j-c1)**2/ssx) )
#     psf/=psf.sum()


import numpy as np
    import sys
    import imgProcessor
from numpy import isnan
from numba import njit
from imgProcessor.equations.numbaGaussian2d import numbaGaussian2d
    from skimage.morphology import square
    from skimage.filters import rank
    from skimage.transform._warps import rescale
    from imgProcessor.imgIO import imread
    from fancytools.os.PathStr import PathStr
    from pylab import plt

    cx, cy = ax // 2, ax // 2

    numbaGaussian2d(psf, sx, sy)
    s0, s1 = image.shape[:2]
    # for all px ignoring border for now
    for i in range(ksize, s0 - ksize):
        for j in range(ksize, s1 - ksize):
            c_px = image[i, j]
            if not isnan(c_px):
                sdev = 0.0
                for ii in range(ax):
                    for jj in range(ay):
                        n_px = image[i - ii + cx, j - jj + cy]
                        sdev += psf[ii, jj] * (n_px - c_px)**2

                sint[i, j] = (sdev)**0.5


@njit
def _calc_variPSF(image, sint, sx, sy, psf, ksize):
    ax = psf.shape[0]
    ay = psf.shape[1]
    cx, cy = ax // 2, ax // 2

    # for all px ignoring border for now
    for i in range(ksize, image.shape[0] - ksize):
        for j in range(ksize, image.shape[1] - ksize):
            c_px = image[i, j]
            if not isnan(c_px):


# Path: imgProcessor/equations/numbaGaussian2d.py
# @njit
# def numbaGaussian2d(psf, sy, sx):
#     '''
#     2d Gaussian to be used in numba code
#     '''
#     ps0, ps1 = psf.shape
#     c0,c1 = ps0//2, ps1//2
#     ssx = 2*sx**2
#     ssy = 2*sy**2
#     for i in range(ps0):
#         for j in range(ps1):
#             psf[i,j]=exp( -( (i-c0)**2/ssy
#                             +(j-c1)**2/ssx) )
#     psf/=psf.sum()


# Path: imgProcessor/uncertainty/positionToIntensityUncertainty.py
import numpy as np
    import sys
    import imgProcessor
from numpy import isnan
from numba import njit
from imgProcessor.equations.numbaGaussian2d import numbaGaussian2d
    from skimage.morphology import square
    from skimage.filters import rank
    from skimage.transform._warps import rescale
    from imgProcessor.imgIO import imread
    from fancytools.os.PathStr import PathStr
    from pylab import plt

    cx, cy = ax // 2, ax // 2

    numbaGaussian2d(psf, sx, sy)
    s0, s1 = image.shape[:2]
    # for all px ignoring border for now
    for i in range(ksize, s0 - ksize):
        for j in range(ksize, s1 - ksize):
            c_px = image[i, j]
            if not isnan(c_px):
                sdev = 0.0
                for ii in range(ax):
                    for jj in range(ay):
                        n_px = image[i - ii + cx, j - jj + cy]
                        sdev += psf[ii, jj] * (n_px - c_px)**2

                sint[i, j] = (sdev)**0.5


@njit
def _calc_variPSF(image, sint, sx, sy, psf, ksize):
    ax = psf.shape[0]
    ay = psf.shape[1]
    cx, cy = ax // 2, ax // 2

    # for all px ignoring border for now
    for i in range(ksize, image.shape[0] - ksize):
        for j in range(ksize, image.shape[1] - ksize):
            c_px = image[i, j]
            if not isnan(c_px):


                numbaGaussian2d(psf, sx[i, j], sy[i, j])
