00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 """
00011 :py:class:`PSCalib.SegGeometryStore` - is a factory class/method to switch between different device-dependent
00012 segments/sensors to access their pixel geometry uling :py:class:`PSCalib.SegGeometry` interface.
00013
00014 Usage::
00015
00016 from PSCalib.SegGeometryStore import sgs
00017
00018 sg = sgs.Create('SENS2X1:V1', pbits=0377)
00019 sg2= sgs.Create('EPIX100:V1', pbits=0377)
00020 sg3= sgs.Create('PNCCD:V1', pbits=0377)
00021 sg4= sgs.Create('ANDOR3D:V1', pbits=0377)
00022
00023 sg.print_seg_info(pbits=0377)
00024 size_arr = sg.size()
00025 rows = sg.rows()
00026 cols = sg.cols()
00027 shape = sg.shape()
00028 pix_size = sg.pixel_scale_size()
00029 area = sg.pixel_area_array()
00030 mask = sg.pixel_mask(mbits=0377)
00031 sizeX = sg.pixel_size_array('X')
00032 sizeX, sizeY, sizeZ = sg.pixel_size_array()
00033 X = sg.pixel_coord_array('X')
00034 X,Y,Z = sg.pixel_coord_array()
00035 xmin = sg.pixel_coord_min('X')
00036 ymax = sg.pixel_coord_max('Y')
00037 xmin, ymin, zmin = sg.pixel_coord_min()
00038 xmax, ymax, zmax = sg.pixel_coord_mas()
00039 ...
00040
00041 @see other interface methods in :py:class:`PSCalib.SegGeometry`, :py:class:`PSCalib.SegGeometryCspad2x1V1`
00042
00043 This software was developed for the SIT project. If you use all or
00044 part of it, please give an appropriate acknowledgment.
00045
00046 @version $Id: 2013-03-08$
00047
00048 @author Mikhail S. Dubrovin
00049 """
00050
00051
00052 __version__ = "$Revision: 11400 $"
00053
00054
00055 from PSCalib.SegGeometryCspad2x1V1 import cspad2x1_one
00056 from PSCalib.SegGeometryEpix100V1 import epix2x2_one
00057 from PSCalib.SegGeometryMatrixV1 import SegGeometryMatrixV1, segment_one, matrix_pars
00058
00059
00060
00061 class SegGeometryStore() :
00062 """Factory class for SegGeometry-base objects of different detectors"""
00063
00064
00065
00066 def __init__(sp) :
00067 pass
00068
00069
00070
00071 def Create(sp, segname='SENS2X1:V1', pbits=0 ) :
00072 """ Factory method returns device dependent SINGLETON object with interface implementation
00073 """
00074 if segname=='SENS2X1:V1' : return cspad2x1_one
00075 if segname=='EPIX100:V1' : return epix2x2_one
00076 if segname=='PNCCD:V1' : return segment_one
00077
00078 if segname[:4]=='MTRX' :
00079 rows, cols, psize_row, psize_col = matrix_pars(segname)
00080 return SegGeometryMatrixV1(rows, cols, psize_row, psize_col,\
00081 pix_size_depth=100,\
00082 pix_scale_size=min(psize_row, psize_col))
00083 return None
00084
00085
00086
00087 sgs = SegGeometryStore()
00088
00089
00090
00091
00092
00093 def test_seggeom() :
00094
00095 import sys
00096
00097 from time import time
00098 t0_sec = time()
00099
00100 if len(sys.argv)==1 : print 'For test(s) use command: python', sys.argv[0], '<test-number=1-3>'
00101
00102 elif(sys.argv[1]=='1') :
00103 sg = sgs.Create('SENS2X1:V1', pbits=0377)
00104 sg.print_seg_info(pbits=0377)
00105
00106 elif(sys.argv[1]=='2') :
00107 sg = sgs.Create('EPIX100:V1', pbits=0377)
00108 sg.print_seg_info(pbits=0377)
00109
00110 elif(sys.argv[1]=='3') :
00111 sg = sgs.Create('PNCCD:V1', pbits=0377)
00112 sg.print_seg_info(pbits=0377)
00113
00114 elif(sys.argv[1]=='4') :
00115 sg = sgs.Create('MTRX:512:512:54:54', pbits=0377)
00116 print 'Consumed time for MTRX:512:512:54:54 (sec) =', time()-t0_sec
00117 sg.print_seg_info(pbits=0377)
00118
00119 else : print 'Non-expected arguments: sys.argv=', sys.argv, ' use 0,1,2,...'
00120
00121
00122
00123 if __name__ == "__main__" :
00124 test_seggeom()
00125 print 'End of test.'
00126
00127