From: <ai...@us...> - 2009-02-18 23:57:37
|
Revision: 9552 http://plplot.svn.sourceforge.net/plplot/?rev=9552&view=rev Author: airwin Date: 2009-02-18 22:58:12 +0000 (Wed, 18 Feb 2009) Log Message: ----------- Add broken-down time as an option to specify the offsets in configqsas. Modified Paths: -------------- trunk/lib/qsastime/README.qsastime_API trunk/lib/qsastime/qsastime.c trunk/lib/qsastime/qsastime.h trunk/src/plbox.c Modified: trunk/lib/qsastime/README.qsastime_API =================================================================== --- trunk/lib/qsastime/README.qsastime_API 2009-02-18 20:36:22 UTC (rev 9551) +++ trunk/lib/qsastime/README.qsastime_API 2009-02-18 22:58:12 UTC (rev 9552) @@ -4,12 +4,19 @@ ========================= -void configqsas(double scale, double offset1, double offset2, int ccontrol); +void configqsas(double scale, double offset1, double offset2, int ccontrol, int ifbtime_offset, int year, int month, int day, int hour, int min, double sec); +Within this routine if ifbtime_offset is false, then the broken-down +time arguments are ignored. If ifbtime_offset is true, then the input +offset1 and offset2 values are ignored, and instead, the broken-down +time values are used to calculate offset1 and offset2 with the help of +an internal call to setFromUT. + This routine allocates memory for the global qsasconfig pointer to a QSASConfig struct. It initializes the four variables encapsulated -in QSASConfig with scale, offset1, offset2, and ccontrol. Further details -of the meaning of these four variables is contained in qsastime.h. +in QSASConfig with scale, offset1, offset2, and ccontrol. Further +details of the meaning of these four variables is contained in +qsastime.h. Although this API gives the user a large degree of flexibility in choosing the transformation between broken-down time and continuous time, a number of @@ -101,12 +108,13 @@ double sec, double *ctime); Determine continuous time (ctime). Wraps the existing internal (not -visible by default) setFromUT to use the four global variables discussed above in the -transformation from broken-down-time to ctime. Note, because of the -transformation implied by the four variables mentioned above, the ctime -result can be stored in just a double assuming the user has picked a -reasonable epoch that is not so distant from his plotted range of times that -it causes a noticable loss of numerical precision. +visible by default) setFromUT to use the four global variables +discussed above in the transformation from broken-down-time to ctime. +Note, because of the transformation implied by the four variables +mentioned above, the ctime result can be stored in just a double +assuming the user has picked a reasonable epoch that is not so distant +from his plotted range of times that it causes a noticable loss of +numerical precision. ========================= Modified: trunk/lib/qsastime/qsastime.c =================================================================== --- trunk/lib/qsastime/qsastime.c 2009-02-18 20:36:22 UTC (rev 9551) +++ trunk/lib/qsastime/qsastime.c 2009-02-18 22:58:12 UTC (rev 9552) @@ -859,10 +859,12 @@ return posn; } -void configqsas(double scale, double offset1, double offset2, int ccontrol) +void configqsas(double scale, double offset1, double offset2, int ccontrol, int ifbtime_offset, int year, int month, int day, int hour, int min, double sec) { /* Configure the transformation between continuous time and broken-down time that is used for ctimeqsas, btimeqsas, and strfqsas. */ + int forceJulian, ret; + MJDtime MJD_value, *MJD=&MJD_value; /* Allocate memory for qsasconfig if that hasn't been done by a previous call. */ @@ -875,6 +877,19 @@ } if(scale != 0.) { + if(ifbtime_offset) { + if(ccontrol & 0x1) + forceJulian = 1; + else + forceJulian = -1; + ret = setFromUT(year, month, day, hour, min, sec, MJD, forceJulian); + if(ret) { + fprintf(stderr, "configqsas: some problem with broken-down arguments\n"); + exit(EXIT_FAILURE); + } + offset1 = (double)MJD->base_day; + offset2 = MJD->time_sec/(double)SecInDay; + } qsasconfig->scale = scale; qsasconfig->offset1 = offset1; qsasconfig->offset2 = offset2; @@ -884,7 +899,7 @@ default is continuous time (stored as a double) is seconds since 1970-01-01 while broken-down time is Gregorian with no other additional corrections. */ - qsasconfig->scale = 1./86400.; + qsasconfig->scale = 1./(double)SecInDay; qsasconfig->offset1 = (double) MJD_1970; qsasconfig->offset2 = 0.; qsasconfig->ccontrol = 0x0; Modified: trunk/lib/qsastime/qsastime.h =================================================================== --- trunk/lib/qsastime/qsastime.h 2009-02-18 20:36:22 UTC (rev 9551) +++ trunk/lib/qsastime/qsastime.h 2009-02-18 22:58:12 UTC (rev 9552) @@ -101,7 +101,7 @@ QSASTIMEDLLIMPEXP_DATA(QSASConfig) *qsasconfig; /* externally accessible functions */ -QSASTIMEDLLIMPEXP void configqsas(double scale, double offset1, double offset2, int ccontrol); +QSASTIMEDLLIMPEXP void configqsas(double scale, double offset1, double offset2, int ccontrol, int ifbtime_offset, int year, int month, int day, int hour, int min, double sec); QSASTIMEDLLIMPEXP void closeqsas(void); QSASTIMEDLLIMPEXP int ctimeqsas(int year, int month, int day, int hour, int min, double sec, double * ctime); QSASTIMEDLLIMPEXP void btimeqsas(int *year, int *month, int *day, int *hour, int *min, double *sec, double ctime); Modified: trunk/src/plbox.c =================================================================== --- trunk/src/plbox.c 2009-02-18 20:36:22 UTC (rev 9551) +++ trunk/src/plbox.c 2009-02-18 22:58:12 UTC (rev 9552) @@ -1252,7 +1252,7 @@ for (tn = tp; BETW(tn, vpwxmi, vpwxma); tn += xtick1) { if (ldx) { t = (double) tn; - configqsas(0., 0., 0., 0x0); + configqsas(1./86400., 0., 0., 0x0, 1, 1970, 0, 1, 0, 0, 0.); ctimeqsas(1970,0,1,0,0,t,&tm); strfqsas(string, STRING_LEN, timefmt, tm); closeqsas(); @@ -1303,7 +1303,7 @@ for (tn = tp; BETW(tn, vpwymi, vpwyma); tn += ytick1) { if (ldy) { t = (double) tn; - configqsas(0., 0., 0., 0x0); + configqsas(1./86400., 0., 0., 0x0, 1, 1970, 0, 1, 0, 0, 0.); ctimeqsas(1970,0,1,0,0,t,&tm); strfqsas(string, STRING_LEN, timefmt, tm); closeqsas(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |