Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
a44917d8
Commit
a44917d8
authored
Sep 15, 2008
by
Uwe Schulzweida
Browse files
cdfReadVarSliceDP: add swapxy support
parent
c03408a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
a44917d8
...
...
@@ -2,6 +2,8 @@
* add new function: streamSync
* add new taxis functions: taxisXXXVdateBounds and taxisXXXVtimeBounds
* cdfReadVarSliceDP: add swapxy support
* netcdf: support of timeunit 'year'
* Version 1.2.1 released
2008-08-13 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
...
...
src/stream_cdf.c
View file @
a44917d8
...
...
@@ -741,7 +741,9 @@ void cdfDefTime(int streamID)
unitstr
[
0
]
=
0
;
if
(
streamptr
->
tsteps
[
0
].
taxis
.
type
==
TAXIS_ABSOLUTE
)
{
if
(
streamptr
->
tsteps
[
0
].
taxis
.
unit
==
TUNIT_MONTH
)
if
(
streamptr
->
tsteps
[
0
].
taxis
.
unit
==
TUNIT_YEAR
)
sprintf
(
unitstr
,
"year as %s"
,
"%Y.%f"
);
else
if
(
streamptr
->
tsteps
[
0
].
taxis
.
unit
==
TUNIT_MONTH
)
sprintf
(
unitstr
,
"month as %s"
,
"%Y%m.%f"
);
else
sprintf
(
unitstr
,
"day as %s"
,
"%Y%m%d.%f"
);
...
...
@@ -2719,6 +2721,7 @@ int cdfReadVarSliceDP(int streamID, int varID, int levelID, double *data, int *n
int
ndimsp
;
int
dimids
[
9
];
int
swapyz
=
FALSE
;
int
swapxy
=
FALSE
;
double
missval
;
int
laddoffset
,
lscalefactor
;
double
addoffset
,
scalefactor
;
...
...
@@ -2752,6 +2755,10 @@ int cdfReadVarSliceDP(int streamID, int varID, int levelID, double *data, int *n
{
cdfReadGridTraj
(
streamID
,
gridID
);
}
else
if
(
gridInqType
(
gridID
)
==
GRID_CELL
)
{
xid
=
streamptr
->
xdimID
[
gridindex
];
}
else
{
xid
=
streamptr
->
xdimID
[
gridindex
];
...
...
@@ -2788,6 +2795,20 @@ int cdfReadVarSliceDP(int streamID, int varID, int levelID, double *data, int *n
}
}
if
(
yid
!=
UNDEFID
&&
xid
!=
UNDEFID
)
{
if
(
xid
==
dimids
[
ndimsp
-
1
]
&&
yid
==
dimids
[
ndimsp
-
2
]
)
swapxy
=
FALSE
;
else
if
(
yid
==
dimids
[
ndimsp
-
1
]
&&
xid
==
dimids
[
ndimsp
-
2
]
)
swapxy
=
TRUE
;
else
{
char
name
[
256
];
vlistInqVarName
(
vlistID
,
varID
,
name
);
Error
(
func
,
"Unsupported array structure for %s
\n
"
,
name
);
}
}
if
(
swapyz
)
{
if
(
yid
!=
UNDEFID
)
...
...
@@ -2804,6 +2825,14 @@ int cdfReadVarSliceDP(int streamID, int varID, int levelID, double *data, int *n
count
[
ndims
]
=
1
;
ndims
++
;
}
if
(
xid
!=
UNDEFID
)
{
start
[
ndims
]
=
0
;
/* count[ndims] = gridInqXsize(gridID); */
cdf_inq_dimlen
(
fileID
,
xid
,
&
size
);
count
[
ndims
]
=
size
;
ndims
++
;
}
}
else
{
...
...
@@ -2813,23 +2842,45 @@ int cdfReadVarSliceDP(int streamID, int varID, int levelID, double *data, int *n
count
[
ndims
]
=
1
;
ndims
++
;
}
if
(
yid
!=
UNDEFID
)
if
(
swapxy
)
{
start
[
ndims
]
=
0
;
/* count[ndims] = gridInqYsize(gridID); */
cdf_inq_dimlen
(
fileID
,
yid
,
&
size
);
count
[
ndims
]
=
size
;
ndims
++
;
if
(
xid
!=
UNDEFID
)
{
start
[
ndims
]
=
0
;
/* count[ndims] = gridInqXsize(gridID); */
cdf_inq_dimlen
(
fileID
,
xid
,
&
size
);
count
[
ndims
]
=
size
;
ndims
++
;
}
if
(
yid
!=
UNDEFID
)
{
start
[
ndims
]
=
0
;
/* count[ndims] = gridInqYsize(gridID); */
cdf_inq_dimlen
(
fileID
,
yid
,
&
size
);
count
[
ndims
]
=
size
;
ndims
++
;
}
}
else
{
if
(
yid
!=
UNDEFID
)
{
start
[
ndims
]
=
0
;
/* count[ndims] = gridInqYsize(gridID); */
cdf_inq_dimlen
(
fileID
,
yid
,
&
size
);
count
[
ndims
]
=
size
;
ndims
++
;
}
if
(
xid
!=
UNDEFID
)
{
start
[
ndims
]
=
0
;
/* count[ndims] = gridInqXsize(gridID); */
cdf_inq_dimlen
(
fileID
,
xid
,
&
size
);
count
[
ndims
]
=
size
;
ndims
++
;
}
}
}
if
(
xid
!=
UNDEFID
)
{
start
[
ndims
]
=
0
;
/* count[ndims] = gridInqXsize(gridID); */
cdf_inq_dimlen
(
fileID
,
xid
,
&
size
);
count
[
ndims
]
=
size
;
ndims
++
;
}
if
(
CDI_Debug
)
...
...
@@ -4477,6 +4528,21 @@ int cdfInqContents(int streamID)
{
if
(
(
int
)
ysize
==
0
)
size
=
xsize
;
else
size
=
ysize
;
/* Check size of 1 dimensional coordinate variables */
{
int
dimid
;
size_t
dimsize
;
dimid
=
ncvars
[
yvarid
].
dimids
[
0
];
cdf_inq_dimlen
(
fileID
,
dimid
,
&
dimsize
);
if
(
dimsize
!=
size
)
{
Warning
(
func
,
"Variable %s has unsupported array structure, skipped!"
,
ncvars
[
ncvarid
].
name
);
ncvars
[
ncvarid
].
isvar
=
-
1
;
continue
;
}
}
}
if
(
ncvars
[
yvarid
].
xtype
==
NC_FLOAT
)
grid
.
prec
=
DATATYPE_FLT32
;
...
...
src/taxis.c
View file @
a44917d8
...
...
@@ -1109,6 +1109,7 @@ void splitTimevalue(double timevalue, int timeunit, int *date, int *time)
int
vdate
=
0
,
vtime
=
0
;
int
hour
,
minute
;
int
year
,
month
,
day
;
static
int
lwarn
=
TRUE
;
if
(
timeunit
==
TUNIT_HOUR
)
{
...
...
@@ -1140,9 +1141,18 @@ void splitTimevalue(double timevalue, int timeunit, int *date, int *time)
vdate
=
(
int
)
timevalue
*
100
;
vtime
=
0
;
}
else
if
(
timeunit
==
TUNIT_YEAR
)
{
vdate
=
(
int
)
timevalue
*
10000
;
vtime
=
0
;
}
else
{
Message
(
func
,
"Unsupported TIMEUNIT: %s!"
,
tunitNamePtr
(
timeunit
));
if
(
lwarn
)
{
Warning
(
func
,
"timeunit %s unsupported!"
,
tunitNamePtr
(
timeunit
));
lwarn
=
FALSE
;
}
}
/* verify date and time */
...
...
@@ -1185,7 +1195,14 @@ double encode_timeval(int date, int time, TAXIS *taxis)
if
(
taxis
->
type
==
TAXIS_ABSOLUTE
)
{
if
(
taxis
->
unit
==
TUNIT_MONTH
)
if
(
taxis
->
unit
==
TUNIT_YEAR
)
{
int
year
,
month
,
day
;
decode_date
(
date
,
&
year
,
&
month
,
&
day
);
timevalue
=
year
;
}
else
if
(
taxis
->
unit
==
TUNIT_MONTH
)
{
int
year
,
month
,
day
;
decode_date
(
date
,
&
year
,
&
month
,
&
day
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment