Skip to main content

getMainCultivation

@nmi-agro/fdm-source


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

Function: getMainCultivation()

getMainCultivation<T>(cultivations, year): T | undefined

Defined in: fdm-calculator/src/mineralization/builders.ts:38

Internal

Determines the main cultivation for a given year using the "May 15th" rule.

The NMI models expect one principal cultivation per rotation year. This rule identifies the crop that is active on May 15th of the specified year. If no cultivation spans that date (e.g. a late-starting crop), the function falls back to the first non-catchcrop in the year, then to any cultivation.

When multiple cultivations overlap May 15th, the most recently started one takes precedence (sorted descending by b_lu_start).

Type Parameters

T

T extends object

Parameters

cultivations

T[]

All cultivations for the given year.

year

number

Calendar year to evaluate (e.g. 2026).

Returns

T | undefined

The main cultivation for the year, or undefined if the list is empty.