Skip to content

Commit

Permalink
decArgo_20220428_049a commit
Browse files Browse the repository at this point in the history
  • Loading branch information
couppeym committed Nov 24, 2022
1 parent 48bbd82 commit fa5950c
Show file tree
Hide file tree
Showing 64 changed files with 9,379 additions and 15,764 deletions.
Binary file modified decArgo_doc/decoder_versions/_argo_decoder_versions.xlsx
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@
% output parameters initialization
o_profStruct = [];

% current float WMO number
global g_decArgo_floatNum;

% current cycle number
global g_decArgo_cycleNum;

% default values
global g_decArgo_dateDef;

Expand All @@ -46,7 +40,6 @@

% QC flag values (char)
global g_decArgo_qcStrNoQc;
global g_decArgo_qcStrInterpolated;


% add profile date dans location
Expand Down Expand Up @@ -111,56 +104,6 @@
a_profStruct.locationQc = g_decArgo_qcStrNoQc;
a_profStruct.iridiumLocation = 0;

elseif (a_profStruct.date ~= g_decArgo_dateDef)

% there is no GPS locations for the previous cycle, we must interpolate
% between existing GPS locations
prevLocDate = g_decArgo_dateDef;
nextLocDate = g_decArgo_dateDef;

% find the previous GPS location
idPrev = find((gpsLocDate <= a_profStruct.date) & (gpsLocQc == 1));
if (~isempty(idPrev))
% previous good GPS locations exist, use the last one
[~, idMax] = max(gpsLocDate(idPrev));
prevLocDate = gpsLocDate(idPrev(idMax));
prevLocLon = gpsLocLon(idPrev(idMax));
prevLocLat = gpsLocLat(idPrev(idMax));
end

% find the next GPS location
idNext = find((gpsLocDate >= a_profStruct.date) & (gpsLocQc == 1));
if (~isempty(idNext))
% next good GPS locations exist, use the first one
[~, idMin] = min(gpsLocDate(idNext));
nextLocDate = gpsLocDate(idNext(idMin));
nextLocLon = gpsLocLon(idNext(idMin));
nextLocLat = gpsLocLat(idNext(idMin));
end

% interpolate between the 2 locations
if ((prevLocDate ~= g_decArgo_dateDef) && (nextLocDate ~= g_decArgo_dateDef))

% interpolate the locations
[interpLocLon, interpLocLat] = interpolate_between_2_locations(...
prevLocDate, prevLocLon, prevLocLat, ...
nextLocDate, nextLocLon, nextLocLat, ...
a_profStruct.date);

if (~isnan(interpLocLon))
% assign the interpolated location to the profile
a_profStruct.locationDate = a_profStruct.date;
a_profStruct.locationLon = interpLocLon;
a_profStruct.locationLat = interpLocLat;
a_profStruct.locationQc = g_decArgo_qcStrInterpolated;
a_profStruct.iridiumLocation = 0;
a_profStruct.posSystem = 'GPS';
else
fprintf('WARNING: Float #%d Cycle #%d: time inconsistency detected while interpolating for profile location processing - profile not located\n', ...
g_decArgo_floatNum, ...
g_decArgo_cycleNum);
end
end
end
end

Expand All @@ -180,8 +123,23 @@

% positioning system
a_profStruct.posSystem = 'IRIDIUM';

else

[locDate, locLon, locLat, locQc, ~] = ...
compute_profile_location2_from_iridium_locations_ir_sbd(a_iridiumMailData, a_profStruct.cycleNumber-1);
if (~isempty(locDate))
% assign the averaged Iridium location to the profile
a_profStruct.locationDate2 = locDate;
a_profStruct.locationLon2 = locLon;
a_profStruct.locationLat2 = locLat;
a_profStruct.locationQc2 = locQc;
a_profStruct.iridiumLocation2 = 1;

% positioning system
a_profStruct.posSystem2 = 'IRIDIUM';
end
end

end

else
Expand Down Expand Up @@ -237,62 +195,13 @@
a_profStruct.locationQc = num2str(gpsLocQc(idLocCy(idMin))); % it is '1'
a_profStruct.iridiumLocation = 0;

elseif (a_profStruct.date ~= g_decArgo_dateDef)

% there is no good GPS locations for this cycle, we must interpolate between
% the existing GPS locations
prevLocDate = g_decArgo_dateDef;
nextLocDate = g_decArgo_dateDef;

% find the previous GPS location
idPrev = find((gpsLocDate <= a_profStruct.date) & (gpsLocQc == 1));
if (~isempty(idPrev))
% previous good GPS locations exist, use the last one
[~, idMax] = max(gpsLocDate(idPrev));
prevLocDate = gpsLocDate(idPrev(idMax));
prevLocLon = gpsLocLon(idPrev(idMax));
prevLocLat = gpsLocLat(idPrev(idMax));
end

