gpm.accessor package

Contents

gpm.accessor package#

Submodules#

gpm.accessor.methods module#

This module defines GPM-API xarray accessors.

class gpm.accessor.methods.GPM_Base_Accessor(xarray_obj)[source][source]#

Bases: object

collocate(product, product_type='RS', version=None, scan_modes=None, variables=None, groups=None, verbose=True, decode_cf=True, chunks={})[source][source]#

Collocate a product on the provided dataset.

It assumes that along all the input dataset, there is an approximate collocated product.

crop(extent)[source][source]#
crop_around_point(lon, lat, distance=None, size=None)[source][source]#
crop_by_continent(name)[source][source]#
crop_by_country(name)[source][source]#
property end_time[source]#
extent(padding=0, size=None)[source][source]#
extract_at_points(points, method='nearest', new_dim='points')[source][source]#
extract_transect_around_point(point, azimuth, distance, steps=100, method='linear', new_dim='transect')[source][source]#
extract_transect_at_points(points, method='linear', new_dim='transect')[source][source]#
extract_transect_between_points(start_point, end_point, steps=100, method='linear', new_dim='transect')[source][source]#
get_crop_slices_around_point(lon, lat, distance=None, size=None)[source][source]#
get_crop_slices_by_continent(name)[source][source]#
get_crop_slices_by_country(name)[source][source]#
get_crop_slices_by_extent(extent)[source][source]#
get_height_at_bin(bins)[source][source]#
get_slices_contiguous_granules(min_size=2)[source][source]#

Return a list of slices ensuring contiguous granules.

The minimum size of the output slices is 2.

Note: for GRID (i.e. IMERG) products, it checks for regular timesteps ! Note: No granule_id is provided for GRID products.

Parameters:
Returns:

list_slices – List of slice object to select contiguous granules. Output format: [slice(start,stop), slice(start,stop),...]

Return type:

list

get_slices_contiguous_scans(min_size=2, min_n_scans=3, x='lon', y='lat', along_track_dim='along_track', cross_track_dim='cross_track')[source][source]#

Return a list of slices ensuring contiguous scans (and granules).

It checks for contiguous scans only in the middle of the cross-track ! If a scan geolocation is NaN, it will be considered non-contiguous.

An input with less than 3 scans (along-track) returns an empty list, since scan contiguity can’t be verified. Consecutive non-contiguous scans are discarded and not included in the outputs. The minimum size of the output slices is 2.

Parameters:
Returns:

list_slices – List of slice object to select contiguous scans. Output format: [slice(start,stop), slice(start,stop),...]

Return type:

list

get_slices_regular(min_size=None, min_n_scans=3, x='lon', y='lat', along_track_dim='along_track', cross_track_dim='cross_track')[source][source]#

Return a list of slices to select regular GPM objects.

For GPM ORBITS, it returns slices to select contiguous scans with valid geolocation. For GPM GRID, it returns slices to select periods with regular timesteps.

For more information, read the documentation of: - gpm.utils.checks.get_slices_contiguous_scans - gpm.utils.checks.get_slices_regular_time

Parameters:
  • xr_obj (xarray.DataArray or xarray.Dataset) – GPM xarray object.

  • min_size (int) – Minimum size for a slice to be returned. If None, default to 1 for GRID objects, 2 for ORBIT objects.

  • min_n_scans (int) – Minimum number of scans to be able to check for scan contiguity. For visualization purpose, this value might want to be set to 2. This parameter applies only to ORBIT objects.

Returns:

list_slices – List of slice object to select regular portions. Output format: [slice(start,stop), slice(start,stop),...]

Return type:

list

get_slices_regular_time(tolerance=None, min_size=1)[source][source]#

Return a list of slices ensuring timesteps to be regular.

Output format: [slice(start,stop), slice(start,stop),…]

Consecutive non-regular timesteps leads to slices of size 1. An xarray object with a single timestep leads to a slice of size 1. If min_size=1 (the default), such slices are returned.

Parameters:
  • xr_obj (xarray.DataArray or xarray.Dataset) – GPM xarray object.

  • tolerance (numpy.timedelta64, optional) – The timedelta tolerance to define regular vs. non-regular timesteps. The default is None. If GPM GRID object, it uses the first 2 timesteps to derive the tolerance timedelta. If GPM ORBIT object, it uses the ORBIT_TIME_TOLERANCE.

  • min_size (int) – Minimum size for a slice to be returned.

Returns:

list_slices – List of slice object to select regular time intervals. Output format: [slice(start,stop), slice(start,stop),...]

Return type:

list

get_slices_valid_geolocation(min_size=2, x='lon', y='lat', along_track_dim='along_track', cross_track_dim='cross_track')[source][source]#

Return a list of GPM ORBIT along-track slices with valid geolocation.

The minimum size of the output slices is 2.

If at a given cross-track index, there are always wrong geolocation, it discards such cross-track index(es) before identifying the along-track slices.

Parameters:
Returns:

list_slices – List of slice object with valid geolocation. Output format: [slice(start,stop), slice(start,stop),...]

Return type:

list

property has_contiguous_scans[source]#
property has_missing_granules[source]#
property has_regular_time[source]#
property has_valid_geolocation[source]#
property is_grid[source]#
property is_orbit[source]#
property is_regular[source]#
property is_spatial_2d[source]#
property is_spatial_3d[source]#
isel(indexers=None, drop=False, **indexers_kwargs)[source][source]#

Perform index-based dimension selection.

mask_above_bin(bins, strict=True, fillvalue=nan)[source][source]#
mask_below_bin(bins, strict=True, fillvalue=nan)[source][source]#
mask_between_bins(bottom_bins, top_bins, strict=True, fillvalue=nan)[source][source]#
plot_map_mesh(x=None, y=None, ax=None, edgecolors='k', linewidth=0.1, add_background=True, fig_kwargs=None, subplot_kwargs=None, **plot_kwargs)[source][source]#
plot_map_mesh_centroids(x=None, y=None, ax=None, c='r', s=1, add_background=True, fig_kwargs=None, subplot_kwargs=None, **plot_kwargs)[source][source]#

Plot GPM orbit granule mesh centroids in a cartographic map.

plot_swath(ax=None, facecolor='orange', edgecolor='black', alpha=0.4, add_background=True, fig_kwargs=None, subplot_kwargs=None, **plot_kwargs)[source][source]#

Plot GPM orbit granule.

plot_swath_lines(ax=None, x='lon', y='lat', linestyle='--', color='k', add_background=True, subplot_kwargs=None, fig_kwargs=None, **plot_kwargs)[source][source]#

Plot GPM orbit granule swath lines.

plot_transect_line(ax=None, add_direction=True, add_background=True, fig_kwargs=None, subplot_kwargs=None, text_kwargs=None, line_kwargs=None, **common_kwargs)[source][source]#
property pyproj_crs[source]#
property pyresample_area[source]#
quadmesh_centroids(crs=None, origin='bottom')[source][source]#

Return quadmesh x and y centroids of shaope (N,M).

quadmesh_corners(crs=None)[source][source]#

Return quadmesh x and y corners of shape (N+1, M+1).

quadmesh_polygons(crs=None)[source][source]#

Return an array with quadmesh shapely polygons.

quadmesh_vertices(crs=None, ccw=True, origin='bottom')[source][source]#

Return the quadmesh vertices array with shape (N, M, 4, 2).

Parameters:
  • origin (str) – Origin of the y axis. The default is bottom.

  • ccw (bool, optional) – If True, vertices are ordered counterclockwise. If False, vertices are ordered clockwise. The default is True.

remap_on(dst_ds, radius_of_influence=20000, fill_value=nan)[source][source]#

Remap dataset to another one using nearest-neighbour.

sel(indexers=None, drop=False, **indexers_kwargs)[source][source]#

Perform value-based coordinate selection.

