{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In order to enable inversion of an STFT via the inverse STFT in "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "istft",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the signal windowing must obey the constraint of \"Nonzero OverLap Add\" (NOLA), and the input signal must have complete windowing coverage (i.e. "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "(x.shape[axis] - nperseg) % (nperseg-noverlap) == 0"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "). The "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "padded"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " argument may be used to accomplish this."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Given a time-domain signal "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x[n]"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", a window "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "w[n]"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and a hop size "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "H"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " = "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "nperseg - noverlap",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the windowed frame at time index "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "t"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is given by"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "x_{t}[n]=x[n]w[n-tH]"
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The overlap-add (OLA) reconstruction equation is given by"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "x[n]=\\frac{\\sum_{t}x_{t}[n]w[n-tH]}{\\sum_{t}w^{2}[n-tH]}"
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The NOLA constraint ensures that every normalization term that appears in the denominator of the OLA reconstruction equation is nonzero. Whether a choice of "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "window"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "nperseg"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "noverlap"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " satisfy this constraint can be tested with "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "check_NOLA",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.signal._spectral_py:check_NOLA"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "versionadded",
          "base_type": "neutral",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "versionadded 0.19.0"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Strong",
              "__tag": 4048,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Array API Standard Support"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "stft",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is not in-scope for support of Python Array API Standard compatible backends other than NumPy."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "See "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "dev-arrayapi",
              "domain": null,
              "role": "ref",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for more information."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "f",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Array of sample frequencies."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "t",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Array of segment times."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "Zxx",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "STFT of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "x"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". By default, the last axis of "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "Zxx",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": null,
                        "version": null,
                        "kind": "local",
                        "path": "Zxx"
                      },
                      "kind": "local"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " corresponds to the segment times."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Compute the Short Time Fourier Transform (legacy function)."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "x",
              "annotation": "array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Time series of measurement values"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "fs",
              "annotation": "float, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Sampling frequency of the "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "x"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " time series. Defaults to 1.0."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "window",
              "annotation": "str or tuple or array_like, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Desired window to use. If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "window"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is a string or tuple, it is passed to "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "get_window",
                      "reference": {
                        "__type": "LocalRef",
                        "__tag": 4022,
                        "kind": "module",
                        "path": "scipy.signal.windows._windows:get_window"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to generate the window values, which are DFT-even by default. See "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "get_window",
                      "reference": {
                        "__type": "LocalRef",
                        "__tag": 4022,
                        "kind": "module",
                        "path": "scipy.signal.windows._windows:get_window"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " for a list of windows and required parameters. If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "window"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is array_like it will be used directly as the window and its length must be nperseg. Defaults to a periodic Hann window."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "nperseg",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Length of each segment. Defaults to 256."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "noverlap",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Number of points to overlap between segments. If "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "None",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "noverlap = nperseg // 2"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". Defaults to "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "None",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". When specified, the COLA constraint must be met (see Notes below)."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "nfft",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Length of the FFT used, if a zero padded FFT is desired. If "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "None",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", the FFT length is "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "nperseg"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". Defaults to "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "None",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "detrend",
              "annotation": "str or function or `False`, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Specifies how to detrend each segment. If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "detrend"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is a string, it is passed as the "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "type",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " argument to the "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "detrend"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " function. If it is a function, it takes a segment and returns a detrended segment. If "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "detrend"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "False",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", no detrending is done. Defaults to "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "False",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "return_onesided",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "True",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", return a one-sided spectrum for real data. If "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "False",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " return a two-sided spectrum. Defaults to "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "True",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", but for complex data, a two-sided spectrum is always returned."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "boundary",
              "annotation": "str or None, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Specifies whether the input signal is extended at both ends, and how to generate the new values, in order to center the first windowed segment on the first input point. This has the benefit of enabling reconstruction of the first input point when the employed window function starts at zero. Valid options are "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "['even', 'odd', 'constant', 'zeros', None]"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". Defaults to 'zeros', for zero padding extension. I.e. "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "[1, 2, 3, 4]"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is extended to "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "[0, 1, 2, 3, 4, 0]"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " for "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "nperseg=3"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "padded",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Specifies whether the input signal is zero-padded at the end to make the signal fit exactly into an integer number of window segments, so that all of the signal is included in the output. Defaults to "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "True",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". Padding occurs after boundary extension, if "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "boundary"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is not "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "None",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", and "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "padded"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "True",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", as is the default."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "axis",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Axis along which the STFT is computed; the default is over the last axis (i.e. "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "axis=-1"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ")."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "scaling: {'spectrum', 'psd'}",
              "annotation": "",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The default 'spectrum' scaling allows each frequency line of "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "Zxx",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": null,
                        "version": null,
                        "kind": "local",
                        "path": "Zxx"
                      },
                      "kind": "local"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to be interpreted as a magnitude spectrum. The 'psd' option scales each line to a power spectral density - it allows to calculate the signal's energy by numerically integrating over "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "abs(Zxx)**2"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                },
                {
                  "__type": "Admonition",
                  "__tag": 4056,
                  "kind": "versionadded",
                  "base_type": "neutral",
                  "children": [
                    {
                      "__type": "AdmonitionTitle",
                      "__tag": 4055,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "versionadded 1.9.0"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "STFTs can be used as a way of quantifying the change of a nonstationary signal's frequency and phase content over time."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/scipy/signal/_spectral_py.py",
  "item_line": 1431,
  "item_type": "function",
  "aliases": [
    "scipy.signal.stft"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy import signal\nimport matplotlib.pyplot as plt\nrng = np.random.default_rng()\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nGenerate a test signal, a 2 Vrms sine wave whose frequency is slowly\nmodulated around 3kHz, corrupted by white noise of exponentially\ndecreasing magnitude sampled at 10 kHz.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "fs = 10e3\nN = 1e5\namp = 2 * np.sqrt(2)\nnoise_power = 0.01 * fs / 2\ntime = np.arange(N) / float(fs)\nmod = 500*np.cos(2*np.pi*0.25*time)\ncarrier = amp * np.sin(2*np.pi*3e3*time + mod)\nnoise = rng.normal(scale=np.sqrt(noise_power),\n                   size=time.shape)\nnoise *= np.exp(-time/5)\nx = carrier + noise\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nCompute and plot the STFT's magnitude.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "f, t, Zxx = signal.stft(x, fs, nperseg=1000)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.pcolormesh(t, f, np.abs(Zxx), vmin=0, vmax=amp, shading='gouraud')\nplt.title('STFT Magnitude')\nplt.ylabel('Frequency [Hz]')\nplt.xlabel('Time [sec]')\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.show()\n",
        "execution_status": "success"
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "1.17.1",
          "kind": "assets",
          "path": "fig-fa4ff677f983ebaf.png"
        }
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nCompare the energy of the signal `x` with the energy of its STFT:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "E_x = sum(x**2) / fs  # Energy of x\nf, t, Zxx = signal.stft(x, fs, nperseg=1000, return_onesided=False,\n                        scaling='psd')\ndf, dt = f[1] - f[0], t[1] - t[0]\nE_Zxx = sum(np.sum(Zxx.real**2 + Zxx.imag**2, axis=0) * df) * dt\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.isclose(E_x, E_Zxx, rtol=1e-2)\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "ShortTimeFFT",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.signal._short_time_fft:ShortTimeFFT"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Newer STFT/ISTFT implementation providing more features."
            }
          ]
        }
      ],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "check_COLA",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.signal._spectral_py:check_COLA"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Check whether the Constant OverLap Add (COLA) constraint is met"
            }
          ]
        }
      ],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "check_NOLA",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.signal._spectral_py:check_NOLA"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Check whether the Nonzero Overlap Add (NOLA) constraint is met"
            }
          ]
        }
      ],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "csd",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.signal._spectral_py:csd"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Cross spectral density by Welch's method."
            }
          ]
        }
      ],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "istft",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "istft"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Inverse Short Time Fourier Transform"
            }
          ]
        }
      ],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "lombscargle",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.signal._spectral_py:lombscargle"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Lomb-Scargle periodogram for unevenly sampled data"
            }
          ]
        }
      ],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "spectrogram",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "spectrogram"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Spectrogram by Welch's method."
            }
          ]
        }
      ],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "welch",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.signal._spectral_py:welch"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Power spectral density by Welch's method."
            }
          ]
        }
      ],
      "type": "func"
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "x",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "fs",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "1.0"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "window",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "hann_periodic"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "nperseg",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "256"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "noverlap",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "nfft",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "detrend",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "return_onesided",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "True"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "boundary",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "zeros"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "padded",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "True"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "axis",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "-1"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "scaling",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "spectrum"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "stft"
  },
  "references": [
    ".. [1] Oppenheim, Alan V., Ronald W. Schafer, John R. Buck",
    "       \"Discrete-Time Signal Processing\", Prentice Hall, 1999.",
    ".. [2] Daniel W. Griffin, Jae S. Lim \"Signal Estimation from",
    "       Modified Short-Time Fourier Transform\", IEEE 1984,",
    "       10.1109/TASSP.1984.1164317"
  ],
  "qa": "scipy.signal._spectral_py:stft",
  "arbitrary": [],
  "local_refs": [
    "'psd'}",
    "Zxx",
    "axis",
    "boundary",
    "detrend",
    "f",
    "fs",
    "nfft",
    "noverlap",
    "nperseg",
    "padded",
    "return_onesided",
    "scaling: {'spectrum'",
    "t",
    "window",
    "x"
  ]
}