diff --git a/docs/source/Crab_skymap_with_wobbles.png b/docs/source/Crab_skymap_with_wobbles.png new file mode 100644 index 0000000..9eb47a4 Binary files /dev/null and b/docs/source/Crab_skymap_with_wobbles.png differ diff --git a/docs/source/example.ipynb b/docs/source/example.ipynb index 5b83a3a..5d28904 100644 --- a/docs/source/example.ipynb +++ b/docs/source/example.ipynb @@ -29,13 +29,14 @@ "from iact_estimator import RESOURCES_PATH\n", "from iact_estimator.io import read_yaml\n", "from iact_estimator.core import (\n", - "\n", " initialize_model,\n", " prepare_data,\n", " source_detection,\n", " calculate,\n", ")\n", - "from iact_estimator.plots import plot_spectrum, plot_sed, plot_transit, plot_altitude_airmass" + "from iact_estimator.plots.physics import plot_spectrum, plot_sed\n", + "from iact_estimator.plots.observability import plot_transit, plot_altitude_airmass\n", + "from iact_estimator.plots.wobble_skymap import plot_skymap_with_wobbles, load_wobbles" ] }, { @@ -46,8 +47,8 @@ }, "outputs": [], "source": [ - "output_path=Path.cwd()\n", - "config = read_yaml(RESOURCES_PATH/\"config.yml\")\n", + "output_path = Path.cwd()\n", + "config = read_yaml(RESOURCES_PATH / \"config.yml\")\n", "source_name = \"Crab\"\n", "\n", "observer = Observer.at_site(\"Roque de los Muchachos\")\n", @@ -97,26 +98,26 @@ "observer = Observer.at_site(\"Roque de los Muchachos\")\n", "\n", "date_time = DatetimePicker(\n", - " value=datetime.now(timezone.utc),\n", - " description='Select a datetime',\n", - " disabled=False\n", + " value=datetime.now(timezone.utc), description=\"Select a datetime\", disabled=False\n", ")\n", "\n", "crab = FixedTarget.from_name(\"Crab\")\n", "plot_crab = True if (crab.coord == target_source.coord) else False\n", "\n", + "\n", "def interactive_plot_transit(date_time):\n", - " with quantity_support():\n", - " plot_transit(\n", - " config,\n", - " source_name,\n", - " target_source,\n", - " observer,\n", - " time = Time(date_time).utc,\n", - " merge_profiles=True,\n", - " plot_crab=False,\n", - " savefig=False,\n", - " )\n", + " with quantity_support():\n", + " plot_transit(\n", + " config,\n", + " source_name,\n", + " target_source,\n", + " observer,\n", + " time=Time(date_time).utc,\n", + " merge_profiles=True,\n", + " plot_crab=False,\n", + " savefig=False,\n", + " )\n", + "\n", "\n", "interact(interactive_plot_transit, date_time=date_time)\n", "plt.show()" @@ -136,25 +137,24 @@ "outputs": [], "source": [ "date_time = DatetimePicker(\n", - " value=datetime.now(timezone.utc),\n", - " description='Select a datetime',\n", - " disabled=False\n", + " value=datetime.now(timezone.utc), description=\"Select a datetime\", disabled=False\n", ")\n", "\n", - "def plot_alt(date_time):\n", "\n", + "def plot_alt(date_time):\n", " print(date_time)\n", "\n", " plot_altitude_airmass(\n", - " config,\n", - " source_name,\n", - " target_source,\n", - " observer,\n", - " time=Time(date_time).utc,\n", - " brightness_shading=True,\n", - " airmass_yaxis=True,\n", - " savefig=False,\n", - " )\n", + " config,\n", + " source_name,\n", + " target_source,\n", + " observer,\n", + " time=Time(date_time).utc,\n", + " brightness_shading=True,\n", + " airmass_yaxis=True,\n", + " savefig=False,\n", + " )\n", + "\n", "\n", "interact(plot_alt, date_time=date_time)\n", "plt.show()" @@ -174,13 +174,13 @@ "outputs": [], "source": [ "plot_spectrum(\n", - " config,\n", - " plot_energy_bounds,\n", - " assumed_spectrum,\n", - " source_name,\n", - " plotting_options,\n", - " savefig=False,\n", - " )" + " config,\n", + " plot_energy_bounds,\n", + " assumed_spectrum,\n", + " source_name,\n", + " plotting_options,\n", + " savefig=False,\n", + ")" ] }, { @@ -204,9 +204,7 @@ " energy_bins, gamma_rate, background_rate, config, assumed_spectrum\n", ")\n", "\n", - "combined_significance = source_detection(\n", - " sigmas, u.Quantity(config[\"observation_time\"])\n", - ")" + "combined_significance = source_detection(sigmas, u.Quantity(config[\"observation_time\"]))" ] }, { @@ -215,25 +213,23 @@ "metadata": {}, "outputs": [], "source": [ - "annotation_options = {\"rotation\": 45,\n", - " \"xytext\": (10, 10),\n", - " \"size\": 15}\n", + "annotation_options = {\"rotation\": 45, \"xytext\": (10, 10), \"size\": 15}\n", "\n", "with quantity_support():\n", " plot_sed(\n", - " config,\n", - " sigmas,\n", - " combined_significance,\n", - " source_name,\n", - " assumed_spectrum,\n", - " en,\n", - " sed,\n", - " dsed,\n", - " detected,\n", - " savefig=False,\n", - " annotation_options=annotation_options,\n", - " )\n", - " plt.ylim(1.e-12, 2.e-10)" + " config,\n", + " sigmas,\n", + " combined_significance,\n", + " source_name,\n", + " assumed_spectrum,\n", + " en,\n", + " sed,\n", + " dsed,\n", + " detected,\n", + " savefig=False,\n", + " annotation_options=annotation_options,\n", + " )\n", + " plt.ylim(1.0e-12, 2.0e-10)" ] }, { @@ -241,7 +237,18 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "instrument_fov = u.Quantity(config[\"fov\"])\n", + "wobble_offsets, wobble_angles = load_wobbles(config[\"wobbles\"])\n", + "plot_skymap_with_wobbles(\n", + " target_source,\n", + " observer,\n", + " instrument_fov,\n", + " wobble_angles,\n", + " wobble_offsets,\n", + " config,\n", + ")" + ] } ], "metadata": {