Skip to content
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

Add EstimatorPubResult with plotting methods #1820

Open
4 tasks
ihincks opened this issue Jul 26, 2024 · 0 comments · May be fixed by #1951
Open
4 tasks

Add EstimatorPubResult with plotting methods #1820

ihincks opened this issue Jul 26, 2024 · 0 comments · May be fixed by #1951
Assignees
Labels
enhancement New feature or request

Comments

@ihincks
Copy link
Collaborator

ihincks commented Jul 26, 2024

What is the expected feature or enhancement?

Just like there exists a SamplerPubResult, we should introduce an EstimatorPubResult. The value of this is that we can add convenience methods to the pub result class. For example, methods to help plot ZNE data would be especially helpful.

** Details

Here is a snippet that makes a plot. Please note that it is just something I found lying around that may help the assignee get started---it's certainly not meant to represent exactly what we need.

result = service.job(<some zne job id>).result()
pub_result = result[0]

nfs = result.metadata["resilience"]["zne"]["noise_factors"]
nfs_x = result.metadata["resilience"]["zne"]["extrapolated_noise_factors"]

models = result.metadata["resilience"]["zne"]["extrapolator"]
plt.figure(figsize=(5 * len(models), 4))

for idx_model, model in enumerate(models):
    plt.subplot(1, len(models), idx_model + 1)
    for idx in range(pub_result.data.evs_noise_factors.shape[2]):
        lines = plt.errorbar(
            nfs,
            pub_result.data.evs_noise_factors[0,0,idx],
            fmt='.',
            yerr=pub_result.data.stds_noise_factors[0,0,idx]
        )

        plt.plot(
            nfs_x,
            means:=pub_result.data.evs_extrapolated[0,0,idx,idx_model,:],
            color=(color:=lines[0].get_color()),
            alpha=0.3
        )

        plt.fill_between(
            nfs_x,
            means-(stds:=pub_result.data.stds_extrapolated[0,0,idx, idx_model, :]),
            means+ stds,
            color=color,
            alpha=0.1
        )

        plt.ylim([-0.05,1.05])

Acceptance criteria

  • Estimator jobs return EstimatorPubResults
  • The new pub result class has a plotting method for ZNE
  • The plotting method raises sensible errors when ZNE data is not present
  • The plot looks good in a variety of regimes, such as when the fit blows up to infinity because of insufficient data
@ihincks ihincks added the enhancement New feature or request label Jul 26, 2024
@joshuasn joshuasn self-assigned this Sep 10, 2024
@joshuasn joshuasn linked a pull request Sep 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants