tools

User interface and plotting tools for use in Jupyter notebooks

Source code

General Attributes and Methods

class gravity_toolkit.tools.widgets(**kwargs)[source]
select_directory(**kwargs)[source]

Widgets for setting directory and updating local data repository

Attributes:
directory_label: obj

Text widget for setting working data directory

directory_button: obj

Button widget for setting working data directory with Tkinter file dialog

update: obj

Checkbox widget for updating GRACE/GRACE-FO data in directory

set_directory(b)[source]

function for directory selection

select_product()[source]

Widgets for setting specific data product and months

center: obj

Dropdown menu widget for setting processing center

release: obj

Dropdown menu widget for setting GRACE/GRACE-FO data release

product: obj

Dropdown menu widget for setting GRACE/GRACE-FO data product

months: obj

Selection widget for setting GRACE/GRACE-FO months

set_release(sender)[source]

function for updating available releases

set_product(sender)[source]

function for updating available products

update_months(sender)[source]

function for updating available months

select_options(**kwargs)[source]

Widgets for setting data truncation and harmonic replacements

lmax: obj

Text entry widget for setting spherical harmonic degree

mmax: obj

Text entry widget for setting spherical harmonic order

geocenter: obj

Dropdown menu widget for setting geocenter data product

C20: obj

Dropdown menu widget for setting C20 data product

CS21: obj

Dropdown menu widget for setting C21 and S21 data product

CS22: obj

Dropdown menu widget for setting C22 and S22 data product

C30: obj

Dropdown menu widget for setting C30 data product

C50: obj

Dropdown menu widget for setting C50 data product

pole_tide: obj

Checkbox widget for correcting for Pole Tide Drift [74]

atm: obj

Checkbox widget for correcting ECMWF Atmospheric Jumps [18]

set_max_degree(sender)[source]

function for setting max degree of a product

set_max_order(sender)[source]

function for setting default max order

set_pole_tide(sender)[source]

function for setting default pole tide correction for a release

set_atm_corr(sender)[source]

function for setting default ATM correction for a release

select_corrections(**kwargs)[source]

Widgets for setting data corrections and processing

Attributes:
GIA_label: obj

Text entry widget for setting GIA correction file

GIA_button: obj

Button widget for setting GIA correction file with Tkinter file dialog

GIA: obj

Dropdown menu for setting GIA model file type

remove_label: obj

Text entry widget for setting spherical harmonic files to be removed

remove_button: obj

Button widget for setting remove files with Tkinter file dialog

remove_format: obj

Dropdown menu for setting remove file type

redistribute_removed: obj

Checkbox widget for redestributing removed file mass over the ocean

mask_label: obj

Text entry widget for setting land-sea mask file for ocean redistribution

mask_button: obj

Button widget for setting land-sea mask files with Tkinter file dialog

gaussian: obj

Text entry widget for setting Gaussian Smoothing Radius in kilometers

destripe: obj

Checkbox widget for destriping spherical harmonics [64]

spacing: obj

Text entry widget for setting output spatial degree spacing

interval: obj

Dropdown menu widget for setting output degree interval

units: obj

Dropdown menu widget for setting output units

select_GIA_file(b)[source]

function for GIA file selection

select_remove_file(b)[source]

function for removed file selection

set_removefile(sender)[source]

function for updating removed file list

set_removelabel()[source]

function for updating removed file label

select_mask_file(b)[source]

function for mask file selection

select_output(**kwargs)[source]

Widget for setting output data file format

Attributes:
output_format: obj

Dropdown menu widget for setting output file format

property base_directory

Returns the data directory

property GIA_model

Returns the GIA model file

property landmask

Returns the land-sea mask file

property unit_index

Returns the index for output spatial units

property format

Returns the output format string

class gravity_toolkit.tools.colormap(**kwargs)[source]

Widgets for setting matplotlib colormaps for visualization

Attributes:
range: obj

Slider widget for setting output colormap normalization

step: obj

Slider widget for setting output colormap discretization

name

Dropdown widget for setting output colormap

reverse

Checkbox widget for reversing the output colormap

property value

return string for Matplotlib colormaps

property norm

return normalization for Matplotlib

property levels

return tick steps for Matplotlib colorbars

property label

return tick labels for Matplotlib colorbars

gravity_toolkit.tools.from_cpt(filename, use_extremes=True, **kwargs)[source]

Reads GMT color palette table files and registers the colormap to be recognizable by plt.cm.get_cmap()

Can import HSV (hue-saturation-value) or RGB values

Parameters:
filename: str

color palette table file

use_extremes: bool, default True

use the under, over and bad values from the cpt file

**kwargs: dict

optional arguments for LinearSegmentedColormap

gravity_toolkit.tools.custom_colormap(N, map_name, **kwargs)[source]

Calculates a custom colormap and registers it to be recognizable by plt.cm.get_cmap()

Parameters:
N: int

number of slices in initial HSV color map

map_name: str

name of color map

  • 'Joughin': [34] standard velocity colormap

  • 'Rignot': [52] standard velocity colormap

  • 'Seroussi': [56] velocity divergence colormap

**kwargs: dict

optional arguments for LinearSegmentedColormap

gravity_toolkit.tools.shift_grid(lon0, data, lon, CYCLIC=360.0)[source]

Shift global grid east or west to a new base longitude

Parallels the mpl_toolkits.basemap.shiftgrid function

Parameters:
lon0: np.ndarray

Starting longitude for shifted grid lon0 (_type_): _description_

data: np.ndarray

data grid to be shifted

lon: np.ndarray

longitude array to be shifted

CYCLIC: float, default 360.0

width of periodic domain

Returns:
shift_data: np.ndarray

shifted data grid

shift_lon: np.ndarray

shifted longitude array

gravity_toolkit.tools.interp_grid(data, xin, yin, xout, yout, order=0)[source]

Interpolate gridded data to a new grid

Parallels the mpl_toolkits.basemap.interp function

Parameters:
datain: np.ndarray

input data grid to be interpolated

xin: np.ndarray

input x-coordinate array (monotonically increasing)

yin: np.ndarray

input y-coordinate array (monotonically increasing)

xout: np.ndarray

output x-coordinate array

yout: np.ndarray

output y-coordinate array

order: int, default 0

interpolation order

  • 0: nearest-neighbor interpolation

  • k: bivariate spline interpolation of degree k

Returns:
interp_data: np.ndarray

interpolated data grid

gravity_toolkit.tools.mask_oceans(xin, yin, data=None, order=0, lakes=False, iceshelves=True, resolution='qd')[source]

Mask a data grid over global ocean and water points

Parallels the mpl_toolkits.basemap.maskoceans function

Parameters:
xin: np.ndarray

input x-coordinate array (monotonically increasing)

yin: np.ndarray

input y-coordinate array (monotonically increasing)

data: np.ndarray or NoneType

input data grid to be masked

order: int, default 0

interpolation order

  • 0: nearest-neighbor interpolation

  • k: bivariate spline interpolation of degree k

lakes: bool, default False

Mask inland water points

iceshelves: bool, default True

Mask Greenland and Antarctic ice shelves

resolution: str, default ‘qd’

Resolution of the land-sea mask

  • '1d': 1-degree spacing

  • 'hd': 0.5-degree spacing

  • 'qd': 0.25-degree spacing

Returns:
mask: np.ndarray

mask grid

datain: np.ndarray

masked data grid