예제 #1
0
    def interpolate(self, energy):
        a = json.load(open(self.json))
        e, t = numpy.array([]), numpy.array([])
        for z in self.all_elements:
            if 'count' not in a[element_symbol(z)]:
                continue
            if a[element_symbol(z)]['count'] < self.reliability:
                continue
            t = numpy.append(t, a[element_symbol(z)]['dpp'][0])
            if z < 46:
                e = numpy.append(e, edge_energy(z, 'k'))
            else:
                e = numpy.append(e, edge_energy(z, 'l3'))

        s = numpy.argsort(e)
        return (numpy.interp(energy, e[s], t[s]))
예제 #2
0
 def select(self, el):
     '''Choose the ROI configured for element el'''
     if type(el) is int:
         if el < 1 or el > 3:
             self.myprint(error_msg('\n%d is not a valid ROI channel\n' % el))
             return
         el = self.slots[el-1]
     if el is None:
         self.myprint(error_msg('\nThat ROI is not configured\n'))
         return
     if Z_number(el) is None:
         self.myprint(error_msg('\n%s is not an element\n' % el))
         return
     selected = False
     vor = user_ns['vor']
     BMMuser = user_ns['BMMuser']
     for i in range(3):
         if element_symbol(el) == self.slots[i]:
             BMMuser.roi_channel = i+1
             if i == 0:      # help out the best effort callback
                 (BMMuser.roi1, BMMuser.roi2, BMMuser.roi3, BMMuser.roi4) = ('ROI1', 'ROI2', 'ROI3', 'ROI4')
                 (BMMuser.dtc1, BMMuser.dtc2, BMMuser.dtc3, BMMuser.dtc4) = ('DTC1', 'DTC2', 'DTC3', 'DTC4')
                 vor.set_hints(1)
             elif i == 1:
                 (BMMuser.roi1, BMMuser.roi2, BMMuser.roi3, BMMuser.roi4) = ('ROI2_1', 'ROI2_2', 'ROI2_3', 'ROI2_4')
                 (BMMuser.dtc1, BMMuser.dtc2, BMMuser.dtc3, BMMuser.dtc4) = ('DTC2_1', 'DTC2_2', 'DTC2_3', 'DTC2_4')
                 vor.set_hints(2)
             elif i == 2:
                 (BMMuser.roi1, BMMuser.roi2, BMMuser.roi3, BMMuser.roi4) = ('ROI3_1', 'ROI3_2', 'ROI3_3', 'ROI3_4')
                 (BMMuser.dtc1, BMMuser.dtc2, BMMuser.dtc3, BMMuser.dtc4) = ('DTC3_1', 'DTC3_2', 'DTC3_3', 'DTC3_4')
                 vor.set_hints(3)
             report('Set ROI channel to %s at channel %d' % (el.capitalize(), i+1))
             selected = True
     if not selected:
         self.myprint(whisper('%s is not in a configured channel, not changing BMMuser.roi_channel' % el.capitalize()))
예제 #3
0
 def set_roi(self, i, el):
     '''Configure an ROI channel i ∈ (1 .. 3) for element el'''
     if Z_number(el) is None:
         self.slots[i - 1] = None
     else:
         self.slots[i - 1] = element_symbol(el)
     BMM_log_info('Set ROI channel %d to %s' % (i, str(self.slots[i - 1])))
예제 #4
0
 def move(self, el):
     '''Move to the slot configured for element el'''
     if type(el) is int:
         if el < 1 or el > 5:
             print(error_msg('\n%d is not a valid foil slot\n' % el))
             return (yield from null())
         el = self.slots[el - 1]
     if el is None:
         print(error_msg('\nThat slot is empty\n'))
         return (yield from null())
     el = el.capitalize()
     if Z_number(el) is None:
         print(error_msg('\n%s is not an element\n' % el))
         return (yield from null())
     moved = False
     for i in range(5):
         if element_symbol(el) == self.slots[i]:
             yield from mv(xafs_linxs, self.position(i))
             report('Moved xafs_linxs to %s at slot %d' %
                    (el.capitalize(), i + 1))
             moved = True
     if not moved:
         print(
             warning_msg(
                 '%s is not in the reference holder, not moving xafs_linxs'
                 % el.capitalize()))
         yield from null()
예제 #5
0
 def set_slot(self, i, el):
     '''Configure a slot i ∈ (0 .. 4) for element el'''
     if Z_number(el) is None:
         self.slots[i - 1] = None
     else:
         self.slots[i - 1] = element_symbol(el)
     BMM_log_info('Set reference slot %d to %s' %
                  (i, str(self.slots[i - 1])))
예제 #6
0
    def periodic_table(self, el=None):
        start = time.time()
        results = {}
        for z in self.all_elements:
            el = element_symbol(z)
            results[el] = self.overhead(el)

        j = json.dumps(results)
        f = open(self.json, "w")
        f.write(j)
        f.close()
        end = time.time()
        print('\n\nThat took %.1f min' % ((end - start) / 60))
예제 #7
0
 def overhead_per_point(self, element, edge=None):
     a = json.load(open(self.json))
     element = element_symbol(element)
     if edge is not None and edge.lower() in ('l2', 'l1'):
         return ([self.interpolate(edge_energy(element, edge)), 0])
     if element in a and 'dpp' in a[element]:
         return (a[element]['dpp'])
     else:
         if edge is None or edge.lower() not in ('l2', 'l1'):
             edge = 'k'
             if Z_number(element) > 45:
                 edge = 'l3'
         return ([self.interpolate(edge_energy(element, edge)), 0])