示例#1
0
def example2():
    # generate random spherical harmonics coefficients with a given
    # power spectrum and plot its bandspectrum
    degrees = np.arange(201)
    scale = 10
    power = 1. / (1. + (degrees / scale)**2)**2

    coeffs = SHCoeffs.from_random(power)
    coeffs.plot_powerperband(show=False, fname='power.png')

    # expand coefficients into two different spatial grids and plot it
    grid1 = coeffs.expand(kind='GLQ')
    grid1.plot_rawdata(show=False, fname='GLQGrid.png')

    grid2 = coeffs.expand(kind='DH1')
    grid2.plot_rawdata(show=False, fname='DHGrid.png')
示例#2
0
def example2():
    # generate random spherical harmonics coefficients with a given
    # power spectrum and plot its bandspectrum
    degrees = np.arange(201)
    scale = 10
    power = 1. / (1. + (degrees / scale)**2)**2

    coeffs = SHCoeffs.from_random(power)
    coeffs.plot_powerperband(show=False, fname='power.png')

    # expand coefficients into two different spatial grids and plot it
    grid1 = coeffs.expand(kind='GLQ')
    grid1.plot_rawdata(show=False, fname='GLQGrid.png')

    grid2 = coeffs.expand(kind='DH1')
    grid2.plot_rawdata(show=False,fname='DHGrid.png')
示例#3
0
def example1():
    # generate random spherical harmonics coefficients with a given
    # power spectrum and plot its bandspectrum
    degrees = np.arange(201)
    scale = 10
    power = 1. / (1. + (degrees / scale)**2)**2

    coeffs = SHCoeffs.from_random(power)
    coeffs.plot_powerperband(show=False, fname='power.png')

    # expand coefficients into a spatial grid and plot it
    grid1 = coeffs.expand(kind='DH1')
    grid1.plot_rawdata(show=False, fname='DHGrid_unrotated.png')

    # rotate coefficients, expand to grid and plot again
    coeffs.rotate(40., 0., 0., degrees=True)
    grid2 = coeffs.expand(kind='DH1')
    grid2.plot_rawdata(show=False, fname='DHGrid_rotated.png')
示例#4
0
def example1():
    # generate random spherical harmonics coefficients with a given
    # power spectrum and plot its bandspectrum
    degrees = np.arange(201)
    scale = 10
    power = 1. / (1. + (degrees / scale)**2)**2

    coeffs = SHCoeffs.from_random(power)
    coeffs.plot_powerperband(show=False, fname='power.png')

    # expand coefficients into a spatial grid and plot it
    grid1 = coeffs.expand(kind='DH1')
    grid1.plot_rawdata(show=False, fname='DHGrid_unrotated.png')

    # rotate coefficients, expand to grid and plot again
    coeffs.rotate(40., 0., 0., degrees=True)
    grid2 = coeffs.expand(kind='DH1')
    grid2.plot_rawdata(show=False, fname='DHGrid_rotated.png')
示例#5
0
def spectral_domain(shcs, nodes, research_boundary, r, mode=None, ratio=None):
    '''
    Spectrum domain method used to perform signal leakage correction in GRACE data processing.
    
    Usage:
    Ms,Ms_std = spetral_domain(SHCs,nodes,research_boundary,r)
    Ms,Ms_std = spetral_domain(SHCs,nodes,research_boundary,r,'window',ratio)

    Inputs:
    shcs -> [float 4d array] spherical harmonic coefficients before signal leakage correction
    nodes -> [object] grid nodes that represent mascons in the study area. The nodes are described as a set of discerte grid points [[lat0,lon0],..,[latn,lonn]].
    research_boundary -> [float 2d array] Study area surrounded by a polygon, which is defined as a series of points [[lat0,lon0],..,[latn,lonn]].
    r -> [float] Gaussian filter radius

    Parameters:
    mode -> [optional, str, default = None] If None, the global spherical harmonic coefficients are used to fit mascons. If 'window', the windowed spherical harmonic coefficients are used to fit mascons.
    ratio -> [optional, str, default = None] The ratio of the study area to the global area, which is mainly used to determine the Shannon number approximately. If None, the mode must be set to None. 

    Outputs:
    Ms -> [float 2d array] series of mascons or rate of mascons. The first dimension is time and the second dimension is the value of mascon. 
    If the size of the first dimension is 1, it means rate of mascon.
    Ms_std -> [float 2d array] standard deviation for series of mascons or rate of mascons. 
    '''
    lmax = shcs.shape[-1] - 1
    nlat = (lmax + 1) * 2
    psf_shcs_gau, mas = [], []

    for node in nodes.nodes:

        psf_grid_class = SHGrid.from_cap(0.1, node[0], node[1], lmax)
        psf_grid = psf_grid_class.data

        psf_shc = SHExpandDH(psf_grid, sampling=2)
        psf_shc_gau = filter_gaussian(r, psf_shc)

        psf_shcs_gau.append(SHCilmToVector(psf_shc_gau))
    psf_shcs_gau = np.array(psf_shcs_gau)

    A = psf_shcs_gau.T

    if mode is None:
        for shc in shcs:
            y = SHCilmToVector(shc)
            lamb, ma = L_curve(A, y)
            mas.append(ma)
    else:
        mask_boundary = Curve2Mask(nlat, research_boundary, 0, sampling=2)

        # estimate the Shannon number
        N = np.ceil((lmax + 1)**2 * ratio)  # Rough Shannon number
        slepian = Slepian.from_mask(mask_boundary, lmax, N)
        slepian_tapers = slepian.tapers
        N = np.ceil(slepian.shannon)  # Accurate Shannon Number

        for shc in shcs:
            shc_class = SHCoeffs.from_array(shc)
            slepian_coeffs = slepian.expand(shc_class, N)
            shc_slepian = SlepianCoeffsToSH(slepian_coeffs.falpha,
                                            slepian_tapers, N)

            y = SHCilmToVector(shc_slepian)
            lamb, ma = L_curve(A, y)
            mas.append(ma)
    mas = np.array(mas)

    return mas, np.zeros_like(mas)