1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
# -*- coding: utf-8 -*-
"""
.. module:: simple.py
:platform: Unix
:synopsis: Generate test files in data exchange.
:Author:
`Francesco De Carlo <mailto: decarlof@gmail.com>`_
:Organization:
Argonne National Laboratory, Argonne, IL 60439 USA
:Version: 2014.08.15
"""
import dxfile.dxtomo as dx
import numpy as np
import datetime
import os
import time
def main():
fname = './demo.h5'
experimenter_name="Francesco De Carlo"
experimenter_affiliation="Argonne National Laboratory"
experimenter_email="decarlo@aps.anl.gov"
instrument_comment="32-ID TXM"
sample_name = 'sample_name'
size = 180
theta = range(0, 180, 180/size)
if (fname != None):
if os.path.isfile(fname):
print "Data Exchange file already exists: ", fname
else:
# Create new folder.
dirPath = os.path.dirname(fname)
if not os.path.exists(dirPath):
os.makedirs(dirPath)
# Open DataExchange file
f = dx.File(fname, mode='w')
# Write the Data Exchange HDF5 file.
f.add_entry(dx.Entry.experimenter(name={'value':experimenter_name}))
f.add_entry(dx.Entry.experimenter(affiliation={'value':experimenter_affiliation}))
f.add_entry(dx.Entry.experimenter(email={'value':experimenter_email}))
f.add_entry(dx.Entry.instrument(comment={'value': instrument_comment}))
f.add_entry(dx.Entry.sample( name={'value':sample_name}))
f.add_entry(dx.Entry.data(theta={'value': theta, 'units':'degrees'}))
f.close()
else:
print "Nothing to do ..."
if __name__ == "__main__":
main()
|