Esempio n. 1
0
 def read_attributes(self, h5file_group: Union[Group,
                                               File]) -> Dict[str, Any]:
     """
     Read data from h5 file group that is stored directly as `<h5py.Group>.attrs`, or saved in subgroups titled
     `<h5py.Group>/__lists` and `<h5py.Group>/__dicts`.
     """
     attributes = self.h5_attrs_to_dict(h5file_group.attrs)
     if '__dicts' in h5file_group:
         for dict_name in h5file_group['__dicts']:
             attributes[dict_name] = io.read(
                 self.filename, h5file_group['__dicts/' + dict_name])
     if '__lists' in h5file_group:
         for list_name in h5file_group['__lists']:
             attributes[list_name] = io.read(
                 self.filename, h5file_group['__lists/' + list_name])
     return attributes
Esempio n. 2
0
    def create_from_file(cls, filename: str) -> object:
        """Read initdata and spectral data from file, and use those to create a new SpectrumData object.

        Returns
        -------
        SpectrumData
            new SpectrumData object, initialized with data read from file
        """
        import scqubits.io_utils.fileio as io
        return io.read(filename)
Esempio n. 3
0
 def read_objects(self, h5file_group: Union[Group,
                                            File]) -> Dict[str, io.IOData]:
     """
     Read data from the given h5 file group that represents a Python object other than an ndarray, list, or dict.
     """
     inner_objects = {}
     h5file_group = h5file_group["__objects"]
     for obj_name in h5file_group:
         inner_objects[obj_name] = io.read(self.filename,
                                           h5file_group[obj_name])
     return inner_objects
Esempio n. 4
0
    def read_attributes(self, h5file_group):
        """
        Read data from h5 file group that is stored directly as `<h5py.Group>.attrs`, or saved in subgroups titled
        `<h5py.Group>/__lists` and `<h5py.Group>/__dicts`.

        Parameters
        ----------
        h5file_group: h5py.Group

        Returns
        -------
        dict [str, dict or list]
        """
        attributes = self.h5_attrs_to_dict(h5file_group.attrs)
        if '__dicts' in h5file_group:
            for dict_name in h5file_group['__dicts']:
                attributes[dict_name] = io.read(self.filename, h5file_group['__dicts/' + dict_name])
        if '__lists' in h5file_group:
            for list_name in h5file_group['__lists']:
                attributes[list_name] = io.read(self.filename, h5file_group['__lists/' + list_name])
        return attributes
Esempio n. 5
0
    def read_objects(self, h5file_group):
        """
        Read data from the given h5 file group that represents a Python object other than an ndarray, list, or dict.

        Parameters
        ----------
        h5file_group: h5py.Group

        Returns
        -------
        dict [str, IOData]
        """
        inner_objects = {}
        h5file_group = h5file_group["__objects"]
        for obj_name in h5file_group:
            inner_objects[obj_name] = io.read(self.filename, h5file_group[obj_name])
        return inner_objects