def gaus_pixval(g, pix):
    """ Calculates the value at a pixel pix due to a gaussian object g. """
    from .const import fwsig, pi
    from math import sin, cos, exp
    cen = g.centre_pix
    peak = g.peak_flux
    bmaj_p, bmin_p, bpa_p = g.size_pix
    a4 = bmaj_p / fwsig
    a5 = bmin_p / fwsig
    a6 = (bpa_p + 90.0) * pi / 180.0
    spa = sin(a6)
    cpa = cos(a6)
    dr1 = ((pix[0] - cen[0]) * cpa + (pix[1] - cen[1]) * spa) / a4
    dr2 = ((pix[1] - cen[1]) * cpa - (pix[0] - cen[0]) * spa) / a5
    pixval = peak * exp(-0.5 * (dr1 * dr1 + dr2 * dr2))
    return pixval
