DM_limits.py
## @package python.DM_limits
#
# example script accessing the limits of an existing ODM
#
from __future__ import print_function # print function syntax as in python 3
import sys, time
from os import path
from optparse import OptionParser
# import pyDM_d as pyDM #for pyDM in debug mode
from opals import pyDM # for pyDM in release mode
##
# this function is called when _import is called directly
def main(argv=sys.argv):
# raw_input("Press Enter to continue...")
scriptName = path.basename(path.splitext(__file__)[0])
parser = OptionParser(usage="Usage: %prog [options]\n" + __doc__)
parser.add_option("-i", "--input", help="odm input file", dest="filename")
(options, args) = parser.parse_args(argv)
if not options.filename:
print("ERROR: No ODM file specified")
print()
parser.print_help()
return
if pyDM.Datamanager.isValidODM(options.filename) == False:
print("ERROR: " + options.filename + " is not a valid ODM")
return
start = time.clock()
# slow method: fully open the ODM
# dm = pyDM.Datamanager.load(options.filename,True,False)
# limit = dm.getLimit()
# fast method: directly accessing the ODM header
limit = pyDM.Datamanager.getLimitODM(options.filename)
end = time.clock()
# output some odm statistics
# print("ODM contains",dm.sizePoint(),"points")
print("2D-limit (%.3f," % limit.xmin, "%.3f) -" % limit.ymin, "(%.3f," % limit.xmax, "%.3f)" % limit.ymax)
print("finished in", "%.2f [s]" % (end - start))
if __name__ == "__main__":
main()