@@ -244,7 +244,8 @@ def _get_current_offset_metadata(metadata, channel_name):
244244 """
245245 voltage_offset = metadata [0 ]['detector_config' ][channel_name ]['output_offset' ]
246246 close_loop_norm = metadata [0 ]['detector_config' ][channel_name ]['close_loop_norm' ]
247- return voltage_offset / close_loop_norm
247+ output_gain = metadata [0 ]['detector_config' ][channel_name ]['output_gain' ]
248+ return voltage_offset * output_gain / close_loop_norm
248249
249250class IVanalysis (object ):
250251 """
@@ -1830,7 +1831,8 @@ def plot_noise_model(self, idx='all', xlims=(10, 2e5), ylims_current=None,
18301831 )
18311832
18321833
1833- 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 = False ):
18341836 """
18351837 Function to get a dictionary of offsets of i0 and ibias used by
18361838 QETpy to calculate the i0, r0, p0, etc. of a given dIdV.
@@ -1844,6 +1846,16 @@ def get_offsets_dict(self, metadata, channel_name, lgcdiagnostics=False):
18441846
18451847 channel_name: str
18461848 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 False. 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.
18471859
18481860 Returns
18491861 -------
@@ -1860,14 +1872,26 @@ def get_offsets_dict(self, metadata, channel_name, lgcdiagnostics=False):
18601872 IV_ibias_offset = self .ivobj .ibias_off [0 ][1 ]
18611873 IV_ibias_offset_err = self .ivobj .ibias_off_err [0 ][1 ]
18621874
1863- 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' ]
18641887
18651888 return_dict = {
18661889 "i0_off" : IV_i0_offset ,
18671890 "i0_off_err" : IV_i0_offset_err ,
18681891 "ibias_off" : IV_ibias_offset ,
18691892 "ibias_off_err" : IV_ibias_offset_err ,
18701893 "i0_changable_offset" : output_offset_during_didv ,
1894+ "output_offset" : output_offset ,
18711895 "rp" : rp_measured ,
18721896 "IVobj" : self ,
18731897 }
0 commit comments