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
3d45e06f
Commit
3d45e06f
authored
17 years ago
by
Yves Gouriou
Browse files
Options
Downloads
Patches
Plain Diff
2007-11-27 Y.Gouriou fonction de correction D. Mathias
parent
617aadfe
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_util/dev_corMethod1.m
+52
-39
52 additions, 39 deletions
tsg_util/dev_corMethod1.m
with
52 additions
and
39 deletions
tsg_util/dev_corMethod1.m
+
52
−
39
View file @
3d45e06f
function
[
correction
]
=
dev_corMethod1
(
sample
,
TIME_WINDOWS
)
function
[
tsg
]
=
...
dev_corMethod1
(
tsg
,
sample
,
dateMin
,
dateMax
,
TIME_WINDOWS
)
%
% TO DO
% 1) Test if there are NaN values in 'sample':
% We could get some problem with the computation of the median and std
% 2) Initialisation de la structure 'cor'
%
% *************************************************************************
% The correction is computed between dateMin and dateMax
% ------------------------------------------------------
dt
=
find
(
sample
.
TIME
>=
dateMin
&
sample
.
TIME
<=
dateMax
);
% Calcul des valeurs medianes de correction: achaque point de
% comparaison, on attribue la mediane des corrections dans une fenetre de
% 10 jours. Puis on interpole entre chaque mediane pour avoir la correction
% a appliquer en chaque point de donnee TSG
% TO DO : Initialisation de la structure 'cor'
% --------------------------------------------
% Fenetre de temps = 10 jours pour le calcul des valeurs medianes de
% correction
% ------------------------------------------------------------------
COR_mediane
=
[
0
0
];
erreur_mediane
=
[
0
0
];
for
i
=
1
:
length
(
sample
)
% --------------------------------------------
for
i
=
1
:
length
(
dt
)
is
=
find
(
sample
.
TIME
>
sample
.
TIME
(
i
)
-
TIME_WINDOWS
/
2
&
...
sample
.
TIME
<
sample
.
TIME
(
i
)
+
TIME_WINDOWS
/
2
);
% Find the sample witihin TIME_WINDOWS
% ------------------------------------
ind
=
find
(
sample
.
TIME
(
dt
)
>=
sample
.
TIME
(
dt
(
i
))
-
TIME_WINDOWS
/
2
&
...
sample
.
TIME
(
dt
)
<=
sample
.
TIME
(
dt
(
i
))
+
TIME_WINDOWS
/
2
);
if
~
isempty
(
is
)
COR_mediane
=
[
COR_mediane
;
...
[
sample
.
TIME
(
i
)
median
(
sample
.
PSAL_DIF
(
is
))]];
erreur_mediane
=
[
erreur_mediane
;
...
[
std
(
sample
.
PSAL_DIF
(
is
))/
sqrt
(
length
(
is
))
length
(
is
)]];
% Compute the median difference and error witihn TIME_WINDOWS
% -----------------------------------------------------------
if
~
isempty
(
j
)
cor
.
TIME
(
i
)
=
sample
.
TIME
(
i
);
cor
.
DIFF
(
i
)
=
median
(
sample
.
PSAL_DIF
(
ind
));
cor
.
ERROR
(
i
)
=
std
(
sample
.
PSAL_DIF
(
ind
))/
sqrt
(
length
(
ind
));
cor
.
NVALUE
(
i
)
=
length
(
ind
);
end
end
% The error is maximum if the median is computed with less than 4 samples
% -----------------------------------------------------------------------
cor
.
ERROR
(
find
(
cor
.
NVALUE
<
4
)
)
=
1
;
COR_mediane
=
COR_mediane
(
2
:
length
(
COR_mediane
),:);
erreur_mediane
=
erreur_mediane
(
2
:
length
(
erreur_mediane
),:);
erreur_mediane
(
find
(
erreur_mediane
(:,
2
)
<
4
),
1
)
=
1
;
% The correction is applied between dateMin and dateMax
% We attribute to dateMin the first correction computed
% and to dateMax the last one
%
% Find the tsg date in the interval dateMin-dateMax
% -------------------------------------------------
dtTsg
=
find
(
tsg
.
TIME
>=
dateMin
&
tsg
.
TIME
<=
dateMax
);
% Complete les series de correction PAS TRES BON
if
COR_mediane
(
1
,
1
)
~=
tsg
.
TIME
(
1
)
COR_mediane
=
[[
tsg
.
TIME
(
1
)
COR_mediane
(
1
,
2
)];
COR_mediane
];
if
cor
.
TIME
(
1
)
~=
dateMin
cor
.
TIME
=
[
tsg
.
TIME
(
dtTsg
(
1
))
cor
.
TIME
];
cor
.
DIFF
=
[
cor
.
DIFF
(
1
)
cor
.
DIFF
];
cor
.
ERROR
=
[
cor
.
ERROR
(
1
)
cor
.
ERROR
];
cor
.
NVALUE
=
[
cor
.
NVALUE
(
1
)
cor
.
NVALUE
];
end
% Pas très bon : La correction ne doit pas être appliquée + de 10 jours
% avant ou après le dernier echantillon
% --------------------------------------------------------------------
if
COR_mediane
(
length
(
COR_mediane
),
1
)
~=
tsg
.
TIME
(
end
)
COR_mediane
=
[
COR_mediane
;
...
[
tsg
.
TIME
(
end
)
...
COR_mediane
(
length
(
COR_mediane
),
2
)]];
if
cor
.
TIME
(
end
)
~=
dateMax
cor
.
TIME
=
[
cor
.
TIME
tsg
.
TIME
(
dtTsg
(
end
))];
cor
.
DIFF
=
[
cor
.
DIFF
cor
.
DIFF
(
end
)];
cor
.
ERROR
=
[
cor
.
ERROR
cor
.
ERROR
(
end
)];
cor
.
NVALUE
=
[
cor
.
NVALUE
cor
.
NVALUE
(
end
)];
end
COR
=
interp1
(
COR_mediane
(:,
1
),
COR_mediane
(:,
2
),
tsg
.
TIME
);
% The correction is applied to the TSG between dateMin and dateMax using
% a linear interpolation
% ----------------------------------------------------------------------
tsg
.
PSAL_ADJ
(
dtTsg
)
=
tsg
.
PSAL
(
dtTsg
)
+
...
interp1
(
cor
.
TIME
,
cor
.
DIFF
,
tsg
.
TIME
(
dtTsg
));
tsg
.
PSAL_ERR
(
dtTsg
)
=
interp1
(
cor
.
TIME
,
cor
.
ERROR
,
tsg
.
TIME
(
dtTsg
));
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