{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The defaults are chosen such that "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "signal.czt(x)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is equivalent to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "fft.fft(x)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and, if "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "m > len(x)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", that "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "signal.czt(x, m)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is equivalent to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "fft.fft(x, m)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If the transform needs to be repeated, use "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "CZT",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.signal._czt:CZT"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to construct a specialized transform function which can be reused without recomputing constants."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "An example application is in system identification, repeatedly evaluating small slices of the z-transform of a system, around where a pole is expected to exist, to refine the estimate of the pole's true location. "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            }
          ]
        },
        {
          "__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": "CrossRef",
              "__tag": 4002,
              "value": "czt",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.signal._czt:czt"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "SCIPY_ARRAY_API=1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "====================  ====================  ====================\nLibrary               CPU                   GPU\n====================  ====================  ====================\nNumPy                 ✅                     n/a                 \nCuPy                  n/a                   ✅                   \nPyTorch               ⛔                     ⛔                   \nJAX                   ⛔                     ⛔                   \nDask                  ⛔                     n/a                 \n====================  ====================  ====================",
          "execution_status": null
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__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": "out",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "An array of the same dimensions as "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "x"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", but with the length of the transformed axis set to "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "m"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Compute the frequency response around a spiral in the Z plane."
            }
          ]
        }
      ],
      "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",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The signal to transform."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "m",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The number of output points desired.  Default is the length of the input data."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "w",
              "annotation": "complex, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The ratio between points in each step.  This must be precise or the accumulated error will degrade the tail of the output sequence. Defaults to equally spaced points around the entire unit circle."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "a",
              "annotation": "complex, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The starting point in the complex plane.  Default is 1+0j."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "axis",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Axis over which to compute the FFT. If not given, the last axis is used."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "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/_czt.py",
  "item_line": 394,
  "item_type": "function",
  "aliases": [
    "scipy.signal.czt"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "Generate a sinusoid:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nf1, f2, fs = 8, 10, 200  # Hz\nt = np.linspace(0, 1, fs, endpoint=False)\nx = np.sin(2*np.pi*t*f2)\nimport matplotlib.pyplot as plt\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.plot(t, x)\nplt.axis([0, 1, -1.1, 1.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-378d64a0ef420924.png"
        }
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nIts discrete Fourier transform has all of its energy in a single frequency\nbin:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.fft import rfft, rfftfreq\nfrom scipy.signal import czt, czt_points\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.plot(rfftfreq(fs, 1/fs), abs(rfft(x)))\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.margins(0, 0.1)\nplt.show()\n",
        "execution_status": "success"
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "1.17.1",
          "kind": "assets",
          "path": "fig-4eb10a6d7e7cb9dc.png"
        }
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nHowever, if the sinusoid is logarithmically-decaying:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "x = np.exp(-t*f1) * np.sin(2*np.pi*t*f2)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.plot(t, x)\nplt.axis([0, 1, -1.1, 1.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-87f9ffb9e8b4ef73.png"
        }
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nthe DFT will have spectral leakage:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.plot(rfftfreq(fs, 1/fs), abs(rfft(x)))\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.margins(0, 0.1)\nplt.show()\n",
        "execution_status": "success"
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "1.17.1",
          "kind": "assets",
          "path": "fig-7829464b44166d6f.png"
        }
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nWhile the DFT always samples the z-transform around the unit circle, the\nchirp z-transform allows us to sample the Z-transform along any\nlogarithmic spiral, such as a circle with radius smaller than unity:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "M = fs // 2  # Just positive frequencies, like rfft\na = np.exp(-f1/fs)  # Starting point of the circle, radius < 1\nw = np.exp(-1j*np.pi/M)  # \"Step size\" of circle\npoints = czt_points(M + 1, w, a)  # M + 1 to include Nyquist\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.plot(points.real, points.imag, '.')\nplt.gca().add_patch(plt.Circle((0,0), radius=1, fill=False, alpha=.3))\nplt.axis('equal'); plt.axis([-1.05, 1.05, -0.05, 1.05])\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-3c488f88dd2be6c7.png"
        }
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nWith the correct radius, this transforms the decaying sinusoid (and others\nwith the same decay rate) without spectral leakage:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "z_vals = czt(x, M + 1, w, a)  # Include Nyquist for comparison to rfft\nfreqs = np.angle(points)*fs/(2*np.pi)  # angle = omega, radius = sigma\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.plot(freqs, abs(z_vals))\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.margins(0, 0.1)\nplt.show()\n",
        "execution_status": "success"
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "1.17.1",
          "kind": "assets",
          "path": "fig-4eb10a6d7e7cb9dc.png"
        }
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "CZT",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.signal._czt:CZT"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Class that creates a callable chirp z-transform function."
            }
          ]
        }
      ],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "zoom_fft",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.signal._czt:zoom_fft"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Convenience function for partial FFT calculations."
            }
          ]
        }
      ],
      "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": "m",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "w",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "a",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "(1+0j)"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "axis",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "-1"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "czt"
  },
  "references": [
    ".. [1] Steve Alan Shilling, \"A study of the chirp z-transform and its",
    "       applications\", pg 20 (1970)",
    "       https://krex.k-state.edu/dspace/bitstream/handle/2097/7844/LD2668R41972S43.pdf"
  ],
  "qa": "scipy.signal._czt:czt",
  "arbitrary": [],
  "local_refs": [
    "a",
    "axis",
    "m",
    "out",
    "w",
    "x"
  ]
}