def from_dict(cls, json_obj): """Recreate an object from the JSON representation. Parameters ---------- json_obj : dict JSON representation Returns ------- LSR : LSR object """ json_obj = remove_class(json_obj) json_obj['reaction'] = json_to_pmutt(json_obj['reaction']) json_obj['surf_specie'] = json_to_pmutt(json_obj['surf_specie']) json_obj['gas_specie'] = json_to_pmutt(json_obj['gas_specie']) return cls(**json_obj)
def from_dict(cls, json_obj): """Recreate an object from the JSON representation. Parameters ---------- json_obj : dict JSON representation Returns ------- shomate : Shomate object """ json_obj = remove_class(json_obj) # Reconstruct statmech model json_obj['model'] = \ json_to_pmutt(json_obj['model']) json_obj['misc_models'] = json_to_pmutt(json_obj['misc_models']) return cls(**json_obj)
def from_dict(cls, json_obj): """Recreate an object from the JSON representation. Parameters ---------- json_obj : dict JSON representation Returns ------- EmpiricalBase : EmpiricalBase object """ json_obj = remove_class(json_obj) # Reconstruct statmech model json_obj['statmech_model'] = json_to_pmutt(json_obj['statmech_model']) json_obj['misc_models'] = \ [json_to_pmutt(mix_model) for mix_model in json_obj['misc_models']] return cls(**json_obj)
def from_dict(cls, json_obj): """Recreate an object from the JSON representation. Parameters ---------- json_obj : dict JSON representation Returns ------- Zacros : Zacros object """ json_obj = remove_class(json_obj) # Reconstruct statmech model json_obj['statmech_model'] = \ json_to_pmutt(json_obj['statmech_model']) json_obj['references'] = \ json_to_pmutt(json_obj['references']) return cls(**json_obj)
def from_dict(cls, json_obj): """Recreate an object from the JSON representation. Parameters ---------- json_obj : dict JSON representation Returns ------- StatMech : StatMech object """ json_obj = json_pmutt.remove_class(json_obj) name = json_obj['name'] trans_model = json_pmutt.json_to_pmutt(json_obj['trans_model']) vib_model = json_pmutt.json_to_pmutt(json_obj['vib_model']) rot_model = json_pmutt.json_to_pmutt(json_obj['rot_model']) elec_model = json_pmutt.json_to_pmutt(json_obj['elec_model']) nucl_model = json_pmutt.json_to_pmutt(json_obj['nucl_model']) references = json_pmutt.json_to_pmutt(json_obj['references']) notes = json_obj['notes'] return cls(name=name, trans_model=trans_model, vib_model=vib_model, rot_model=rot_model, elec_model=elec_model, nucl_model=nucl_model, references=references, notes=notes)
def from_dict(cls, json_obj): """Recreate an object from the JSON representation. Parameters ---------- json_obj : dict JSON representation Returns ------- PhaseDiagram : PhaseDiagram object """ json_obj = remove_class(json_obj) json_obj['reactions'] = [ json_to_pmutt(reaction) for reaction in json_obj['reactions'] ] return cls(**json_obj)
def from_dict(cls, json_obj): """Recreate an object from the JSON representation. Parameters ---------- json_obj : dict JSON representation Returns ------- References : References object """ json_obj = remove_class(json_obj) json_obj['offset'] = np.array(json_obj['offset']) json_obj['references'] = [json_to_pmutt(ref_dict) for ref_dict in json_obj['references']] return cls(**json_obj)
def find(self, **kwargs): """Find records in collection using desired criteria Parameters ---------- max_records : int Maximum number of records to return kwargs : keyword arguments Arguments to use for `self.collection.find` method. See `pymongo.collection.Collection.find`_ method Returns ------- results : list of pmutt objects .. _`pymongo.collection.Collection.find`: http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.find """ return [ json_to_pmutt(result) for result in self.collection.find(**kwargs) ]
def get_specie_from_smiles(self, smiles, obj_type=None, max_records=1): """Searches database for object matching SMILES string Parameters ---------- smiles : str Smiles representation of interested species obj_type : str, optional Type of object to return. Default will return the first encountered specie matching the smiles string regardless of type. Suggested types are: - 'nasa' - 'shomate' - 'statmech' max_records : int, optional Maximum number of records to find. Set this parameter to a -1 if all records are desired. Default is 1 Returns ------- specie : pmutt model object or list of pmutt model objects Object(s) representing the interested species """ # Set up filter to find records db_filter = {'smiles': smiles} if obj_type is not None: db_filter['type'] = obj_type # Get species from database species = [] for i, result in enumerate(self.collection.find(filter=db_filter)): specie = json_to_pmutt(result) # Only return one record if desired if max_records == 1: species = specie break species.append(specie) # Determine if record limit reached if (i + 1) == max_records: break return species