From 0f89a9d1d29ceeb73d1afc2bc34a8f453d02ace8 Mon Sep 17 00:00:00 2001
From: Lewin Probst <info@emirror.de>
Date: Wed, 11 Dec 2019 09:21:29 +0100
Subject: [PATCH] Small Bugfixes.

---
 VERSION                             | 2 +-
 lib/+artoa/+controller/+track/run.m | 7 +++++++
 lib/+artoa/+trajectory/calculate.m  | 9 +++++++--
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/VERSION b/VERSION
index 3fdc173..d800886 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-122
\ No newline at end of file
+123
\ No newline at end of file
diff --git a/lib/+artoa/+controller/+track/run.m b/lib/+artoa/+controller/+track/run.m
index ebdacbe..5072436 100644
--- a/lib/+artoa/+controller/+track/run.m
+++ b/lib/+artoa/+controller/+track/run.m
@@ -109,6 +109,13 @@ trajectoryObject.clockError = trajectoryClockError;
 trajectoryObject.residuals = trajectoryResiduals;
 trajectoryObject.velocities = trajectoryVelocities;
 trajectoryObject.timeDivergenceToGps = trajectoryTimeDivergenceToGps;
+% find pressure and temperature values
+selectedIndices = (artoaWorkspace.statusPressure == 1) & (artoaWorkspace.statusTemperature == 1);
+[~, dateIndices, indices] = intersect(trajectoryDates, artoaWorkspace.rafosDate(selectedIndices));
+trajectoryObject.pressure = NaN(size(trajectoryDates));
+trajectoryObject.pressure(dateIndices) = artoaWorkspace.pressure(indices);
+trajectoryObject.temperature = NaN(size(trajectoryDates));
+trajectoryObject.temperature(dateIndices) = artoaWorkspace.temperature(indices);
 
 %% Generate trajectory id
 if isempty(artoaWorkspace.trajectoryOutput.trajectories)
diff --git a/lib/+artoa/+trajectory/calculate.m b/lib/+artoa/+trajectory/calculate.m
index ed5199c..e4927c6 100644
--- a/lib/+artoa/+trajectory/calculate.m
+++ b/lib/+artoa/+trajectory/calculate.m
@@ -225,7 +225,10 @@ for oCombination = 1:size(soundsourceCombinations, 1)
     % set reference point to the last position of trajectory if not set
     % manually
     currentCombination = soundsourceCombinations(oCombination, :);
-    if isempty(currentCombination.referencePosition{1})
+    if isempty(currentCombination.referencePosition{1}) ...
+            && isempty(trajectory)
+        return;
+    elseif isempty(currentCombination.referencePosition{1})
         currentCombination.referencePosition{1} = num2str(trajectory(end, :));
     end
     [segmentPositions, segmentDates, segmentClockError, segmentResiduals] = artoa.trajectory.calculateCombinationSegment( ...
@@ -291,7 +294,9 @@ for oCombination = 1:size(soundsourceCombinations, 1)
     
     % calculate vertical velocities
     % get intersecting dates
-    verticalVelocityDates = intersect(pPressureAndDate{2}, segmentDates);
+    %verticalVelocityDates = NaN(size(segmentDates));
+    [verticalVelocityDates, ~, indicesDates] = intersect(pPressureAndDate{2}, segmentDates);
+    %verticalVelocityDates(indicesDates) = segmentDates(indicesDates);
     [segmentVerticalVelocity, segmentVerticalDates] = artoa.trajectory.verticalVelocity( ...
         verticalVelocityDates, ...
         pPressureAndDate{1}(ismember(pPressureAndDate{2}, verticalVelocityDates)), ...
-- 
GitLab