Commits
Ville Suoranta authored cd486f1feac Merge
45 45 | |
46 46 | datapath=os.environ.get('CASAPATH').split()[0]+'/casatestdata/unittest/importfitsidi/' |
47 47 | |
48 48 | myname = 'importfitsidi-unit-test' |
49 49 | |
50 50 | # default dataset name |
51 51 | my_dataset_names = ['n09q2_1_1-shortened.IDI1', |
52 52 | 'n09q2_1_1-shortened-part1.IDI1', |
53 53 | 'n09q2_1_1-shortened-part2.IDI1', |
54 54 | 'emerlin_multiuv.IDI1', |
55 - | '1331_3030_C-Band_5GHz__64.000_128.fits'] |
55 + | '1331_3030_C-Band_5GHz__64.000_128.fits', |
56 + | 'VLBA_TL015A_tl015arecor_BIN0_SRC0_1_201020T164655.idifits'] |
56 57 | |
57 58 | # name of the resulting MS |
58 59 | msname = my_dataset_names[0]+'.ms' |
59 60 | |
60 61 | def checktable(thename, theexpectation): |
61 62 | global msname, myname |
62 63 | _tb.open(msname+"/"+thename) |
63 64 | if thename == "": |
64 65 | thename = "MAIN" |
65 66 | for mycell in theexpectation: |
820 821 | |
821 822 | _tb.open(msname+'/OBSERVATION') |
822 823 | nr = _tb.nrows() |
823 824 | _tb.close() |
824 825 | if not nr==1: |
825 826 | retValue['success']=False |
826 827 | retValue['error_msgs']=retValue['error_msgs']+'Check of table OBSERVATION failed' |
827 828 | |
828 829 | self.assertTrue(retValue['success']) |
829 830 | |
830 - | |
831 831 | def test5(self): |
832 832 | '''fitsidi-import: Test e-MERLIN polarization swapping''' |
833 833 | retValue = {'success': True, 'msgs': "", 'error_msgs': '' } |
834 834 | |
835 835 | # FITS-IDI files from the e-MERLIN correlator have some |
836 836 | # baselines in non-canonical order. Make sure that |
837 837 | # importfitsidi correctly swaps the cross-polarisation |
838 838 | # products when it swaps the antennas. |
839 839 | # |
840 840 | self.res = importfitsidi(my_dataset_names[4], msname) |
929 929 | retValue['success']=False |
930 930 | retValue['error_msgs']=retValue['error_msgs']+'Cannot open MS' |
931 931 | else: |
932 932 | results = numpy.isclose(rec['phase'], expected, rtol=8e-7, atol=1e-8).all() |
933 933 | if not results: |
934 934 | retValue['success']=False |
935 935 | retValue['error_msgs']=retValue['error_msgs']+'Crosspol check for De-Pi baseline failed' |
936 936 | |
937 937 | self.assertTrue(retValue['success']) |
938 938 | |
939 - | |
939 + | def test6(self): |
940 + | '''fitsidi-import: Test import of gain curves''' |
941 + | retValue = {'success': True, 'msgs': "", 'error_msgs': '' } |
942 + | |
943 + | self.res = importfitsidi(my_dataset_names[5], msname, |
944 + | constobsid=True, scanreindexgap_s=5) |
945 + | print(myname, ": Success! Now checking output ...") |
946 + | mscomponents = set(["table.dat", |
947 + | # "table.f0", |
948 + | "table.f1", |
949 + | "table.f2", |
950 + | "table.f3", |
951 + | "table.f4", |
952 + | "table.f5", |
953 + | "table.f6", |
954 + | "table.f7", |
955 + | "table.f8", |
956 + | "ANTENNA/table.dat", |
957 + | "DATA_DESCRIPTION/table.dat", |
958 + | "FEED/table.dat", |
959 + | "FIELD/table.dat", |
960 + | "FLAG_CMD/table.dat", |
961 + | "HISTORY/table.dat", |
962 + | "OBSERVATION/table.dat", |
963 + | "POINTING/table.dat", |
964 + | "POLARIZATION/table.dat", |
965 + | "PROCESSOR/table.dat", |
966 + | "SPECTRAL_WINDOW/table.dat", |
967 + | "STATE/table.dat", |
968 + | "ANTENNA/table.f0", |
969 + | "DATA_DESCRIPTION/table.f0", |
970 + | "FEED/table.f0", |
971 + | "FIELD/table.f0", |
972 + | "FLAG_CMD/table.f0", |
973 + | "GAIN_CURVE/table.f0", |
974 + | "HISTORY/table.f0", |
975 + | "OBSERVATION/table.f0", |
976 + | "POINTING/table.f0", |
977 + | "POLARIZATION/table.f0", |
978 + | "PROCESSOR/table.f0", |
979 + | "SPECTRAL_WINDOW/table.f0", |
980 + | "STATE/table.f0" |
981 + | ]) |
982 + | for name in mscomponents: |
983 + | if not os.access(msname+"/"+name, os.F_OK): |
984 + | print(myname, ": Error ", msname+"/"+name, "doesn't exist ...") |
985 + | retValue['success']=False |
986 + | retValue['error_msgs']=retValue['error_msgs']+msname+'/'+name+' does not exist' |
987 + | else: |
988 + | print(myname, ": ", name, "present.") |
989 + | print(myname, ": MS exists. All tables present. Try opening as MS ...") |
990 + | try: |
991 + | _ms.open(msname) |
992 + | except: |
993 + | print(myname, ": Error Cannot open MS table", tablename) |
994 + | retValue['success']=False |
995 + | retValue['error_msgs']=retValue['error_msgs']+'Cannot open MS table '+tablename |
996 + | else: |
997 + | _ms.close() |
998 + | print(myname, ": OK. Checking tables in detail ...") |
999 + | retValue['success']=True |
1000 + | |
1001 + | name = "GAIN_CURVE" |
1002 + | expected = [ ['TYPE', 8, 'POWER(ZA)', 0], |
1003 + | ['NUM_POLY', 8, 3, 0], |
1004 + | ['GAIN', 8, [[0.80699998, 0.01596000, |
1005 + | -0.00020470], |
1006 + | [0.80699998, 0.01596000, |
1007 + | -0.00020470]], 1E-8], |
1008 + | ['SENSITIVITY', 8, [0.07699999, 0.06499999], 1E-8], |
1009 + | ] |
1010 + | results = checktable(name, expected) |
1011 + | if not results: |
1012 + | retValue['success']=False |
1013 + | retValue['error_msgs']=retValue['error_msgs']+'Check of table '+name+' failed' |
1014 + | |
1015 + | self.assertTrue(retValue['success']) |
1016 + | |
940 1017 | def suite(): |
941 1018 | return [test_importfitsidi] |
942 1019 | |
943 1020 | if is_CASA6: |
944 1021 | if __name__ == '__main__': |
945 1022 | unittest.main() |