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
6d5ce556
Commit
6d5ce556
authored
17 years ago
by
jacques.grelet_ird.fr
Browse files
Options
Downloads
Patches
Plain Diff
add comments
if no data for <var>_WS and <var>_EXT, dimension DAYD_WS or DAYD_EXT are not defined
parent
723f788b
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/writeTSGDataNetCDF.m
+50
-29
50 additions, 29 deletions
tsg_io/writeTSGDataNetCDF.m
with
50 additions
and
29 deletions
tsg_io/writeTSGDataNetCDF.m
+
50
−
29
View file @
6d5ce556
...
...
@@ -13,7 +13,9 @@ function [error] = writeTSGDataNetCDF( hTsgGUI, filename)
%
% The data are store using setappdata - Variable name : 'tsg_data'
%
% Caution : replace the fill-value with NaN
% Actually, with DAYD, DAYD_WS and DAT_EXT dimensions defined: 61 variables
% DAYD, DAYD_WS dimensions defined: 57 variables
% DAYD only dimension defined: 53 variables
%
% $Id$
...
...
@@ -52,8 +54,8 @@ tsg = getappdata( hTsgGUI, 'tsg_data');
nca
=
tsg_nc
(
'tsg_ncattr.csv'
);
nca_keys
=
keys
(
nca
);
% Get
GF3
variables list codes from class tsg_nc with file 'tsg_ncvar.csv'
% --------------------------------------------------------------------
---
% Get variables list codes from class tsg_nc with file 'tsg_ncvar.csv'
% --------------------------------------------------------------------
ncv
=
tsg_nc
(
'tsg_ncvar.csv'
);
ncv_keys
=
keys
(
ncv
);
ncv_fieldNames
=
get_fieldnames
(
ncv
);
...
...
@@ -68,10 +70,31 @@ fprintf('...writing %s : ', filename);
% Variable dimensions
% -------------------
nc
(
'DAYD'
)
=
numel
(
tsg
.
DAYD
);
nc
(
'DAYD_WS'
)
=
numel
(
tsg
.
DAYD_WS
);
% number of water samples
nc
(
'DAYD_EXT'
)
=
numel
(
tsg
.
DAYD_EXT
);
% number of external SSPS or SSTP comparison
nc
(
'NCOEF_CAL'
)
=
5
;
% number of calibration coefficients
nc
(
'NCOEF_LIN'
)
=
2
;
% number of linearisation coefficients
% if dimension is empty (no data), don't create, because create empty
% dimension quive it unlimited dimension, but you can only have one
% unlimited dimension in a file
% --------------------------------------------------------------------
% number of water samples
% -----------------------
if
~
isempty
(
tsg
.
DAYD_WS
)
nc
(
'DAYD_WS'
)
=
numel
(
tsg
.
DAYD_WS
);
end
% number of external SSPS or SSTP comparison
% ------------------------------------------
if
~
isempty
(
tsg
.
DAYD_EXT
)
nc
(
'DAYD_EXT'
)
=
numel
(
tsg
.
DAYD_EXT
);
end
% number of calibration coefficients
% ----------------------------------
nc
(
'NCOEF_CAL'
)
=
5
;
% number of linearisation coefficients
% ------------------------------------
nc
(
'NCOEF_LIN'
)
=
2
;
% Fixed dimensions
% ----------------
...
...
@@ -99,8 +122,8 @@ for i=1:numel(ncv_keys)
dimension
=
get
(
ncv
,
variable
,
ncv_fieldNames
{
1
});
nctype
=
get
(
ncv
,
variable
,
ncv_fieldNames
{
2
});
%
defin
e dimension, value must be a cell
% --------------------------------------
%
create variabl
e dimension, value must be a cell
% --------------------------------------
---------
switch
nctype
case
'double'
nc
{
variable
}
=
ncdouble
(
dimension
);
...
...
@@ -118,13 +141,19 @@ for i=1:numel(ncv_keys)
nc
{
variable
}
=
ncfloat
(
dimension
);
end
% jump dimension and nctype field
% -------------------------------
%
create variable attribute,
jump dimension and nctype field
s
% -------------------------------
----------------------------
for
j
=
3
:
numel
(
ncv_fieldNames
)
fieldName
=
ncv_fieldNames
{
j
};
value
=
get
(
ncv
,
variable
,
fieldName
);
% if field is empy, it's not a attribute for this netcdf variable
% ---------------------------------------------------------------
if
~
isempty
(
value
)
% only two type for variable attribute: char or float, could be
% modified in the futur ...
% -------------------------------------------------------------
if
ischar
(
value
)
nc
{
variable
}
.
(
fieldName
)
=
ncchar
(
value
);
else
...
...
@@ -158,30 +187,22 @@ end
% Write measurements (variables)
% -------------------------------
for
i
=
1
:
numel
(
ncv_keys
)
% get netcdf variable name
% ------------------------
variable
=
ncv_keys
{
i
};
% display waitbar
% ---------------
waitbar
(
i
/
numel
(
ncv_keys
),
wb
,
[
'writing '
variable
' variable'
]);
% DATE as two dimension
% don't work under windows
% nc{variable}(:) = tsg.(variable);
%if strmatch('DATE', variable)
% nc{variable}(:,:) = tsg.(variable);
%else
% other one dimension
% under Linux, when you write an with empty matrix to an unlimited
% variable dimension, nc was corrupted to double object
% works well on windows
if
~
isempty
(
tsg
.
(
variable
))
%nc{variable}(1:length(tsg.(variable))) = tsg.(variable);
nc
{
variable
}(:)
=
tsg
.
(
variable
);
end
%end
% don't write value if empty data, netcdf use FillValue_ attribute
% in case of unlimited dimension, for example only, use:
% nc{variable}(1:length(tsg.(variable))) = tsg.(variable);
% ----------------------------------------------------------------
if
~
isempty
(
tsg
.
(
variable
))
nc
{
variable
}(:)
=
tsg
.
(
variable
);
end
end
% Close waitbar
...
...
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