diff --git a/tool/lib/journalLib.jq b/tool/lib/journalLib.jq index 94a811a..3aec814 100644 --- a/tool/lib/journalLib.jq +++ b/tool/lib/journalLib.jq @@ -13,14 +13,13 @@ def ingestionDose($customUnits): .dose end; -# this probably isnt right def addStandardDeviations($expectationX; $standardDeviationX; $expectationY; $standardDeviationY): (pow($standardDeviationX; 2) + pow($expectationX; 2)) as $sumX | (pow($standardDeviationY; 2) + pow($expectationY; 2)) as $sumY | (pow($expectationX; 2) * pow($expectationY; 2)) as $expectations | ($sumX * $sumY - $expectations) as $productVariance | if $productVariance > 0.0000001 then - $productVariance | debug | sqrt + $productVariance | sqrt else null end; @@ -32,7 +31,7 @@ def ingestionStandardDeviation($customUnits): if .customUnitId != null then ($customUnits | map(select(.id == $ingestion.customUnitId))[0]) as $customUnit | - ($ingestion | ingestionDose($customUnits) // 0) as $expectationX | + ($ingestion.dose // 0) as $expectationX | ($ingestion.estimatedDoseStandardDeviation // 0) as $standardDeviationX | ($customUnit.dose // 0) as $expectationY | ($customUnit.estimatedDoseStandardDeviation // 0) as $standardDeviationY | @@ -126,7 +125,8 @@ def ingestionInfo($customUnits): end | .unit |= $unit | - .dose += $dose; + .dose |= $dose | + .standardDeviation |= $standardDeviation; def addIngestionInfo($rhs): . as $lhs | @@ -144,7 +144,8 @@ def addIngestionInfo($rhs): .isEstimate |= true end | - .dose += $rhs.dose; + .dose += $rhs.dose | + .standardDeviation += $rhs.standardDeviation; def addIngestionInfos: . as $ingestionInfos |