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
a712bef1
Commit
a712bef1
authored
15 years ago
by
gael.alory_legos.obs-mip.fr
Browse files
Options
Downloads
Patches
Plain Diff
nouveau module de lecture pour fichiers Astrolabe (*.ast)
parent
b85b43e1
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/readAsciiAstro.m
+193
-0
193 additions, 0 deletions
tsg_io/readAsciiAstro.m
with
193 additions
and
0 deletions
tsg_io/readAsciiAstro.m
0 → 100755
+
193
−
0
View file @
a712bef1
function
[
error
]
=
readAsciiTsg
(
hMainFig
,
filename
)
% readAsciiTsg( hMainFig, filename )
% Function to read TSG data in ASCII format.
%
% Input
% -----
% hMainFig ........... Handle to the main user interface
% filename ........... Data filename
% type ............... Can read 3 types of data : WS, EXT, TSG
%
% Output
% ------
% error .............. 1: OK - -1 : an error occured
%
% $Id: readAsciiTsg.m 457 2009-03-23 14:00:24Z jgrelet $
% 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
);
% Read the header till the header line has been read
% --------------------------------------------------
OK
=
0
;
while
~
OK
% Read every line
% ---------------
line
=
fgetl
(
fid
);
c
=
textscan
(
line
,
'%s'
);
switch
char
(
c
{
1
}(
1
)
)
case
'%HEADER'
% Read the header then quit the while loop
% ----------------------------------------
header
=
c
{
1
}(
2
:
end
);
nHeader
=
length
(
header
);
OK
=
1
;
otherwise
% Get the parameter Name (Delete '%')
% ----------------------------------
Para
=
char
(
strtok
(
c
{
1
}(
1
),
'%'
)
);
% Read the parameter value
% ------------------------
ind
=
strmatch
(
Para
,
tsgNames
);
if
~
isempty
(
ind
)
% patch added for composed name
% -----------------------------
a
=
c
{
1
}(
2
:
end
)
'
;
str
=
[];
for
i
=
a
str
=
sprintf
(
'%s %s'
,
str
,
char
(
i
));
end
% copy to tsg struct & remove leading and trailing white space
% ------------------------------------------------------------
tsg
.
(
Para
)
=
strtrim
(
str
);
end
end
end
% Builld the format depending on the header parameters
% 1 - Decimate the HEADER - The 5th first parameters are always
% %HEADER YEAR MNTH DAYX hh mm ss
% 2 - The 4 Date and time parametes are read in %d
% -------------------------------------------------------------
format
=
'%s %d %d %d'
;
for
i
=
5
:
nHeader
format
=
[
format
' %f'
];
end
% Read the data in a cell
% -----------------------
cellData
=
textscan
(
fid
,
format
);
% Convert cell to a structure
% ---------------------------
s
=
cell2struct
(
cellData
,
header
,
2
);
clear
cellData
% Date (y m d h m s) in the first 4 elements in data
% --------------------------------------------------
ddmmyy
=
char
(
s
.
(
char
(
header
(
1
))))
;
%ddmmyy_str = sprintf('%06d', ddmmyy);
dd
=
str2num
(
ddmmyy
(:,
1
:
2
));
mm
=
str2num
(
ddmmyy
(:,
3
:
4
));
yy
=
2000
+
str2num
(
ddmmyy
(:,
5
:
6
));
% Attn: valab apres 2000!
hh
=
double
(
s
.
(
char
(
header
(
2
)))
);
mi
=
double
(
s
.
(
char
(
header
(
3
)))
);
ss
=
double
(
s
.
(
char
(
header
(
4
)))
);
tsg
.
report
.
tsgfile
=
filename
;
tsg
.
DAYD
=
datenum
(
yy
,
mm
,
dd
,
hh
,
mi
,
ss
);
tsg
.
DATE
=
datestr
(
tsg
.
DAYD
,
'yyyymmddHHMMSS'
);
nHeader
=
length
(
header
);
for
i
=
5
:
nHeader
% QC should be converted in int8
% ----------------------------------
if
~
isempty
(
strfind
(
char
(
header
(
i
)),
'_QC'
))
tsg
.
(
char
(
header
(
i
)))
=
int8
(
s
.
(
char
(
header
(
i
))));
else
tsg
.
(
char
(
header
(
i
)))
=
s
.
(
char
(
header
(
i
)));
end
end
flag
=
1
;
%par defaut, tout a Good
miss
=-
90
;
tsg
.
SSTP_QC
=
repmat
(
flag
,[
length
(
tsg
.
DAYD
)
1
]);
tsg
.
SSPS_QC
=
repmat
(
flag
,[
length
(
tsg
.
DAYD
)
1
]);
tsg
.
SSTP
(
tsg
.
SSTP
<
miss
)
=
nan
;
tsg
.
SSPS
(
tsg
.
SSPS
<
miss
)
=
nan
;
tsg
.
SSJT
(
tsg
.
SSJT
<
miss
)
=
nan
;
tsg
.
SSTP_QC
(
isnan
(
tsg
.
SSTP
))
=
nan
;
tsg
.
SSPS_QC
(
isnan
(
tsg
.
SSPS
))
=
nan
;
tsg
.
PLATFORM_NAME
=
'astrolabe'
;
tsg
.
SHIP_CALL_SIGN
=
'FHZI'
;
tsg
.
PROJECT_NAME
=
'SURVOSTRAL'
;
tsg
.
PI_NAME
=
'Rosemary Morrow'
;
tsg
.
DATA_ACQUISITION
=
'IPEV'
;
tsg
.
PROCESSING_CENTRE
=
'SURVOSTRAL'
;
tsg
.
PROCESSING_STATES
=
'2C+'
;
tsg
.
SAMPLING_PERIOD
=
'60'
;
% populate tsg.file structure
% ---------------------------
[
tsg
.
file
.
pathstr
,
tsg
.
file
.
name
,
tsg
.
file
.
ext
,
tsg
.
file
.
versn
]
=
...
fileparts
(
filename
);
% Perform somme automatic tests
% -----------------------------
automaticQC
(
hMainFig
);
tsg
.
file
.
type
=
'ASCII'
;
% 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