Commit 11981299 authored by Pithon Kabiro's avatar Pithon Kabiro
Browse files

New function: get timestamp of missing observations

Currently, this function is only available in the scope of the
function that formats observations for the scatter plot chart.

Get the timestamp of the observations that are available in the first
array but are missing from the second.
parent 60cb21f2
......@@ -808,6 +808,44 @@ const formatSTAResponseForScatterPlot = function (obsArrayOne, obsArrayTwo) {
console.log(obsArrayOneChecked.length);
console.log(obsArrayTwoChecked.length);
// Create arrays with timestamps only
const obsArrayOneTimestamp = obsArrayOneChecked.map(
(obsTimeValue) => obsTimeValue[0]
);
const obsArrayTwoTimestamp = obsArrayTwoChecked.map(
(obsTimeValue) => obsTimeValue[0]
);
// console.log(obsArrayOneTimestamp);
/**
*
* @param {Array} obsTimestampArrayOne An array of timestamps for the first set of observations
* @param {Array} obsTimestampArrayTwo An array of timstamps for the second set of observations
* @returns {Array} An array of timestamps missing from the second set of observations
*/
const getMissingTimestampFromSecondArray = function (
obsTimestampArrayOne,
obsTimestampArrayTwo
) {
const differenceBetweenArrays = obsTimestampArrayOne.filter(
(timestampOne) => !obsTimestampArrayTwo.includes(timestampOne)
);
// .concat(
// obsTimestampArrayTwo.filter(
// (timestampTwo) => !obsArrayTwo.includes(timestampTwo)
// )
// );
return differenceBetweenArrays;
};
const missingTimestamp = getMissingTimestampFromSecondArray(
obsArrayOneTimestamp,
obsArrayTwoTimestamp
);
console.log(missingTimestamp);
};
(async () => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment