This function applies the Nutrient Aggregation logic from ECHO's Water Pollutant Loading Tool to add nitrogen subspecies together to approximate a total nitrogen value on a single day at a single site. Before summing subspecies, this function runs TADA_AggregateMeasurements to obtain the max value of a characteristic-fraction-speciation at a given site, date, and depth. Where necessary, it uses conversion factors to convert nitrogen subspecies expressed as nitrate, nitrite, ammonia, ammonium, etc. to as nitrogen based on the atomic weights of the different elements in the compound. The reference table is contained within the package but may be edited/customized by users. Nutrient equations are as follows:
Usage
TADA_CalculateTotalNP(.data, sum_ref, daily_agg = c("max", "min", "mean"))
Arguments
- .data
TADA dataframe, ideally harmonized using TADA_HarmonizeSynonyms. If user wants to consider grouping N or P subspecies across multiple organizations, user should have run TADA_FindNearbySites and grouped all nearby sites to one common MonitoringLocationIdentifier, TADA.LatitudeMeasure, TADA.LongitudeMeasure, etc.
- sum_ref
Optional. A custom summation reference dataframe the user has loaded into the R environment. Dataframe must have same columns as default TADA.summation reference table.
- daily_agg
The function used to aggregate to a single characteristic-unit-fraction-speciation at the same location and depth on the same day for multiple measurements. Defaults to 'max', but can be set to 'min' or 'mean'.
Value
Input TADA dataframe with additional rows representing total N and P summation values from adding up subspecies. Note that for total phosphorus, these additional rows are simply a re-classification of phosphorus or phosphate into the total phosphorus as P format. These new rows share the same date and monitoring location as the subspecies, but an additional note is added in the TADA.NutrientSummation.Flag column describing how the total was derived. Also adds TADA.NutrientSummationGroup and TADA.NutrientSummationEquation columns, which can be used to trace how the total was calculated and from which subspecies.
Details
NITROGEN:
TOTAL N (UNFILTERED)
TOTAL N (FILTERED) + TOTAL N (PARTICULATE)
TOTAL KJELDAHL NITROGEN + NITRATE + NITRITE
ORGANIC N + AMMONIA + NITRATE + NITRITE
OTHER NITROGEN FORMS
PHOSPHORUS:
TOTAL PHOSPHORUS
PHOSPHATE
OTHER PHOSPHORUS FORMS
Equations are applied in the order above. The function looks for groups of nutrients that exactly match each equation before looking for every combination within each equation (for example, a group of nitrogen subspecies including AMMONIA and NITRATE will be passed over in an initial sweep of groups of subspecies containing ORG N, AMMONIA, NITRATE, and NITRITE, but will be caught as the function moves down the hierarchy of equations to fewer and fewer subspecies). Eventually, even groups with only one subspecies will be used to represent a TOTAL N value for that site/day/depth.