def calc_jacobian(self, ffs): jacobian = np.empty((len(ffs[0].data), len(ffs) / 2), dtype=float) for ff in ffs: import_weights(ff.data) for i, index_ff in enumerate(xrange(0, len(ffs), 2)): # i = 0, 1, 2, ... # index_ff = 0, 2, 4, ... for index_datum in xrange(0, len(ffs[0].data)): dydp = (ffs[index_ff].data[index_datum].value - ffs[index_ff + 1].data[index_datum].value) / 2 jacobian[index_datum, i] = ffs[index_ff].data[index_datum].weight * dydp logger.log(8, 'created {} jacobian'.format(jacobian.shape)) return jacobian
def return_ref_data(args_ref): logger.log(20, '~~ GATHERING REFERENCE DATA ~~'.rjust(79, '~')) ref_data = calculate.main(args_ref) compare.import_weights(ref_data) return ref_data
def main(args): """ Arguments --------- args : string Evaluated using parser returned by return_calculate_parser(). """ logger.log(1, ">>> main <<<") if isinstance(args, basestring): args.split() parser = return_calculate_parser() opts = parser.parse_args(args) # commands looks like: # {'me': [['a1.01.mae', 'a2.01.mae', 'a3.01.mae'], # ['b1.01.mae', 'b2.01.mae']], # 'mb': [['a1.01.mae'], ['b1.01.mae']], # 'jeig': [['a1.01.in,a1.out', 'b1.01.in,b1.out']] # } commands = {key: value for key, value in opts.__dict__.iteritems() if key in COM_ALL and value} pretty_all_commands(commands) # commands_for_filenames looks like: # {'a1.01.mae': ['me', 'mb'], # 'a1.01.in': ['jeig'], # 'a1.out': ['jeig'], # 'a2.01.mae': ['me'], # 'a3.01.mae': ['me'], # 'b1.01.mae': ['me', 'mb'], # 'b1.01.in': ['jeig'], # 'b1.out': ['jeig'], # 'b2.01.mae': ['me'] # } commands_for_filenames = sort_commands_by_filename(commands) pretty_commands_for_files(commands_for_filenames) # inps looks like: # {'a1.01.mae': <__main__.Mae object at 0x1110e10>, # 'a1.01.in': None, # 'a1.out': None, # 'a2.01.mae': <__main__.Mae object at 0x1733b23>, # 'a3.01.mae': <__main__.Mae object at 0x1853e12>, # 'b1.01.mae': <__main__.Mae object at 0x2540e10>, # 'b1.01.in': None, # 'b1.out': None, # 'b2.01.mae': <__main__.Mae object at 0x1353e11>, # } inps = {} for filename, commands_for_filename in commands_for_filenames.iteritems(): if any(x in COM_MACROMODEL for x in commands_for_filename): if os.path.splitext(filename)[1] == ".mae": inps[filename] = filetypes.Mae(os.path.join(opts.directory, filename)) inps[filename].commands = commands_for_filename inps[filename].write_com(sometext=opts.append) else: inps[filename] = None # Check whether or not to skip MacroModel calculations. if opts.norun: logger.log(15, " -- Skipping MacroModel calculations.") else: for filename, some_class in inps.iteritems(): # Works if some class is None too. if hasattr(some_class, "run"): some_class.run(check_tokens=opts.check) # data is a list comprised of datatypes.Datum objects. data = collect_data(commands, inps, direc=opts.directory) if opts.weight: compare.import_weights(data) if opts.doprint: pretty_data(data, log_level=None) logger.log(1, ">>> data: {}".format(data)) return data