-
-
Notifications
You must be signed in to change notification settings - Fork 396
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
Get list of unique products #3096
Changes from all commits
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 |
---|---|---|
|
@@ -457,6 +457,8 @@ def get_product_list_async(self, observations): | |
Note that obsid is NOT the same as obs_id, and inputting obs_id values will result in | ||
an error. See column documentation `here <https://masttest.stsci.edu/api/v0/_productsfields.html>`__. | ||
|
||
To return unique data products, use ``Observations.get_unique_product_list``. | ||
|
||
Parameters | ||
---------- | ||
observations : str or `~astropy.table.Row` or list/Table of same | ||
|
@@ -959,8 +961,32 @@ def _remove_duplicate_products(self, data_products): | |
number_unique = len(unique_products) | ||
if number_unique < number: | ||
log.info(f"{number - number_unique} of {number} products were duplicates. " | ||
f"Only downloading {number_unique} unique product(s).") | ||
f"Only returning {number_unique} unique product(s).") | ||
|
||
return unique_products | ||
|
||
def get_unique_product_list(self, observations): | ||
""" | ||
Given a "Product Group Id" (column name obsid), returns a list of associated data products with | ||
unique dataURIs. Note that obsid is NOT the same as obs_id, and inputting obs_id values will result in | ||
an error. See column documentation `here <https://masttest.stsci.edu/api/v0/_productsfields.html>`__. | ||
|
||
Parameters | ||
---------- | ||
observations : str or `~astropy.table.Row` or list/Table of same | ||
Row/Table of MAST query results (e.g. output from `query_object`) | ||
or single/list of MAST Product Group Id(s) (obsid). | ||
See description `here <https://masttest.stsci.edu/api/v0/_c_a_o_mfields.html>`__. | ||
|
||
Returns | ||
------- | ||
unique_products : `~astropy.table.Table` | ||
Table containing products with unique dataURIs. | ||
""" | ||
products = self.get_product_list(observations) | ||
unique_products = self._remove_duplicate_products(products) | ||
if len(unique_products) < len(products): | ||
log.info("To return all products, use `Observations.get_product_list`") | ||
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. This log message could be slightly more informative if you include the numbers, for example "{len(products) - len(unique_products)} duplicate products removed; To return all products, use 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. Ah never mind, the other log message captures that info! You're way ahead of me :) |
||
return unique_products | ||
|
||
|
||
|
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.
Nitpicking, but it would be nice to avoid (and also clean up) these types of
here
links. Some reading in the topics: https://heyoka.medium.com/dont-use-click-here-f32f445d1021We have a bunch of these already, mostly in the mast module, so I don't hold merging up, but I would really encourage a cleanup.