|
1 | 1 | from time import perf_counter |
| 2 | +import math |
2 | 3 | import io |
3 | 4 | import zipfile |
4 | 5 | import base64 |
@@ -266,7 +267,9 @@ def update( |
266 | 267 | y_gate, y_amplitude, y_resolution, |
267 | 268 | n_charges, plot_choice, |
268 | 269 | auto_vg, print_charge_state, |
269 | | - *dac_values |
| 270 | + *dac_values, |
| 271 | + minimal_area_fraction : float = 0.008, |
| 272 | + maxmim_number_of_charge_states : int = 100 |
270 | 273 | ): |
271 | 274 | """ |
272 | 275 | Update the heatmap based on the input values and return the |
@@ -364,15 +367,22 @@ def update( |
364 | 367 | fig.update_xaxes(title_text=x_gate, ticktext=x_text, tickvals=x_tickvals) |
365 | 368 | fig.update_yaxes(title_text=y_gate, ticktext=y_text, tickvals=y_tickvals) |
366 | 369 |
|
367 | | - charge_states = unique_last_axis(n).astype(int) |
| 370 | + n_int = n.astype(int) |
| 371 | + charge_states = unique_last_axis(n_int) |
| 372 | + total_size = math.prod(n.shape[:-1]) |
368 | 373 |
|
369 | 374 | # Optionally annotate the figure with the distinct charge states |
370 | 375 | if print_charge_state == 'True': |
371 | | - if charge_states.shape[0] <= 100: |
| 376 | + if charge_states.shape[0] <= maxmim_number_of_charge_states: |
372 | 377 | for charge_state in charge_states: |
373 | | - ix, iy = np.where(np.all(n == charge_state, axis=-1)) |
| 378 | + ix, iy = np.where(np.all(n_int == charge_state, axis=-1)) |
374 | 379 | avg_x = iy.mean() |
375 | 380 | avg_y = ix.mean() |
| 381 | + |
| 382 | + area_fraction = ix.size / total_size |
| 383 | + if area_fraction < minimal_area_fraction: |
| 384 | + continue |
| 385 | + |
376 | 386 | label = ','.join(map(str, charge_state)) |
377 | 387 | fig.add_annotation( |
378 | 388 | x=avg_x, |
|
0 commit comments