lisa_noise.io.read ================== .. py:module:: lisa_noise.io.read .. autoapi-nested-parse:: Read and process LISA TDI data from Mojito L1 HDF5 files. Functions --------- .. autoapisummary:: lisa_noise.io.read.load_segment lisa_noise.io.read.read_window_kwargs lisa_noise.io.read.read_processing_kwargs lisa_noise.io.read.count_segments lisa_noise.io.read.read_inference_result lisa_noise.io.read.get_XYZ_inst_cov lisa_noise.io.read.get_XYZ_cov Module Contents --------------- .. py:function:: load_segment(data_file: str, segment_idx: int, science_band: tuple[float, float]) Load, process, and crop a single segment ready for inference. :param data_file: Path to the Mojito L1 HDF5 file. :type data_file: str :param segment_idx: Index of the segment to extract (``segment0``, ``segment1``, …). :type segment_idx: int :param science_band: Frequency band in Hz used to crop the FFT output. :type science_band: (f_min, f_max) :returns: Loaded and science-band-cropped segment ready for model setup. :rtype: SegmentData .. py:function:: read_window_kwargs(data_file: str) -> dict[str, Any] | None The taper MojitoProcessor applied, e.g. ``{"window": "tukey", "alpha": 0.025}``. ``None`` when the file records no window (``/pipeline_params/window``). .. py:function:: read_processing_kwargs(data_file: str) -> dict[str, Any] | None The filter and decimation MojitoProcessor applied, with its defaults. ``None`` when the file has no ``/pipeline_params`` group. MojitoProcessor does not record the original sampling rate; it is taken from the spacing of the light travel times, which are stored at the Level-1 rate. :returns: ``fs_in``, ``fs_out``, ``filter`` (``highpass_cutoff``, ``lowpass_cutoff``, ``order``), ``downsample`` (``target_fs``, ``kaiser_window``; ``None`` at the native rate) and ``zero_phase``. :rtype: dict .. py:function:: count_segments(data_file: str) -> int Return the number of processed segments in a Mojito L1 HDF5 file. Counts the ``/processed/segment*`` groups directly without reconstructing any segment, so it is cheap enough to call at submit time. :param data_file: Path to the Mojito L1 HDF5 file. :type data_file: str :returns: Number of segments available in the file. :rtype: int .. py:function:: read_inference_result(path: str) -> lisa_noise.types.PipelineResult Read a single-segment pipeline output file into a :class:`PipelineResult`. Inverse of :func:`lisa_noise.io.write.write_inference_result`. .. py:function:: get_XYZ_inst_cov(path: str, frequency: numpy.ndarray, time: float) -> numpy.ndarray Reconstruct the XYZ noise covariance from a pipeline output file. Reads a combined (collected) output file, selects the segment that contains ``time`` (else the one with the nearest midpoint), and rebuilds the covariance from the best-fit parameters using whichever model was fit (recorded in the file). :param path: Path to a combined HDF5 file written by :func:`lisa_noise.io.write.collect_segments` (one group per segment). :type path: str :param frequency: Frequency grid in Hz at which to evaluate the covariance. :type frequency: (Nf,) ndarray :param time: Requested TCB epoch in seconds. The segment containing it is used, or, if none does, the one whose midpoint is nearest. :type time: float :returns: XYZ noise covariance: auto-PSDs on the diagonal, CSDs off-diagonal. :rtype: (Nf, 3, 3) complex ndarray .. py:function:: get_XYZ_cov(path: str, time: float, data_file: str | None = None, segment: int | None = None) -> tuple[numpy.ndarray, numpy.ndarray] The covariance of conditioned data, from the fit of the segment at ``time``. Where :func:`get_XYZ_inst_cov` returns the instrument covariance ``C(f)`` on any frequency grid, this returns a data model, ``C_data = k * (R C + A)``: the filter response, the aliased power and the taper convolution of a conditioning, applied to the fitted spectra. Without ``data_file`` it is the model the segment was fitted with, i.e. the covariance of the tapered segment in the processed file the fit was made on, and it lives on that segment's own DFT grid, which is returned with it. With ``data_file`` and ``segment`` it is the covariance of that segment of *another* processed file, rebuilt from its own light travel times, conditioning record and window (:func:`lisa_noise.modelled.from_result.data_model_from_result`), which is how an analysis that conditions its own data obtains the covariance of what it analyses. In both cases the signal templates of the analysis must be passed through the same conditioning. :param path: Path to a combined HDF5 file written by :func:`lisa_noise.io.write.collect_segments`. :type path: str :param time: Requested TCB epoch in seconds. The fit of the segment containing it is used, or, if none does, of the one whose midpoint is nearest. :type time: float :param data_file: Another processed (MojitoProcessor) file to condition the fit for. :type data_file: str, optional :param segment: The segment of ``data_file`` to use; required with ``data_file``. :type segment: int, optional :returns: * **freq** (*(Nf,) ndarray*) -- The science-band slice of ``np.fft.rfftfreq(N, delta_t)`` of the segment. * **cov** (*(Nf, 3, 3) complex ndarray*) -- ``C_data`` at those frequencies, in the convention of ``get_XYZ_inst_cov``.