From f38903e5efa63015630f34af2fdb2f39ad888ba8 Mon Sep 17 00:00:00 2001 From: Pithon Kabiro <pithon.kabiro@hft-stuttgart.de> Date: Fri, 24 Sep 2021 13:48:52 +0200 Subject: [PATCH] New functions: calculate daily min/max values Calculate the minimum and maximum of observation values for a daily interval --- public/js/src_modules/aggregate.mjs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/public/js/src_modules/aggregate.mjs b/public/js/src_modules/aggregate.mjs index 6691c1c..97c2c07 100644 --- a/public/js/src_modules/aggregate.mjs +++ b/public/js/src_modules/aggregate.mjs @@ -5,6 +5,28 @@ import { extractObservationValuesWithinMonthInterval, } from "./aggregateHelpers.mjs"; +/** + * Calculate the minimum observation values that fall within a time interval delimited by a start date and end date + * @param {Array} obsValuesForDaysIntervalArr An array of observation values that fall within our time interval + * @returns {Number} A floating-point number representing the minimum of observation values + */ +const calculateMinimumObservationValuesWithinDatesInterval = function ( + obsValuesForDaysIntervalArr +) { + return Math.min(...obsValuesForDaysIntervalArr); +}; + +/** + * Calculate the maximum observation values that fall within a time interval delimited by a start date and end date + * @param {Array} obsValuesForDaysIntervalArr An array of observation values that fall within our time interval + * @returns {Number} A floating-point number representing the maximum of observation values + */ +const calculateMaximumObservationValuesWithinDatesInterval = function ( + obsValuesForDaysIntervalArr +) { + return Math.max(...obsValuesForDaysIntervalArr); +}; + /** * Calculate the sum of observation values that fall within a time interval delimited by a start date and end date * @param {Array} obsValuesForDaysIntervalArr An array of observation values that fall within our time interval -- GitLab