{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "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": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Instantiate a "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "ShortTimeFFT",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.signal._short_time_fft:ShortTimeFFT"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " by only providing a dual window."
            }
          ]
        }
      ],
      "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": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If an STFT is invertible, it is possible to calculate the window "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "win",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " from a given dual window "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "dual_win",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". All other parameters have the same meaning as in the initializer of "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "ShortTimeFFT",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.signal._short_time_fft:ShortTimeFFT"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "As explained in the "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "tutorial_stft",
              "domain": null,
              "role": "ref",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " section of the "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "user_guide",
              "domain": null,
              "role": "ref",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", an invertible STFT can be interpreted as series expansion of time-shifted and frequency modulated dual windows. E.g., the series coefficient S[q,p] belongs to the term, which shifted "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "dual_win",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " by p * "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "delta_t",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and multiplied it by exp( 2 * j * pi * t * q * "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "delta_f",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ")."
            }
          ]
        }
      ],
      "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/_short_time_fft.py",
  "item_line": 461,
  "item_type": "classmethod",
  "aliases": [
    "scipy.signal.ShortTimeFFT.from_dual"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "The following example discusses decomposing a signal into time- and\nfrequency-shifted Gaussians. A Gaussian with standard deviation of\none made up of 51 samples will be used:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.signal import ShortTimeFFT\nfrom scipy.signal.windows import gaussian\nT, N = 0.1, 51\nd_win = gaussian(N, std=1/T, sym=True)  # symmetric Gaussian window\nt = T * (np.arange(N) - N//2)\nfg1, ax1 = plt.subplots()\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "ax1.set_title(r\"Dual Window: Gaussian with $\\sigma_t=1$\")\nax1.set(xlabel=f\"Time $t$ in seconds ({N} samples, $T={T}$ s)\",\n       xlim=(t[0], t[-1]), ylim=(0, 1.1*np.max(d_win)))\nax1.plot(t, d_win, 'C0-')\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe following plot with the overlap of 41, 11 and 2 samples show how\nthe `hop` interval affects the shape of the window `win`:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "fig2, axx = plt.subplots(3, 1, sharex='all')\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "axx[0].set_title(r\"Windows for hop$\\in\\{10, 40, 49\\}$\")\nfor c_, h_ in enumerate([10, 40, 49]):\n    SFT = ShortTimeFFT.from_dual(d_win, h_, 1/T)\n    axx[c_].plot(t + h_ * T, SFT.win, 'k--', alpha=.3, label=None)\n    axx[c_].plot(t - h_ * T, SFT.win, 'k:', alpha=.3, label=None)\n    axx[c_].plot(t, SFT.win, f'C{c_+1}',\n                    label=r\"$\\Delta t=%0.1f\\,$s\" % SFT.delta_t)\n    axx[c_].set_ylim(0, 1.1*max(SFT.win))\n    axx[c_].legend(loc='center')\naxx[-1].set(xlabel=f\"Time $t$ in seconds ({N} samples, $T={T}$ s)\",\n            xlim=(t[0], t[-1]))\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-19a9b1c59eb99a79.png"
        }
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "1.17.1",
          "kind": "assets",
          "path": "fig-155b842262ef2310.png"
        }
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nBeside the window `win` centered at t = 0 the previous (t = -`delta_t`)\nand following window (t = `delta_t`) are depicted. It can be seen that\nfor small `hop` intervals, the window is compact and smooth, having a\ngood time-frequency concentration in the STFT. For the large `hop`\ninterval of 4.9 s, the window has small values around t = 0, which are\nnot covered by the overlap of the adjacent windows, which could lead to\nnumeric inaccuracies. Furthermore, the peaky shape at the beginning and\nthe end of the window points to a higher bandwidth, resulting in a\npoorer time-frequency resolution of the STFT.\nHence, the choice of the `hop` interval will be a compromise between\na time-frequency resolution and memory requirements demanded by small\n`hop` sizes."
      }
    ],
    "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": "Create instance using standard initializer."
            }
          ]
        }
      ],
      "type": null
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "from_window",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.signal._short_time_fft:ShortTimeFFT.from_window"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Create instance by wrapping "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "get_window",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "type": null
    }
  ],
  "signature": null,
  "references": null,
  "qa": "scipy.signal._short_time_fft:ShortTimeFFT.from_dual",
  "arbitrary": [],
  "local_refs": []
}