Exemplo n.º 1
0
def test_deploy_calib_array():
    print 80 * '_', '\nTest deploy_calib_array'

    cdir = './calib'
    if not os.path.exists(cdir): gu.create_directory(cdir, verb=True)
    #cdir  = '/reg/d/psdm/CXI/cxi83714/calib'

    src = 'CxiDs1.0:Cspad.0'
    type = 'pedestals'
    run_start = 9991
    run_end = None
    arr = gu.np.ones((32, 185, 388))
    cmts = {
        'exp': 'cxi83714',
        'ifname': 'input-file-name',
        'app': 'my-app-name',
        'comment': 'my-comment'
    }
    deploy_calib_array(cdir,
                       src,
                       type,
                       run_start,
                       run_end,
                       arr,
                       cmts,
                       fmt='%.1f',
                       pbits=3)
Exemplo n.º 2
0
    def makeCalibFileName(self, src, type, run_start, run_end=None):
        """Returns calibration file name.
        """
        if os.path.basename(self.cdir.rstrip('/')) != 'calib':
            if self.pbits & 1:
                print 'WARNING! NOT calib DIRECTORY: %s' % self.cdir
            return None

        # there have been problems with calib-dir mounts on the mon nodes.
        # raise an exception here to try to detect this problem
        #assert os.path.isdir(self.cdir), 'psana calib-dir must exist: '+self.cdir

        if not os.path.isdir(self.cdir):
            print 'WARNING! psana calib-dir is not found: %s' % self.cdir
            return None

        if not self._setGroup(src):
            return None

        if run_start < 0:
            if self.pbits & 1:
                print 'WARNING! START RUN NUMBER IS NEGATIVE: %d' % run_start
            return None

        if run_start > 9999:
            if self.pbits & 1:
                print 'WARNING! START RUN NUMBER EXCEEDS 4-DIGITS: %d' % run_start
            return None

        if run_end is None:
            self.cfname = '%d-end.data' % (run_start)

        else:

            if run_end < 0:
                if self.pbits & 1:
                    print 'WARNING! END RUN NUMBER IS NEGATIVE: %d' % run_end
                return None

            if run_end > 9999:
                if self.pbits & 1:
                    print 'WARNING! END RUN NUMBER IS TOO BIG: %d' % run_end
                return None

            if run_end < run_start:
                if self.pbits & 1:
                    print 'WARNING! END RUN:%d < START RUN:%d' % (run_end,
                                                                  run_start)
                return None

            self.cfname = '%d-%d.data' % (run_start, run_end)

        dir = self.cdir
        for subdir in (self.group, src, type):
            dir = os.path.join(dir, subdir)
            gu.create_directory(dir, self.pbits)

        return os.path.join(dir, self.cfname)
Exemplo n.º 3
0
def test_deploy_calib_file():
    print 80 * '_', '\nTest deploy_calib_file'
    cdir = './calib'
    if not os.path.exists(cdir): gu.create_directory(cdir, verb=True)
    #cdir  = '/reg/d/psdm/CXI/cxi83714/calib'

    src = 'CxiDs1.0:Cspad.0'
    type = 'geometry'
    run_start = 9992
    run_end = None
    fname = '/reg/g/psdm/detector/alignment/cspad/calib-cxi-camera1-2014-09-24/2016-06-15-geometry-cxil0216-r150-camera1-z95mm.txt'
    cmts = {'exp': 'cxi83714', 'app': 'my-app-name', 'comment': 'my-comment'}
    deploy_calib_file(cdir,
                      src,
                      type,
                      run_start,
                      run_end,
                      fname,
                      cmts,
                      pbits=3)
Exemplo n.º 4
0
def test01():

    # assuming /reg/d/psdm/CXI/cxid2714/calib/CsPad::CalibV1/CxiDs1.0:Cspad.0/pedestals/15-end.data

    #cdir  = '/reg/d/psdm/CXI/cxid2714/calib/'
    #cdir  = '/reg/d/psdm/CXI/cxi80410/calib/'
    cdir = '/reg/d/psdm/CXI/cxi83714/calib/'

    group = 'CsPad::CalibV1'
    src = 'CxiDs1.0:Cspad.0'
    type = 'pedestals'
    rnum = 134
    #rnum  = 123456789

    #--------------------------

    print 80 * '_', '\nTest 1'
    print 'Finding calib file for\n  dir = %s\n  grp = %s\n  src = %s\n  type= %s\n  run = %d' % \
          (cdir, group, src, type, rnum)

    cff = CalibFileFinder(cdir, group, 0377)
    fname = cff.findCalibFile(src, type, rnum)

    #--------------------------

    print 80 * '_', '\nTest 2'
    print 'Test methods find_calib_file and make_calib_file_name'
    fname_existing = find_calib_file(cdir, src, type, rnum, pbits=1)
    print '  fname_existing : %s' % fname_existing

    cdir = './calib'
    run_start = 134
    gu.create_directory(cdir, True)
    fname_new = make_calib_file_name(cdir,
                                     src,
                                     type,
                                     run_start,
                                     run_end=None,
                                     pbits=0)
    print '  fname_new      : %s' % fname_new