Commits
57 57 | myshape = wtsp.shape |
58 58 | ncorr = myshape[0] |
59 59 | nrow = myshape[2] |
60 60 | rtol = 1e-7 |
61 61 | for row in range(nrow): |
62 62 | fr = numpy.extract(numpy.logical_not(flag[:,:,row]), dr[:,:,row]) |
63 63 | fi = numpy.extract(numpy.logical_not(flag[:,:,row]), di[:,:,row]) |
64 64 | if len(fr) <= 1: |
65 65 | expec = 0 |
66 66 | else: |
67 - | print "len real", len(fr) |
68 - | print "len imag", len(fi) |
69 67 | vr = numpy.var(fr, ddof=1) |
70 68 | vi = numpy.var(fi, ddof=1) |
71 69 | expec = 2/(vr + vi) |
72 70 | self.assertTrue( |
73 71 | numpy.all(numpy.isclose(wt[:, row], expec, rtol=rtol)), |
74 72 | "WEIGHT fail at row" + str(row) + ". got: " + str(wt[:, row]) + " expec " + str(expec) |
75 73 | ) |
76 74 | self.assertTrue(len(numpy.unique(wtsp[:,:,row])) == 1, "Weight values are not the same") |
77 75 | self.assertTrue(numpy.all(numpy.isclose(wtsp[:,:,row], expec, rtol)), "Incorrect weights") |
78 76 | if expec == 0: |
110 108 | """Test channel binning""" |
111 109 | mytb = tbtool() |
112 110 | mytb.open(src) |
113 111 | expflag = mytb.getcol("FLAG") |
114 112 | expfrow = mytb.getcol("FLAG_ROW") |
115 113 | mytb.done() |
116 114 | dst = "ngc5921.split.ms" |
117 115 | for i in [0,1]: |
118 116 | for chanbin in ["195.312kHz", 8]: |
119 117 | shutil.copytree(src, dst) |
120 - | myms = mstool() |
121 118 | if i == 0: |
119 + | myms = mstool() |
122 120 | myms.open(dst, nomodify=False) |
123 121 | myms.statwt2(chanbin=chanbin) |
124 122 | myms.done() |
125 123 | else: |
126 124 | statwt2(dst, chanbin=chanbin) |
127 125 | [wt, wtsp, flag, frow, data] = _get_dst_cols(dst) |
128 126 | dr = numpy.real(data) |
129 127 | di = numpy.imag(data) |
130 128 | myshape = wtsp.shape |
131 129 | ncorr = myshape[0] |
155 153 | self.assertTrue( |
156 154 | numpy.all(numpy.isclose(wt[:, row], expwt, rtol=rtol)), |
157 155 | "WEIGHT fail at row" + str(row) + ". got: " + str(wt[:, row]) + " expec " + str(expec) |
158 156 | ) |
159 157 | if expec == 0: |
160 158 | self.assertTrue(frow[row], "FLAG_ROW is not true") |
161 159 | else: |
162 160 | self.assertFalse(frow[row], "FLAG_ROW is not false") |
163 161 | shutil.rmtree(dst) |
164 162 | |
163 + | def test_minsamp(self): |
164 + | """Test minimum number of points""" |
165 + | dst = "ngc5921.split.minsamp.ms" |
166 + | for i in [0,1]: |
167 + | for minsamp in [60, 80]: |
168 + | shutil.copytree(src, dst) |
169 + | if i == 0: |
170 + | myms = mstool() |
171 + | myms.open(dst, nomodify=False) |
172 + | myms.statwt2(minsamp=minsamp) |
173 + | myms.done() |
174 + | else: |
175 + | statwt2(dst, minsamp=minsamp) |
176 + | [wt, wtsp, flag, frow, data] = _get_dst_cols(dst) |
177 + | if minsamp == 60: |
178 + | self.assertTrue((wt[:, 30] > 0).all(), "Incorrect weight row 30") |
179 + | self.assertTrue((wtsp[:, :, 30] > 0).all(), "Incorrect weight spectrum row 30") |
180 + | self.assertFalse(flag[:,:,30].all(), "Incorrect flag row 30") |
181 + | self.assertFalse(frow[30], "Incorrect flagrow row 30") |
182 + | else: |
183 + | self.assertTrue((wt[:, 30] == 0).all(), "Incorrect weight row 30") |
184 + | self.assertTrue((wtsp[:, :, 30] == 0).all(), "Incorrect weight spectrum row 30") |
185 + | self.assertTrue(flag[:,:,30].all(), "Incorrect flag row 30") |
186 + | self.assertTrue(frow[30], "Incorrect flagrow row 30") |
187 + | shutil.rmtree(dst) |
188 + | |
165 189 | def suite(): |
166 190 | return [statwt2_test] |
167 191 | |