Skip to content

Commit

Permalink
Update example notebook for skymap with wobbles
Browse files Browse the repository at this point in the history
  • Loading branch information
HealthyPear committed Dec 5, 2024
1 parent a2aa132 commit a81ae89
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 58 deletions.
Binary file added docs/source/Crab_skymap_with_wobbles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 65 additions & 58 deletions docs/source/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand All @@ -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",
Expand Down Expand Up @@ -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()"
Expand All @@ -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()"
Expand All @@ -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",
")"
]
},
{
Expand All @@ -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\"]))"
]
},
{
Expand All @@ -215,33 +213,42 @@
"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)"
]
},
{
"cell_type": "code",
"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": {
Expand Down

0 comments on commit a81ae89

Please sign in to comment.