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
9df3a458
Commit
9df3a458
authored
15 years ago
by
jacques.grelet_ird.fr
Browse files
Options
Downloads
Patches
Plain Diff
improve and correct bug during reading labview .ini configuration file
parent
ff34d2f4
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/readTsgIniLabview.m
+97
-80
97 additions, 80 deletions
tsg_io/readTsgIniLabview.m
with
97 additions
and
80 deletions
tsg_io/readTsgIniLabview.m
+
97
−
80
View file @
9df3a458
...
...
@@ -26,6 +26,10 @@ nc = dynaload('tsgqc_netcdf.csv');
nca_keys
=
keys
(
nc
.
ATTRIBUTES
);
ncv_keys
=
keys
(
nc
.
VARIABLES
);
% initialize contexte, eg [GLOBAL] in configuration file
% ------------------------------------------------------
context
=
[];
% read first line
% -------------
inputText
=
textscan
(
fid
,
'%s'
,
1
,
'delimiter'
,
'\n'
);
...
...
@@ -33,25 +37,32 @@ inputText = textscan(fid, '%s', 1, 'delimiter', '\n');
% test the end-of-file
% --------------------
while
~
feof
(
fid
)
% use string instead cell
% -----------------------
str
=
inputText
{
1
}{
1
};
% check if line define a context
% ------------------------------
match
=
regexp
(
str
,
'^\[(.+)\]$'
,
'tokens'
);
if
~
isempty
(
match
)
context
=
match
{
1
}{
1
};
end
% Iterate from each element from object nca and additional variables
% ------------------------------------------------------------------
for
ii
=
nca_keys
% get key, use char because i is cell
% -----------------------------------
clef
=
char
(
ii
);
% construct regex with pair cle=value
% and extract value
% ------------------------------------
regex
=
strcat
(
'^\s*'
,
clef
,
'\s*=\s*(
\w
.+)$'
);
regex
=
strcat
(
'^\s*'
,
clef
,
'\s*=\s*(.+)$'
);
match
=
regexp
(
str
,
regex
,
'tokens'
);
% build tsg struct
% ----------------
if
~
isempty
(
match
)
...
...
@@ -64,89 +75,95 @@ while ~feof(fid)
end
end
% Iterate from each element from object nca and additional variables
% ------------------------------------------------------------------
for
ii
=
ncv_keys
% get key, use char because i is cell
% -----------------------------------
clef
=
char
(
ii
);
% construct regex with pair cle=value and extract value
% simple variables are : SSPS_DEPH=8.00000000E+0
% coeff variables are : SSJT_CALCOEF_G=4,23058298E-3 or
% CNDC_LINCOEF_OFFSET=0.00000000E+0
% ------------------------------------
if
~
isempty
(
strfind
(
clef
,
'COEF'
))
regex
=
strcat
(
'^\s*'
,
clef
,
'_(\w+)?\s*=\s*(.*)$'
);
match
=
regexp
(
str
,
regex
,
'tokens'
);
elseif
~
isempty
(
strfind
(
clef
,
'DEPH'
))
regex
=
strcat
(
'^\s*'
,
clef
,
'\s*=\s*(.*)$'
);
%regex = strcat('^\s*\w*_DEPH_?\w*\s*=\s*(\w.+)$');
match
=
regexp
(
str
,
regex
,
'tokens'
);
else
match
=
[];
end
% check if we are is the right paragraph context
% ----------------------------------------------
if
strcmp
(
context
,
tsg
.
TYPE_TSG
)
||
strcmp
(
context
,
tsg
.
TYPE_TINT
)
%
build tsg struct
% ----------------
if
~
isempty
(
match
)
%
Iterate from each element from object nca and additional variables
% ----------------
--------------------------------------------------
for
ii
=
ncv_keys
% variable SSPS_DEPH return one match, SSJT_CALCOEF_G two
% -------------------------------------------------------
switch
size
(
match
{
1
},
2
)
% in case of calibration coefficients, have key/value pair
% --------------------------------------------------------
case
2
% get key
% --------
k
=
match
{
1
}{
1
};
% convert date in julian day when key is 'DATE', else to double
% -------------------------------------------------------------
if
strcmpi
(
k
,
'DATE'
)
v
=
datenumToJulian
(
datenum
(
match
{
1
}{
2
},
'dd/mm/yyyy'
));
else
v
=
str2double
(
match
{
1
}{
2
});
end
% add key to _CONV array, with length of STRING8
% ----------------------------------------------
tsg
.
([
clef
'_CONV'
])
=
[
tsg
.
([
clef
'_CONV'
]);
padding
(
k
,
8
)];
% add value to coefficients array
% -------------------------------
tsg
.
(
clef
)
=
[
tsg
.
(
clef
);
v
];
% for debbuging only
% ------------------
%fprintf('%s: %s -> %f\n', clef, k, v);
case
1
% add value to variable array
% ---------------------------
tsg
.
(
clef
)
=
str2double
(
match
{
1
}{
1
});
% for debbuging only
% ------------------
%fprintf('%s: %f\n', clef, tsg.(clef));
% get key, use char because i is cell
% -----------------------------------
clef
=
char
(
ii
);
% construct regex with pair cle=value and extract value
% simple variables are : SSPS_DEPH=8.00000000E+0
% coeff variables are : SSJT_CALCOEF_G=4,23058298E-3 or
% CNDC_LINCOEF_OFFSET=0.00000000E+0
% ------------------------------------
if
~
isempty
(
strfind
(
clef
,
'COEF'
))
regex
=
strcat
(
'^\s*'
,
clef
,
'_(\w+)?\s*=\s*(.*)$'
);
match
=
regexp
(
str
,
regex
,
'tokens'
);
elseif
~
isempty
(
strfind
(
clef
,
'DEPH'
))
regex
=
strcat
(
'^\s*'
,
clef
,
'\s*=\s*(.*)$'
);
%regex = strcat('^\s*\w*_DEPH_?\w*\s*=\s*(\w.+)$');
match
=
regexp
(
str
,
regex
,
'tokens'
);
else
match
=
[];
end
% quit for loop
% -------------
continue
% build tsg struct
% ----------------
if
~
isempty
(
match
)
% variable SSPS_DEPH return one match, SSJT_CALCOEF_G two
% -------------------------------------------------------
switch
size
(
match
{
1
},
2
)
% in case of calibration coefficients, have key/value pair
% --------------------------------------------------------
case
2
% get key
% --------
k
=
match
{
1
}{
1
};
% convert date in julian day when key is 'DATE', else to double
% -------------------------------------------------------------
if
strcmpi
(
k
,
'DATE'
)
v
=
datenumToJulian
(
datenum
(
match
{
1
}{
2
},
'dd/mm/yyyy'
));
else
v
=
str2double
(
match
{
1
}{
2
});
end
% add key to _CONV array, with length of STRING8
% ----------------------------------------------
tsg
.
([
clef
'_CONV'
])
=
[
tsg
.
([
clef
'_CONV'
]);
padding
(
k
,
8
)];
% add value to coefficients array
% -------------------------------
tsg
.
(
clef
)
=
[
tsg
.
(
clef
);
v
];
% for debbuging only
% ------------------
%fprintf('%s: %s -> %f\n', clef, k, v);
case
1
% add value to variable array
% ---------------------------
tsg
.
(
clef
)
=
str2double
(
match
{
1
}{
1
});
% for debbuging only
% ------------------
%fprintf('%s: %f\n', clef, tsg.(clef));
end
% quit for loop
% -------------
continue
end
% end of match
end
% end
of match
end
% end
ncv_keys
end
%
end ncv_keys
end
%
of of test in context
% read next line
% --------------
inputText
=
textscan
(
fid
,
'%s'
,
1
,
'delimiter'
,
'\n'
);
end
% end of while loop
% Save the data in the application GUI
...
...
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