Exemple #1
0
def start(chano,
          stc,
          name='test',
          path='../data/',
          exposures=[10, 100, 1000, 10000],
          mov={'shift': [0, 1, 2, 3, 4, 5]}):

    normalized_name = os.path.normpath(path + '/' + name)
    path, name, extension = FileTools.splitname(normalized_name)
    base_name = os.path.normpath(path + "/" + name)

    mask = 'Exposure: {:6d} Theta: {:6.2f} Shift: {:6.2f} Phi: {:6.2f}'

    time.sleep(5)
    print("\n\n")

    try:
        for motor, sweep in mov.items():
            for x in sweep:

                setattr(chano, motor, x)
                for exposure in exposures:
                    stc.exposure = exposure
                    image = stc.capture()
                    newname = FileTools.newname(base_name + '.npz')

                    np.savez(newname,
                             image=image,
                             exposure=exposure,
                             chanosat_pos=chano.pos)

                    print(
                        mask.format(exposure, chano.theta, chano.shift,
                                    chano.phi))

                    time_now = time.gmtime(time.time())
                    print("\n" + time.strftime("%X", time_now), end='')
                    print(' - Saved as: {}'.format(os.path.relpath(newname)))
                    time.sleep(1)

    except:
        print('\n\nUnexpected error.'
              ' Trying to reset chanosat to zero position\n\n')
        chano.pos = [0, 0, 0]
        time.sleep(1)
        raise
Exemple #2
0
import time

parser = argparse.ArgumentParser()
parser.add_argument('-name', type=str, default='dark')
parser.add_argument('-path', type=str, default='../data/')
parser.add_argument('-stc', type=str, default='/dev/video1')
parser.add_argument('-captures', type=str, default=10)

params = parser.parse_args()

stc = Device(dev_name=params.stc)

exposures = [1, 10, 50, 100, 200, 500, 1000, 2000, 5000, 10000]

normalized_name = os.path.normpath(params.path + '/' + params.name)
path, name, extension = FileTools.splitname(normalized_name)
base_name = os.path.normpath(path + "/" + name)

mask = 'Exposure: {:6d}'

time.sleep(5)
print("\n\n")

for exposure in exposures:
    stc.exposure = exposure
    print(mask.format(exposure))
    for i in range(params.captures):
        image = stc.capture()
        filename = base_name + '{:02d}_exp_{:06}.npz'.format(i, exposure)
        np.savez(filename, image=image)
        time_now = time.gmtime(time.time())