Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
artoa4argo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
argoTools
artoa4argo
Commits
9b2e81ab
Commit
9b2e81ab
authored
5 years ago
by
leprob001
Browse files
Options
Downloads
Patches
Plain Diff
Added export function of startEndToa and its test.
parent
0b071390
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
+tests/+startendtoa/save.m
+74
-0
74 additions, 0 deletions
+tests/+startendtoa/save.m
lib/+artoa/+save/startEndToa.m
+98
-0
98 additions, 0 deletions
lib/+artoa/+save/startEndToa.m
with
172 additions
and
0 deletions
+tests/+startendtoa/save.m
0 → 100644
+
74
−
0
View file @
9b2e81ab
function
[
success
]
=
save
()
%SAVE Test function for saving a start end toa file.
% Uses a test rfb data file from the data folder. Uses only dummy fields
% for saving, because the actual algorithm for creating the data is not yet
% implemented.
[
currentDirectory
,
~
,
~
]
=
fileparts
(
mfilename
(
'fullpath'
));
dataFileName
=
fullfile
(
currentDirectory
,
'..'
,
'data'
,
'0272.rfb'
);
% Select trajectory number
track
=
2
;
rfb
=
artoa
.
load
.
rfb
(
dataFileName
);
% load test mat file exported from old version of artoa3
load
(
fullfile
(
currentDirectory
,
'..'
,
'data'
,
'float_0272_globals.mat'
));
% get global variables that have been imported from the mat file
global
TOA_DATE
TOA
TOA_SEL
SOSOREF
afoffbeg
afoffend
% convert global variables to toaData format
toa
=
struct
();
toa
.
status
=
zeros
(
length
(
TOA
),
1
);
toa
.
status
(
TOA_SEL
>
0
)
=
1
;
% marks that the toa has been selected
toa
.
toa
=
TOA
;
toa
.
toaDate
=
TOA_DATE
;
toa
.
soundSource
=
cell
(
length
(
TOA
),
1
);
toa
.
soundSource
(:)
=
{
''
};
for
i
=
1
:
length
(
toa
.
soundSource
)
if
TOA_SEL
(
i
)
==
0
continue
;
end
toa
.
soundSource
{
i
}
=
strtrim
(
SOSOREF
(
TOA_SEL
(
i
),
:));
end
%% Setup trajectory
trajectory
=
struct
();
trajectory
.
trackingMethod
=
TRAJ
(
track
)
.
tmethod
;
trajectory
.
interval
=
TRAJ
(
track
)
.
interval
;
trajectory
.
gapSize
=
TRAJ
(
track
)
.
gapsize
;
trajectory
.
interpolationMethod
=
TRAJ
(
track
)
.
imethod
;
trajectory
.
soundSpeedMethod
=
TRAJ
(
track
)
.
ssmethod
;
trajectory
.
dopplerCorrection
=
TRAJ
(
track
)
.
doppler
;
trajectory
.
velocityMethod
=
TRAJ
(
track
)
.
vmethod
;
trajectory
.
status
=
TRAJ
(
track
)
.
status
;
trajectory
.
toaData
=
toa
;
trajectory
.
latitude
=
TRAJ
(
track
)
.
lat
;
trajectory
.
longitude
=
TRAJ
(
track
)
.
lon
;
trajectory
.
date
=
TRAJ
(
track
)
.
date
;
trajectory
.
pressure
=
TRAJ
(
track
)
.
pres
;
trajectory
.
temperature
=
TRAJ
(
track
)
.
temp
;
trajectory
.
iflag
=
TRAJ
(
track
)
.
iflag
;
trajectory
.
clockError
=
TRAJ
(
track
)
.
clockerror
;
trajectory
.
misfits
=
TRAJ
(
track
)
.
misfits
;
trajectory
.
residualsPlotted
=
TRAJ
(
track
)
.
plotresiduals
;
trajectory
.
velocityTotal
=
TRAJ
(
track
)
.
vtot
;
trajectory
.
velocityLatitude
=
TRAJ
(
track
)
.
vlat
;
trajectory
.
velocityLongitude
=
TRAJ
(
track
)
.
vlon
;
trajectory
.
velocityVertical
=
TRAJ
(
track
)
.
vvert
;
trajectory
.
velocityVerticalDate
=
TRAJ
(
track
)
.
vvert_date
;
trajectory
.
additionalFloatOffsetBegin
=
afoffbeg
;
trajectory
.
additionalFloatOffsetEnd
=
afoffend
;
%% Setup sound sources
soundsources
=
artoa
.
load
.
soundsources
(
fullfile
(
currentDirectory
,
'..'
,
'data'
,
'HAFOS.soso'
));
%% Save data
saveToFilename
=
fullfile
(
currentDirectory
,
'..'
,
'data'
,
'startEndToaOutput.trj4'
);
success
=
artoa
.
save
.
startEndToa
(
saveToFilename
,
trajectory
,
soundsources
);
end
This diff is collapsed.
Click to expand it.
lib/+artoa/+save/startEndToa.m
0 → 100644
+
98
−
0
View file @
9b2e81ab
function
[
success
]
=
startEndToa
(
pFilename
,
pTrajectory
,
pSoundSources
)
%STARTENDTOA Saves the given data in start end toa format.
% Saves start and ending position of the given float.
%
% Parameters:
% pFilename (string) The destination filename.
% pSoundSources (struct) The sound sources loaded using
% artoa.load.soundsource function.
% pTrajectory (struct) The trajectory data according to the memory
% data format specification, see projects wiki.
%% Initialize return variables
success
=
false
;
%% Initialize variables required for processing and defaults
noSoundSource
=
'No SoSo'
;
dataString
=
''
;
%% Parameter check
parameterError
=
false
;
if
(
~
isstring
(
pFilename
)
&&
~
ischar
(
pFilename
))
warning
([
mfilename
': Given filename is neither a string nor a char!'
]);
parameterError
=
true
;
end
if
(
~
isstruct
(
pSoundSources
))
warning
([
mfilename
': Given sound source data is not a struct!'
]);
parameterError
=
true
;
end
if
(
~
isstruct
(
pTrajectory
))
warning
([
mfilename
': Given trajectory data is not a struct!'
]);
parameterError
=
true
;
end
if
(
parameterError
)
return
;
else
clear
parameterError
;
end
%% Collect data
indexStart
=
find
(
...
pTrajectory
.
toaData
.
toaDate
==
min
(
pTrajectory
.
toaData
.
toaDate
)
...
);
indexEnd
=
find
(
...
pTrajectory
.
toaData
.
toaDate
==
max
(
pTrajectory
.
toaData
.
toaDate
)
...
);
% Collect toa
startToa
=
pTrajectory
.
toaData
.
toa
(
indexStart
);
endToa
=
pTrajectory
.
toaData
.
toa
(
indexEnd
);
% Collect toa date
startToaDate
=
pTrajectory
.
toaData
.
toaDate
(
indexStart
);
endToaDate
=
pTrajectory
.
toaData
.
toaDate
(
indexEnd
);
% Collect sound source names
startSources
=
pTrajectory
.
toaData
.
soundSource
(
indexStart
);
endSources
=
pTrajectory
.
toaData
.
soundSource
(
indexEnd
);
% Replace non selected soundsources by default string
startNotSelectedIndices
=
contains
(
startSources
,
''
);
startSources
(
startNotSelectedIndices
)
=
{
noSoundSource
};
endNotSelectedIndices
=
contains
(
endSources
,
''
);
endSources
(
endNotSelectedIndices
)
=
{
noSoundSource
};
for
i
=
1
:
length
(
startToa
)
dataString
=
[
dataString
...
num2str
(
startToaDate
(
i
))
' '
...
num2str
(
startToa
(
i
))
' '
...
startSources
{
i
}
' '
...
num2str
(
endToaDate
(
i
))
' '
...
num2str
(
endToa
(
i
))
' '
...
endSources
{
i
}
newline
...
];
end
%% Save to file
saveToFile
(
pFilename
,
''
,
dataString
);
%% Update return variable
success
=
true
;
%% Nested functions
function
saveToFile
(
pFilename
,
pHeader
,
pData
)
fid
=
fopen
(
pFilename
,
'w'
);
fprintf
(
fid
,
pHeader
);
fprintf
(
fid
,
pData
);
fclose
(
fid
);
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment