Commit 37294420 authored by Fabian Wachsmann's avatar Fabian Wachsmann
Browse files

Set time bounds for subdaily frequencies if ta=cmip or if frequency is decadal

parent 9c7c08b1
......@@ -4793,9 +4793,10 @@ get_time_bounds(list_t *kvl, int taxisID, int ifreq, juldate_t ref_date, juldate
* cell_methods or frequency itself*/
/***/
if (!taxisHasBounds(taxisID) || strcmp(kv_get_a_val(kvl, "tb", "n"), "y") == 0
|| time_axis == 2 )
if (!taxisHasBounds(taxisID) || strcmp(kv_get_a_val(kvl, "ta", "n"), "cmip") == 0
|| time_axis == 2 || ifreq == 8 )
{
if (Options::cdoVerbose) cdoPrint("10.4. Time bounds are created for frequency '%d'.", ifreq);
vtime0b = 0;
vtime1b = 0;
......@@ -4901,24 +4902,60 @@ get_time_bounds(list_t *kvl, int taxisID, int ifreq, juldate_t ref_date, juldate
/***/
else if ( ifreq == 4)
{
time_bnds[0] = time_val - 0.125;
time_bnds[1] = time_val + 0.125;
return time_bnds;
cdiDecodeTime(taxisInqVtime(taxisID), &hour, &min, &sec);
int iv[]= {0,6,12,18,24};
size_t ivsize = sizeof(iv)/sizeof(iv[0]);
int minid = 0, newhour[2];
double diff = juldate_to_seconds(juldate_sub(jtime_val, juldate_encode(calendar, vdatecorr, cdiEncodeTime(0, 0, 0))));
for ( size_t loopid = 1; loopid < ivsize; loopid++ )
{
if ( std::fabs(juldate_to_seconds(juldate_sub(jtime_val, juldate_encode(calendar, vdatecorr, cdiEncodeTime(iv[loopid], 0, 0))))) < diff )
{
minid = loopid;
diff = std::fabs(juldate_to_seconds(juldate_sub(jtime_val, juldate_encode(calendar, vdatecorr, cdiEncodeTime(iv[minid], 0, 0)))));
}
}
newhour[0] = ( hour-iv[minid] < 0 ) ? iv[minid-1] : iv[minid];
newhour[1] = ( hour-iv[minid] < 0 ) ? iv[minid] : iv[minid+1];
vtime0b = cdiEncodeTime(newhour[0], 0 , 0);
vtime1b = cdiEncodeTime(newhour[1], 0 , 0);
vdate0b = cdiEncodeDate(year, month, day);
vdate1b = vdate0b;
}
else if ( ifreq == 5)
{
time_bnds[0] = time_val - 0.0625;
time_bnds[1] = time_val + 0.0625;
return time_bnds;
cdiDecodeTime(taxisInqVtime(taxisID), &hour, &min, &sec);
int iv[]= {0,3,6,9,12,15,18,21,24};
size_t ivsize = sizeof(iv)/sizeof(iv[0]);
int minid = 0, newhour[2];
double diff = juldate_to_seconds(juldate_sub(jtime_val, juldate_encode(calendar, vdatecorr, cdiEncodeTime(0, 0, 0))));
for ( size_t loopid = 1; loopid < ivsize; loopid++ )
{
if ( std::fabs(juldate_to_seconds(juldate_sub(jtime_val, juldate_encode(calendar, vdatecorr, cdiEncodeTime(iv[loopid], 0, 0))))) < diff )
{
minid = loopid;
diff = std::fabs(juldate_to_seconds(juldate_sub(jtime_val, juldate_encode(calendar, vdatecorr, cdiEncodeTime(iv[minid], 0, 0)))));
}
}
newhour[0] = ( hour-iv[minid] < 0 ) ? iv[minid-1] : iv[minid];
newhour[1] = ( hour-iv[minid] < 0 ) ? iv[minid] : iv[minid+1];
vtime0b = cdiEncodeTime(newhour[0], 0 , 0);
vtime1b = cdiEncodeTime(newhour[1], 0 , 0);
vdate0b = cdiEncodeDate(year, month, day);
vdate1b = vdate0b;
}
else if ( ifreq == 6)
{
juldate_t time_bnds1;
int halfhourinseconds = 60*30;
time_bnds1 = juldate_add_seconds(halfhourinseconds, jtime_val);
time_bnds[1] = juldate_to_seconds(juldate_sub(time_bnds1, ref_date)) / tunitsec;
time_bnds[0] = ( juldate_to_seconds(juldate_sub(time_bnds1, ref_date)) - 3600. ) / tunitsec;
return time_bnds;
cdiDecodeTime(taxisInqVtime(taxisID), &hour, &min, &sec);
vtime0b = cdiEncodeTime(hour, 0 , 0);
vtime1b = cdiEncodeTime(hour+1, 0 , 0);
vdate0b = cdiEncodeDate(year, month, day);
vdate1b = vdate0b;
}
else if ( ifreq == 8)
{
......
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