% find the next GPS location
idNext = find((gpsLocDate >= a_profStruct.date) & (gpsLocQc == 1));
if (~isempty(idNext))
% next good GPS locations exist, use the first one
[~, idMin] = min(gpsLocDate(idNext));
nextLocDate = gpsLocDate(idNext(idMin));
nextLocLon = gpsLocLon(idNext(idMin));
nextLocLat = gpsLocLat(idNext(idMin));
end

% interpolate between the 2 locations
if ((prevLocDate ~= g_decArgo_dateDef) && (nextLocDate ~= g_decArgo_dateDef))

% interpolate the locations
[interpLocLon, interpLocLat] = interpolate_between_2_locations(...
prevLocDate, prevLocLon, prevLocLat, ...
nextLocDate, nextLocLon, nextLocLat, ...
a_profStruct.date);

if (~isnan(interpLocLon))
% assign the interpolated location to the profile
a_profStruct.locationDate = a_profStruct.date;
a_profStruct.locationLon = interpLocLon;
a_profStruct.locationLat = interpLocLat;
a_profStruct.locationQc = g_decArgo_qcStrInterpolated;
a_profStruct.iridiumLocation = 0;
a_profStruct.posSystem = 'GPS';
else
fprintf('WARNING: Float #%d Cycle #%d: time inconsistency detected while interpolating for profile location processing - profile not located\n', ...
g_decArgo_floatNum, ...
g_decArgo_cycleNum);
end
end
end
end

% we have not been able to set a location for the profile, we will use the
% Iridium locations
if (a_profStruct.locationDate == g_decArgo_dateDef)

[locDate, locLon, locLat, locQc, ~] = ...
compute_profile_location_from_iridium_locations_ir_sbd(a_iridiumMailData, a_profStruct.cycleNumber);
if (~isempty(locDate))
Expand All @@ -302,9 +211,25 @@
a_profStruct.locationLat = locLat;
a_profStruct.locationQc = locQc;
a_profStruct.iridiumLocation = 1;

% positioning system
a_profStruct.posSystem = 'IRIDIUM';

else

[locDate, locLon, locLat, locQc, ~] = ...
compute_profile_location2_from_iridium_locations_ir_sbd(a_iridiumMailData, a_profStruct.cycleNumber);
if (~isempty(locDate))
% assign the averaged Iridium location to the profile
a_profStruct.locationDate2 = locDate;
a_profStruct.locationLon2 = locLon;
a_profStruct.locationLat2 = locLat;
a_profStruct.locationQc2 = locQc;
a_profStruct.iridiumLocation2 = 1;

% positioning system
a_profStruct.posSystem2 = 'IRIDIUM';
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,51 @@
o_tabProfiles(idP) = prof;
end

% Loop 6: extrapolate existing locations
profList = find(([o_tabProfiles.date] ~= g_decArgo_dateDef) & ...
([o_tabProfiles.locationDate] == g_decArgo_dateDef));
if (~isempty(profList))

idF = find([o_tabProfiles.date] < o_tabProfiles(profList(1)).date);

% look for the previous cycles
cyDateList = [o_tabProfiles(idF).date];
cyLonList = [o_tabProfiles(idF).locationLon];
cyLatList = [o_tabProfiles(idF).locationLat];
[~, idUnique, ~] = unique(cyDateList);
cyDateList = cyDateList(idUnique);
cyLonList = cyLonList(idUnique);
cyLatList = cyLatList(idUnique);

if (length(cyDateList) > 1)

% extrapolate the locations
[extrapLocLon, extrapLocLat] = extrapolate_locations(...
cyDateList(end-1), ...
cyLonList(end-1), ...
cyLatList(end-1), ...
cyDateList(end), ...
cyLonList(end), ...
cyLatList(end), ...
[o_tabProfiles(profList).date]);

% assign the extrapolated location to the profile
for id = 1:length(profList)
o_tabProfiles(profList(id)).locationDate = o_tabProfiles(profList(id)).date;
o_tabProfiles(profList(id)).locationLon = extrapLocLon(id);
o_tabProfiles(profList(id)).locationLat = extrapLocLat(id);
o_tabProfiles(profList(id)).locationQc = g_decArgo_qcStrInterpolated;
end
else

% use the launch location with a POSITION_QC=3
for id = 1:length(profList)
o_tabProfiles(profList(id)).locationDate = o_tabProfiles(profList(id)).date;
o_tabProfiles(profList(id)).locationLon = a_gpsLocLon(a_gpsLocCycleNum == -1);
o_tabProfiles(profList(id)).locationLat = a_gpsLocLat(a_gpsLocCycleNum == -1);
o_tabProfiles(profList(id)).locationQc = g_decArgo_qcStrCorrectable;
end
end
end

return
Loading

0 comments on commit fa5950c

Please sign in to comment.