Slices are treated as inclusive of both the start and stop values, unlike normal Python indexing. The gpm sel method is empowered to:

  • slice by gpm-id strings !

  • slice by any xarray coordinate value !

You can use string shortcuts for datetime coordinates (e.g., ‘2000-01’ to select all values in January 2000).

slice_range_at_bin(bins)[source][source]#
slice_range_at_height(value)[source][source]#
slice_range_at_max_value(variable=None)[source][source]#
slice_range_at_min_value(variable=None)[source][source]#
slice_range_at_value(value, variable=None)[source][source]#
property spatial_dimensions[source]#
property start_time[source]#
subset_by_time(start_time=None, end_time=None)[source][source]#

Filter a GPM xarray object by start_time and end_time.

Parameters:
Returns:

xr_obj – GPM xarray object

Return type:

xarray.DataArray or xarray.Dataset

subset_by_time_slice(slice)[source][source]#
subset_range_where_values(variable=None, vmin=-inf, vmax=inf)[source][source]#
subset_range_with_valid_data(variable=None)[source][source]#
property vertical_dimension[source]#
class gpm.accessor.methods.GPM_DataArray_Accessor(xarray_obj)[source][source]#

Bases: GPM_Base_Accessor

property decibel[source]#
get_slices_var_between(dim, vmin=-inf, vmax=inf, criteria='all')[source][source]#

Return a list of slices along the dim dimension where values are between the interval.

If the xarray.DataArray has additional dimensions, the criteria parameter is used to determine whether all values within each slice index must be between the interval (if set to "all") or if at least one value within the slice index must be between the interval (if set to "any").

get_slices_var_equals(dim, values, union=True, criteria='all')[source][source]#

Return a list of slices along the dim dimension where values occurs.

The function is applied recursively to each value in values. If the xarray.DataArray has additional dimensions, the “criteria” parameter is used to determine whether all values within each slice index must be equal to value (if set to "all") or if at least one value within the slice index must be equal to value (if set to "any").

If values are a list of values: - if union=True, it return slices corresponding to the sequence of consecutive values. - if union=False, it return slices for each value in values.

If union=False [0,0, 1, 1] with values=[0,1] will return [slice(0,2), slice(2,4)] If union=True [0,0, 1, 1] with values=[0,1] will return [slice(0,4)]

union matters when multiple values are specified criteria matters when the xarray.DataArray has multiple dimensions.

property idecibel[source]#
integrate_profile_concentration(name, scale_factor=None, units=None)[source][source]#
plot_cross_section(x=None, y=None, ax=None, add_colorbar=True, zoom=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source][source]#

Plot GPM cross-section.

If RGB DataArray, all other plot_kwargs are ignored !

plot_image(x=None, y=None, ax=None, add_colorbar=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source][source]#

Plot data using imshow.

Parameters:
  • da (xarray.DataArray) – xarray DataArray.

  • x (str, optional) – X dimension name. If None, takes the second dimension. The default is None.

  • y (str, optional) – Y dimension name. If None, takes the first dimension. The default is None.

  • ax (cartopy.mpl.geoaxes.GeoAxes, optional) – The matplotlib axes where to plot the image. If None, a figure is initialized using the specified fig_kwargs. The default is None.

  • add_colorbar (bool, optional) – Whether to add a colorbar. The default is True.

  • interpolation (str, optional) – Argument to be passed to imshow. The default is "nearest".

  • fig_kwargs (dict, optional) – Figure options to be passed to matplotlib.pyplot.subplots. The default is None. Only used if ax is None.

  • subplot_kwargs (dict, optional) – Subplot options to be passed to matplotlib.pyplot.subplots. The default is None. Only used if `ax` is None.

  • cbar_kwargs (dict, optional) – Colorbar options. The default is None.

  • **plot_kwargs – Additional arguments to be passed to the plotting function. Examples include cmap, norm, vmin, vmax, levels, … For FacetGrid plots, specify row, col and col_wrap. With rgb you can specify the name of the xarray.DataArray RGB dimension.

