Skip to content

Commit 6a8ec7e

Browse files
authored
Merge pull request #53 from spice-herald/maintenance/qetpy
Update for QETpy >= v1.7.2
2 parents 197ff6d + cf00d66 commit 6a8ec7e

File tree

3 files changed

+50
-62
lines changed

3 files changed

+50
-62
lines changed

pytesdaq/analyzer/analyzer.py

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,10 @@ def fit_didv(self, data_array=None, sample_rate=None, unit='Amps',
430430
r0 = analysis_config['r0'][ichan]
431431
rp = analysis_config['rp'][ichan]
432432
dt = analysis_config['dt'][ichan]
433-
add180phase=analysis_config['add_180phase'][ichan]
433+
add180phase = analysis_config['add_180phase'][ichan]
434+
tes_bias = analysis_config['tes_bias'][ichan]
434435

436+
435437
if add_autocuts:
436438
cut = qp.autocuts_didv(
437439
traces,
@@ -478,78 +480,77 @@ def fit_didv(self, data_array=None, sample_rate=None, unit='Amps',
478480
signal.filtfilt(b, a, data_array_truncated[ichan,:], axis=-1,
479481
padtype='even')
480482
)
481-
482-
483+
483484
# fit
484485
result = None
486+
poles = None
485487
if do_fit_1pole:
486488
print('Info: Starting dIdV 1-pole Fit')
487489
didv_inst.dofit(1)
488490
result = didv_inst.fitresult(1)
491+
poles = 1
489492
print('Info: dIdV 1-pole Fit Done')
490493

491494
if do_fit_2pole:
492495
print('Info: Starting dIdV 2-pole Fit')
493496
didv_inst.dofit(2)
494497
result = didv_inst.fitresult(2)
498+
poles = 2
495499
print('Info: dIdV 2-pole Fit Done')
496500

497501
if do_fit_3pole:
498502
print('Info: Starting dIdV 3-pole Fit')
499503
didv_inst.dofit(3)
500504
result = didv_inst.fitresult(3)
505+
poles = 3
501506
print('Info: dIdV 3-pole Fit Done')
502507

508+
# Calculate R0/I0/P0 (infinite loop approximation)
509+
ilg_params = None
510+
if (do_fit_2pole or do_fit_3pole):
511+
ilg_params = qp.get_biasparams_ilg(
512+
result['params'], result['cov'],
513+
tes_bias, tes_bias*0.05,
514+
rshunt, rp)
515+
516+
# calc small signal parameters
517+
didv_inst.calc_smallsignal_params(
518+
biasparams=ilg_params,
519+
poles=poles
520+
)
503521

522+
# Add result to list
523+
if do_fit_1pole:
524+
result = didv_inst.fitresult(1)
525+
if do_fit_2pole:
526+
result = didv_inst.fitresult(2)
527+
if do_fit_3pole:
528+
result = didv_inst.fitresult(3)
504529

505-
# Calculate R0/I0/P0 (infinite loop
506-
# approximation)
507-
if ((do_fit_2pole or do_fit_3pole)
508-
and 'smallsignalparams' in result):
509-
didv = result['didv0']
510-
tes_bias = self._analysis_config['tes_bias'][ichan]
511-
512-
# R0
513-
r0_infinite = (abs(1/didv) + rp + rshunt)
514-
515-
# IO
516-
i0_infinite = (tes_bias*rshunt)/(r0_infinite+rshunt+rp)
517-
518-
# P0
519-
p0_infinite = tes_bias*rshunt*i0_infinite - (rp + rshunt)*pow(i0_infinite,2)
530+
if do_fit_2pole or do_fit_3pole:
531+
# add infinite loop gain parameters
520532
result['infinite_l'] = dict()
521-
result['infinite_l']['r0'] = r0_infinite
522-
result['infinite_l']['i0'] = i0_infinite
523-
result['infinite_l']['p0'] = p0_infinite
524-
525-
526-
533+
result['infinite_l']['r0'] = ilg_params['r0']
534+
result['infinite_l']['i0'] = ilg_params['i0']
535+
result['infinite_l']['p0'] = ilg_params['p0']
527536

528-
# Add result to list
529537
result_list.append(result)
530-
538+
531539
# Fitted response
532540
dt = 1/sample_rate
533541
time = np.arange(0,nb_samples)*dt
534-
535-
key = 'params'
536-
if 'smallsignalparams' in result:
537-
key = 'smallsignalparams'
538-
539542
fit_array[ichan,:] = norm*qp.squarewaveresponse(
540543
time,
541544
sg_current,
542545
sg_freq,
543-
dutycycle,
544-
**result[key],)
545-
546+
result['params'],
547+
dutycycle=dutycycle,
548+
rsh=rshunt)
549+
546550
didv_data_dict['fit_array'] = fit_array
547551
didv_data_dict['results'] = result_list
548552

549553
return data_array_truncated, didv_data_dict
550-
551-
552-
553554

554555

555556
def _store_data(self, data_array, cuts_val):

pytesdaq/scope/readout.py

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -508,16 +508,13 @@ def run(self, save_redis=False, do_plot=False):
508508
if self._do_get_fit_param:
509509
self._fill_fit_param()
510510
self._do_get_fit_param = False
511-
512-
513-
514511

515512
# Do analysis
516513
self._selected_data_array, self._didv_data_dict, nb_avg = self._analyzer.process(
517514
selected_data_array,
518515
self._adc_config
519516
)
520-
517+
521518
# display running avg
522519
if self._is_qt_ui:
523520
if nb_avg>0:
@@ -606,8 +603,6 @@ def run(self, save_redis=False, do_plot=False):
606603

607604
self._selected_channel_name_list.append(name)
608605

609-
610-
611606

612607
# Histogram
613608
if do_plot:
@@ -621,6 +616,8 @@ def run(self, save_redis=False, do_plot=False):
621616
fit_dt,
622617
self._analyzer.freq_array)
623618

619+
if self._didv_data_dict is not None:
620+
self._first_draw = True
624621

625622
# Fit results
626623
if self._didv_data_dict is not None and self._is_qt_ui:
@@ -632,8 +629,7 @@ def run(self, save_redis=False, do_plot=False):
632629
rp = None
633630
if resistance_type!='Rp':
634631
rp = float(self._analyzer.get_config('rp'))
635-
636-
632+
637633
# loop channel
638634
nb_chan = len(self._didv_data_dict['results'])
639635

@@ -651,8 +647,6 @@ def run(self, save_redis=False, do_plot=False):
651647
if 'infinite_l' in self._didv_data_dict['results'][ichan]:
652648
result_infinite_l = self._didv_data_dict['results'][ichan]['infinite_l']
653649

654-
655-
656650
rshunt = result['rsh']
657651
result_list.append(['Input Rsh [mOhms]', f"{rshunt*1000:.2f}"])
658652

@@ -668,9 +662,9 @@ def run(self, save_redis=False, do_plot=False):
668662
if resistance_type=='Rn':
669663
rn = result['rp']-rp
670664
result_list.append(['Rn [mOhms]', f"{rn*1000:.2f}"])
671-
672-
673-
if 'tau0' in result:
665+
666+
667+
if ('tau0' in result and result['tau0'] is not None):
674668
result_list.append(['tau0 [us]', f"{result['tau0']*1e6:.3f}"])
675669

676670
#if 'tau3' in result:
@@ -679,13 +673,13 @@ def run(self, save_redis=False, do_plot=False):
679673
result_list.append(['L [nH]', f"{result['L']*1e9:.3f}"])
680674
result_list.append(['dt [mus]', f"{result['dt']*1e6:.3f}"])
681675

682-
if 'l' in result:
676+
if ('l' in result and result['l'] is not None):
683677
result_list.append(['loop gain (l)', f"{result['l']:.3f}"])
684678

685-
if 'beta' in result:
679+
if ('beta' in result and result['beta'] is not None):
686680
result_list.append(['beta', f"{result['beta']:.3f}"])
687681

688-
if 'gratio' in result:
682+
if ('gratio' in result and result['gratio'] is not None):
689683
result_list.append(['gratio', f"{result['gratio']:.3f}"])
690684

691685

@@ -860,12 +854,10 @@ def _plot_data(self, data_array, fit_array=None, fit_dt=None, freq_array=[]):
860854
if self._do_stop_run:
861855
return
862856

863-
864857
# chan/bins
865858
nchan = np.size(data_array,0)
866859
nbins = np.size(data_array,1)
867860

868-
869861
# sanity checks
870862
if nchan == 0 or nbins==0:
871863
return
@@ -883,19 +875,14 @@ def _plot_data(self, data_array, fit_array=None, fit_dt=None, freq_array=[]):
883875
if freq_array is None or len(freq_array)!=nbins:
884876
return
885877

886-
887878
if self._nb_bins != nbins:
888879
self._nb_bins = nbins
889880
self._first_draw = True
890881

891-
892882
# label
893883
ylabel = self._analyzer.get_config('unit')
894884
if self._analyzer.get_config('calc_psd'):
895885
ylabel = ylabel + '/rtHz'
896-
897-
898-
899886

900887
# draw!
901888
if self._first_draw:

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
setup(name='pytesdaq',
11-
version='0.4.0',
11+
version='0.4.1',
1212
description='DAQ and Intruments control for TES development',
1313
long_description=long_description,
1414
long_description_content_type='text/markdown',
@@ -31,7 +31,7 @@
3131
'paramiko>=3.2.0',
3232
'walrus',
3333
'h5py',
34-
'qetpy>=1.6.8',
34+
'qetpy>=1.7.2',
3535
'scipy',
3636
'seaborn',
3737
'astropy',

0 commit comments

Comments
 (0)