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
07caa0be
Commit
07caa0be
authored
12 years ago
by
jacques.grelet_ird.fr
Browse files
Options
Downloads
Patches
Plain Diff
this file was moved to tsg_tools directory
parent
274955f3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tsg_util/netcdfTOtsgqc.m
+0
-211
0 additions, 211 deletions
tsg_util/netcdfTOtsgqc.m
with
0 additions
and
211 deletions
tsg_util/netcdfTOtsgqc.m
deleted
100644 → 0
+
0
−
211
View file @
274955f3
% Conversion d'une liste de fichier NetCDF TSG en fichier ASCCI
%
% La liste des fichiers netCDF doit tre plac dans un dichier ASCII.
% un nom de fichier par ligne
%
clear
all
;
clc
;
% Repertoire des fichiers NetCdf en lecture
% -----------------------------------------
dirIn
=
'D:\temp\'
;
% Repertoire des fichiers ASCII en criture
% -----------------------------------------
dirOut
=
dirIn
;
% Nom du fichier qui liste les fichiers netCdf
% --------------------------------------------
fichierListe
=
'list_nc.txt'
;
% Liste des paramtres crire - Create empty structure array
% ------------------------------------------------------------
PARA
=
{
'CNDC'
;
'CNDC_CAL'
;
...
'SSPS'
;
'SSPS_QC'
;
'SSPS_CAL'
;
...
'SSPS_ADJUSTED'
;
'SSPS_ADJUSTED_QC'
;
'SSPS_ADJUSTED_ERROR'
;
...
'SSJT'
;
'SSJT_QC'
;
'SSJT_CAL'
;
...
'SSJT_ADJUSTED'
;
'SSJT_ADJUSTED_QC'
;
'SSJT_ADJUSTED_ERROR'
;
...
'SSTP'
;
'SSTP_QC'
;
'SSTP_CAL'
;
...
'SSTP_ADJUSTED'
;
'SSTP_ADJUSTED_QC'
;
'SSTP_ADJUSTED_ERROR'
};
nPara
=
size
(
PARA
,
1
);
% Lecture du nom des fichiers convertir. Ceux-ci se trouvent dans
% le fichier liste_nc.txt
% -----------------------------------------------------------------
list_nc
=
textread
([
dirIn
fichierListe
],
'%s'
);
% Conversion du nom des fichiers en caracteres
% --------------------------------------------
list_nc
=
char
(
list_nc
);
% Boucle sur les fichiers convertir
% ----------------------------------
nfiles
=
size
(
list_nc
,
1
);
for
i
=
1
:
nfiles
% Create structure array
% ----------------------
tsg
=
struct
;
fileName
=
deblank
(
list_nc
(
i
,:));
display
(
[
'Traitement du fichier : '
fileName
]);
% Ouverture d'un fichier NetCdf en lecture
% ----------------------------------------
nc
=
netcdf
([
dirIn
fileName
],
'read'
);
if
~
isempty
(
nc
)
% Creation et ouverture du fichier en criture .tsgqc
% ---------------------------------------------------
ind
=
find
(
fileName
==
'.'
);
fileNameOut
=
fileName
(
1
:
ind
-
1
);
fid
=
fopen
([
dirOut
fileNameOut
'.tsgqc'
],
'wt'
);
display
(
[
' Ecriture du fichier : '
fileNameOut
]);
% --------------------------------
% Get global attributes: meta data
% --------------------------------
global_att
=
att
(
nc
);
for
iatt
=
1
:
length
(
global_att
)
% extract name and value from netcdf globals attributes
% -----------------------------------------------------
attribute
=
name
(
global_att
{
iatt
});
value
=
global_att
{
iatt
}(:);
% assign globals attributes in base workspace
% -------------------------------------------
assignin
(
'base'
,
attribute
,
value
);
% populate tsg structure with globals attributes
% ----------------------------------------------
tsg
.
(
attribute
)
=
value
;
end
% end of attributes loop
% ----------------------------
% Get variables describing TSG
% ----------------------------
variables
=
var
(
nc
);
for
ivar
=
1
:
length
(
variables
)
% extract name and value from netcdf variables
% --------------------------------------------
variable
=
name
(
variables
{
ivar
});
nv
=
nc
{
ivar
};
% use autonan mode, remplace fillValue with NaN
% ---------------------------------------------
nv
=
autonan
(
nv
,
true
);
% populate tsg structure with netcdf variables
% --------------------------------------------
tsg
.
(
variable
)
=
nv
(:);
% assign netcdf variables in base workspace
% -----------------------------------------
assignin
(
'base'
,
variable
,
nv
(:));
end
% end of variables loop
% Initialise le tableau des variables crire
% --------------------------------------------
nbRecords
=
length
(
tsg
.
DAYD
);
tsg_data
=
NaN
*
ones
(
nPara
+
8
,
nbRecords
);
% Selectionne les paramtres et cre le tableau en criture
% --------------------------------------------------------
if
nbRecords
~=
0
% Met en forme les dates et positions
% ------------------------------------
year
=
str2num
(
tsg
.
DATE
(:,
1
:
4
));
month
=
str2num
(
tsg
.
DATE
(:,
5
:
6
));
day
=
str2num
(
tsg
.
DATE
(:,
7
:
8
));
hour
=
str2num
(
tsg
.
DATE
(:,
10
:
11
));
min
=
str2num
(
tsg
.
DATE
(:,
12
:
13
));
sec
=
str2num
(
tsg
.
DATE
(:,
14
:
15
));
%[year, month, day, hour, min, sec] = datevec( julianToDatenum(tsg.DAYD) );
tsg_data
=
[
year
month
day
hour
min
fix
(
sec
)
tsg
.
LATX
mod
(
tsg
.
LONX
+
180
,
360
)
-
180
];
header
=
'YEAR MNTH DAYX hh mi ss LATX LONX'
;
format
=
'%04d %02d %02d %02d %02d %02d %12.7f %12.7f'
;
% Boucle sur les paramtres sauvegarder
% ---------------------------------------
for
iPara
=
1
:
nPara
% Slectionne le nom du paramtre
% -------------------------------
para
=
PARA
{
iPara
};
if
isempty
(
tsg
.
(
para
))
tsg
.
(
para
)
=
NaN
*
ones
(
size
(
tsg
.
DAYD
)
);
end
if
findstr
(
'_QC'
,
para
)
% Test pour contourner un bug de TSGQC. Les QC devaient tre casts
% en byte sinon la valeur 0 devenait gale -127
ind
=
0
;
ind
=
find
(
tsg
.
(
para
)
==
-
127
);
if
~
isempty
(
ind
)
tsg
.
(
para
)(
ind
)
=
0
;
end
tsg_data
=
[
tsg_data
double
(
tsg
.
(
para
))];
format
=
[
format
' %1d'
];
else
tsg_data
=
[
tsg_data
tsg
.
(
para
)];
format
=
[
format
' %6.3f'
];
end
header
=
[
header
' '
para
];
end
% Fin de boucle sur les paramtres sauvegarder
% Write some information
% ----------------------
if
~
isempty
(
tsg
.
DATE_CREATION
)
fprintf
(
fid
,
'%%DATE_CREATION %s\n'
,
tsg
.
DATE_CREATION
);
end
if
~
isempty
(
tsg
.
CYCLE_MESURE
)
fprintf
(
fid
,
'%%CYCLE_MESURE %s\n'
,
tsg
.
CYCLE_MESURE
);
end
if
~
isempty
(
tsg
.
PLATFORM_NAME
)
fprintf
(
fid
,
'%%PLATFORM_NAME %s\n'
,
tsg
.
PLATFORM_NAME
);
end
if
~
isempty
(
tsg
.
SHIP_CALL_SIGN
)
fprintf
(
fid
,
'%%SHIP_CALL_SIGN %s\n'
,
tsg
.
SHIP_CALL_SIGN
);
end
if
~
isempty
(
tsg
.
PI_NAME
)
fprintf
(
fid
,
'%%PI_NAME %s\n'
,
tsg
.
PI_NAME
);
end
if
~
isempty
(
tsg
.
DATA_ACQUISITION
)
fprintf
(
fid
,
'%%DATA_ACQUISITION %s\n'
,
tsg
.
DATA_ACQUISITION
);
end
% Write the file
% --------------
fprintf
(
fid
,
'%%HEADER %s\n'
,
header
);
fprintf
(
fid
,
[
format
'\n'
],
tsg_data
'
);
% Everything OK
% -------------
error
=
1
;
end
% Selectionne les paramtres et cre le tableau en criture
fclose
(
fid
);
% Clear the Workspace
% -------------------
clear
tsg
tsg_data
;
else
msg_error
=
'ok'
;
if
isempty
(
nc
)
msg_error
=
[
'Problem opening file : '
fileName
];
end
end
end
% Find Boucle sur les fichiers convertir
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