-
Notifications
You must be signed in to change notification settings - Fork 6
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
[FEAT] Add plot that shows the max depth of each profile #159
Conversation
tillmrtz
commented
Dec 3, 2024
•
edited
Loading
edited
To do:
|
@@ -1305,3 +1305,38 @@ def plot_ioosqc(data, suspect_threshold=[25], fail_threshold=[50], title='', ax= | |||
if force_plot: | |||
plt.show() | |||
return fig, ax | |||
|
|||
def plot_max_depth_per_profile(ds: xr.Dataset, bins= 20, **kw: dict) -> tuple({plt.Figure, plt.Axes}): | |||
""" |
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.
add ax as a parameter
ax=None
And add below the
if ax is None:
fig, ax = plt.subplots()
force_plot = True
else:
fig = plt.gcf()
force_plot = False
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.
You can check the other examples and the end you would put also
if force_plot:
plt.show()
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.
Changed to:
if ax is None:
fig, ax = plt.subplots(1,2)
force_plot = True
I hope this is correct, since I want to plots, like in plot_outlier_duration()
glidertest/plots.py
Outdated
ax[0].set_xlabel('Profile Number') | ||
ax[0].set_ylabel('Max Depth') | ||
ax[0].set_title('Max Depth per Profile') | ||
ax[0].grid() |
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.
Maybe to avoid repetition you can do a
[a.grid() for a in ax]
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.
done
glidertest/plots.py
Outdated
max_depths = group_profiles.values | ||
profile_nums = group_profiles.profile_num.values | ||
with plt.style.context(glidertest_style_file): | ||
fig, ax = plt.subplots(1, 2, figsize=(18, 6)) |
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.
The figure size is already specified in the glidertest_style_file and is 14,10
We do change it in the function when we make them smaller (ex. plot_basic_vars
)
I suggest we keep the standard size and resize later if desired by specifying the figure size
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.
Deleted the figsize adjustment
glidertest/plots.py
Outdated
with plt.style.context(glidertest_style_file): | ||
fig, ax = plt.subplots(1, 2, figsize=(18, 6)) | ||
ax[0].plot(profile_nums, max_depths,**kw) | ||
ax[0].set_xlabel('Profile Number') |
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.
We are generally using capital letter only for the first 'word' so maybe change to 'Profile number'
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.
Changed
glidertest/plots.py
Outdated
fig, ax = plt.subplots(1, 2, figsize=(18, 6)) | ||
ax[0].plot(profile_nums, max_depths,**kw) | ||
ax[0].set_xlabel('Profile Number') | ||
ax[0].set_ylabel('Max Depth') |
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.
Same as before maybe use 'Max depth' and add units in round paranthesis
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.
Chnaged
glidertest/plots.py
Outdated
ax[0].plot(profile_nums, max_depths,**kw) | ||
ax[0].set_xlabel('Profile Number') | ||
ax[0].set_ylabel('Max Depth') | ||
ax[0].set_title('Max Depth per Profile') |
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.
Same here with the capitall letters
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.
done
glidertest/plots.py
Outdated
ax[1].hist(max_depths, bins=bins) | ||
ax[1].set_xlabel('Max Depth') | ||
ax[1].set_ylabel('Number of Profiles') | ||
ax[1].set_title('Histogram of Max Depth per Profile') |
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.
ax[1] labels and title without the extra capital letters
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.
done
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.
Revised the max_depth_per_profile
glidertest/plots.py
Outdated
fig = plt.gcf() | ||
force_plot = False | ||
|
||
ax[0].plot(profile_nums, max_depths,**kw) |
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.
You can avoid creating a new variable and just say:
ax[0].plot(max_depths.profile_num, max_depths,**kw)
Looks good! You now want to make the tests and add this function to the demo |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
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.
Created the test function and added the max-depth plot to demo notebook
All changes approved |