Skip to main content

calculateNitrogenBalancesFieldToFarm

@nmi-agro/fdm-source


@nmi-agro/fdm-source / fdm-calculator/src / calculateNitrogenBalancesFieldToFarm

Function: calculateNitrogenBalancesFieldToFarm()

calculateNitrogenBalancesFieldToFarm(fieldsWithBalanceResults, hasErrors, fieldErrorMessages): NitrogenBalanceNumeric

Defined in: fdm-calculator/src/balance/nitrogen/index.ts:353

Aggregates nitrogen balances from individual fields to the farm level.

This function takes an array of nitrogen balance results for individual fields and aggregates them to provide an overall nitrogen balance for the entire farm. It calculates weighted averages of nitrogen supply, removal, and emission based on the area of each field.

The function returns a comprehensive nitrogen balance for the farm, including total supply, removal, emission, and the overall balance.

Parameters

fieldsWithBalanceResults

NitrogenBalanceFieldResultNumeric[]

An array of nitrogen balance results for individual fields, potentially including errors.

hasErrors

boolean

Indicates if any field calculations failed.

fieldErrorMessages

string[]

A list of error messages for fields that failed to calculate.

Returns

NitrogenBalanceNumeric

The aggregated nitrogen balance for the farm.