-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to be able to ignore N-sample while LST-binning #932
Changes from 3 commits
2d62541
68f65da
2f59937
3f2f1f6
592911b
b1288c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
from ..datacontainer import DataContainer | ||
from ..data import DATA_PATH | ||
import shutil | ||
|
||
|
||
@pytest.mark.filterwarnings("ignore:The default for the `center` keyword has changed") | ||
@pytest.mark.filterwarnings("ignore:Degrees of freedom <= 0 for slice") | ||
@pytest.mark.filterwarnings("ignore:Mean of empty slice") | ||
|
@@ -134,7 +136,7 @@ def test_lstbin(self): | |
output = lstbin.lst_bin(self.data_list, self.lst_list, flags_list=None, dlst=0.01, | ||
verbose=False, sig_clip=True, min_N=15, flag_below_min_N=True, sigma=2) | ||
# test wrapping | ||
lst_list = [(copy.deepcopy(l) + 6) % (2 * np.pi) for l in self.lst_list] | ||
lst_list = [(copy.deepcopy(_lst) + 6) % (2 * np.pi) for _lst in self.lst_list] | ||
output = lstbin.lst_bin(self.data_list, lst_list, dlst=0.001, begin_lst=np.pi) | ||
assert output[0][0] > output[0][-1] | ||
assert len(output[0]) == 175 | ||
|
@@ -168,6 +170,33 @@ def test_lstbin(self): | |
assert np.all(np.isclose(output[2][k], output2[2][k])) | ||
assert np.all(np.isclose(output[1][k], output2[1][k])) | ||
|
||
# test weighted_by_nsamples, nsamples are propagated but data is not weighted by nsamples if set to False | ||
output1 = lstbin.lst_bin(self.data_list, self.lst_list, dlst=dlst, | ||
flags_list=self.flgs_list, nsamples_list=self.nsmp_list, | ||
weight_by_nsamples=True) | ||
|
||
nsmps1 = copy.deepcopy(self.nsmps1) | ||
nsmps1[(24, 25, 'ee')][:, 32] = 0 | ||
nsmps2 = copy.deepcopy(self.nsmps2) | ||
nsmps2[(24, 25, 'ee')][:, 32] = 0 | ||
nsmps3 = copy.deepcopy(self.nsmps3) | ||
nsmps3[(24, 25, 'ee')][:, 32] = 0 | ||
nsmps_list = [nsmps1, nsmps2, nsmps3] | ||
output = lstbin.lst_bin(self.data_list, self.lst_list, dlst=dlst, | ||
flags_list=self.flgs_list, nsamples_list=nsmps_list, | ||
weight_by_nsamples=True) | ||
# Check Nsamples are all 0 | ||
assert np.allclose(output[-1][(24, 25, 'ee')].real[:, 32], 0) | ||
# Check data got weighted sum to 0 | ||
assert np.allclose(output[1][(24, 25, 'ee')].real[100, 32], 0) | ||
output = lstbin.lst_bin(self.data_list, self.lst_list, dlst=dlst, | ||
flags_list=self.flgs_list, nsamples_list=nsmps_list, | ||
weight_by_nsamples=False) | ||
# Check Nsamples are all 0 | ||
assert np.allclose(output[-1][(24, 25, 'ee')].real[:, 32], 0) | ||
# Check data is the same as before | ||
assert np.allclose(output[1][(24, 25, 'ee')].real, output1[1][(24, 25, 'ee')].real) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we please extract this into its own test? |
||
def test_lstbin_vary_nsamps(self): | ||
# test execution | ||
pytest.raises(NotImplementedError, lstbin.lst_bin, self.data_list, self.lst_list, flags_list=self.flgs_list, | ||
|
@@ -244,6 +273,16 @@ def test_lst_bin_files(self): | |
os.remove(output_lst_file) | ||
os.remove(output_std_file) | ||
|
||
# test weight_by_nsamples | ||
lstbin.lst_bin_files(self.data_files, ntimes_per_file=250, outdir="./", overwrite=True, | ||
verbose=False, rephase=True, weight_by_nsamples=False, file_ext=file_ext) | ||
output_lst_file = "./zen.ee.LST.0.20124.uvh5" | ||
output_std_file = "./zen.ee.STD.0.20124.uvh5" | ||
assert os.path.exists(output_lst_file) | ||
assert os.path.exists(output_std_file) | ||
os.remove(output_lst_file) | ||
os.remove(output_std_file) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also extract this into its own test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually so for here I did not do anything I just tested there is no error running this new option so it kind of falls into the "# basic execution" catalogue, similar to all the tests above like testing the |
||
# test data_list is empty | ||
data_files = [[sorted(glob.glob(DATA_PATH + '/zen.2458043.*XRAA.uvh5'))[0]], | ||
[sorted(glob.glob(DATA_PATH + '/zen.2458045.*XRAA.uvh5'))[-1]]] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work. As far as I know, there's no way to set the flag to False on the command line. So I think you'll need to use something like
--weight-by-flags-only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, thanks! I will switch all the options to
weight_by_flags_only
.