Skip to content

[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

Conversation

WilliamHPNielsen
Copy link
Contributor

@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 like plot_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:

  • Add two functions average_rowwise and average_columnwise

@codecov
Copy link

codecov bot commented Jan 4, 2019

Codecov Report

Merging #1428 into master will decrease coverage by 0.35%.
The diff coverage is 9.09%.

@@            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

Copy link
Contributor

@astafan8 astafan8 left a 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:
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

indentation

Suggested change
return ax, cbax
return ax, cbax

modified_axs.append(mod_ax)
modified_cbaxs.append(mod_cbax)

return modified_axs, modified_cbaxs
Copy link
Contributor

Choose a reason for hiding this comment

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

missing newline

Suggested change
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}')
Copy link
Contributor

Choose a reason for hiding this comment

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

newline for readability

Suggested change
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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
columns. Leave the line plots unchanged.
rows. Leave the line plots unchanged.

@jenshnielsen jenshnielsen reopened this Jan 4, 2019
@WilliamHPNielsen
Copy link
Contributor Author

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.

@ThorvaldLarsen
Copy link
Contributor

Thanks. @WilliamHPNielsen the quick fix is in PR qdev-dk/qdev-wrappers#166. Just waiting for #1430 then it should be ready for merging.

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

Successfully merging this pull request may close these issues.

4 participants