plot_map(x=None, y=None, ax=None, add_colorbar=True, add_swath_lines=True, add_background=True, interpolation='nearest', fig_kwargs=None, subplot_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source][source]#

Plot data on a geographic map.

Parameters:
  • da (xarray.DataArray) – xarray DataArray.

  • x (str, optional) – Longitude coordinate name. If None, takes the second dimension. The default is None.

  • y (str, optional) – Latitude coordinate name. If None, takes the first dimension. The default is None.

  • ax (cartopy.mpl.geoaxes.GeoAxes, optional) – The cartopy GeoAxes where to plot the map. If None, a figure is initialized using the specified fig_kwargs and subplot_kwargs. The default is None.

  • add_colorbar (bool, optional) – Whether to add a colorbar. The default is True.

  • add_swath_lines (bool, optional) – Whether to plot the swath sides with a dashed line. The default is True. This argument only applies for ORBIT objects.

  • add_background (bool, optional) – Whether to add the map background. The default is True.

  • interpolation (str, optional) – Argument to be passed to matplotlib.axes.Axes.imshow. Only applies for GRID objects. The default is "nearest".

  • fig_kwargs (dict, optional) – Figure options to be passed to matplotlib.pyplot.subplots. The default is None. Only used if ax is None.

  • subplot_kwargs (dict, optional) – Dictionary of keyword arguments for matplotlib.pyplot.subplots. Must contain the Cartopy CRS ` projection key if specified. The default is None. Only used if ax is None.

  • cbar_kwargs (dict, optional) – Colorbar options. The default is None.

  • **plot_kwargs – Additional arguments to be passed to the plotting function. Examples include cmap, norm, vmin, vmax, levels, … For FacetGrid plots, specify row, col and col_wrap. With rgb you can specify the name of the xarray.DataArray RGB dimension.

title(prefix_product=True, add_timestep=True, time_idx=None, resolution='m', timezone='UTC')[source][source]#

Generate the plot title for a GPM xarray.DataArray.

Parameters:
  • da (xarray.DataArray) – GPM xarray DataArray.

  • prefix_product (bool, optional) – Whether to add the GPM product as prefix. The default is True.

  • add_timestep (bool, optional) – Whether to add time information to the title. The default is True. For GRID objects (like IMERG), the timestep is added only if the xarray.DataArray has 1 timestep.

  • time_idx (int, optional) – Index of timestep to select, instead of selecting the middle. The default is None.

  • resolution (str, optional) – The maximum temporal resolution to display. The default is “m” (for minutes).

  • timezone (str, optional) – The timezone of the time to display. The default is “UTC” (as the reference timezone of the dataset).

Returns:

title_str – Title of the xarray.DataArray.

Return type:

str

class gpm.accessor.methods.GPM_Dataset_Accessor(xarray_obj)[source][source]#

Bases: GPM_Base_Accessor

available_retrievals()[source][source]#
property bin_variables[source]#
property cross_section_variables[source]#
extract_dataset_above_bin(bins, new_range_size=None, strict=False, reverse=False)[source][source]#
extract_dataset_below_bin(bins, new_range_size=None, strict=False, reverse=False)[source][source]#
extract_l2_dataset(bin_ellipsoid='binEllipsoid', new_range_size=None, shortened_range=True)[source][source]#
property frequency_variables[source]#
plot_cross_section(x=None, y=None, ax=None, add_colorbar=True, zoom=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source][source]#

Plot GPM cross-section.

If RGB DataArray, all other plot_kwargs are ignored !

plot_image(x=None, y=None, ax=None, add_colorbar=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source][source]#

Plot data using imshow.

Parameters:
  • da (xarray.DataArray) – xarray DataArray.

  • x (str, optional) – X dimension name. If None, takes the second dimension. The default is None.

  • y (str, optional) – Y dimension name. If None, takes the first dimension. The default is None.

  • ax (cartopy.mpl.geoaxes.GeoAxes, optional) – The matplotlib axes where to plot the image. If None, a figure is initialized using the specified fig_kwargs. The default is None.

  • add_colorbar (bool, optional) – Whether to add a colorbar. The default is True.

  • interpolation (str, optional) – Argument to be passed to imshow. The default is "nearest".

  • fig_kwargs (dict, optional) – Figure options to be passed to matplotlib.pyplot.subplots. The default is None. Only used if ax is None.

  • subplot_kwargs (dict, optional) – Subplot options to be passed to matplotlib.pyplot.subplots. The default is None. Only used if `ax` is None.

  • cbar_kwargs (dict, optional) – Colorbar options. The default is None.

  • **plot_kwargs – Additional arguments to be passed to the plotting function. Examples include cmap, norm, vmin, vmax, levels, … For FacetGrid plots, specify row, col and col_wrap. With rgb you can specify the name of the xarray.DataArray RGB dimension.

plot_map(x=None, y=None, ax=None, add_colorbar=True, add_swath_lines=True, add_background=True, interpolation='nearest', fig_kwargs=None, subplot_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source][source]#

Plot data on a geographic map.

Parameters:
  • da (xarray.DataArray) – xarray DataArray.

  • x (str, optional) – Longitude coordinate name. If None, takes the second dimension. The default is None.

  • y (str, optional) – Latitude coordinate name. If None, takes the first dimension. The default is None.

  • ax (cartopy.mpl.geoaxes.GeoAxes, optional) – The cartopy GeoAxes where to plot the map. If None, a figure is initialized using the specified fig_kwargs and subplot_kwargs. The default is None.

  • add_colorbar (bool, optional) – Whether to add a colorbar. The default is True.

  • add_swath_lines (bool, optional) – Whether to plot the swath sides with a dashed line. The default is True. This argument only applies for ORBIT objects.

  • add_background (bool, optional) – Whether to add the map background. The default is True.

  • interpolation (str, optional) – Argument to be passed to matplotlib.axes.Axes.imshow. Only applies for GRID objects. The default is "nearest".

  • fig_kwargs (dict, optional) – Figure options to be passed to matplotlib.pyplot.subplots. The default is None. Only used if ax is None.

  • subplot_kwargs (dict, optional) – Dictionary of keyword arguments for matplotlib.pyplot.subplots. Must contain the Cartopy CRS ` projection key if specified. The default is None. Only used if ax is None.

  • cbar_kwargs (dict, optional) – Colorbar options. The default is None.

  • **plot_kwargs – Additional arguments to be passed to the plotting function. Examples include cmap, norm, vmin, vmax, levels, … For FacetGrid plots, specify row, col and col_wrap. With rgb you can specify the name of the xarray.DataArray RGB dimension.

retrieve(name, **kwargs)[source][source]#
select_bin_variables()[source][source]#
select_cross_section_variables(strict=False, squeeze=True)[source][source]#
select_frequency_variables()[source][source]#
select_spatial_2d_variables(strict=False, squeeze=True)[source][source]#
select_spatial_3d_variables(strict=False, squeeze=True)[source][source]#
select_vertical_variables()[source][source]#
set_encoding(encoding_dict=None)[source][source]#
slice_range_at_temperature(temperature, variable_temperature='airTemperature')[source][source]#
property spatial_2d_variables[source]#
property spatial_3d_variables[source]#
title(add_timestep=True, time_idx=None, resolution='m', timezone='UTC')[source][source]#

Generate the GPM Dataset title.

Parameters:
  • ds (xarray.Dataset) – GPM xarray Dataset.

  • add_timestep (bool, optional) – Whether to add time information to the title. The default is True. For GRID objects (like IMERG), the timestep is added only if the xarray.DataArray has 1 timestep.

  • time_idx (int, optional) – Index of timestep to select, instead of selecting the middle. The default is None.

  • resolution (str, optional) – The maximum temporal resolution to display. The default is “m” (for minutes).

  • timezone (str, optional) – The timezone of the time to display. The default is “UTC” (as the reference timezone of the dataset).

Returns:

title_str – Title of the Dataset.

Return type:

str

