예제 #1
0
    def _parse_line(self, line):
        """Gets the string line with data from input file,
           creates and returns the geometry object for this string.
        """
        keys = ['pname','pindex','oname','oindex','x0','y0','z0','rot_z','rot_y','rot_x','tilt_z','tilt_y','tilt_x']
        f = line.split()
        if len(f) != len(keys):
            logger.debug('The list length for fields from file: %d is not equal to expected: %d' % (len(f), len(keys)))
            return
    
        vals = [str  (f[0]),
                int  (f[1]),
                str  (f[2]),
                int  (f[3]),
                float(f[4]),
                float(f[5]),
                float(f[6]),
                float(f[7]),
                float(f[8]),
                float(f[9]),
                float(f[10]),
                float(f[11]),
                float(f[12])
               ]

        # catch positive Z for IP - in the image-matrix psana frame (z opposite to beam) 
        # detector Z relative to IP should always be negative. 
        if vals[0][:2]=='IP' and vals[6]>0: vals[6]=-vals[6]
    
        d = dict(zip(keys, vals))
        d['use_wide_pix_center'] = self.use_wide_pix_center
        return GeometryObject(**d)
예제 #2
0
 def _find_parent(self, geobj):
     """Finds and returns parent for geobj geometry object.
     """
     for geo in self.list_of_geos:
         if geo == geobj: continue
         if  geo.oindex == geobj.pindex \
         and geo.oname  == geobj.pname:
             return geo
 
     # The name of parent object is not found among geo names in the self.list_of_geos
     # add top parent object to the list
     if geobj.pname is not None:
         top_parent = GeometryObject(pname=None, pindex=0, oname=geobj.pname, oindex=geobj.pindex,\
                                     use_wide_pix_center=self.use_wide_pix_center)
         self.list_of_geos.append(top_parent)
         return top_parent
                
     return None # for top parent itself
예제 #3
0
    def _parse_line(self, line):
        """Gets the string line with data from input file,
           creates and returns the geometry object for this string.
        """
        keys = [
            'pname', 'pindex', 'oname', 'oindex', 'x0', 'y0', 'z0', 'rot_z',
            'rot_y', 'rot_x', 'tilt_z', 'tilt_y', 'tilt_x'
        ]
        f = line.split()
        if len(f) != len(keys):
            print(
                'The list length for fields from file: %d is not equal to expected: %d'
                % (len(f), len(keys)))
            return

        vals = [
            str(f[0]),
            int(f[1]),
            str(f[2]),
            int(f[3]),
            float(f[4]),
            float(f[5]),
            float(f[6]),
            float(f[7]),
            float(f[8]),
            float(f[9]),
            float(f[10]),
            float(f[11]),
            float(f[12])
        ]

        #print('keys: ', keys)
        #print('vals: ', vals)

        d = dict(zip(keys, vals))
        #print('d=', d)
        #return d
        return GeometryObject(**d)