AllUpstreamSubids: Find All Upstream SUBIDs

View source: R/function_AllUpstreamSubids.R

AllUpstreamSubidsR Documentation

Find All Upstream SUBIDs

Description

Function to find all SUBIDs of upstream sub-catchments for a single sub-catchment.

Usage

AllUpstreamSubids(
  subid,
  gd,
  bd = NULL,
  sort = FALSE,
  get.weights = FALSE,
  write.arcgis = FALSE
)

Arguments

subid

SUBID of a target sub-catchment (must exist in gd).

gd

A data frame, containing 'SUBID' and 'MAINDOWN' columns, e.g. an imported 'GeoData.txt' file. Mandatory argument. See 'Details'.

bd

A data frame, containing 'BRANCHID' and 'SOURCEID' columns, and 'MAINPART' with argument get.weights, e.g. an imported 'BranchData.txt' file. Optional argument.

sort

Logical. If TRUE, the resulting upstream SUBID vector will be sorted according to order in argument gd, i.e. in downstream order for a working GeoData table.

get.weights

Logical. If TRUE, flow weights are computed along the upstream SUBID sequence. See details.

write.arcgis

Logical. If TRUE, a string containing an SQL expression suitable for ArcGIS's 'Select By Attributes' feature will be written to the clipboard.

Details

AllUpstreamSubids finds all upstream SUBIDs of a given SUBID (including itself but not including potential irrigation links or groundwater flows) using GeoData columns 'SUBID' and 'MAINDOWN', i.e the full upstream catchment. If a BranchData file is provided, the function will also include upstream areas which are connected through an upstream bifurcation. The results can be directly used as 'partial model setup file' ('pmsf.txt') using the export function WritePmsf.

If argument get.weights is set to TRUE, weighting fractions are returned along with upstream SUBIDs. The fractions are based on column 'MAINPART' in argument bd. The function considers fractions from bifurcation branches which flow into the basin, and fractions where bifurcation branches remove discharge from the basin. Fractions are incrementally updated, i.e. nested bifurcation fractions are multiplied.

For details on bifurcation handling in HYPE, see the HYPE online documentation for BranchData.txt.

Value

If get.weights is FALSE, AllUpstreamSubids returns a vector of SUBIDs, otherwise a two-column data frame with SUBIDs in the first, and flow weight fractions in the second column.

See Also

UpstreamGeoData, AllDownstreamSubids

Examples

te <- ReadGeoData(filename = system.file("demo_model", "GeoData.txt", package = "HYPEtools"))
AllUpstreamSubids(subid = 63794, gd = te)


rcapell/HYPEtools documentation built on Feb. 28, 2024, 2:29 p.m.