-
Notifications
You must be signed in to change notification settings - Fork 327
[wip] Suggestion for averaging with plot_by_id #1428
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
[wip] Suggestion for averaging with plot_by_id #1428
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1428 +/- ##
=========================================
- Coverage 74.26% 73.9% -0.36%
=========================================
Files 85 85
Lines 9946 10001 +55
=========================================
+ Hits 7386 7391 +5
- Misses 2560 2610 +50 |
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.
nice and sweet!
Comments for the notebook:
- "Note that this function produces the same output." -> probably better to say that the output types of those functions are similar.
And this is indeed quite weird to work with the data via plotting objects in my opinion. Hence i'd suggest that this does not live in qcodes. Or I just need to think it over again.
# | ||
|
||
|
||
def _get_axis(coords: np.ndarray, avg_dim: str) -> np.ndarray: |
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 file is becoming too big, shall we give this a separate module maybe? :)
|
||
mesh = ax.collections[0] | ||
if not isinstance(mesh, QuadMesh): | ||
return ax, cbax |
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.
indentation
return ax, cbax | |
return ax, cbax |
modified_axs.append(mod_ax) | ||
modified_cbaxs.append(mod_cbax) | ||
|
||
return modified_axs, modified_cbaxs |
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.
missing newline
return modified_axs, modified_cbaxs | |
return modified_axs, modified_cbaxs | |
elif avg_dim == 'row': | ||
bins = coords[:, 0][:, 1] | ||
else: | ||
raise ValueError(f'Unknown avg_dim: {avg_dim}') |
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.
newline for readability
raise ValueError(f'Unknown avg_dim: {avg_dim}') | |
raise ValueError(f'Unknown avg_dim: {avg_dim}') | |
def average_rowwise(axs_and_cbaxs: AxesTupleList) -> AxesTupleList: | ||
""" | ||
Take the output plots of plot_by_id and average every heatmap along its | ||
columns. Leave the line plots unchanged. |
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.
columns. Leave the line plots unchanged. | |
rows. Leave the line plots unchanged. |
I'm closing this since we've agreed to do something else instead. It's better to pass some data object between operations than a matplotlib object. Thorvald will make a quickfix PR in wrappers. |
Thanks. @WilliamHPNielsen the quick fix is in PR qdev-dk/qdev-wrappers#166. Just waiting for #1430 then it should be ready for merging. |
@ThorvaldLarsen requested the possibility to average heatmap produced by
plot_by_id
along rows or columns. The averaging is only supposed to be for visualisation. Thorvald, does this do the trick?This PR introduces two small functions to do that. There is a notebook explaining the concept, but no tests, since I am not really sure whether this ought to go into wrappers instead.
@jenshnielsen and @astafan8, let me know what you think.
The idea is to have functions that return
axs, cbs
(but modified with whatever operation that function does) just likeplot_by_id
, so that daisychaining becomes easy. Of course, for the two functions introduced in this PR, there can be no meaningful daisychaining, but we could imagine future functions for e.g. subtracting averages.Changes proposed in this pull request:
average_rowwise
andaverage_columnwise