Read a CrossSpectralDensity object from an HDF5 file. Parameters ---------- fname : path-like The name of the file to read the CSD from. The extension ``'.h5'`` will be appended if the given filename doesn't have it already. Returns ------- csd : instance of
(fname)
| 627 | |
| 628 | |
| 629 | def read_csd(fname): |
| 630 | """Read a CrossSpectralDensity object from an HDF5 file. |
| 631 | |
| 632 | Parameters |
| 633 | ---------- |
| 634 | fname : path-like |
| 635 | The name of the file to read the CSD from. The extension ``'.h5'`` will |
| 636 | be appended if the given filename doesn't have it already. |
| 637 | |
| 638 | Returns |
| 639 | ------- |
| 640 | csd : instance of CrossSpectralDensity |
| 641 | The CSD that was stored in the file. |
| 642 | |
| 643 | See Also |
| 644 | -------- |
| 645 | CrossSpectralDensity.save : For saving CSD objects. |
| 646 | """ |
| 647 | read_hdf5, _ = _import_h5io_funcs() |
| 648 | if not fname.endswith(".h5"): |
| 649 | fname += ".h5" |
| 650 | |
| 651 | csd_dict = read_hdf5(fname, title="conpy") |
| 652 | |
| 653 | if csd_dict["projs"] is not None: |
| 654 | # Avoid circular import |
| 655 | from ..proj import Projection |
| 656 | |
| 657 | csd_dict["projs"] = [Projection(**proj) for proj in csd_dict["projs"]] |
| 658 | |
| 659 | return CrossSpectralDensity(**csd_dict) |
| 660 | |
| 661 | |
| 662 | @verbose |