Commit 1179bcc4 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Seasstat: added support for time bounds

parent cf528bb0
......@@ -5,6 +5,7 @@
2014-11-24 Uwe Schulzweida
* Seasstat: added support for time bounds
* Timstat: added time bounds
2014-11-21 Uwe Schulzweida
......
......@@ -6,6 +6,7 @@ Version 1.6.6 (27 November 2014):
New operators:
* outputtab: table output
Fixed bugs:
* seasmean: sets all time_bnds to the same values [Bug #5329]
* histcount: doesn't recognize missing values
* filesdes: doesn't work for GRIB2 files [Bug #5307]
......
......@@ -43,6 +43,8 @@ void *Seasstat(void *argument)
int vdate = 0, vtime = 0;
int vdate0 = 0, vtime0 = 0;
int vdate1 = 0, vtime1 = 0;
int vdate_lb = 0, vdate_ub = 0, date_lb = 0, date_ub = 0;
int vtime_lb = 0, vtime_ub = 0, time_lb = 0, time_ub = 0;
int nrecs, nrecords;
int varID, levelID, recID;
int tsID;
......@@ -55,6 +57,7 @@ void *Seasstat(void *argument)
int nmiss;
int nvars, nlevel;
int *recVarID, *recLevelID;
int taxis_has_bounds = FALSE;
int newseas, oldmon = 0, newmon;
int nseason = 0;
field_t **vars1 = NULL, **vars2 = NULL, **samp1 = NULL;
......@@ -85,7 +88,8 @@ void *Seasstat(void *argument)
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = taxisDuplicate(taxisID1);
if ( taxisHasBounds(taxisID2) ) taxisDeleteBounds(taxisID2);
if ( taxisInqType(taxisID2) == TAXIS_FORECAST ) taxisDefType(taxisID2, TAXIS_RELATIVE);
taxis_has_bounds = taxisHasBounds(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
......@@ -118,6 +122,20 @@ void *Seasstat(void *argument)
{
vdate = taxisInqVdate(taxisID1);
vtime = taxisInqVtime(taxisID1);
if ( taxis_has_bounds )
{
taxisInqVdateBounds(taxisID1, &date_lb, &date_ub);
taxisInqVtimeBounds(taxisID1, &time_lb, &time_ub);
if ( nsets == 0 )
{ vdate_lb = date_lb; vtime_lb = time_lb; }
}
else
{
if ( nsets == 0 )
{ vdate_lb = vdate; vtime_lb = vtime; }
}
cdiDecodeDate(vdate, &year, &month, &day);
if ( month < 1 || month > 12 )
cdoAbort("Month %d out of range!", month);
......@@ -159,6 +177,11 @@ void *Seasstat(void *argument)
oldmon = newmon;
if ( taxis_has_bounds )
{ vdate_ub = date_ub; vtime_ub = time_ub; }
else
{ vdate_ub = vdate; vtime_ub = vtime; }
for ( recID = 0; recID < nrecs; recID++ )
{
streamInqRecord(streamID1, &varID, &levelID);
......@@ -291,6 +314,8 @@ void *Seasstat(void *argument)
taxisDefVdate(taxisID2, vdate1);
taxisDefVtime(taxisID2, vtime1);
taxisDefVdateBounds(taxisID2, vdate_lb, vdate_ub);
taxisDefVtimeBounds(taxisID2, vtime_lb, vtime_ub);
streamDefTimestep(streamID2, otsID);
if ( nsets < 3 )
......
......@@ -255,18 +255,12 @@ void *Timstat(void *argument)
taxisInqVdateBounds(taxisID1, &date_lb, &date_ub);
taxisInqVtimeBounds(taxisID1, &time_lb, &time_ub);
if ( nsets == 0 )
{
vdate_lb = date_lb;
vtime_lb = time_lb;
}
{ vdate_lb = date_lb; vtime_lb = time_lb; }
}
else
{
if ( nsets == 0 )
{
vdate_lb = vdate;
vtime_lb = vtime;
}
{ vdate_lb = vdate; vtime_lb = vtime; }
}
if ( nsets == 0 ) SET_DATE(indate2, vdate, vtime);
......@@ -275,15 +269,9 @@ void *Timstat(void *argument)
if ( DATE_IS_NEQ(indate1, indate2, cmplen) ) break;
if ( taxis_has_bounds )
{
vdate_ub = date_ub;
vtime_ub = time_ub;
}
{ vdate_ub = date_ub; vtime_ub = time_ub; }
else
{
vdate_ub = vdate;
vtime_ub = vtime;
}
{ vdate_ub = vdate; vtime_ub = vtime; }
for ( recID = 0; recID < nrecs; recID++ )
{
......@@ -443,22 +431,16 @@ void *Timstat(void *argument)
taxisDefVdate(taxisID2, vdate0);
taxisDefVtime(taxisID2, vtime0);
// if ( taxis_has_bounds )
{
taxisDefVdateBounds(taxisID2, vdate_lb, vdate_ub);
taxisDefVtimeBounds(taxisID2, vtime_lb, vtime_ub);
}
taxisDefVdateBounds(taxisID2, vdate_lb, vdate_ub);
taxisDefVtimeBounds(taxisID2, vtime_lb, vtime_ub);
streamDefTimestep(streamID2, otsID);
if ( cdoDiag )
{
taxisDefVdate(taxisID3, vdate0);
taxisDefVtime(taxisID3, vtime0);
// if ( taxis_has_bounds )
{
taxisDefVdateBounds(taxisID3, vdate_lb, vdate_ub);
taxisDefVtimeBounds(taxisID3, vtime_lb, vtime_ub);
}
taxisDefVdateBounds(taxisID3, vdate_lb, vdate_ub);
taxisDefVtimeBounds(taxisID3, vtime_lb, vtime_ub);
streamDefTimestep(streamID3, otsID);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment