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

plot only one lightcurve rather than all #270

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

xoubish
Copy link
Contributor

@xoubish xoubish commented Apr 11, 2024

The plotting of light curve plotted all in a df_lc, I added a module to only plot one given an index (create_figures was there so I added create_figure)

@xoubish xoubish requested review from afaisst and troyraen April 11, 2024 19:21
Copy link
Contributor

@troyraen troyraen left a comment

Choose a reason for hiding this comment

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

I think it makes a lot of sense to have a function that makes a single plot.

Can you update create_figures to use this new function? There is very little difference between the two and all the duplicated code is hard to maintain. Alternately, you could get rid of create_figures altogether and just put the little bit of extra logic needed to create multiple plots right in the main notebook.

One other suggestion below about using objectid.

Comment on lines +109 to +110
index : int
Index of the object to plot. This is not the object ID but the position in the list of grouped objects.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use the objectid? This is exactly what it's for. A positional index is ambiguous since rows for the same object can be scattered around the dataframe. Even if the meaning were clear, using that index forces the user to do an additional step to figure out what it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had forgotten that objectid is just an index, I was thinking it comes from the main catalog where the RA/DEC were read and thought it would be difficult to figure out which ids exist.

Comment on lines +123 to +128
grouped = list(df_lc.groupby('objectid'))
if index < 0 or index >= len(grouped):
print(f"Index {index} is out of bounds. No figure created.")
return False

objectid, singleobj_df = grouped[index]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to give unexpected results unless clearly documented. The groupby done in the top line will sort the groups by objectid. If the user had them sorted differently when they found the index, the last line will grab a different group than they wanted.

It would be more direct and unambiguous to have the user send in an objectid and use it to get the right group here, like: df_lc.groupby('objectid').get_group(objectid).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants