extended "scalar" capabilities to "special" having arbitrary dimension (defaults to 1, i.e. former scalar case). Breaks backward compatibility since "--scalar" is now "--special". However, "-s" still works as before...
This commit is contained in:
parent
9aa22d4a08
commit
77df55c998
|
@ -19,25 +19,28 @@ Shift values of scalar, vector, or tensor columns by given offset.
|
||||||
|
|
||||||
""", version = scriptID)
|
""", version = scriptID)
|
||||||
|
|
||||||
parser.add_option('-s','--scalar', dest='scalar', action='extend', metavar='<string LIST>',
|
parser.add_option('-s','--special', dest='special', action='extend', type='string', metavar='<string LIST>',
|
||||||
help='column heading to shift by scalar')
|
help='heading of columns containing field values of special dimension')
|
||||||
|
parser.add_option('-d','--dimension', dest='N', action='store', type='int', metavar='int',
|
||||||
|
help='dimension of special field values [%default]')
|
||||||
parser.add_option('-v','--vector', dest='vector', action='extend', metavar='<string LIST>',
|
parser.add_option('-v','--vector', dest='vector', action='extend', metavar='<string LIST>',
|
||||||
help='column heading to shift by vector')
|
help='column heading to shift by vector')
|
||||||
parser.add_option('-t','--tensor', dest='tensor', action='extend', metavar='<string LIST>',
|
parser.add_option('-t','--tensor', dest='tensor', action='extend', metavar='<string LIST>',
|
||||||
help='column heading to shift by tensor')
|
help='column heading to shift by tensor')
|
||||||
parser.add_option('-d','--delta', dest='delta', action='extend', metavar='<float LIST>',
|
parser.add_option('-o','--offset', dest='delta', action='extend', metavar='<float LIST>',
|
||||||
help='list of scalar, vector, and tensor shifts (in this order!)')
|
help='list of scalar/special, vector, and tensor shifts (in this order!)')
|
||||||
|
|
||||||
parser.set_defaults(scalar = [])
|
parser.set_defaults(special = [])
|
||||||
parser.set_defaults(vector = [])
|
parser.set_defaults(vector = [])
|
||||||
parser.set_defaults(tensor = [])
|
parser.set_defaults(tensor = [])
|
||||||
parser.set_defaults(delta = [])
|
parser.set_defaults(delta = [])
|
||||||
|
parser.set_defaults(N = 1)
|
||||||
|
|
||||||
(options,filenames) = parser.parse_args()
|
(options,filenames) = parser.parse_args()
|
||||||
|
|
||||||
options.delta = np.array(options.delta,'d')
|
options.delta = np.array(options.delta,'d')
|
||||||
datainfo = { # list of requested labels per datatype
|
datainfo = { # list of requested labels per datatype
|
||||||
'scalar': {'len':1,
|
'special': {'len':options.N,
|
||||||
'label':[]},
|
'label':[]},
|
||||||
'vector': {'len':3,
|
'vector': {'len':3,
|
||||||
'label':[]},
|
'label':[]},
|
||||||
|
@ -46,9 +49,9 @@ datainfo = {
|
||||||
}
|
}
|
||||||
|
|
||||||
length = 0
|
length = 0
|
||||||
if options.scalar != []: datainfo['scalar']['label'] += options.scalar; length += len(options.scalar)*datainfo['scalar']['len']
|
if options.special != []: datainfo['special']['label'] += options.special; length += len(options.scalar)*datainfo['special']['len']
|
||||||
if options.vector != []: datainfo['vector']['label'] += options.vector; length += len(options.vector)*datainfo['vector']['len']
|
if options.vector != []: datainfo['vector']['label'] += options.vector; length += len(options.vector)*datainfo['vector']['len']
|
||||||
if options.tensor != []: datainfo['tensor']['label'] += options.tensor; length += len(options.tensor)*datainfo['tensor']['len']
|
if options.tensor != []: datainfo['tensor']['label'] += options.tensor; length += len(options.tensor)*datainfo['tensor']['len']
|
||||||
if len(options.delta) != length:
|
if len(options.delta) != length:
|
||||||
parser.error('length of offset vector does not match column types...')
|
parser.error('length of offset vector does not match column types...')
|
||||||
|
|
||||||
|
@ -76,8 +79,7 @@ for file in files:
|
||||||
|
|
||||||
for datatype,info in datainfo.items():
|
for datatype,info in datainfo.items():
|
||||||
for label in info['label']:
|
for label in info['label']:
|
||||||
key = {True :'1_%s',
|
key = '1_'+label if info['len'] > 1 else label # non-scalar labels have to start with '1_'
|
||||||
False:'%s' }[info['len']>1]%label
|
|
||||||
if key in table.labels:
|
if key in table.labels:
|
||||||
active[datatype].append(label)
|
active[datatype].append(label)
|
||||||
column[datatype][label] = table.labels.index(key) # remember columns of requested data
|
column[datatype][label] = table.labels.index(key) # remember columns of requested data
|
||||||
|
|
Loading…
Reference in New Issue