{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8382eebe-ea67-402e-b4da-64d9f616f0c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "from finesse.virgo import Virgo\n",
    "from rich.console import Console\n",
    "from matplotlib.pyplot import figure, show\n",
    "from numpy import save, array, geomspace\n",
    "from finesse.analysis.actions import FrequencyResponse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "77a9edfb-d910-4264-a29c-1674a4841c8d",
   "metadata": {},
   "outputs": [],
   "source": [
    "console = Console()\n",
    "\n",
    "virgo = Virgo()\n",
    "virgo.make()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2d780140-9125-4a81-927e-daf298504add",
   "metadata": {},
   "outputs": [],
   "source": [
    "result = virgo.get_QNLS([5, 5000, 1000])\n",
    "\n",
    "Figure = figure()\n",
    "_ = Figure.gca().loglog(result.x0, abs(result[\"NSR_with_RP\"]))\n",
    "Figure.gca().grid(True, \"both\", \"both\")\n",
    "show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8261c88c-8104-4ef9-9a0f-c186891c8b27",
   "metadata": {},
   "outputs": [],
   "source": [
    "save(\n",
    "    \"sensitivities/finesse-virgo.npy\",\n",
    "    array([result.x0, abs(result[\"NSR_with_RP\"])]),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e6519eb5-8dbc-4656-8036-3a4522787cff",
   "metadata": {},
   "outputs": [],
   "source": [
    "result = virgo.model.run(FrequencyResponse(geomspace(5, 5000, 1000), [\"DARM_Fz\"], [\"B1p_56.I\"]))\n",
    "\n",
    "Figure = figure()\n",
    "_ = Figure.gca().loglog(result.f, abs(result[\"B1p_56.I\", \"DARM_Fz\"]))\n",
    "Figure.gca().grid(True, \"both\", \"both\")\n",
    "show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f40772e1-6e9d-462f-8a42-195cc772fb88",
   "metadata": {},
   "outputs": [],
   "source": [
    "virgo.plot_DARM()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "870833dc-4b69-403d-9d50-2c187e66750d",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
