Skip to content
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

Refactor bootstrapping code #27

Merged
merged 17 commits into from
Mar 12, 2018
Merged

Refactor bootstrapping code #27

merged 17 commits into from
Mar 12, 2018

Conversation

philbull
Copy link
Collaborator

Refactor the support functions for bootstrapping, and the way PSpecData handles groups of baselines.

@acliu acliu mentioned this pull request Feb 1, 2018
@coveralls
Copy link

coveralls commented Feb 20, 2018

Coverage Status

Coverage increased (+3.4%) to 70.936% when pulling 2c949d4 on boot_refactor into f941d8b on pspec_graduation.

@philbull philbull self-assigned this Feb 20, 2018
Copy link

@carinacheng carinacheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the "group_baselines" function: If "keep_remainder" is True, can we tack on each of the 'remainder' baselines onto a group? For example, if there are 52 baselines and 5 groups, instead of having 5 groups of 10 and a remainder group of 2, can we have 5 groups total, where 3 of the groups have 10 and 2 of them have 11?

@philbull
Copy link
Collaborator Author

Sure, I can make it do that.

@philbull
Copy link
Collaborator Author

OK, I've addressed @carinacheng's comment, fixed some bugs, and added unit tests.

 * Implement test to check normalisation using Parseval's theorem
   (based on code by Aaron E-W)
 * Add functions to return power spectrum units and array of delays
@philbull
Copy link
Collaborator Author

philbull commented Mar 4, 2018

I've now (hopefully) fixed the units of pspec(), added tests on the normalisation based on Parseval's theorem, and added a couple of extra methods to output units and an array of delays.

Copy link
Contributor

@acliu acliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the specific comments, I would also like:
i) an iPython notebook demonstrating the bootstrap stuff.
ii) some tests for new functions related to the units + axes of pspec outputs.


# Randomize baseline order if requested
if randomize:
if seed is not None: random.seed(seed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to have the seed default to a time seed if it's "None"? When no seed is used, the answer ends up the same every time, and I think we want to avoid that.

Bootstrap-sampled set of baselines (will include multiple instances of
some baselines).
"""
if seed is not None: random.seed(seed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same concern here.

raise IndexError("No datasets have been added yet; cannot "
"calculate power spectrum units.")
else:
pspec_units = "(%s)^2 (ns)^-1" % self.dsets[0].vis_units
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any other reference in the code to vis_units. Has this been implemented?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.dsets[0] is a UVData object. The UVData class has a standard property called vis_units, so I think this should be fine.

Test baseline grouping behavior.
"""
# Generate example lists of baselines
bls1 = [(0,i) for i in range(1)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original pspecdata tutorial notebook has tuples with 3 elements. I think the code works fine with 3-element tuples (right?), but all of this should be clarified.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll add a comment in the tests. This code just shuffles tuples or lists of tuples -- it doesn't care if they are valid 3-element baseline tuples or not. I think we don't need a validity check at this point either, as all of that will be done on passing the baselines into pspec()


def test_parseval(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually no longer sure that this is the right test. Let's talk about it in person.


# Check that random seed works
g1 = boot.group_baselines(bls5, 3, randomize=True, seed=10)
g2 = boot.group_baselines(bls5, 3, randomize=True, seed=11)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g2 doesn't seem to be used?

"""
Group baselines together into equal-sized sets.

These groups can be passed into PSpecData.pspec(), where the corresponding
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have an explicit demonstration of this?

@philbull philbull added this to the Ready for IDR 2.1 analysis milestone Mar 12, 2018
@philbull
Copy link
Collaborator Author

By agreement with Adrian, some of the requested changes (e.g. to documentation) can be made at a later date. We will merge this now to push forward the graduation of this code into master...

@philbull philbull merged commit 845d9c0 into pspec_graduation Mar 12, 2018
@philbull philbull deleted the boot_refactor branch March 12, 2018 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants