def load_centers(iterable): dict_ = CIDict() for row in iterable: if row[0] != '': dict_.update({row[0]:row[1]}) for key, value in dict_.items(): # Turns '(1,2,3)' etc, that is, textual representations of vectors, # into Vector objects. Will cut off the last digit of the third # componant, but I don't care because the third componant will # always be 0.0 dict_[key] = np.array([float(y[:-1]) for y in value[1:].split()]) return dict_
def moments(path, selections, centers): with open('published params.csv', 'rb') as f: reader = csv.reader(f) new_calc = ezb.Calculator(reader, normalize = False) moments = CIDict() for name in structures.keys(): if name.upper() == '1QD5': continue moments.update({name: ezb.moment(structures[name], selections[name], centers[name], new_calc, paramless_option = '0', old_style_gly = True) }) with open(path, 'wb') as f: target = csv.writer(f) for name, moment in moments.items(): row = [name.upper()] + [str(component) for component in moment] target.writerow(row)