Beispiel #1
0
def generate_result_maps(data, sourcelist):
    """Return a source and residual image

    Given a data array (image) and list of sources, return two images, one
    showing the sources themselves and the other the residual after the
    sources have been removed from the input data.
    """
    residual_map = numpy.array(data) # array constructor copies by default
    gaussian_map = numpy.zeros(residual_map.shape)
    for src in sourcelist:
        # Include everything with 6 times the std deviation along the major
        # axis. Should be very very close to 100% of the flux.
        box_size = 6 * src.smaj.value / math.sqrt(2 * math.log(2))

        lower_bound_x = max(0, int(src.x.value - 1 - box_size))
        upper_bound_x = min(residual_map.shape[0], int(src.x.value - 1 + box_size))
        lower_bound_y = max(0, int(src.y.value - 1 - box_size))
        upper_bound_y = min(residual_map.shape[1], int(src.y.value - 1 + box_size))

        local_gaussian = gaussian(
            src.peak.value,
            src.x.value,
            src.y.value,
            src.smaj.value,
            src.smin.value,
            src.theta.value
        )(
            numpy.indices(residual_map.shape)[0,lower_bound_x:upper_bound_x,lower_bound_y:upper_bound_y],
            numpy.indices(residual_map.shape)[1,lower_bound_x:upper_bound_x,lower_bound_y:upper_bound_y]
        )

        gaussian_map[lower_bound_x:upper_bound_x, lower_bound_y:upper_bound_y] += local_gaussian
        residual_map[lower_bound_x:upper_bound_x, lower_bound_y:upper_bound_y] -= local_gaussian

    return gaussian_map, residual_map
Beispiel #2
0
 def setUp(self):
     Xin, Yin = numpy.indices((500, 500))
     self.height = 10
     self.x = 250
     self.y = 250
     self.maj = 40
     self.min = 40
     self.theta = 0
     self.mygauss = numpy.ma.array(gaussian(self.height, self.x, self.y, self.maj, self.min, self.theta)(Xin, Yin))
     self.moments = moments(self.mygauss, beam, 0)
     self.fit = fitgaussian(self.mygauss, self.moments)
Beispiel #3
0
 def setUp(self):
     Xin, Yin = numpy.indices((500, 500))
     self.peak = 10
     self.xbar = 250
     self.ybar = 250
     self.semimajor = 40
     self.semiminor = 20
     self.theta = 0
     self.mygauss = numpy.ma.array(
         gaussian(self.peak, self.xbar, self.ybar, self.semimajor,
                  self.semiminor, self.theta)(Xin, Yin))
     self.moments = moments(self.mygauss, beam, 0)
Beispiel #4
0
 def setUp(self):
     Xin, Yin = numpy.indices((500, 500))
     self.peak = 10
     self.xbar = 250
     self.ybar = 250
     self.semimajor = 40
     self.semiminor = 20
     self.theta = 0
     self.mygauss = numpy.ma.array(
         gaussian(self.peak, self.xbar, self.ybar,
                  self.semimajor, self.semiminor, self.theta)(Xin, Yin))
     self.moments = moments(self.mygauss, beam, 0)
Beispiel #5
0
 def setUp(self):
     Xin, Yin = numpy.indices((500, 500))
     self.height = 10
     self.x = 250
     self.y = 250
     self.maj = 40
     self.min = 40
     self.theta = 0
     self.mygauss = numpy.ma.array(
         gaussian(self.height, self.x, self.y, self.maj, self.min,
                  self.theta)(Xin, Yin))
     self.moments = moments(self.mygauss, beam, 0)
     self.fit = fitgaussian(self.mygauss, self.moments)
Beispiel #6
0
def generate_result_maps(data, sourcelist):
    """Return a source and residual image

    Given a data array (image) and list of sources, return two images, one
    showing the sources themselves and the other the residual after the
    sources have been removed from the input data.
    """
    residual_map = numpy.array(data)  # array constructor copies by default
    gaussian_map = numpy.zeros(residual_map.shape)
    for src in sourcelist:
        # Include everything with 6 times the std deviation along the major
        # axis. Should be very very close to 100% of the flux.
        box_size = 6 * src.smaj.value / math.sqrt(2 * math.log(2))

        lower_bound_x = max(0, int(src.x.value - 1 - box_size))
        upper_bound_x = min(residual_map.shape[0],
                            int(src.x.value - 1 + box_size))
        lower_bound_y = max(0, int(src.y.value - 1 - box_size))
        upper_bound_y = min(residual_map.shape[1],
                            int(src.y.value - 1 + box_size))

        local_gaussian = gaussian(
            src.peak.value, src.x.value, src.y.value, src.smaj.value,
            src.smin.value, src.theta.value)(
                numpy.indices(residual_map.shape)[0,
                                                  lower_bound_x:upper_bound_x,
                                                  lower_bound_y:upper_bound_y],
                numpy.indices(residual_map.shape)[1,
                                                  lower_bound_x:upper_bound_x,
                                                  lower_bound_y:upper_bound_y])

        gaussian_map[lower_bound_x:upper_bound_x,
                     lower_bound_y:upper_bound_y] += local_gaussian
        residual_map[lower_bound_x:upper_bound_x,
                     lower_bound_y:upper_bound_y] -= local_gaussian

    return gaussian_map, residual_map