From 1b612c0c5a68b62605efa275837c8c912c979bca Mon Sep 17 00:00:00 2001 From: Takeshi Nakazato Date: Mon, 26 Jul 2021 17:24:09 +0900 Subject: [PATCH 1/3] fix insufficient precision issue in T+dT syntax --- ms/MSSel/MSTimeGram.yy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ms/MSSel/MSTimeGram.yy b/ms/MSSel/MSTimeGram.yy index 52ac0270e95..c76e5f6124a 100644 --- a/ms/MSSel/MSTimeGram.yy +++ b/ms/MSSel/MSTimeGram.yy @@ -169,11 +169,11 @@ rangetimeexpr: yeartimeexpr DASH yeartimeexpr MSTimeParse::thisMSTParser->setDefaults($3,false); MSTimeParse::thisMSTParser->validate($1); MSTimeParse::thisMSTParser->validate($3); - Double s; - s=$3.sec; + Double s0 = Double($1.sec) + Double($1.fsec) / 1000.0; + Double s1 = Double($3.sec) + Double($3.fsec) / 1000.0; - Time time0($1.year,$1.month,$1.day,$1.hour,$1.minute,(Double)$1.sec); - Time time1($3.year,$3.month,$3.day,$3.hour,$3.minute,s); + Time time0($1.year,$1.month,$1.day,$1.hour,$1.minute,s0); + Time time1($3.year,$3.month,$3.day,$3.hour,$3.minute,s1); Double mjd=time1.modifiedJulianDay()*86400.0; time1 = time0 + mjd; From f1beb78c54ddcd9822ddc937f434331fd5624740 Mon Sep 17 00:00:00 2001 From: Takeshi Nakazato Date: Wed, 28 Jul 2021 15:33:57 +0900 Subject: [PATCH 2/3] further improvement of precision using MVEpoch --- ms/MSSel/MSTimeGram.yy | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ms/MSSel/MSTimeGram.yy b/ms/MSSel/MSTimeGram.yy index c76e5f6124a..ad984bd1897 100644 --- a/ms/MSSel/MSTimeGram.yy +++ b/ms/MSSel/MSTimeGram.yy @@ -174,11 +174,12 @@ rangetimeexpr: yeartimeexpr DASH yeartimeexpr Time time0($1.year,$1.month,$1.day,$1.hour,$1.minute,s0); Time time1($3.year,$3.month,$3.day,$3.hour,$3.minute,s1); - Double mjd=time1.modifiedJulianDay()*86400.0; - - time1 = time0 + mjd; - const MEpoch *t0=new MEpoch(MVEpoch(time0.modifiedJulianDay())); - const MEpoch *t1=new MEpoch(MVEpoch(time1.modifiedJulianDay())); + Double mjd0 = time0.modifiedJulianDay(); + Double mjd1 = time1.modifiedJulianDay(); + MVEpoch mve0(mjd0); + MVEpoch mve1(mjd0, mjd1); + const MEpoch *t0=new MEpoch(mve0); + const MEpoch *t1=new MEpoch(mve1); $$ = MSTimeParse::thisMSTParser->selectTimeRange(t0,t1,MSTimeEdgeInclusiveRange,MSTimeEdgeBuffer); MSTGgarbageCollector(t0); From cbf8e7c5bc9db1c5592ac122d1c13b11a3ed5847 Mon Sep 17 00:00:00 2001 From: Takeshi Nakazato Date: Thu, 29 Jul 2021 11:47:46 +0900 Subject: [PATCH 3/3] Define minimal set of verification tests in tMSTimeGram --- ms/MSSel/test/tMSTimeGram.out | 8 +++++++ ms/MSSel/test/tMSTimeGram.run | 42 +++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 ms/MSSel/test/tMSTimeGram.out diff --git a/ms/MSSel/test/tMSTimeGram.out b/ms/MSSel/test/tMSTimeGram.out new file mode 100644 index 00000000000..1fc92dd16b0 --- /dev/null +++ b/ms/MSSel/test/tMSTimeGram.out @@ -0,0 +1,8 @@ +Original table has rows 1058 +TableExprNode has rows = 1058 +After mssel constructor called +selected table has rows 46 +Original table has rows 1058 +TableExprNode has rows = 1058 +After mssel constructor called +selected table has rows 46 diff --git a/ms/MSSel/test/tMSTimeGram.run b/ms/MSSel/test/tMSTimeGram.run index 66c49c44a31..b9afb93e26c 100644 --- a/ms/MSSel/test/tMSTimeGram.run +++ b/ms/MSSel/test/tMSTimeGram.run @@ -1,3 +1,41 @@ #! /bin/sh -echo "UNTESTED" -exit 3 +# ----------------------------------------------------------------------------- +# Usage: tMSTimeGram.run +# ----------------------------------------------------------------------------- +# This script executes the program tMSTimeGram to test the +# MSTimeGram module. +# +# $Id$ +#----------------------------------------------------------------------------- + + MS=$CASADEMO"mssel_test_small.ms" + + runCmd(){ + # Uncomment following line to generate an output close to a + # script to run the tests + #echo "#Test:$1"; echo $3; + + eval "$2 $3" + } + + getTestMS() { + tar zxf $testsrcdir/$MS.tgz + } + + cleanup() { + \rm -rf $MS + } + + # Get the test MS (un-tar it from $testsrcdir). + getTestMS; + + # T1~T2 syntax: selects single timestamp, 2014/09/20/10:37:51.360000 + runCmd 1 "$casa_checktool" " ./tMSTimeGram $MS '2014/09/20/10:37:51.0~10:37:51.5'"; + + # T+dT syntax: selects single timestamp, 2014/09/20/10:37:51.360000 + runCmd 2 "$casa_checktool" " ./tMSTimeGram $MS '2014/09/20/10:37:51.0+0:0:0.5'"; + + # + # Remove the test MS and any other cleanup required. + # + cleanup;