to_dask_dataframe()[source][source]#

Convert an xarray.Dataset to a dask.dataframe.DataFrame.

to_pandas_dataframe()[source][source]#

Convert an xarray.Dataset to a pandas.DataFrame.

property variables[source]#
property vertical_variables[source]#
gpm.accessor.methods.auto_wrap_docstring(func)[source][source]#

Decorator to add the source function docstring to the accessor method.

gpm.accessor.methods.get_imported_gpm_method(accessor_method: Callable) Callable[source][source]#

Return the source function called by the accessor method.

gpm.accessor.methods.get_imported_gpm_method_path(function: Callable) tuple[str, str][source][source]#

Get path of imported gpm method in accessor method source code (format is “module.method”)).

Module contents#

This directory defines GPM-API xarray accessors.

class gpm.accessor.GPM_DataArray_Accessor(xarray_obj)[source][source]#

Bases: GPM_Base_Accessor

property decibel[source]#
get_slices_var_between(dim, vmin=-inf, vmax=inf, criteria='all')[source][source]#

Return a list of slices along the dim dimension where values are between the interval.

If the xarray.DataArray has additional dimensions, the criteria parameter is used to determine whether all values within each slice index must be between the interval (if set to "all") or if at least one value within the slice index must be between the interval (if set to "any").

get_slices_var_equals(dim, values, union=True, criteria='all')[source][source]#

Return a list of slices along the dim dimension where values occurs.

The function is applied recursively to each value in values. If the xarray.DataArray has additional dimensions, the “criteria” parameter is used to determine whether all values within each slice index must be equal to value (if set to "all") or if at least one value within the slice index must be equal to value (if set to "any").

If values are a list of values: - if union=True, it return slices corresponding to the sequence of consecutive values. - if union=False, it return slices for each value in values.

If union=False [0,0, 1, 1] with values=[0,1] will return [slice(0,2), slice(2,4)] If union=True [0,0, 1, 1] with values=[0,1] will return [slice(0,4)]

union matters when multiple values are specified criteria matters when the xarray.DataArray has multiple dimensions.

property idecibel[source]#
integrate_profile_concentration(name, scale_factor=None, units=None)[source][source]#
plot_cross_section(x=None, y=None, ax=None, add_colorbar=True, zoom=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source][source]#

Plot GPM cross-section.

If RGB DataArray, all other plot_kwargs are ignored !

plot_image(x=None, y=None, ax=None, add_colorbar=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source][source]#

Plot data using imshow.

Parameters:
  • da (xarray.DataArray) – xarray DataArray.

  • x (str, optional) – X dimension name. If None, takes the second dimension. The default is None.

  • y (str, optional) – Y dimension name. If None, takes the first dimension. The default is None.

  • ax (cartopy.mpl.geoaxes.GeoAxes, optional) – The matplotlib axes where to plot the image. If None, a figure is initialized using the specified fig_kwargs. The default is None.

  • add_colorbar (bool, optional) – Whether to add a colorbar. The default is True.

  • interpolation (str, optional) – Argument to be passed to imshow. The default is "nearest".

  • fig_kwargs (dict, optional) – Figure options to be passed to matplotlib.pyplot.subplots. The default is None. Only used if ax is None.

  • subplot_kwargs (dict, optional) – Subplot options to be passed to matplotlib.pyplot.subplots. The default is None. Only used if `ax` is None.

  • cbar_kwargs (dict, optional) – Colorbar options. The default is None.

  • **plot_kwargs – Additional arguments to be passed to the plotting function. Examples include cmap, norm, vmin, vmax, levels, … For FacetGrid plots, specify row, col and col_wrap. With rgb you can specify the name of the xarray.DataArray RGB dimension.

plot_map(x=None, y=None, ax=None, add_colorbar=True, add_swath_lines=True, add_background=True, interpolation='nearest', fig_kwargs=None, subplot_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source][source]#

Plot data on a geographic map.

Parameters:
  • da (xarray.DataArray) – xarray DataArray.

  • x (str, optional) – Longitude coordinate name. If None, takes the second dimension. The default is None.

  • y (str, optional) – Latitude coordinate name. If None, takes the first dimension. The default is None.

  • ax (cartopy.mpl.geoaxes.GeoAxes, optional) – The cartopy GeoAxes where to plot the map. If None, a figure is initialized using the specified fig_kwargs and subplot_kwargs. The default is None.

  • add_colorbar (bool, optional) – Whether to add a colorbar. The default is True.

  • add_swath_lines (bool, optional) – Whether to plot the swath sides with a dashed line. The default is True. This argument only applies for ORBIT objects.

  • add_background (bool, optional) – Whether to add the map background. The default is True.

  • interpolation (str, optional) – Argument to be passed to matplotlib.axes.Axes.imshow. Only applies for GRID objects. The default is "nearest".

  • fig_kwargs (dict, optional) – Figure options to be passed to matplotlib.pyplot.subplots. The default is None. Only used if ax is None.

  • subplot_kwargs (dict, optional) – Dictionary of keyword arguments for matplotlib.pyplot.subplots. Must contain the Cartopy CRS ` projection key if specified. The default is None. Only used if ax is None.

  • cbar_kwargs (dict, optional) – Colorbar options. The default is None.

  • **plot_kwargs – Additional arguments to be passed to the plotting function. Examples include cmap, norm, vmin, vmax, levels, … For FacetGrid plots, specify row, col and col_wrap. With rgb you can specify the name of the xarray.DataArray RGB dimension.

title(prefix_product=True, add_timestep=True, time_idx=None, resolution='m', timezone='UTC')[source][source]#

Generate the plot title for a GPM xarray.DataArray.

Parameters:
  • da (xarray.DataArray) – GPM xarray DataArray.

  • prefix_product (bool, optional) – Whether to add the GPM product as prefix. The default is True.

  • add_timestep (bool, optional) – Whether to add time information to the title. The default is True. For GRID objects (like IMERG), the timestep is added only if the xarray.DataArray has 1 timestep.

  • time_idx (int, optional) – Index of timestep to select, instead of selecting the middle. The default is None.

  • resolution (str, optional) – The maximum temporal resolution to display. The default is “m” (for minutes).

  • timezone (str, optional) – The timezone of the time to display. The default is “UTC” (as the reference timezone of the dataset).

Returns:

title_str – Title of the xarray.DataArray.

Return type:

str

class gpm.accessor.GPM_Dataset_Accessor(xarray_obj)[source][source]#

Bases: GPM_Base_Accessor

available_retrievals()[source][source]#
property bin_variables[source]#
property cross_section_variables[source]#
extract_dataset_above_bin(bins, new_range_size=None, strict=False, reverse=False)[source][source]#
extract_dataset_below_bin(bins, new_range_size=None, strict=False, reverse=False)[source][source]#
extract_l2_dataset(bin_ellipsoid='binEllipsoid', new_range_size=None, shortened_range=True)[source][source]#
property frequency_variables[source]#
plot_cross_section(x=None, y=None, ax=None, add_colorbar=True, zoom=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source][source]#

Plot GPM cross-section.

If RGB DataArray, all other plot_kwargs are ignored !

plot_image(x=None, y=None, ax=None, add_colorbar=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source][source]#

Plot data using imshow.

Parameters:
  • da (xarray.DataArray) – xarray DataArray.

  • x (str, optional) – X dimension name. If None, takes the second dimension. The default is None.

  • y (str, optional) – Y dimension name. If None, takes the first dimension. The default is None.

  • ax (cartopy.mpl.geoaxes.GeoAxes, optional) – The matplotlib axes where to plot the image. If None, a figure is initialized using the specified fig_kwargs. The default is None.

  • add_colorbar (bool, optional) – Whether to add a colorbar. The default is True.

  • interpolation (str, optional) – Argument to be passed to imshow. The default is "nearest".

  • fig_kwargs (dict, optional) – Figure options to be passed to matplotlib.pyplot.subplots. The default is None. Only used if ax is None.

  • subplot_kwargs (dict, optional) – Subplot options to be passed to matplotlib.pyplot.subplots. The default is None. Only used if `ax` is None.

  • cbar_kwargs (dict, optional) – Colorbar options. The default is None.

  • **plot_kwargs – Additional arguments to be passed to the plotting function. Examples include cmap, norm, vmin, vmax, levels, … For FacetGrid plots, specify row, col and col_wrap. With rgb you can specify the name of the xarray.DataArray RGB dimension.

plot_map(x=None, y=None, ax=None, add_colorbar=True, add_swath_lines=True, add_background=True, interpolation='nearest', fig_kwargs=None, subplot_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source][source]#

Plot data on a geographic map.

Parameters:
  • da (xarray.DataArray) – xarray DataArray.

  • x (str, optional) – Longitude coordinate name. If None, takes the second dimension. The default is None.

  • y (str, optional) – Latitude coordinate name. If None, takes the first dimension. The default is None.

  • ax (cartopy.mpl.geoaxes.GeoAxes, optional) – The cartopy GeoAxes where to plot the map. If None, a figure is initialized using the specified fig_kwargs and subplot_kwargs. The default is None.

  • add_colorbar (bool, optional) – Whether to add a colorbar. The default is True.

  • add_swath_lines (bool, optional) – Whether to plot the swath sides with a dashed line. The default is True. This argument only applies for ORBIT objects.

  • add_background (bool, optional) – Whether to add the map background. The default is True.

  • interpolation (str, optional) – Argument to be passed to matplotlib.axes.Axes.imshow. Only applies for GRID objects. The default is "nearest".

  • fig_kwargs (dict, optional) – Figure options to be passed to matplotlib.pyplot.subplots. The default is None. Only used if ax is None.

  • subplot_kwargs (dict, optional) – Dictionary of keyword arguments for matplotlib.pyplot.subplots. Must contain the Cartopy CRS ` projection key if specified. The default is None. Only used if ax is None.

  • cbar_kwargs (dict, optional) – Colorbar options. The default is None.

  • **plot_kwargs – Additional arguments to be passed to the plotting function. Examples include cmap, norm, vmin, vmax, levels, … For FacetGrid plots, specify row, col and col_wrap. With rgb you can specify the name of the xarray.DataArray RGB dimension.

