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

plot_tune_summary crashing for unassigned channels in v7.2.0 #757

Closed
swh76 opened this issue Jan 24, 2023 · 0 comments · Fixed by #758
Closed

plot_tune_summary crashing for unassigned channels in v7.2.0 #757

swh76 opened this issue Jan 24, 2023 · 0 comments · Fixed by #758
Assignees
Labels
bug Something isn't working

Comments

@swh76
Copy link
Collaborator

swh76 commented Jan 24, 2023

Describe the bug

The plot_tune_summary function crashes in latest pysmurf version v7.2.0 if any channels are unassigned. This is an unanticipated consequence of recent PR #741. Right now the function just crashes out on the first unassigned channel it encounters while plotting with an error like this:

[ 2023-01-21 07:40:26 ]  Eta plot 1 of 65
[ 2023-01-21 07:40:27 ]  Eta plot 2 of 65
[ 2023-01-21 07:40:27 ]  Eta plot 3 of 65
[ 2023-01-21 07:40:28 ]  Eta plot 4 of 65
[ 2023-01-21 07:40:28 ]  Eta plot 5 of 65
[ 2023-01-21 07:40:29 ]  Eta plot 6 of 65
[ 2023-01-21 07:40:29 ]  Eta plot 7 of 65
[ 2023-01-21 07:40:30 ]  Eta plot 8 of 65
[ 2023-01-21 07:40:31 ]  Eta plot 9 of 65
[ 2023-01-21 07:40:31 ]  Eta plot 10 of 65
[ 2023-01-21 07:40:32 ]  Eta plot 11 of 65
[ 2023-01-21 07:40:32 ]  Eta plot 12 of 65
[ 2023-01-21 07:40:33 ]  Eta plot 13 of 65
[ 2023-01-21 07:40:34 ]  Eta plot 14 of 65
[ 2023-01-21 07:40:34 ]  Eta plot 15 of 65
[ 2023-01-21 07:40:35 ]  Eta plot 16 of 65
[ 2023-01-21 07:40:35 ]  Eta plot 17 of 65
[ 2023-01-21 07:40:36 ]  Eta plot 18 of 65
[ 2023-01-21 07:40:37 ]  Eta plot 19 of 65
[ 2023-01-21 07:40:37 ]  Eta plot 20 of 65
/usr/local/src/pysmurf/python/pysmurf/client/tune/smurf_tune.py:1410: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  fig = plt.figure(figsize=(9,4.5))
[ 2023-01-21 07:40:38 ]  Eta plot 21 of 65
[ 2023-01-21 07:40:38 ]  Eta plot 22 of 65
[ 2023-01-21 07:40:39 ]  Eta plot 23 of 65
[ 2023-01-21 07:40:39 ]  Eta plot 24 of 65
[ 2023-01-21 07:40:40 ]  Eta plot 25 of 65
[ 2023-01-21 07:40:41 ]  Eta plot 26 of 65
[ 2023-01-21 07:40:41 ]  Eta plot 27 of 65
[ 2023-01-21 07:40:42 ]  Eta plot 28 of 65
[ 2023-01-21 07:40:42 ]  Eta plot 29 of 65
[ 2023-01-21 07:40:43 ]  Eta plot 30 of 65
[ 2023-01-21 07:40:44 ]  Eta plot 31 of 65
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-24-8547bcb77669> in <module>
     13 # Refine eta calibrations
     14 S.run_serial_eta_scan(band)
---> 15 S.plot_tune_summary(band,eta_scan=True,show_plot=True)

/usr/local/src/pysmurf/python/pysmurf/client/util/pub.py in wrapper(S, pub_action, *args, **kwargs)
     48                     S.pub._action_ts = S.get_timestamp()
     49 
---> 50                 rv = func(S, *args, **kwargs)
     51 
     52             finally:

/usr/local/src/pysmurf/python/pysmurf/client/tune/smurf_tune.py in plot_tune_summary(self, band, eta_scan, show_plot, save_plot, eta_width, channels, plot_summary, plotname_append)
    572                         timestamp=timestamp, save_plot=save_plot,
    573                         show_plot=show_plot, peak_freq=r['freq'],
--> 574                         channel=channel, plotname_append=plotname_append)
    575 
    576     @set_action()

/usr/local/src/pysmurf/python/pysmurf/client/util/pub.py in wrapper(S, pub_action, *args, **kwargs)
     48                     S.pub._action_ts = S.get_timestamp()
     49 
---> 50                 rv = func(S, *args, **kwargs)
     51 
     52             finally:

/usr/local/src/pysmurf/python/pysmurf/client/tune/smurf_tune.py in plot_eta_fit(self, freq, resp, eta, eta_mag, peak_freq, eta_phase_deg, r2, save_plot, plotname_append, show_plot, timestamp, res_num, band, sk_fit, f_slow, resp_slow, channel)
   1398         I = np.real(resp)
   1399         Q = np.imag(resp)
-> 1400         amp = np.sqrt(I**2 + Q**2)
   1401         phase = np.unwrap(np.arctan2(Q, I))  # radians
   1402 

TypeError: unsupported operand type(s) for ** or pow(): 'NoneType' and 'int'

it chokes when it tries to plot the data from the the freq_resp dictionary because the stored response and frequency data is None;

# print(S.freq_resp[0]['resonances'][30])
{'freq': 4322.52, 'eta': 1, 'eta_scaled': 1, 'eta_phase': 0, 'r2': 1, 'eta_mag': 1, 'latency': 0, 'Q': 1, 'freq_eta_scan': None, 'resp_eta_scan': None, 'subband': 315, 'channel': -1, 'offset': 0.5200000000004366}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant