@@ -55,6 +55,43 @@ def test_read_antpos():
5555 np .testing .assert_allclose (test_antpos , test_obj .antpos )
5656
5757
58+ def test_calc_uvw ():
59+ """Antenna Position file to uvws test.
60+
61+ Read in antenna positions, convert to uvws,
62+ check equality with predefined uvw file.
63+ """
64+ test_obj = UVGridder ()
65+ test_obj .read_antpos (
66+ os .path .join (TEST_DATA_PATH , "test_antpos.txt" ), skiprows = 1 , delimiter = ","
67+ )
68+ test_antpos = np .array (
69+ [
70+ [0 , 0 , 0 ],
71+ [1 , 0 , 0 ],
72+ [0 , 1 , 0 ],
73+ [- 1 , 0 , 0 ],
74+ [0 , - 1 , 0 ],
75+ [1 , 1 , 0 ],
76+ [- 1 , - 1 , 0 ],
77+ [1 , - 1 , 0 ],
78+ [- 1 , 1 , 0 ],
79+ ]
80+ ).T
81+
82+ u = (
83+ np .expand_dims (test_antpos [0 ], 0 ).astype (np .float64 )
84+ - np .expand_dims (test_antpos [0 ], 1 ).astype (np .float64 )
85+ ).ravel ()
86+ v = (
87+ np .expand_dims (test_antpos [1 ], 0 ).astype (np .float64 )
88+ - np .expand_dims (test_antpos [1 ], 1 ).astype (np .float64 )
89+ ).ravel ()
90+
91+ np .testing .assert_allclose (u , test_obj .uvw_array [0 ])
92+ np .testing .assert_allclose (v , test_obj .uvw_array [1 ])
93+
94+
5895def test_freq_from_int ():
5996 """Create frequency array from integer input."""
6097 test_obj = UVGridder ()
@@ -142,19 +179,26 @@ def test_zero_uvbin():
142179 test_uvbin = {}
143180 test_obj .set_uvw_array (test_uvw )
144181 test_obj .uvw_to_dict ()
182+
145183 assert test_obj .uvbins == test_uvbin
146184
147185
148186def test_uvbin_is_dict ():
149187 """Test uvbins get saved as dict."""
150188 test_obj = UVGridder ()
151- test_uvw = np .zeros ((3 , 200 )) + np .array ([[14.6 ], [0 ], [0 ]])
152- test_uvbin = {"14.600,0.000" : 200 }
189+ test_uvw = np .concatenate (
190+ [
191+ np .tile ([14.6 , 0 , 0 ], (1 , 1 )),
192+ np .tile ([0 , 14.6 , 0 ], (2 , 1 )),
193+ np .tile ([14.6 , 14.6 , 0 ], (3 , 1 )),
194+ ],
195+ axis = 0 ,
196+ ).T
197+ test_uvbin = {"14.600,0.000" : 1 , "0.000,14.600" : 2 , "14.600,14.600" : 3 }
198+ test_uvbin = {np .str_ (key ): np .int64 (val ) for (key , val ) in test_uvbin .items ()}
153199 test_obj .set_uvw_array (test_uvw )
154200 test_obj .uvw_to_dict ()
155- print (f"{ test_uvbin = :} " )
156- print (f"{ test_obj .uvbins = :} " )
157- test_obj .uvbins == test_uvbin
201+ np .testing .assert_equal (test_obj .uvbins , test_uvbin )
158202
159203
160204def test_gauss_sum ():
0 commit comments