Introduction

Launched in March 2002, the Gravity Recovery and Climate Experiment (GRACE) satellite mission has provided direct observations of the global gravity field and its temporal variations with an unprecedented accuracy (Tapley et al. 2004). As a joint satellite mission between the National Aeronautics and Space Administration (NASA) and the German Aerospace Center (DLR), GRACE has proven to be an invaluable tool for monitoring the mass transport and redistribution in the Earth’s fluid envelopes with a footprint of ~300 km. To measure the Earth’s gravity field from space, two GRACE satellites fly at an altitude of ~450 km in the same near-polar orbit with one 220 km ahead of the other. Any mass variation at the Earth’s surface, in principle, causes the change of distance between two GRACE satellites, which is detected at micrometer precision. Thus, by observing the distance between two satellites by the K-band ranging (KBR) instrument and orbit perturbations by GPS tracking, GRACE satellites can “sense” the gravity field and its variations in a direct way. The GRACE observations are processed and released by the Center for Space Research (CSR) at the University of Texas at Austin, the Geo-Forschungs-Zentrum (GFZ) at Potsdam, the Jet Propulsion Laboratory (JPL), among others. The main products released by these data processing centers are level-2 GRACE solutions, i.e., geopotential fields in the form of spherical harmonic (SH) coefficients (Stokes coefficients), which can be used to interpret global gravity field changes and mass variations at the Earth’s surface.

