corrected defaults and simplified loops

This commit is contained in:
Martin Diehl 2015-05-25 10:49:20 +00:00
parent 1f160dfd72
commit 5900fa4bf5
2 changed files with 10 additions and 20 deletions

View File

@ -21,18 +21,18 @@ Average each data block of size 'packing' into single values thus reducing the f
parser.add_option('-c','--coordinates', dest='coords', metavar='string', parser.add_option('-c','--coordinates', dest='coords', metavar='string',
help='column heading for coordinates [%default]') help='column heading for coordinates [%default]')
parser.add_option('-p','--packing', dest='packing', type='int', nargs=3, metavar='int int int', parser.add_option('-p','--packing', dest='packing', type='int', nargs=3, metavar='int int int',
help='size of packed group %default') help='size of packed group [%default]')
parser.add_option('--shift', dest='shift', type='int', nargs=3, metavar='int int int', parser.add_option('--shift', dest='shift', type='int', nargs=3, metavar='int int int',
help='shift vector of packing stencil %default') help='shift vector of packing stencil [%default]')
parser.add_option('-g', '--grid', dest='grid', type='int', nargs=3, metavar='int int int', parser.add_option('-g', '--grid', dest='grid', type='int', nargs=3, metavar='int int int',
help='grid in x,y,z [autodetect]') help='grid in x,y,z [autodetect]')
parser.add_option('-s', '--size', dest='size', type='float', nargs=3, metavar='float float float', parser.add_option('-s', '--size', dest='size', type='float', nargs=3, metavar='float float float',
help='size in x,y,z [autodetect]') help='size in x,y,z [autodetect]')
parser.set_defaults(coords = 'ipinitialcoord') parser.set_defaults(coords = 'ipinitialcoord')
parser.set_defaults(packing = [2,2,2]) parser.set_defaults(packing = (2,2,2))
parser.set_defaults(shift = [0,0,0]) parser.set_defaults(shift = (0,0,0))
parser.set_defaults(grid = [0,0,0]) parser.set_defaults(grid = (0,0,0))
parser.set_defaults(size = [0.0,0.0,0.0]) parser.set_defaults(size = (0.0,0.0,0.0))
(options,filenames) = parser.parse_args() (options,filenames) = parser.parse_args()

View File

@ -29,13 +29,6 @@ parser.set_defaults(randomSeed = None)
if options.label == None: if options.label == None:
parser.error('no data column specified...') parser.error('no data column specified...')
datainfo = { # list of requested labels per datatype
'scalar': {'len':1,
'label':[]},
}
datainfo['scalar']['label'] += options.label
# --- loop over input files ------------------------------------------------------------------------- # --- loop over input files -------------------------------------------------------------------------
for name in filenames: for name in filenames:
if not os.path.exists(name): continue if not os.path.exists(name): continue
@ -53,7 +46,7 @@ for name in filenames:
active = [] active = []
column = {} column = {}
for label in datainfo['scalar']['label']: for label in options.label:
if label in table.labels: if label in table.labels:
active.append(label) active.append(label)
column[label] = table.labels.index(label) # remember columns of requested data column[label] = table.labels.index(label) # remember columns of requested data
@ -66,9 +59,6 @@ for name in filenames:
# ------------------------------------------ process data ------------------------------------------ # ------------------------------------------ process data ------------------------------------------
permutation = {} permutation = {}
table.data_readArray(active) table.data_readArray(active)
for i,label in enumerate(active): for i,label in enumerate(active):
unique = list(set(table.data[:,i])) unique = list(set(table.data[:,i]))
permutated = np.random.permutation(unique) permutated = np.random.permutation(unique)