Module mjoindices.principal_components

This module provides basic functionality to handle PC data, which is a basic output of the OMI calculation.

class mjoindices.principal_components.PCData(time: ndarray, pc1: ndarray, pc2: ndarray)[source]

Class as a container for the principal component (PC) data.

The basic PC computation mjoindices.omi.omi_calculator.calculate_pcs_from_olr() will return an object of this class as a major result of this package.

Parameters:
  • time – Array containing the numpy.datetime64 dates. :param period: Array containing the pandas.Period dates.

  • pc1 – Array containing the values of PC1 (has to be of same length as the time array).

  • pc2 – Array containing the values of PC2 (has to be of same length as the time array).

property pc1: ndarray

The time series of the PC1 values.

property pc2: ndarray

The time series of the PC2 values.

save_pcs_to_txt_file(filename: Path) None[source]

Saves the computed PCs to a text file.

Please note that the file format is not exactly that of the original data files. However, a suitable reader is available in this module for both formats (mjoindices.principal_components.load_pcs_from_txt_file() and mjoindices.principal_components.load_original_pcs_from_txt_file()).

Parameters:

filename – The full filename.

property time: ndarray

The time grid of the PC time series as array of numpy.datetime64 elements.

mjoindices.principal_components.load_original_pcs_from_txt_file(filename: Path) PCData[source]

Loads the PCs of OMI, which are stored in the original file format. For example, the following file can be loaded: https://www.esrl.noaa.gov/psd/mjo/mjoindex/omi.1x.txt

Note that the present software package stores the PCs slightly different. Those files can be loaded with load_pcs_from_txt_file().

Parameters:

filename – Path to the PC file.

Returns:

The original PC data.

mjoindices.principal_components.load_pcs_from_txt_file(filename: Path) PCData[source]

Loads the PCs of OMI, which were previously saved with this package (mjoindices.principal_components.PCData.save_pcs_to_txt_file()).

Parameters:

filename – Path to the PC file.

Returns:

The PC data.