Numerous studies have demonstrated that GRACE has enabled many achievements in Earth science, e.g., terrestrial water storage (TWS) variations and relevant droughts and floods in the Amazon River basin (Chen et al. 2009b, 2010a; Frappart et al. 2012), ice sheet mass balance in Antarctica and Greenland (Harig and Simons 2012; King et al. 2012; Schrama et al. 2014; Velicogna and Wahr 2006a; Velicogna and Wahr 2006b), mass balance in High Mountain Asia (Jacob et al. 2012; Matsuo and Heki 2010; Yi and Sun 2014), groundwater storage depletion (Famiglietti et al. 2011; Feng et al. 2013; Joodaki et al. 2014; Long et al. 2016; Rodell et al. 2009; Scanlon et al. 2012; Tiwari et al. 2009), mass-induced global and regional sea level variations (Boening et al. 2012; Cazenave et al. 2009; Chambers 2006; Feng et al. 2014; García et al. 2006; Kusche et al. 2016; Willis et al. 2008), and coseismic and post-seismic gravity change caused by the 2004 Sumatra-Andaman earthquake (Chen et al. 2007b; Han et al. 2006; Panet et al. 2007). Following the tremendous success of the GRACE mission and its unique contribution to geodesy, hydrology, oceanography and glaciology, the new U.S.-German GRACE Follow-On satellites are scheduled to launch in 2017, with the aim of ensuring the continuity of the GRACE data with a potentially higher accuracy using advanced laser ranging instruments (http://gracefo.jpl.nasa.gov).

However, because of the limited accuracy of the current GRACE payload and the orbit configuration of GRACE satellites, the signal-to-noise ratio of original GRACE level-2 products is relatively low. In addition, there are highly correlated errors in the gravity field coefficients, which result in north-south stripes in the spatial domain. The post-processing procedure to remove the correlated errors is called destriping. Swenson and Wahr (2006) first proposed a destriping method to reduce the correlation among the gravity field coefficients based on polynomial fitting. Thereafter, more destriping methods were proposed to interpret regional and global mass variations in various case studies (e.g., Chambers 2006; Chen et al. 2007b; Duan et al. 2009). After the destriping process, generally, a Gaussian filter is applied to further reduce high-degree noise in GRACE products (Jekeli 1981; Wahr et al. 1998). In addition to this two-step post-processing method (i.e., destriping+Gaussian filter), additional filters were devised to reduce the noise of GRACE solutions, e.g., the non-isotropic filter (Han et al. 2005), the statistical filter (Davis et al. 2008), the DDK filter (Kusche 2007), the wavelet filter (Schmidt et al. 2006), the wiener filter (Sasgen et al. 2007), and the fan filter (Zhang et al. 2009). However, the classic “destriping+Gaussian filter” method remains one of the most widely used methods for processing GRACE level-2 products.

As mentioned above, noise reduction should be applied before further interpretation of GRACE level-2 products. To facilitate the application of GRACE data, post-processed gridded level-3 products are also available on the official GRACE Tellus website (https://grace.jpl.nasa.gov/). In addition, there are on-line visualization and analysis tools on the market, e.g., the GRACE Plotter (http://www.thegraceplotter.com/) from the Centre National d’Etudes Spatiales (CNES, France), the visualization tool from GFZ (http://icgem.gfz-potsdam.de/ICGEM/ICGEM.html), and the GRACE data analysis website from the University of Colorado Boulder, USA (http://geoid.colorado.edu/grace/dataportal.html). However, for these gridded level-3 products and on-line tools, only the results with specific destriping methods and Gaussian filters are available. Therefore, users cannot assess the differences between various methods and select an optimal one for their case study. In addition, these gridded products cannot provide an unbiased time series of mass variations in a user-specified region, because the signal leakage effect in the region is variant on a case-by-case basis. Moreover, the uncertainties in GRACE products cannot be assessed and provided in most available analysis tools. To alleviate these inconveniences and provide more flexibility, an open-source GRACE Matlab Toolbox (GRAMAT) was developed in this study. Based on the GRAMAT, spatio-temporal mass variations can be estimated from GRACE level-2 data with user-friendly graphical user interfaces (GUIs). Users can also implement the leakage reduction process, assess the uncertainty of GRACE mass estimates, and tentatively modify source codes in GRAMAT to develop their own post-processing methods.

Design and implementation

Workflow of the GRAMAT

Figure 1 illustrates the workflow of the GRAMAT program. It contains two primary stages: the processing of original GRACE level-2 data to retrieve global or regional mass variations in the spatial and temporal domains, and the processing of hydrological model data to reduce the bias and leakage of the GRACE results.

Fig. 1
figure 1

Schematic workflow of the GRAMAT program. Bold abbreviations represent the formats of the data or output, i.e., in the spectral (SHC: spherical harmonic coefficients), spatial (Grids) or temporal (TS: time series) domains

The first step is processing the GRACE level-2 GSM data, which represent the mass variation signals on the land, as mass variations in the atmosphere and ocean are removed during the gravity inversion process. For oceanographic applications, atmosphere and ocean de-aliasing products (GRACE GAD products) must be added back to represent the mass variations in oceans. In addition, Matlab GUIs are presented to facilitate the use of functions in GRAMAT. For example, Fig. 2 shows the Matlab GUI to process GRACE GSM products. In this GUI, the users can select GSM products from different data processing centers, select the destriping methods, replace low-degree coefficients, eliminate the glacial isostatic adjustment (GIA) effect, select the output format of results, among other functions. Furthermore, mass variations in the spatial and temporal domains can be retrieved. As shown in Fig. 1, in addition to the processing of GRACE original level-2 data, bias and leakage during the GRACE data processing can be further estimated. In GRAMAT, hydrological models can be used to estimate the signal leakage and attenuation due to destriping and smoothing. The rescaling process can be accomplished to recover actual mass variations. In addition, the harmonic analysis of mass variation time series can be performed. Additionally, the uncertainty of the mass variation estimates can be estimated based on the functions in GRAMAT.

Fig. 2
figure 2

A Matlab GUI in GRAMAT to process GRACE level-2 GSM data

GRAMAT functions

The main Matlab functions in GRAMAT and their descriptions are summarized in Table 1. A detailed description of main functions is given as follows:

  1. (1)

    gmt_readgsm: This function can be used to read the GRACE level-2 GSM files. There are two formats of GSM files, both of which can be read by the function. One is the official GRACE format; the other one is defined by the International Centre for Global Earth Models (ICGEM), i.e., ICGEM format. Both of them contains the same GRACE GSM data but in different formats.

  2. (2)

    gmt_replace_degree_1: As the reference frame origin used by GRACE is the Earth’s center of mass, the degree one Stokes coefficients are zero in this frame. However, changes in the degree one terms need to be considered, when we interpret mass variations in the centre-of-figure frame. In this function, degree-1 terms estimated by Swenson et al. (2008) are used to substitute original GRACE degree one terms.

  3. (3)

    gmt_replace_C20: Because the original C20 (degree 2 order 0) coefficients have large uncertainties, the independent estimates from the Satellite Laser Ranging (SLR) are used to replace the original ones from GRACE solutions. In this function, the SLR-based C20 values from Cheng et al. (2013) are used.

  4. (4)

    gmt_destriping: This function provides several destriping methods to reduce correlated errors in GRACE SH coefficients. The details on destriping methods will be discussed later.

  5. (5)

    gmt_gaussian_filter: In this function, a Gaussian filter with user-defined radius can be applied to SH coefficients to suppress high-frequency noises in SH coefficients.

  6. (6)

    gmt_gc2mc: This function can be used to convert SH coefficients of geoid from GRACE GSM products into SH coefficients of mass changes in equivalent water height.

  7. (7)

    gmt_gc2lc: This function can be used to convert SH coefficients of geoid from GRACE GSM products into SH coefficients of loading deformation.

  8. (8)

    gmt_cs2grid: In this function, SH coefficients in the spectral domain can be converted into gridded values in the spatial domain with a specified resolution, i.e., 0.25 degree, 0.5 degree, or 1 degree.

  9. (9)

    gmt_grid2cs: In this function, global gridded values can be transformed into SH coefficients with a specified maximum degree.

  10. (10)

    gmt_cs_error: This function can be used to calculate GRACE measurement errors in SH coefficients based on the method proposed by Wahr et al. (2006).

  11. (11)

    gmt_grid2map: This function visualizes the global spatial pattern of gridded values based on the m_map mapping tools.

  12. (12)

    gmt_grid2series: This function can be used to retrieve time series of mass changes in a specific region from grids. In addition to gridded values, the boundary file should be given as input data, which includes the total number of boundary points and their latitudes and longitudes.

  13. (13)

    gmt_harmonic: This function can be used to perform harmonic analysis of time series. The annual, semiannual cycles and the trend can be estimated based on the least square fitting in this function. After removing these estimated components, interannual variations of time series can be derived.

Table 1 Main Matlab functions in GRAMAT and their description

GRAMAT implementation

As a core part of GRAMAT, the GRACE level-2 GSM data processing can be executed by running the Matlab script file GRACE_Matlab_Toolbox_preprocessing_core.m with a control file as input and processed grid values or SH coefficients as output. In addition to creating a control file by users themselves, the Matlab GUI was developed to facilitate the use of functions on the GSM data processing as shown in Fig. 2. The GUI will also create the input control file for the script Matlab_Toolbox_preprocessing_core.m. The format of the control file was pre-defined and explained as follows.

As exemplified in Fig. 3, the first line of the control file contains the total number of GSM files. The second line represents the radius of Gaussian filtering. If “0” is given in this line, no Gaussian filtering will be applied to SH coefficients. The third line specifies the destriping method used, with the options of NONE, SWENSON, CHAMBERS2007, CHAMBERS2012, CHENP3M4, CHENP4M6, and DUAN. The explanation of these destriping methods will be given later. The forth line specifies whether the GIA effect will be removed or not with two predefined options, i.e., GIA_notRemoved and GIA_Removed_Geru. The fifth line specifies the format of GRACE data with two options, i.e., ICGEM and GRACE. The sixth line specifies the format and name of output data. The first parameter in this line represents the format of output data, which is in the form of SH coefficients (SH_MAT) or of gridded values (GRID_MAT) saved as Matlab MAT-files. The second parameter in the line represents the maximum degree of SH coefficients will be saved as output or used for creating gridded values, which should be less than the maximum degree of input GSM data. The third parameter specifies the name of output file. If the first parameter in this line is “GRID_MAT”, there will be the fourth parameter to define the spatial resolution of gridded values with options of 0.25, 0.5, and 1. The seventh line specifies the full pathname of the C20 file. If “NAN” is given in this line, original C20 values will not be replaced by the SLR-based ones. The eighth and ninth lines are set to be “NAN” generally, but can also be used to replace other degree-2 SH coefficients by the SLR-based ones with full pathnames. The tenth line specifies the full pathname of the degree-1 file. The eleventh and twelfth lines specify the directories of input GSM files and the output file, respectively. From the thirteenth line to the end of the control file give the names of input GSM files.

Fig. 3
figure 3

A sample of the control file used in GRAMAT

The output gridded data after running the script file GRACE_Matlab_Toolbox_preprocessing_core.m can be further used to retrieve time series of mass changes in a given region using the function gmt_grid2series and to illustrate the spatial pattern of mass changes globally using the function gmt_grid2map. Then, the function gmt_harmonic can be used to do the harmonic analysis of time series. The bias and leakage during the GRACE data processing can be estimated by using the functions gmt_grid2cs and gmt_cs2grid. The uncertainty of the mass variation estimates due to GRACE measurement errors can be estimated based on the function gmt_cs_error.

Destriping methods in the function gmt_destriping

As a core function in GRAMAT, gmt_destriping can be used to reduce correlated errors in the GRACE GSM data. The main destriping (i.e., decorrelation) methods used in the function are explained as follows. In the spatial domain, the original unconstrained monthly gravity field observed by GRACE shows north-south stripes, which represent the correlated errors in the gravity field coefficients. As an example, Fig. 4a illustrates the spatial pattern of mass variations in November 2003 from the original GRACE Stokes coefficients. Swenson and Wahr (2006) found that for a given order m, Stokes coefficients of the same parity are correlated with each other. They proposed a method to reduce the correlation by using a quadratic polynomial in a moving window of width w centered at degree l. For example, for Cl, m, they used the Stokes coefficients Cl − 2α, m,..., Cl − 2, m, Cl, m, Cl + 2, m,..., Cl + 2α, m to fit a quadratic polynomial, and removed the fitted value from the original Cl, m to derive the de-correlated Cl, m. The relation between the width w of the moving window (i.e., the number of coefficients used for the quadratic polynomial fitting) and α is w = 2α + 1. However, an algorithm to determine the width of moving window was not provided in the paper. Referring to the unpublished results of Swenson and Wahr (2006), Duan et al. (2009) provided the window width in the form of.

$$ w=\max \left(A{e}^{-\frac{m}{K}}+1,5\right) $$
(1)

where m is the order (≥5); max() takes the larger of two arguments. Swenson and Wahr (2006) empirically selected A = 30 and K = 10 based on a trial-and-error procedure.

Fig. 4
figure 4

a Spatial pattern of mass variations in November 2003 obtained from GRACE Stokes coefficients, with no destriping and Gaussian smoothing applied. b Identical to (a), but a 300 km Gaussian smoothing was applied. (c-f) Identical to (b), but destriping methods developed by Swenson and Wahr (2006), Chambers and Bonin (2012), Chen et al. (2007b), and Duan et al. (2009) were applied

To estimate ocean mass change using GRACE, Chambers (2006) modified the algorithm shown above. For the RL02 GRACE solutions, they kept the coefficients of degrees no more than 7 unchanged and fit a 7th-order polynomial to the remaining coefficients of degrees with the same parity for each order up to 50. In their method, only one polynomial is used for the odd/even set of a given order, unlike in the method developed by Swenson and Wahr (2006). For the RL04 GRACE solutions, Chambers (2006) kept the coefficients no more than 11 unchanged, and a 5th-order polynomial was applied. For the latest RL05 GRACE solutions, the optimal parameterization for ocean mass variation estimation based on the model test is to start filtering at degree 15, and use a 4th-order polynomial (Chambers and Bonin 2012). This processing method is designated as P4M15. In addition, Chen et al. (2007b) used the P3M6 method to process GRACE data and estimated the coseismic and post-seismic gravity changes caused by the Sumatra-Andaman earthquake. Later, they used the P4M6 method to estimate the mass balance of ice caps, mountain glaciers, and terrestrial water storage change (Chen et al. 2007a, 2008, 2009a, b, 2010a, b). By contrast, Duan et al. (2009) determined the unchanged portion of coefficients based on the error pattern of the coefficients. Their unchanged portion of coefficients and the width of the moving window depend on both degree and order in a more complex manner.

In summary, the parameterization of destriping methods for GRACE depends on the following criteria:

  1. (i)

    Determination of the unchanged portion of the coefficients: Swenson and Wahr (2006), Chambers (2006) and Chen et al. (2007b), respectively, kept the first 4, 14 and 5 degrees and orders unchanged, whereas Duan et al. (2009) determined the unchanged portion of the coefficients based on their error pattern, which depends on both degree and order.

  2. (ii)

    Selection of the degree of polynomial fitting: Swenson and Wahr (2006) and Duan et al. (2009) used a quadratic polynomial, whereas Chambers (2006) and Chen et al. (2007b) used a 7th- and a 3rd-order polynomial, respectively.

  3. (iii)

    Application of the polynomial fitting to the coefficients (moving window vs. fixed window): Swenson and Wahr (2006) used a moving window with the width depending on the degree, whereas Duan et al. (2009) determined the width of the moving window as a function of both degree and order. Chambers (2006) and Chen et al. (2007b) used a fixed window to fit the polynomial.

In the function gmt_destriping, the aforementioned methods can be applied by using the options of SWENSON, CHAMBERS2007, CHAMBERS2012, CHENP3M4, CHENP4M6, and DUAN. For example, Fig. 4(b-f) shows the global mass variations in November 2003 obtained from GRACE Stokes coefficients based on different destriping methods using gmt_destriping. As shown in Fig. 3(c-f), there is a general consistency among the results from different destriping methods, in which the north-south stripes are significantly reduced. In addition, the destriping process suppresses the north-south stripes more efficiently, compared with only the Gaussian smoothing.

In addition to global mass variations in the spatial domain, the corresponding Stokes coefficient values in the spectral domain are further illustrated in Fig. 5. The mean values of Stokes coefficients over 2002–2014 were removed. Thus, these residual coefficients represent the mass variations. The high variability of high-degree Stokes coefficients mainly represents noise in the original GRACE products (Fig. 5a). As shown in Fig. 5(b-e), further destriping process mentioned above significantly reduces noise in high-degree coefficients but retains the signals in low-degree coefficients.

Fig. 5
figure 5

a Stokes coefficients, converted to mass using Love numbers, from the GRACE products in November 2003. The mean values of Stokes coefficients over 2002–2014 have been removed. b-e Destriped Stokes coefficients based on the methods developed by Swenson and Wahr (2006), Chambers and Bonin (2012), Chen et al. (2007b), and Duan et al. (2009)

For example, we show the GRACE Stokes coefficients (Cnm) of the 25th order in November 2003. In Fig. 6a, Stokes coefficients of even or odd parity of the degrees for the same order show high correlations. These apparent correlations represent systematic errors in high-order coefficients (Swenson and Wahr 2006). In fact, Fig. 6a demonstrates these high correlations in even- or odd-degrees for a fixed order. With the destriping methods discussed above, these systematic errors are significantly reduced (e.g., Fig. 6b), and the results in the spatial domain are dramatically improved (Fig. 4(c-f)).

Fig. 6
figure 6

a Stokes coefficients (Cnm), converted to mass using Love numbers, plotted as a function of degree n for order m = 25 from GRACE products in November 2003. The mean values of Stokes coefficients over 2002–2014 have been removed. The dashed red line and blue line show the Stokes coefficients of even and odd degrees, respectively. b Destriped Stokes coefficients (Cnm) based on the methods developed by Swenson and Wahr (2006), Chambers and Bonin (2012), Chen et al. (2007b), and Duan et al. (2009)

Leakage and bias in GRACE level-2 data processing

GRACE solutions are expressed as the Stokes coefficients with a limited maximum degree lmax. Therefore, the spatial resolution of GRACE products is limited to ~2,000/lmax km in terms of half-wavelengths. Truncation of SH solutions in the spectral domain is equivalent to a low-pass filtering in the spatial domain. The actual mass variation signal in a given region may be dampened because of the limited SH expansion. In addition, the post-processing procedure (e.g., destriping and Gaussian smoothing) may make the average estimate in a given region biased. The signal in the target region may leak to the surrounding areas and cause amplitude damping in the region (leakage-out), and the signal from the surrounding areas may also leak into the target region (leakage-in).

As an example, the leakage-in and leakage-out effects are demonstrated in the spatial domain in the Amazon River basin using the simulated TWS variations based on the Global Land Data Assimilation System (GLDAS) model from the National Aeronautics and Space Administration (NASA) (Ek et al. 2003; Rodell et al. 2004). Fig. 7a shows the simulated TWS variations in March 2003 in the Amazon River basin and its surrounding regions from the GLDAS Noah model. The spatial resolution and signal magnitude decrease when the grid is transformed into SH coefficients and up to the degree/order (d/o) of 60 using the function gmt_grid2cs (Fig. 7b). To estimate the leakage-out effect in the spatial domain, we maintained the simulated TWS variations in the Amazon River basin from the model and set the values outside the basin to zero. Then, based on the gmt_grid2cs and gmt_cs2grid functions in GRAMAT, we performed the SH analysis and synthesis to obtain the leakage-out effect due to the finite SH expansion. As shown in Fig. 7c, the signal inside the basin leaked into the surrounding regions (leakage-out). Furthermore, we kept the grid values outside the basin but set the values in the basin to zero and performed the SH analysis and synthesis to recalculate the grid values in the basin. As illustrated in Fig. 7d, the leakage-in effects are more significant in the marginal regions of the basin than in its center because they are closer to the signals outside the basin. In addition to the leakage effect due to SH truncation shown in Fig. 7, leakage effects can be caused by the destriping and smoothing process. The leakage effects during GRACE data processing can also be estimated in GRAMAT. It should be noted that most model-simulated TWS variations generally do not include groundwater and surface water and have large uncertainties especially for long-term trends, which will induce errors in leakage estimation. However, hydrological models provide independent TWS estimates which can be used to calculate the leakage effects during GRACE data processing.

Fig. 7
figure 7

a TWS variations from the GLDAS Noah model in March 2003. b The grid in panel (a) is transformed to the spherical harmonic domain and up to d/o 60. c Leakage-out and d leakage-in effects because of the limited spherical harmonic expansion. The white lines show the boundaries of the Amazon River basin

Wahr et al. (1998) and Swenson and Wahr (2002) considered “leakage” to include both signal leaking out of the target region and signal leaking into the target region from the surrounding areas. However, Klees et al. (2007) and Longuevergne et al. (2010) called the leakage-out effect “bias” and the leakage-in effect “leakage”. In their naming convention, “leakage” only represents the contamination from outside of the target region. In this paper, if not specifically mentioned, we use the latter name convention.

Suppose function S describes the actual mass variations on the Earth’s surface, then the mean value of mass variations over the region of interest R is.

$$ {\overline{S}}_0=\frac{1}{R_0}{\int}_{\Omega}S\;h\;d\;\Omega $$
(2)

where R0 is the area of the region, h is the ideal basin function (1 inside the basin; 0 outside), and Ω represents the entire Earth surface.

The GRACE estimate of the mean value over the region of interest R is.

$$ \widehat{{\overline{S}}_0}=\frac{1}{R_0}{\int}_{\Omega}\widehat{\overline{S}}\kern0.37em h\;d\;\Omega $$
(3)

where \( \widehat{\overline{S}} \) is the filtered GRACE estimate of mass variation.

To recover the actual average mass variation signal \( {\overline{S}}_0 \) in a given region from the GRACE estimate \( \widehat{{\overline{S}}_0} \), there are two methods. In the first method, the actual average mass variation signal \( {\overline{S}}_0 \) in a given region is re-written as shown in Eq. (4) (Klees et al. 2007).

$$ {\overline{S}}_0=\widehat{{\overline{S}}_0}-{S}_{leakage}+{S}_{bias} $$
(4)

with.

$$ {S}_{leakage}=\frac{1}{R_0}{\int}_{\Omega -\mathrm{R}}{S}_{out}\ \widehat{h}\;d\;\Omega $$
(5)
$$ {S}_{bias}=\frac{1}{R_0}{\int}_{\mathrm{R}}{S}_{in}\ \left(h-\widehat{h}\right)d\kern0.24em \Omega $$
(6)

where Sin and Sout are the actual mass variations in the region of interest and outside it, respectively, and \( \widehat{h} \) is the averaging kernel applied to the GRACE data.

In this method, we must first remove the leakage Sleakage from the GRACE estimate \( \widehat{{\overline{S}}_0} \) and then add the bias Sbias back. To calculate the leakage and bias for a region, a priori information about mass variations both inside and outside the region of interest should be available, which commonly comes from hydrological models and ocean models. Note that the uncertainty of a priori information may cause the overestimation or underestimation of the leakage and bias.

For the other method, we provide the following equation:

$$ {\overline{S}}_0=k\left(\widehat{{\overline{S}}_0}-{S}_{leakage}\right) $$
(7)

where k is the scaling factor (or multiplicative factor), which is expressed as.

$$ k=\frac{\int_{\mathrm{R}}{S}_{in}\ hd\;\Omega}{\int_{\mathrm{R}}{S}_{in}\ \widehat{h}d\;\Omega} $$
(8)

If reliable mass variations over the study region are available, we can use this equation to estimate the scaling factor, but this availability is not guaranteed. Assuming a uniform mass variation in the region of interest, k is simplified to.

$$ k=\frac{R_0}{\int_{\mathrm{R}}\;\widehat{h}d\;\Omega} $$
(9)

Next, to estimate the scaling factor, we need to construct an ideal kernel for the region of interest (1 inside and 0 outside), and decompose it into a limited set of SH coefficients based on the function gmt_grid2cs, then apply the destriping and smoothing process to the corresponding set of SH coefficients based on the functions of gmt_destriping and gmt_gaussian_filter. After that, the SH coefficients need to be converted to gridded values in the spatial domain using gmt_cs2grid. Finally, the remaining signal in the region is derived based on the function gmt_grid2series. The reciprocal of the remaining signal is considered the scaling factor. For example, Fig. 8a shows the ideal kernel for the Amazon River basin (1 inside and 0 outside). After the SH expansion of the ideal kernel to d/o 60 and a 300 km Gaussian smoothing applied, the remaining mean signal in the basin is approximately 0.85 (Fig. 8b). Hence, to derive an unbiased estimate in the basin, a scaling factor of 1.18 should be applied to the averaging kernel. Figure 8c also shows the rescaled averaging kernel in the spatial domain.

Fig. 8
figure 8

a Ideal basin kernel for the Amazon River basin (i.e., ones in the basin and zeroes outside). b Averaging kernel derived by the SH expansion of the ideal kernel to d/o 60 with a 300 km Gaussian smoothing. c Rescaled averaging kernel derived by multiplying the averaging kernel in panel (b) with a scaling factor of 1.18

The scaling method has been extensively used to derive the unbiased mass variation time series for the region of interest. For example, to calibrate the GRACE estimate in the study of mass balance in Antarctica, Velicogna and Wahr (2006b) applied the averaging function to a uniform mass variation over the ice sheet, and the remaining signal in the region was 0.62. Thus, they applied the GRACE estimate with a scaling factor of 1/0.62 to recover the actual mass variation signal over the entire ice sheet. In the Caspian Sea, a scaling factor of 1/0.37 is multiplied with the GRACE original estimate to analyze the water storage variations (Swenson and Wahr 2007). A scaling factor of 1.95 is determined to recover the magnitude damping of GRACE-based groundwater storage variations in northern India (Rodell et al. 2009). For more details on leakage reduction and rescaling, we refer readers to the reviews by Longuevergne et al. (2010), Feng (2014), and Long et al. (2015).

Assessment of GRACE measurement error

In addition to estimating unbiased mass variation series in a target region, the GRAMAT can be used to assess the GRACE measurement error, which can be estimated by two methods generally. In the first method, the measurement error in a given region can be estimated as a root-mean-square (RMS) variability over the oceans at the same latitude as the study region on land (Chen et al. 2009b). If the ocean and atmosphere models perfectly simulate the mass change over the oceans, after the de-aliasing processing, no mass change is detected by GRACE. Therefore, the residuals over the ocean can approximately represent the GRACE measurement error. Note that the ocean variability and deficiencies in the de-aliasing products are included in estimates of the GRACE error. Thus, this approach may overestimate the GRACE measurement error. In contrast to the aforementioned uncertainty estimation in the spatial domain, Wahr et al. (2006) used the second method to determine the uncertainties in the GRACE SH coefficients as the standard deviation of the residuals of coefficients when seasonal cycles were removed. This method may also overestimate the GRACE measurement error because we assume that all non-seasonal variability of Stokes coefficients results from the measurement error. The function gmt_cs_error can be used to estimate the uncertainties in the GRACE SH coefficients; then, the function gmt_cs2grid can be used to further estimate the uncertainties in the spatial domain.

As an example, Fig. 9 shows the spatial patterns of GRACE measurement errors in November 2003 obtained from the original SH coefficients and filtered SH coefficients with a 300 km Gaussian smoothing based on the gmt_cs_error and gmt_cs2grid functions in GRAMAT. As shown in Fig. 9, the GRACE measurement errors depend on the latitude and show high uncertainties in the tropics and low uncertainties in the polar regions, which is consistent with the results of Wahr et al. (2006). Lower uncertainties in the polar regions are primarily due to more observations in these regions because of the near-polar orbit of GRACE satellites. In Fig. 9b, when a 300 km Gaussian smoothing is applied, the magnitude of the GRACE measurement error decreases significantly.

Fig. 9
figure 9

Spatial patterns of GRACE measurement errors in November 2003 (a) without Gaussian smoothing and (b) with a 300 km Gaussian smoothing

Note that the total uncertainty of GRACE estimates is the sum of different error components in quadrature, which includes not only the GRACE measurement error, but also the uncertainty of the leakage correction, and the uncertainty of the scaling factor (e.g., Longuevergne et al. 2010). The uncertainty of the leakage correction can be estimated as the standard deviation of leakage corrections from different hydrological models. The uncertainty of the scaling factor can also be assessed by comparing the scaling factor estimate based on the uniform assumption in the study region and those based on different mass distributions from hydrological models or simulations (e.g., Rodell et al. 2009). The gridded mass changes from hydrological models are the input data for GRAMAT, so the uncertainties in these models are not considered in the current version of GRAMAT.

GRAMAT application: A case study in the Amazon River basin

As a case study, we calculated the TWS variations in the Amazon River basin, the site of the world’s largest annual TWS variations (Fig. 10). We run the script file GRACE_Matlab_Toolbox_preprocessing_core.m with the control file as shown in Fig. 3. Monthly GRACE Release-05 level-2 GSM products from CSR were used to estimate the TWS variations. GRACE GSM products mainly represent the hydrological and geophysical signals on the land, because the mass variations in the atmosphere and ocean have been removed. To reduce the correlated north-south stripes and short-wavelength noise in the original GRACE GSM products, the Swenson destriping method and a 300 km Gauss smoothing filter were applied (Swenson and Wahr 2006; Wahr et al. 1998). In addition, first-degree terms and C20 terms of the SH coefficients were replaced by estimates from satellite laser ranging observations and ocean and atmosphere models (Cheng et al. 2011; Swenson et al. 2008). The GRACE data were further corrected for Glacial Isostatic Adjustment (GIA) on the basis of the model from A et al. (2013). The leakage effect was estimated from the average of four GLDAS models (Noah, VIC, Mosaic, and CLM) (Ek et al. 2003; Koster and Suarez 1992; Liang et al. 1994; Rodell et al. 2004) and removed from the GRACE TWS variation time series. After the leakage reduction process, the rescaled averaging kernel shown in Fig. 8c was applied to retrieve TWS variations in the Amazon River basin. The uncertainty of the GRACE-derived TWS variation estimates was computed as the square root of the sum of different error components’ squares. These error components contain the GRACE measurement error estimated based on the method proposed by Wahr et al. (2006) and the errors caused during the leakage reduction and rescaling (Longuevergne et al. 2010).

Fig. 10
figure 10

Annual amplitudes of GRACE-derived TWS based on Swenson destriping and a 300 km Gaussian filter. (a) and (b) show the results based on the GRAMAT and official gridded level-3 products, respectively. Panel (c) shows the differences between the results from GRAMAT and official products. Note that different color bar is used for the panel (c)

As shown in Fig. 10a, b, the global spatial pattern of TWS annual amplitudes is consistent with the result based on official GRACE level-3 gridded products, which confirms the effectivity of the GRAMAT. The differences between them are relatively small and in the similar magnitude as the nominal GRACE accuracy, i.e., ~2 cm at the spatial resolution of 300 km (Wahr et al. 2006). The GRACE-derived TWS shows significant seasonal variations in the Amazon River basin, with an annual amplitude of 21.5 ± 1.1 cm, and reaches a maximum in April (Fig. 11a). The largest annual variation occurs along the main stream of the river (Fig. 12a). In the spatial domain, the maximum annual phases of TWS variations change gradually from March in the southern Amazon to August in the northern Amazon (Fig. 12b). In addition, by comparing the original TWS time series and modeled linear and seasonal changes, we find significantly abnormal TWS increase in 2009 and TWS loss in 2010 (Fig. 11a). Based on the function gmt_harmonic, we removed seasonal cycles and the linear trend from the original time series and applied a three-month moving average to derive the interannual TWS variations in the Amazon River basin and compared them with precipitation anomalies from the Global Precipitation Climatology Centre (GPCC) monthly dataset (Schneider et al. 2014). Note that the GPCC precipitation data reading and processing are not included in GRAMAT. As shown in Fig. 11b, the precipitation anomalies correlated well with GRACE-derived interannual TWS variations. On interannual timescales, the positive precipitation anomalies coincide with the TWS increase; and vice versa. For example, the increase in precipitation in 2009 is consistent with the GRACE-derived TWS surplus. The severe drought event in 2010 with significant precipitation deficiency is also consistent with the TWS loss detected by GRACE. Furthermore, we calculated the spatial patterns of the TWS anomaly in April 2009 and September 2010 after removing the seasonal cycles based on the gmt_harmonic function in GRAMAT. As shown in Fig. 13, both the abnormal TWS increase and loss detected by GRACE occurred along the main stream of the Amazon River, which indicates the main contribution of surface water to the total TWS variations in the basin.

Fig. 11
figure 11

a Time series of the GRACE-derived TWS variations in the Amazon River basin (red dots). The error bars represent the uncertainties of TWS estimates (one-sigma standard deviations). The blue line represents the seasonal and long-term changes of TWS, which were computed based on the gmt_harmonic function of the GRAMAT. b Interannual TWS variations (red dotted line) and precipitation anomalies (blue bars) in the Amazon River basin. Seasonal cycles and the linear trend were removed, and a three-month moving average was applied. The precipitation anomalies were shifted by two months considering the delayed response of TWS to precipitation

Fig. 12
figure 12

Spatial patterns of the annual amplitudes (a) and phases (b) of TWS variations over the Amazon River basin

Fig. 13
figure 13

Spatial patterns of TWS anomalies in April 2009 (a) and September 2010 (b). The seasonal cycles have been removed based on the gmt_harmonic function in GRAMAT

Concluding remarks

In this paper, we present a GRACE Matlab Toolbox (GRAMAT) to process GRACE level-2 data and estimate spatio-temporal mass variations. This open-source package is likely to be useful for the Earth science community, especially for hydrologists, who are prone to ignore the non-negligible signal distortion and errors during the GRACE level-2 data processing and use GRACE level-3 gridded products directly. Note that the leakage and bias effects and the rescaling can be assessed in this toolbox, which will be very helpful for analyzing the uncertainties in GRACE when comparing GRACE results with other independent observations or model outputs. The GRAMAT provides widely used destriping methods to remove “north-to-south” stripes in the GRACE original Stokes coefficients and retrieve unbiased regional mass variation time series. In addition, harmonic analysis is provided in the package to estimate seasonal cycles, the long-term trend and interannual variations of time series. A case study on TWS variations in the Amazon River basin based on the GRACE data and the GRAMAT further indicate the potentially wide application of the toolbox developed in this study.