Skip to content

Commit 1717774

Browse files
committed
fixed bug when first line of df is dropped, added flipped qetbias flag, defaults to true like convention for sweeps
1 parent 5ae6574 commit 1717774

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

pytesdaq/processing/_iv_didv_tools.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,8 @@ def plot_noise_model(self, idx='all', xlims=(10, 2e5), ylims_current=None,
18311831
)
18321832

18331833

1834-
def get_offsets_dict(self, metadata, channel_name, lgcdiagnostics=False):
1834+
def get_offsets_dict(self, metadata, channel_name, lgcdiagnostics=False,
1835+
lgc_sweepbias_flipped=True):
18351836
"""
18361837
Function to get a dictionary of offsets of i0 and ibias used by
18371838
QETpy to calculate the i0, r0, p0, etc. of a given dIdV.
@@ -1845,6 +1846,16 @@ def get_offsets_dict(self, metadata, channel_name, lgcdiagnostics=False):
18451846
18461847
channel_name: str
18471848
Used to get the right channel out of the metadata
1849+
1850+
lgcdiagnostics: boolean, optional
1851+
If True, prints out diagnostics
1852+
1853+
lgc_sweepbias_flipped: boolean, optional
1854+
Defaults to True. If True, assumes that the bias for the IV sweep
1855+
from which the offset_dict was generated was flipped in polarity
1856+
(i.e. multiplied by negative one). To contradict this, we just
1857+
multiply the ibias_offset by negative one. Defaults to True because
1858+
this is the default way we process IV sweeps.
18481859
18491860
Returns
18501861
-------
@@ -1861,14 +1872,26 @@ def get_offsets_dict(self, metadata, channel_name, lgcdiagnostics=False):
18611872
IV_ibias_offset = self.ivobj.ibias_off[0][1]
18621873
IV_ibias_offset_err = self.ivobj.ibias_off_err[0][1]
18631874

1864-
rp_measured = self.df['rp'][0]
1875+
if lgc_sweepbias_flipped:
1876+
IV_ibias_offset *= -1
1877+
1878+
i = 0
1879+
rp_measured = None
1880+
while rp_measured is None:
1881+
try:
1882+
rp_measured = self.df['rp'][i]
1883+
except KeyError:
1884+
i += 1
1885+
1886+
output_offset = metadata[0]['detector_config'][channel_name]['output_offset']
18651887

18661888
return_dict = {
18671889
"i0_off": IV_i0_offset,
18681890
"i0_off_err": IV_i0_offset_err,
18691891
"ibias_off": IV_ibias_offset,
18701892
"ibias_off_err": IV_ibias_offset_err,
18711893
"i0_changable_offset": output_offset_during_didv,
1894+
"output_offset": output_offset,
18721895
"rp": rp_measured,
18731896
"IVobj": self,
18741897
}

0 commit comments

Comments
 (0)