processing_components/image/operations.py
def remove_continuum_image(im: Image, degree=1, mask=None):
    """ Fit and remove continuum visibility in place
    
    Fit a polynomial in frequency of the specified degree where mask is True

    :param im:
    :param degree: 1 is a constant, 2 is a slope, etc.
    :param mask:
    :return:
    """
    assert isinstance(im, Image)
    
    if mask is not None:
        assert numpy.sum(mask) > 2 * degree, "Insufficient channels for fit"
    
    nchan, npol, ny, nx = im.shape
    channels = numpy.arange(nchan)
    frequency = im.wcs.sub(['spectral']).wcs_pix2world(channels, 0)[0]
    frequency -= frequency[nchan // 2]
    frequency /= numpy.max(frequency)
    wt = numpy.ones_like(frequency)
    if mask is not None:
        wt[mask] = 0.0
    
    for pol in range(npol):
        for y in range(ny):
            for x in range(nx):
                fit = numpy.polyfit(frequency, im.data[:, pol, y, x], w=wt, deg=degree)
                prediction = numpy.polyval(fit, frequency)
                im.data[:, pol, y, x] -= prediction
    return im
 Fit and remove continuum visibility in place
    
    Fit a polynomial in frequency of the specified degree where mask is True

    :param im:
    :param degree: 1 is a constant, 2 is a slope, etc.
    :param mask:
    :return:
    
Fit and remove continuum visibility in place
Fit a polynomial in frequency of the specified degree where mask is True
Fit and remove continuum visibility in place Fit a polynomial in frequency of the specified degree where mask is True
def remove_continuum_image(im: Image, degree=1, mask=None):
    assert isinstance(im, Image)
    if mask is not None:
        assert numpy.sum(mask) > 2 * degree, "Insufficient channels for fit"
    nchan, npol, ny, nx = im.shape
    channels = numpy.arange(nchan)
    frequency = im.wcs.sub(['spectral']).wcs_pix2world(channels, 0)[0]
    frequency -= frequency[nchan // 2]
    frequency /= numpy.max(frequency)
    wt = numpy.ones_like(frequency)
    if mask is not None:
        wt[mask] = 0.0
    for pol in range(npol):
        for y in range(ny):
            for x in range(nx):
                fit = numpy.polyfit(frequency, im.data[:, pol, y, x], w=wt, deg=degree)
                prediction = numpy.polyval(fit, frequency)
                im.data[:, pol, y, x] -= prediction
    return im
def remove_continuum_image ( im : Image , degree = 1 , mask = None ) : assert isinstance ( im , Image ) if mask is not None : assert numpy . sum ( mask ) > 2 * degree , "Insufficient channels for fit" nchan , npol , ny , nx = im . shape channels = numpy . arange ( nchan ) frequency = im . wcs . sub ( [ 'spectral' ] ) . wcs_pix2world ( channels , 0 ) [ 0 ] frequency -= frequency [ nchan // 2 ] frequency /= numpy . max ( frequency ) wt = numpy . ones_like ( frequency ) if mask is not None : wt [ mask ] = 0.0 for pol in range ( npol ) : for y in range ( ny ) : for x in range ( nx ) : fit = numpy . polyfit ( frequency , im . data [ : , pol , y , x ] , w = wt , deg = degree ) prediction = numpy . polyval ( fit , frequency ) im . data [ : , pol , y , x ] -= prediction return im
Fit and remove continuum visibility in place
Fit a polynomial in frequency of the specified degree where mask is True
Fit and remove continuum visibility in place Fit a polynomial in frequency of the specified degree where mask is True
""" Fit and remove continuum visibility in place
    
    Fit a polynomial in frequency of the specified degree where mask is True

    :param im:
    :param degree: 1 is a constant, 2 is a slope, etc.
    :param mask:
    :return:
    """
None
im
Image
None
degree
1 is a constant, 2 is a slope, etc.
1 is a constant 2 is a slope etc .
mask
None