Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TSG QC
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
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
US191
TSG QC
Commits
58bd18f8
Commit
58bd18f8
authored
15 years ago
by
gael.alory_legos.obs-mip.fr
Browse files
Options
Downloads
Patches
Plain Diff
voir message precedent (nouvelle routine a inclure)
parent
608ef9b8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tsg_io/readTsgDataSDF.m
+140
-0
140 additions, 0 deletions
tsg_io/readTsgDataSDF.m
with
140 additions
and
0 deletions
tsg_io/readTsgDataSDF.m
0 → 100644
+
140
−
0
View file @
58bd18f8
function
[
error
]
=
readTsgDataSDF
(
hMainFig
,
filename
)
% readAsciiTsg( hMainFig, filename )
% Function to read TSG data in SDF format
% (standard ORE-SSS format until 2005)
%
% Input
% -----
% hMainFig ........... Handle to the main user interface
% filename ........... Data filename
%
% Output
% ------
% error .............. 1: OK - -1 : an error occured
%
% Get the data from the application GUI
% -------------------------------------
tsg
=
getappdata
(
hMainFig
,
'tsg_data'
);
% Get the fieldnames of tsg structure
% -----------------------------------
tsgNames
=
fieldnames
(
tsg
);
nbFieldNames
=
length
(
tsgNames
);
% Get NO_CONTROL code value
% -------------------------
NO_CONTROL
=
tsg
.
qc
.
hash
.
NO_CONTROL
.
code
;
% Display read file info on console
% ---------------------------------
fprintf
(
'\nREAD_ASCII_FILE\n'
);
tic
;
% Open the file
% -------------
fid
=
fopen
(
filename
,
'rt'
);
% Check file
% -----------
if
fid
==
-
1
msg_error
=
[
'TSG_GOSUD file_lecture : Open file error : '
filename
];
warndlg
(
msg_error
,
'ASCII error dialog'
);
sprintf
(
'...cannot locate %s\n'
,
filename
);
error
=
-
1
;
return
;
end
% Display more info about read file on console
% --------------------------------------------
fprintf
(
'...reading %s : '
,
filename
);
% SDF format has no header
% Columns are:
% ? call_sign cyc_mes yyyymmddHHMM 100*latx 100*lonx 100*ssjt 1000*ssps
% ---------------------------------------------------------------------
format
=
'%s %s %s %s %d %d %d %d %d'
;
% Read the data in a cell
% -----------------------
cellData
=
textscan
(
fid
,
format
);
% Check the file is for a single ship/trip
% ----------------------------------------
nrecords
=
length
(
cellData
{
8
});
call_sign
=
char
(
cellData
{
2
}(
1
));
cycle_mesure
=
char
(
cellData
{
3
}(
1
));
if
~
isempty
(
find
(
call_sign
(
ones
(
1
,
nrecords
),:)
~=
char
(
cellData
{
2
})))
...
|
~
isempty
(
find
(
cycle_mesure
(
ones
(
1
,
nrecords
),:)
~=
char
(
cellData
{
3
})))
msg_error
=
[
'TSG_GOSUD file_lecture : Open file error : '
filename
];
warndlg
(
msg_error
,
'SDF error dialog'
);
sprintf
(
'...file %s contains data from several ships/trips\n'
,
filename
);
error
=
-
1
;
return
;
end
% Fill TSG attributes and variables
% ---------------------------------
tsg
.
SHIP_CALL_SIGN
=
call_sign
;
tsg
.
CYCLE_MESURE
=
cycle_mesure
;
tsg
.
report
.
tsgfile
=
filename
;
sec
=
'00'
;
tsg
.
DATE
=
cat
(
2
,
char
(
cellData
{
4
}),
sec
(
ones
(
1
,
nrecords
),:));
tsg
.
DAYD
=
datenum
(
tsg
.
DATE
,
'yyyymmddHHMMSS'
);
tsg
.
LATX
=
double
(
cellData
{
5
})/
100
;
tsg
.
LONX
=
double
(
cellData
{
6
})/
100
;
tsg
.
SSJT
=
double
(
cellData
{
7
})/
100
;
tsg
.
SSPS
=
double
(
cellData
{
8
})/
1000
;
% Fill external data variables
% ----------------------------
ext
=
find
(
cellData
{
9
}
~=
0
);
if
~
isempty
(
ext
)
next
=
length
(
ext
);
tsg
.
DATE_EXT
=
tsg
.
DATE
(
ext
,:);
tsg
.
DAYD_EXT
=
tsg
.
DAYD
(
ext
,:);
tsg
.
LATX_EXT
=
tsg
.
LATX
(
ext
,:);
tsg
.
LONX_EXT
=
tsg
.
LONX
(
ext
,:);
tsg
.
SSPS_EXT
=
double
(
cellData
{
9
}(
ext
,:))/
1000
;
tsg
.
SSTP_EXT
=
NaN
*
ones
(
next
,
1
);
tsg
.
SSPS_EXT_QC
=
int8
(
NO_CONTROL
)
*
int8
(
ones
(
next
,
1
));
tsg
.
SSTP_EXT_QC
=
int8
(
NO_CONTROL
)
*
int8
(
ones
(
next
,
1
));
type
=
'WS '
;
tsg
.
SSPS_EXT_TYPE
=
type
(
ones
(
1
,
next
),:);
type
=
'UNKN'
;
tsg
.
SSTP_EXT_TYPE
=
type
(
ones
(
1
,
next
),:);
date_anal
=
'19500101000000'
;
tsg
.
SSPS_EXT_ANALDATE
=
date_anal
(
ones
(
1
,
next
),
:);
nbottle
=
'0 '
;
tsg
.
SSPS_EXT_BOTTLE
=
nbottle
(
ones
(
1
,
next
),
:);
end
% populate tsg.file structure
% ---------------------------
[
tsg
.
file
.
pathstr
,
tsg
.
file
.
name
,
tsg
.
file
.
ext
,
tsg
.
file
.
versn
]
=
...
fileparts
(
filename
);
% Perform some automatic tests
% -----------------------------
automaticQC
(
hMainFig
);
tsg
.
file
.
type
=
'SDF'
;
% Save the data in the application GUI
% ------------------------------------
setappdata
(
hMainFig
,
'tsg_data'
,
tsg
);
% Close the file
% --------------
fclose
(
fid
);
% Display time to read file on console
% ------------------------------------
t
=
toc
;
fprintf
(
'...done (%6.2f sec).\n\n'
,
t
);
% Everything OK
% -------------
error
=
1
;
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