-
Notifications
You must be signed in to change notification settings - Fork 20
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
base: main
Are you sure you want to change the base?
Conversation
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 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
.
index : int | ||
Index of the object to plot. This is not the object ID but the position in the list of grouped objects. |
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.
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.
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 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.
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] |
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.
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)
.
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)