def from_cell_str(cls, unit_cell_str, sub=slice(None)): sub = fix_slice(sub) if "," in unit_cell_str: parameters = list(parse_unit(word) for word in unit_cell_str.split(",") if len(word) > 0) if len(parameters) == 1: a = parameters[0] single = numpy.array([[a,0,0],[0,a,0],[0,0,a]], float) elif len(parameters) == 3: a,b,c = parameters single = numpy.array([[[a,0,0],[0,b,0],[0,0,c]]], float) elif len(parameters) == 6: a,b,c,alpha,beta,gamma = parameters uc = UnitCell( numpy.array([[1,0,0],[0,1,0],[0,0,1]], float), numpy.array([True, True, True]), ) uc.set_parameterst(numpy.array([a,b,c]), numpy.array([alpha,beta,gamma])) single = uc.cell elif len(parameters) == 9: single = numpy.array(parameters,float).reshape((3,3)).transpose() else: raise ValueError("If the --cell option contains comma's, one, three, six or nine value(s) are expected.") data = single.reshape((3,3,1)) else: data = [ [ load_track("%s.%s.%s" % (unit_cell_str, v, c), sub) for v in "abc" ] for c in "xyz" ] return cls(data)
def from_prefix(cls, prefix, sub=slice(None)): return cls([load_track('%s.%s' % (prefix, c), sub) for c in 'xyz'])