def load(self): data = icpformat.read(self.path) self.detector.wavelength \ = data.check_wavelength(self.default.wavelength, NG7Icp._wavelength_override) if 'qz' in data: # NG7 automatically increases count times as Qz increases monitor, prefactor = data.monitor, data.prefactor Mon1, Exp = data.Mon1, data.Exp Qz = data.column.qz automonitor = prefactor * (monitor + Mon1 * abs(Qz)**Exp) if data.count_type == 'NEUT': self.monitor.counts = automonitor elif data.count_type == 'TIME': self.monitor.count_time = automonitor else: raise ValueError, "Expected count type 'NEUT' or 'TIME' in " + self.path if 'monitor' in data: self.monitor.counts = data.column.monitor if 'time' in data: self.monitor.count_time = data.column.time * 60 self.monitor.base = 'counts' if self.monitor.counts is not None else 'time' if 's1' in data: self.slit1.x = data.column.s1 if 's2' in data: self.slit2.x = data.column.s2 if 's3' in data: self.slit3.x = data.column.s3 if 's4' in data: self.slit4.x = data.column.s4 if 'qz' in data: Qx = data.column.qx if 'qx' in data else 0 Qz = data.column.qz A, B = qxqz.QxQzL_to_AB(Qx, Qz, self.detector.wavelength) self.sample.angle_x, self.detector.angle_x = A, B # Set initial Qz self.resetQ() # TODO: if the dataset is large, set up a weak reference instead self.detector.counts = data.counts
def load(self): data = icpformat.read(self.path) self.detector.wavelength \ = data.check_wavelength(self.default.wavelength, NG7Icp._wavelength_override) if 'qz' in data: # NG7 automatically increases count times as Qz increases monitor, prefactor = data.monitor,data.prefactor Mon1, Exp = data.Mon1,data.Exp Qz = data.column.qz automonitor = prefactor*(monitor + Mon1 * abs(Qz)**Exp) if data.count_type == 'NEUT': self.monitor.counts = automonitor elif data.count_type == 'TIME': self.monitor.count_time = automonitor else: raise ValueError, "Expected count type 'NEUT' or 'TIME' in "+self.path if 'monitor' in data: self.monitor.counts = data.column.monitor if 'time' in data: self.monitor.count_time = data.column.time*60 self.monitor.base = 'counts' if self.monitor.counts is not None else 'time' if 's1' in data: self.slit1.x = data.column.s1 if 's2' in data: self.slit2.x = data.column.s2 if 's3' in data: self.slit3.x = data.column.s3 if 's4' in data: self.slit4.x = data.column.s4 if 'qz' in data: Qx = data.column.qx if 'qx' in data else 0 Qz = data.column.qz A,B = qxqz.QxQzL_to_AB(Qx,Qz,self.detector.wavelength) self.sample.angle_x,self.detector.angle_x = A,B # Set initial Qz self.resetQ() # TODO: if the dataset is large, set up a weak reference instead self.detector.counts = data.counts
def load(self): # Load the icp data data = icpformat.read(self.path) if data.counts.ndim == 1: self.detector.dims = (1, 1) elif data.counts.ndim == 2: self.detector.dims = (data.counts.shape[1], 1) elif data.counts.ndim == 3: self.detector.dims = (data.counts.shape[1], data.counts.shape[2]) else: raise RuntimeError("Data has too many dimensions in " + self.path) # Slits are either stored in the file or available from the # motor information. For non-reflectometry scans they may # not be available. if 'a1' in data: self.slit1.x = data.column.a1 if 'a2' in data: self.slit2.x = data.column.a2 if 'a5' in data: self.slit3.x = data.column.a5 if 'a6' in data: self.slit4.x = data.column.a6 # Angles are either stored in the file or can be calculated # from the motor details. For non-reflectometry scans they # may not be available. if 'a3' in data: self.sample.angle_x = data.column.a3 if 'a4' in data: self.detector.angle_x = data.column.a4 # Polarization was extracted from the comment line self.polarization = data.polarization # Monitor counts may be recorded or may be inferred from header if 'monitor' in data: # Prefer the monitor column if it exists self.monitor.counts = data.column.monitor elif data.count_type == 'NEUT': # if count by neutron, the 'monitor' field stores counts self.monitor.counts \ = data.monitor*data.prefactor*numpy.ones(data.points,'i') else: # Need monitor rate for normalization; the application # will have to provide the means of setting the rate # and computing the counts based on that rate. pass # Counting time may be recorded or may be inferred from header if data.count_type == 'TIME': # Prefer the target value to the time column when counting by # time because the time column is recorded in minutes rather # than seconds and is not precise enough. # if count by time, the 'monitor' field stores seconds self.monitor.count_time \ = data.monitor*data.prefactor*numpy.ones(data.points,'f') elif 'time' in data: self.monitor.count_time = data.column.time * 60 else: # Need monitor rate for normalization; the application # will have to provide the means of setting the rate # and computing the time based on that rate. pass if 'temp' in data: # record the temperature in sample environment self.sample.environment.temperature = data.column['temp'] if 'h-field' in data: # record the temperature in sample environment self.sample.environment.magnetic_field = data.column['h-field'] # Set initial Qz self.resetQ() # TODO: if counts are huge we may want to make this lazy self.detector.counts = data.counts
def loadcounts(self): # Load the counts from the data file data = icpformat.read(self.path) return data.counts
def load(self): # Load the icp data data = icpformat.read(self.path) if data.counts.ndim == 1: self.detector.dims = (1,1) elif data.counts.ndim == 2: self.detector.dims = (data.counts.shape[1],1) elif data.counts.ndim == 3: self.detector.dims = (data.counts.shape[1],data.counts.shape[2]) else: raise RuntimeError("Data has too many dimensions in "+self.path) # Slits are either stored in the file or available from the # motor information. For non-reflectometry scans they may # not be available. if 'a1' in data: self.slit1.x = data.column.a1 if 'a2' in data: self.slit2.x = data.column.a2 if 'a5' in data: self.slit3.x = data.column.a5 if 'a6' in data: self.slit4.x = data.column.a6 # Angles are either stored in the file or can be calculated # from the motor details. For non-reflectometry scans they # may not be available. if 'a3' in data: self.sample.angle_x = data.column.a3 if 'a4' in data: self.detector.angle_x = data.column.a4 # Polarization was extracted from the comment line self.polarization = data.polarization # Monitor counts may be recorded or may be inferred from header if 'monitor' in data: # Prefer the monitor column if it exists self.monitor.counts = data.column.monitor elif data.count_type == 'NEUT': # if count by neutron, the 'monitor' field stores counts self.monitor.counts \ = data.monitor*data.prefactor*numpy.ones(data.points,'i') else: # Need monitor rate for normalization; the application # will have to provide the means of setting the rate # and computing the counts based on that rate. pass # Counting time may be recorded or may be inferred from header if data.count_type == 'TIME': # Prefer the target value to the time column when counting by # time because the time column is recorded in minutes rather # than seconds and is not precise enough. # if count by time, the 'monitor' field stores seconds self.monitor.count_time \ = data.monitor*data.prefactor*numpy.ones(data.points,'f') elif 'time' in data: self.monitor.count_time = data.column.time*60 else: # Need monitor rate for normalization; the application # will have to provide the means of setting the rate # and computing the time based on that rate. pass if 'temp' in data: # record the temperature in sample environment self.sample.environment.temperature = data.column['temp'] if 'h-field' in data: # record the temperature in sample environment self.sample.environment.magnetic_field = data.column['h-field'] # Set initial Qz self.resetQ() # TODO: if counts are huge we may want to make this lazy self.detector.counts = data.counts
def loadcounts(self): data = icpformat.read(self.path) return data.counts
import math import icpformat as i import simplejson f = i.read("/Users/Matthew/Desktop/Empty/EMPTY001.bt5") plottable_data = [{ 'type':'1d', 'title':'NG7 Data', 'options':{ 'axes':{'xaxis': {'label':'A4'}, 'yaxis': {'label':'Counts'}}, 'series':[], 'legend':{'show': False, 'placement': 'se'}, 'cursor':{'show': True, 'tooltipLocation':'se', 'tooltipOffset': 0}, }, 'metadata':{}, 'clear_existing':True, 'data':[[]] }] temp1 = f.filename temp2 = temp1.replace('.bt5','_mod.json') f_out = open(temp2, 'w') plottable_data[0]["title"] = f.comment plottable_data[0]["options"]["axes"]["xaxis"]["label"]="a2" plottable_data[0]["options"]["axes"]["yaxis"]["label"]="Counts x 10^6 / Monitor" i = 0 while (i < f.points): a2 = f.column["a2"][i]