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

condense to a single read per file type with handling for partial reads #393

Merged
merged 5 commits into from Jul 11, 2018

Conversation

bhazelton
Copy link
Member

@bhazelton bhazelton commented Jul 5, 2018

This PR unifies the read interfaces as discussed in telecons.

@plaplant can you review this?
@nkern I'd also like to make sure it works for you

Fixes #389
Fixes #386

Copy link
Member

@plaplant plaplant left a comment

Choose a reason for hiding this comment

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

Looks great! Just a couple very minor things.

ant_str: A string containing information about what kinds of visibility data
to read-in. Can be 'auto', 'cross', 'all'. Cannot provide ant_str if
antenna_nums and/or bls is not None.
polarizations: List of polarization integers or strings to read-in.
Ex: ['xx', 'yy', ...]
time_range: len-2 list containing min and max range of times (Julian Date) to read-in.
Ex: [2458115.20, 2458115.40]
read_data: Read in the visibility and flag data. If set to false,
only the basic header info and metadata (if read_metadata is True)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a separate read_metadata flag? It seems like it's not a kwarg for this function.

Copy link
Member Author

Choose a reason for hiding this comment

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

read_metadata is only a thing for uvfits because uvfits essentially has 3 levels of things to read: header info, metadata and data, so you need two keyword arguments to tell it what to read beyond the header. Miriad only has 2 levels: metadata & data, so it only needs one keyword argument (if you call it at all it reads the metadata).

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that makes sense. Sorry for not being clear, I was just saying that the docstring has a reference to the read_metadata kwarg, so it probably needs to be clarified.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah! Thanks for catching that and I'm sorry I didn't pay enough attention!

# work out what function should be called depending on what's
# already defined on the object
if self.freq_array is not None:
hdr_read = True
Copy link
Member

Choose a reason for hiding this comment

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

100% a style issue: in my head, I read these variables as "should we read in the data?", not "is the data already loaded?". Calling the variables something like hdr_loaded might make the meaning more clear to the casual reader, but I'm also totally fine keeping it the way it is.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, I'll change the names as you suggest.

else:
data_read = False

if not read_data and not read_metadata:
Copy link
Member

Choose a reason for hiding this comment

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

A very complicated dance of logic! The in-line explanations are very helpful :)

Copy link
Member Author

Choose a reason for hiding this comment

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

good! They helped me write the code :)

@@ -1719,6 +1683,21 @@ def read_miriad(self, filepath, correct_lat_lon=True, run_check=True,
Ex: ['xx', 'yy', ...]
time_range: len-2 list containing min and max range of times (Julian Date) to read-in.
Ex: [2458115.20, 2458115.40]
read_data: Read in the visibility and flag data. If set to false,
only the basic header info and metadata (if read_metadata is True)
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, no read_metadata kwarg.

Copy link
Member Author

Choose a reason for hiding this comment

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

Same reasoning as above, your HDF5 files only seem to have 2 levels.

Copy link
Member

@plaplant plaplant left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks for catching the docstring in read_uvh5 too :)

Feel free to merge this in anytime. @nkern does this work for you?

@nkern
Copy link
Contributor

nkern commented Jul 11, 2018

So if I'm not mistaken, this eliminates the UVData.read_miriad_metadata function in favor for a kwarg in UVData.read_miriad that allows the user to do either a full data+metadata read, or just a metadata read. That seems fine to me, I'll have to change some of my scripts to accommodate, but that shouldn't be an issue.

@nkern
Copy link
Contributor

nkern commented Jul 11, 2018

Looks good to me! Feel free to merge.

@bhazelton bhazelton merged commit 1ac364a into master Jul 11, 2018
@bhazelton bhazelton deleted the streamline_read_funcs branch July 11, 2018 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typo in error message Missing documentation for phase_type parameter
3 participants