Skip to content

Commit d79cbd9

Browse files
authored
Merge pull request #42 from spice-herald/feature/offsets_biasflip
Feature/offsets biasflip
2 parents afc504b + 4c7f61e commit d79cbd9

File tree

5 files changed

+793
-11
lines changed

5 files changed

+793
-11
lines changed

pytesdaq/io/hdf5.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,40 @@ def get_detector_config(self, file_name=None,
11221122
return detector_config
11231123

11241124

1125+
1126+
def get_file_info(self, file_name=None):
1127+
"""
1128+
Get file attributes
1129+
"""
1130+
1131+
# check input
1132+
if file_name is None and self._current_file is None:
1133+
error_msg = 'No file currently open and no "file_name" argument not provided!'
1134+
if self._raise_errors:
1135+
raise ValueError(error_msg)
1136+
else:
1137+
print('ERROR: ' + error_msg)
1138+
print('Please open a file or provide a file name!')
1139+
return metadata
1140+
1141+
# open file if needed
1142+
if (file_name is not None
1143+
and self._current_file_name!=file_name):
1144+
1145+
# check if a file already open
1146+
if self._current_file is not None:
1147+
self._close_file()
1148+
1149+
# open
1150+
self._open_file(file_name, event_list=None,
1151+
load_metadata=False)
1152+
1153+
1154+
# get attibutes
1155+
metadata = self._extract_metadata(self._current_file.attrs)
1156+
return metadata
1157+
1158+
11251159

11261160
def get_connection_dict(self, file_name=None, adc_name='adc1', metadata=None):
11271161
"""

pytesdaq/processing/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
from ._process_iv_didv import *
33
from ._iv_didv_tools_plotting import *
44
from ._iv_didv_tools import *
5+
from .ivsweep import *

pytesdaq/processing/_iv_didv_tools.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

249250
class 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

Comments
 (0)