static void proc_frame(indexer_dv_context *This, unsigned char *UNUSED(framebuffer), int isPAL) { struct tm recDate; time_t t; if (!This->got_record_date || !This->got_record_time) { return; } recDate.tm_sec = This->rec_curr_second; recDate.tm_min = This->rec_curr_minute; recDate.tm_hour = This->rec_curr_hour; recDate.tm_mday = This->rec_curr_day; recDate.tm_mon = This->rec_curr_month - 1; recDate.tm_year = This->rec_curr_year - 1900; recDate.tm_wday = -1; recDate.tm_yday = -1; recDate.tm_isdst = -1; t = mktime(&recDate); if (t == -1) { return; } This->ref_time_read_new = t; if (This->ref_time_read < 0) { This->ref_time_read = This->ref_time_read_new; This->curr_frame = 0; } else { if (This->ref_time_read_new - This->ref_time_read == 1) { This->curr_frame = 0; This->ref_time_read = This->ref_time_read_new; if (This->gap_frame >= 0) { fill_gap(This, isPAL); This->gap_frame = -1; } } else if (This->ref_time_read_new == This->ref_time_read) { /* do nothing */ } else { This->gap_start = This->ref_time_read; This->gap_frame = This->curr_frame; This->ref_time_read = This->ref_time_read_new; This->curr_frame = -1; } } }
void *Tinfo(void *argument) { int vdate_first = 0, vtime_first = 0; int vdate0 = 0, vtime0 = 0; int vdate = 0, vtime = 0; int fdate = 0, ftime = 0; int nrecs, ntsteps; int tsID = 0, ntimeout; int taxisID; int streamID; int vlistID; int year0, month0, day0; int year, month, day; int calendar, unit; int lforecast = FALSE; int incperiod0 = 0, incunit0 = 0; int incperiod = 0, incunit = 0; int its = 0, igap; int ngaps = 0; int ntsm[MAX_GAPS]; int rangetsm[MAX_GAPS][2]; int vdatem[MAX_GAPS][MAX_NTSM]; int vtimem[MAX_GAPS][MAX_NTSM]; juldate_t juldate, juldate0; double jdelta = 0, jdelta0 = 0; int arrow = 0; int i, len; char vdatestr[32], vtimestr[32]; cdoInitialize(argument); streamID = streamOpenRead(cdoStreamName(0)); vlistID = streamInqVlist(streamID); fprintf(stdout, "\n"); taxisID = vlistInqTaxis(vlistID); ntsteps = vlistNtsteps(vlistID); if ( ntsteps != 0 ) { if ( ntsteps == CDI_UNDEFID ) fprintf(stdout, " Time axis : unlimited steps\n"); else fprintf(stdout, " Time axis : %d step%s\n", ntsteps, ntsteps == 1 ? "" : "s"); if ( taxisID != CDI_UNDEFID ) { if ( taxisInqType(taxisID) != TAXIS_ABSOLUTE ) { vdate = taxisInqRdate(taxisID); vtime = taxisInqRtime(taxisID); date2str(vdate, vdatestr, sizeof(vdatestr)); time2str(vtime, vtimestr, sizeof(vtimestr)); fprintf(stdout, " RefTime = %s %s", vdatestr, vtimestr); unit = taxisInqTunit(taxisID); if ( unit != CDI_UNDEFID ) fprintf(stdout, " Units = %s", tunit2str(unit)); calendar = taxisInqCalendar(taxisID); if ( calendar != CDI_UNDEFID ) fprintf(stdout, " Calendar = %s", calendar2str(calendar)); if ( taxisHasBounds(taxisID) ) fprintf(stdout, " Bounds = true"); fprintf(stdout, "\n"); if ( taxisInqType(taxisID) == TAXIS_FORECAST ) { fdate = taxisInqFdate(taxisID); ftime = taxisInqFtime(taxisID); date2str(fdate, vdatestr, sizeof(vdatestr)); time2str(ftime, vtimestr, sizeof(vtimestr)); fprintf(stdout, " Forecast RefTime = %s %s", vdatestr, vtimestr); unit = taxisInqForecastTunit(taxisID); if ( unit != CDI_UNDEFID ) fprintf(stdout, " Units = %s", tunit2str(unit)); fprintf(stdout, "\n"); lforecast = TRUE; } } } calendar = taxisInqCalendar(taxisID); fprintf(stdout, "\n"); fprintf(stdout, " Verification Time "); if ( lforecast ) fprintf(stdout, " Forecast Reference Time "); if ( taxisHasBounds(taxisID) ) fprintf(stdout, " lower bound upper bound"); fprintf(stdout, "\n"); fprintf(stdout, "Timestep YYYY-MM-DD hh:mm:ss Increment"); if ( lforecast ) fprintf(stdout, " YYYY-MM-DD hh:mm:ss Period"); if ( taxisHasBounds(taxisID) ) fprintf(stdout, " YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss Difference"); fprintf(stdout, "\n"); tsID = 0; while ( (nrecs = streamInqTimestep(streamID, tsID)) ) { vdate = taxisInqVdate(taxisID); vtime = taxisInqVtime(taxisID); cdiDecodeDate(vdate, &year, &month, &day); date2str(vdate, vdatestr, sizeof(vdatestr)); time2str(vtime, vtimestr, sizeof(vtimestr)); fprintf(stdout, "%6d %s %s", tsID+1, vdatestr, vtimestr); if ( tsID ) { cdiDecodeDate(vdate0, &year0, &month0, &day0); juldate0 = juldate_encode(calendar, vdate0, vtime0); juldate = juldate_encode(calendar, vdate, vtime); jdelta = juldate_to_seconds(juldate_sub(juldate, juldate0)); getTimeInc(jdelta, vdate0, vdate, &incperiod, &incunit); /* fprintf(stdout, " %g %g %g %d", jdelta, jdelta/3600, fmod(jdelta,3600), incperiod%3600);*/ len = fprintf(stdout, " %3d %s%s", incperiod, tunits[incunit], abs(incperiod)>1?"s":""); for ( i = 0; i < 11-len; ++i ) fprintf(stdout, " "); } else { vdate_first = vdate; vtime_first = vtime; fprintf(stdout, " --------"); } if ( lforecast ) { fdate = taxisInqFdate(taxisID); ftime = taxisInqFtime(taxisID); date2str(fdate, vdatestr, sizeof(vdatestr)); time2str(ftime, vtimestr, sizeof(vtimestr)); fprintf(stdout, " %s %s", vdatestr, vtimestr); double fc_period = taxisInqForecastPeriod(taxisID); fprintf(stdout, " %7g", fc_period); } if ( taxisHasBounds(taxisID) ) printBounds(taxisID, calendar); if ( tsID > 1 && (incperiod != incperiod0 || incunit != incunit0) ) { if ( tsID == 2 && (jdelta0 > jdelta) ) { jdelta0 = jdelta; incperiod0 = incperiod; incunit0 = incunit; its = fill_gap(ngaps, ntsm, rangetsm, vdatem, vtimem, 1, incperiod0, incunit0, vdate_first, vdate, vtime, calendar, day, juldate0, juldate_encode(calendar, vdate_first, vtime_first)); arrow = '^'; } else { its = fill_gap(ngaps, ntsm, rangetsm, vdatem, vtimem, tsID, incperiod0, incunit0, vdate, vdate0, vtime0, calendar, day0, juldate, juldate0); arrow = '<'; if ( its == 0 && incperiod < 0 ) { its = -1; vdate = vdate0; vtime = vtime0; } } if ( its > 0 ) { ngaps++; if ( cdoVerbose ) fprintf(stdout, " %c--- Gap %d, missing %s%d timestep%s", arrow, ngaps, its>=LIM_NTSM?"more than ":"", its, its>1?"s":""); } else if ( its < 0 ) { if ( cdoVerbose ) fprintf(stdout, " %c--- Wrong date/time information, negative increment!", arrow); } } if ( tsID == 1 ) { jdelta0 = jdelta; incperiod0 = incperiod; incunit0 = incunit; } fprintf(stdout, "\n"); vdate0 = vdate; vtime0 = vtime; tsID++; } } streamClose(streamID); fprintf(stdout, "\n"); date2str(vdate_first, vdatestr, sizeof(vdatestr)); time2str(vtime_first, vtimestr, sizeof(vtimestr)); fprintf(stdout, " Start date : %s %s\n", vdatestr, vtimestr); date2str(vdate, vdatestr, sizeof(vdatestr)); time2str(vtime, vtimestr, sizeof(vtimestr)); fprintf(stdout, " End date : %s %s\n", vdatestr, vtimestr); fprintf(stdout, " Increment : %3d %s%s\n", incperiod0, tunits[incunit0], incperiod0>1?"s":""); fprintf(stdout, " Number of timesteps : %d\n", tsID); fprintf(stdout, " Gaps identified : %d\n", ngaps); if ( cdoVerbose && ngaps ) { fprintf(stdout, "\nFound potentially %d gap%s in the time series", ngaps, ngaps>1?"s":""); if ( ngaps >= MAX_GAPS ) { ngaps = MAX_GAPS; fprintf(stdout, ", here are the first %d", ngaps); } fprintf(stdout, ":\n"); for ( igap = 0; igap < ngaps; ++igap ) { fprintf(stdout, " Gap %d between timestep %d and %d, missing %d timestep%s", igap+1, rangetsm[igap][0], rangetsm[igap][1], ntsm[igap], ntsm[igap]>1?"s":""); if ( ntsm[igap] >= MAX_NTSM ) { ntsm[igap] = MAX_NTSM; fprintf(stdout, ", here are the first %d", ntsm[igap]); } fprintf(stdout, ":\n"); ntimeout = 0; for ( its = 0; its < ntsm[igap]; ++its ) { if ( ntimeout == 4 ) { ntimeout = 0; fprintf(stdout, "\n"); } vdate = vdatem[igap][its]; vtime = vtimem[igap][its]; date2str(vdate, vdatestr, sizeof(vdatestr)); time2str(vtime, vtimestr, sizeof(vtimestr)); fprintf(stdout, " %s %s", vdatestr, vtimestr); ntimeout++; tsID++; } fprintf(stdout, "\n"); } } cdoFinish(); return (0); }
void pariplot(GEN a, GEN b, GEN code, GEN ysmlu,GEN ybigu, long prec) { const char BLANK = ' ', YY = '|', XX_UPPER = '\'', XX_LOWER = '.'; long jz, j, i, sig; pari_sp av = avma; int jnew, jpre = 0; /* for lint */ GEN x, dx; double diff, dyj, ysml, ybig, y[ISCR+1]; screen scr; char buf[80], z; sig=gcmp(b,a); if (!sig) return; if (sig<0) { x=a; a=b; b=x; } x = gtofp(a, prec); push_lex(x, code); dx = divru(gtofp(gsub(b,a),prec), ISCR-1); for (j=1; j<=JSCR; j++) scr[1][j]=scr[ISCR][j]=YY; for (i=2; i<ISCR; i++) { scr[i][1] = XX_LOWER; scr[i][JSCR]= XX_UPPER; for (j=2; j<JSCR; j++) scr[i][j] = BLANK; } ysml = ybig = 0.; /* -Wall */ for (i=1; i<=ISCR; i++) { pari_sp av2 = avma; y[i] = gtodouble( READ_EXPR(code,x) ); avma = av2; if (i == 1) ysml = ybig = y[1]; else { if (y[i] < ysml) ysml = y[i]; if (y[i] > ybig) ybig = y[i]; } x = addrr(x,dx); } avma = av; if (ysmlu) ysml = gtodouble(ysmlu); if (ybigu) ybig = gtodouble(ybigu); diff = ybig - ysml; if (!diff) { ybig += 1; diff= 1.; } dyj = ((JSCR-1)*3+2) / diff; /* work around bug in gcc-4.8 (32bit): plot(x=-5,5,sin(x)))) */ jz = 3 - (long)(ysml*dyj + 0.5); /* 3 - DTOL(ysml*dyj) */ z = PICTZERO(jz); jz /= 3; for (i=1; i<=ISCR; i++) { if (0<=jz && jz<=JSCR) scr[i][jz]=z; j = 3 + DTOL((y[i]-ysml)*dyj); jnew = j/3; if (i > 1) fill_gap(scr, i, jnew, jpre); if (0<=jnew && jnew<=JSCR) scr[i][jnew] = PICT(j); jpre = jnew; } pari_putc('\n'); pari_printf("%s ", dsprintf9(ybig, buf)); for (i=1; i<=ISCR; i++) pari_putc(scr[i][JSCR]); pari_putc('\n'); for (j=(JSCR-1); j>=2; j--) { pari_puts(" "); for (i=1; i<=ISCR; i++) pari_putc(scr[i][j]); pari_putc('\n'); } pari_printf("%s ", dsprintf9(ysml, buf)); for (i=1; i<=ISCR; i++) pari_putc(scr[i][1]); pari_putc('\n'); { char line[10 + 32 + 32 + ISCR - 9]; sprintf(line, "%10s%-9.7g%*.7g\n"," ",todbl(a),ISCR-9,todbl(b)); pari_printf(line); } pop_lex(1); }