swirlspy.preprocess package

Data preprocessing.

swirlspy.preprocess.grid_align(da_src: xarray.core.dataarray.DataArray, src_proj4_str: str, x_tgt: numpy.ndarray, y_tgt: numpy.ndarray, tgt_proj4_str: str, method='quick', radius_of_influence=50000, fill_value=None, nprocs=1, segments=None)
Regrid data in an xarray.DataArray to
reference data projection system.

Returns an xarray.DataArray with metadata associated with the new projection system.

Parameters:
  • da_src (xarray.DataArray) – Contains data and metadata to be convert to target grid. Dimensions of data must be (‘y’, ‘x’) or (‘channel’, ‘y’, ‘x’).
  • src_proj4_str (str) – proj4string of da_src’s coordinate projection system.
  • x_tgt (xarray.ndarray) – Target projection system x-coordinate values. MUST be a 1-dimension array.
  • y_tgt (numpy.ndarray) – Target projection system y-coordinate values. MUST be a 1-dimension array.
  • tgt_proj4_str (str) – proj4string of da_ref’s coordinate projection system.
  • method (str) – The resampling method, based on the methods of pyresample.image. Options are ‘quick’, using an approximate but faster nearest neighbour method, and ‘kd_tree’, using an accurate kd_tree method.
  • radius_of_influence (int) – Cut off radius in meters when considering neighbouring pixels.
  • fill_value (int) – Fill value for undefined pixels. Default is None, where they will be masked out.
  • nprocs (int) – Number of precessor cores to use. Defaults to 1.
  • segments (int) – Number of segments to split resampling in. Defaults None, where auto-estimation will be done.
Returns:

da_regrided – Contains data reprojected to the target projection system and associated metadata

Return type:

xarray.DataArray

swirlspy.preprocess.resampling(da_src: xarray.core.dataarray.DataArray, area_def_src: pyresample.geometry.AreaDefinition, area_def_tgt: pyresample.geometry.AreaDefinition, method='quick', radius_of_influence=50000, fill_value=None, nprocs=1, segments=None)

Reprojects data in an xarray.DataArray to another projection system. Returns an xarray.DataArray with metadata associated with the new projection system.

Parameters:
  • da_src (xarray.DataArray) – Contains data and metadata associated with the current projection system. Dimensions of data must be (‘y’, ‘x’) or (‘channel’, ‘y’, ‘x’). ‘y’ coordinates must be in descending order.
  • area_def_src (pyresample.AreaDefinition) – The area definition of the current projection system.
  • area_def_tgt (pyresample.AreaDefinition) – The area definition of the target projection system.
  • method (str) – The resampling method, based on the methods of pyresample.image. Options are ‘quick’, using an approximate but faster nearest neighbour method, and ‘kd_tree’, using an accurate kd_tree method.
  • coord_label (list of strings) – [x_label, y_label]. Defaults to [‘x’, ‘y’].
  • radius_of_influence (int) – Cut off radius in meters when considering neighbouring pixels.
  • fill_value (int) – Fill value for undefined pixels. Default is None, where they will be masked out.
  • nprocs (int) – Number of precessor cores to use. Defaults to 1.
  • segments (int) – Number of segments to split resampling in. Defaults None, where auto-estimation will be done.
Returns:

result – Contains data reprojected to the target projection system and associated metadata

Return type:

xarray.DataArray