retrieve(name, **kwargs)[source][source]#
select_bin_variables()[source][source]#
select_cross_section_variables(strict=False, squeeze=True)[source][source]#
select_frequency_variables()[source][source]#
select_spatial_2d_variables(strict=False, squeeze=True)[source][source]#
select_spatial_3d_variables(strict=False, squeeze=True)[source][source]#
select_vertical_variables()[source][source]#
set_encoding(encoding_dict=None)[source][source]#
slice_range_at_temperature(temperature, variable_temperature='airTemperature')[source][source]#
property spatial_2d_variables[source]#
property spatial_3d_variables[source]#
title(add_timestep=True, time_idx=None, resolution='m', timezone='UTC')[source][source]#

Generate the GPM Dataset title.

Parameters:
  • ds (xarray.Dataset) – GPM xarray Dataset.

  • add_timestep (bool, optional) – Whether to add time information to the title. The default is True. For GRID objects (like IMERG), the timestep is added only if the xarray.DataArray has 1 timestep.

  • time_idx (int, optional) – Index of timestep to select, instead of selecting the middle. The default is None.

  • resolution (str, optional) – The maximum temporal resolution to display. The default is “m” (for minutes).

  • timezone (str, optional) – The timezone of the time to display. The default is “UTC” (as the reference timezone of the dataset).

Returns:

title_str – Title of the Dataset.

Return type:

str

to_dask_dataframe()[source][source]#

Convert an xarray.Dataset to a dask.dataframe.DataFrame.

to_pandas_dataframe()[source][source]#

Convert an xarray.Dataset to a pandas.DataFrame.

property variables[source]#
property vertical_variables[source]#