harp wrapper for tobac segmentation.segmentation_2d() function

segment_2d(
  features,
  field_data,
  threshold,
  data_col = "gridded_data",
  dttm_col = "valid_dttm",
  target = c("max", "min"),
  level = NULL,
  method = "watershed",
  max_distance = NULL,
  pbc_flag = c("none", "h_dim1", "h_dim2", "both"),
  seed_3d_flag = c("column", "box"),
  statistic = NULL
)

Arguments

features

A features data frame, as returned by detect_features_multithreshold().

field_data

A harp_grid_df data frame such as one returned by the harpIO functions harpIO::read_grid() with data_frame = TRUE, harpIO::read_forecast(), or harpIO::read_analysis().

threshold

Threshold for the watershedding field to be used for the mask.

data_col

<tidy-select> The column in field_data containing the fields to be used to detect features in. Should be a <geolist> column. If the named column is not found in field_data, but field_data contains 1 <geolist> column, that <geolist> column is used.

dttm_col

<tidy-select> The column in field_data containing the date-times to be used for the time dimension. Can be numeric with units in Unix time (seconds since 1970-01-01 00:00:00), or a <POSIXt>column. If the named column is not found in field_data, but field_data contains 1 <POSIXt> column, that <POSIXt> column is used.

target

Flag to determine if tracking is targeting minima or maxima in the data. Should be "max" or "min". Default is "max".

level

Levels at which to seed the cells for the watershedding algorithm. Default is NULL.

method

Flag determining the algorithm to use (currently only "watershed" is implemented).

max_distance

Maximum distance from a marker allowed to be classified as belonging to that cell in metres. Default is NULL.

pbc_flag

Sets whether to use periodic boundaries, and if so in which directions. "none" means that we do not have periodic boundaries "hdim_1" means that we are periodic along hdim1, "hdim_2" means that we are periodic along hdim2 and "both" means that we are periodic along both horizontal dimensions

seed_3d_flag

Seed 3D field at feature positions with either the full column (default) or a box of user-set size.

statistic

Default is NULL. Parameter to calculate bulk statistics within feature detection. Named list with callable function(s) to apply over the region of each detected feature and the name of the statistics to appear in the feature output data frame. The functions should be the values and the names of the metric the keys (e.g. list(mean = np.mean)). This probably doesn't work yet as there needs to be a translation between R and Python functions here.

Value

A named list with:

  • segments: A data frame with a geolist column with 2d fields on the same domain as the input data with integer values denoting each segment.

  • features: Feature data frame including the number of cells in the segmented area of the feature at the time step.