def from_dict(cls: S2D, d: Dict[str, Any]) -> S2D: """ Convert a dictionary to a Spectrum2D object Parameters ---------- d : dict A dictionary with the following keys/values: - 'x_data': (n_x_data,) or (n_x_data + 1,) float ndarray - 'x_data_unit': str - 'y_data': (n_y_data,) or (n_y_data + 1,) float ndarray - 'y_data_unit': str - 'z_data': (n_x_data, n_y_data) float Quantity - 'z_data_unit': str There are also the following optional keys: - 'x_tick_labels': list of (int, string) tuples - 'metadata': dict Returns ------- spectrum """ d = _process_dict(d, quantities=['x_data', 'y_data', 'z_data'], optional=['x_tick_labels', 'metadata']) return cls(d['x_data'], d['y_data'], d['z_data'], x_tick_labels=d['x_tick_labels'], metadata=d['metadata'])
def from_dict(cls: T, d: Dict[str, Any]) -> T: """ Convert a dictionary to a StructureFactor object Parameters ---------- d : dict A dictionary with the following keys/values: - 'crystal': dict, see Crystal.from_dict - 'qpts': (n_qpts, 3) float ndarray - 'frequencies': (n_qpts, 3*crystal.n_atoms) float ndarray - 'frequencies_unit': str - 'structure_factors': (n_qpts, 3*crystal.n_atoms) float ndarray - 'structure_factors_unit': str There are also the following optional keys: - 'weights': (n_qpts,) float ndarray - 'temperature': float - 'temperature_unit': str """ crystal = Crystal.from_dict(d['crystal']) d = _process_dict( d, quantities=['frequencies', 'structure_factors', 'temperature'], optional=['weights', 'temperature']) return cls(crystal, d['qpts'], d['frequencies'], d['structure_factors'], d['weights'], d['temperature'])
def from_dict(cls: T, d: Dict[str, Any]) -> T: """ Convert a dictionary to a QpointFrequencies object Parameters ---------- d A dictionary with the following keys/values: - 'crystal': dict, see Crystal.from_dict - 'qpts': (n_qpts, 3) float ndarray - 'frequencies': (n_qpts, n_branches) float ndarray - 'frequencies_unit': str There are also the following optional keys: - 'weights': (n_qpts,) float ndarray """ crystal = Crystal.from_dict(d['crystal']) d = _process_dict(d, quantities=['frequencies'], optional=['weights']) return cls(crystal, d['qpts'], d['frequencies'], d['weights'])
def from_dict(cls: T, d: Dict[str, Any]) -> T: """ Convert a dictionary to a QpointPhononModes object Parameters ---------- d : dict A dictionary with the following keys/values: - 'crystal': dict, see Crystal.from_dict - 'qpts': (n_qpts, 3) float ndarray - 'frequencies': (n_qpts, 3*crystal.n_atoms) float ndarray - 'frequencies_unit': str - 'eigenvectors': (n_qpts, 3*crystal.n_atoms, crystal.n_atoms, 3) complex ndarray There are also the following optional keys: - 'weights': (n_qpts,) float ndarray """ crystal = Crystal.from_dict(d['crystal']) d = _process_dict(d, quantities=['frequencies'], optional=['weights']) return cls(crystal, d['qpts'], d['frequencies'], d['eigenvectors'], d['weights'])
def from_dict(cls: CR, d: Dict[str, Any]) -> CR: """ Convert a dictionary to a Crystal object Parameters ---------- d A dictionary with the following keys/values: - 'cell_vectors': (3, 3) float ndarray - 'cell_vectors_unit': str - 'atom_r': (n_atoms, 3) float ndarray - 'atom_type': (n_atoms,) str ndarray - 'atom_mass': (n_atoms,) float np.ndaaray - 'atom_mass_unit': str Returns ------- crystal """ d = _process_dict(d, quantities=['cell_vectors', 'atom_mass']) return cls(d['cell_vectors'], d['atom_r'], d['atom_type'], d['atom_mass'])
def from_dict(cls, d): """ Convert a dictionary to a DebyeWaller object Parameters ---------- d : dict A dictionary with the following keys/values: - 'crystal': dict, see Crystal.from_dict - 'debye_waller': (n_atoms, 3, 3) float ndarray - 'debye_waller_unit': str - 'temperature': float - 'temperature_unit': str Returns ------- DebyeWaller """ crystal = Crystal.from_dict(d['crystal']) d = _process_dict(d, quantities=['debye_waller', 'temperature'], optional=['temperature']) return cls(crystal, d['debye_waller'], d['temperature'])