-
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6f952a2
[FEAT] Add plot that shows the max depth of each profile
tillmrtz 87f5376
changed function plot_max_depth_per_profile() accroding to Chiara's c…
tillmrtz 9b4581c
created a test function and added the function in the demo notebook
tillmrtz f6f016c
try again
tillmrtz 86b2a37
and again
tillmrtz ad026fd
Merge branch 'main' into Till-patch1
tillmrtz 3d009e4
added test function for max depth
tillmrtz 0675d6c
Wrong function called in test
tillmrtz 845cee2
Merge branch 'Till-patch1' of github.com:tillmrtz/glidertest into Til…
tillmrtz fa2d266
last try
tillmrtz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1305,3 +1305,43 @@ 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, ax = None, **kw: dict) -> tuple({plt.Figure, plt.Axes}): | ||
""" | ||
This function can be used to plot the maximum depth of each profile in a dataset. | ||
|
||
Parameters | ||
---------- | ||
ds: xarray on OG1 format containing the profile number and the maximum depth. | ||
bins: int, optional (default=20) | ||
|
||
Returns | ||
------- | ||
One figure with two plots illustrating the max depth of each profile and a histogram of the max depths | ||
|
||
Original author | ||
---------------- | ||
Till Moritz | ||
""" | ||
max_depths = tools.max_depth_per_profile(ds) | ||
profile_nums = max_depths.profile_num | ||
with plt.style.context(glidertest_style_file): | ||
if ax is None: | ||
fig, ax = plt.subplots(1, 2) | ||
force_plot = True | ||
else: | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. You can avoid creating a new variable and just say: |
||
ax[0].set_xlabel('Profile number') | ||
ax[0].set_ylabel(f'Max depth ({max_depths.units})') | ||
ax[0].set_title('Max depth per profile') | ||
ax[1].hist(max_depths, bins=bins) | ||
ax[1].set_xlabel(f'Max depth ({max_depths.units})') | ||
ax[1].set_ylabel('Number of profiles') | ||
ax[1].set_title('Histogram of max depth per profile') | ||
[a.grid() for a in ax] | ||
if force_plot: | ||
plt.show() | ||
return fig, ax |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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
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()