Skip to content

Commit 16faa63

Browse files
committed
Update example notebook for skymap with wobbles
1 parent 1117bf1 commit 16faa63

File tree

2 files changed

+65
-58
lines changed

2 files changed

+65
-58
lines changed
175 KB
Loading

docs/source/example.ipynb

Lines changed: 65 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@
2929
"from iact_estimator import RESOURCES_PATH\n",
3030
"from iact_estimator.io import read_yaml\n",
3131
"from iact_estimator.core import (\n",
32-
"\n",
3332
" initialize_model,\n",
3433
" prepare_data,\n",
3534
" source_detection,\n",
3635
" calculate,\n",
3736
")\n",
38-
"from iact_estimator.plots import plot_spectrum, plot_sed, plot_transit, plot_altitude_airmass"
37+
"from iact_estimator.plots.physics import plot_spectrum, plot_sed\n",
38+
"from iact_estimator.plots.observability import plot_transit, plot_altitude_airmass\n",
39+
"from iact_estimator.plots.wobble_skymap import plot_skymap_with_wobbles, load_wobbles"
3940
]
4041
},
4142
{
@@ -46,8 +47,8 @@
4647
},
4748
"outputs": [],
4849
"source": [
49-
"output_path=Path.cwd()\n",
50-
"config = read_yaml(RESOURCES_PATH/\"config.yml\")\n",
50+
"output_path = Path.cwd()\n",
51+
"config = read_yaml(RESOURCES_PATH / \"config.yml\")\n",
5152
"source_name = \"Crab\"\n",
5253
"\n",
5354
"observer = Observer.at_site(\"Roque de los Muchachos\")\n",
@@ -97,26 +98,26 @@
9798
"observer = Observer.at_site(\"Roque de los Muchachos\")\n",
9899
"\n",
99100
"date_time = DatetimePicker(\n",
100-
" value=datetime.now(timezone.utc),\n",
101-
" description='Select a datetime',\n",
102-
" disabled=False\n",
101+
" value=datetime.now(timezone.utc), description=\"Select a datetime\", disabled=False\n",
103102
")\n",
104103
"\n",
105104
"crab = FixedTarget.from_name(\"Crab\")\n",
106105
"plot_crab = True if (crab.coord == target_source.coord) else False\n",
107106
"\n",
107+
"\n",
108108
"def interactive_plot_transit(date_time):\n",
109-
" with quantity_support():\n",
110-
" plot_transit(\n",
111-
" config,\n",
112-
" source_name,\n",
113-
" target_source,\n",
114-
" observer,\n",
115-
" time = Time(date_time).utc,\n",
116-
" merge_profiles=True,\n",
117-
" plot_crab=False,\n",
118-
" savefig=False,\n",
119-
" )\n",
109+
" with quantity_support():\n",
110+
" plot_transit(\n",
111+
" config,\n",
112+
" source_name,\n",
113+
" target_source,\n",
114+
" observer,\n",
115+
" time=Time(date_time).utc,\n",
116+
" merge_profiles=True,\n",
117+
" plot_crab=False,\n",
118+
" savefig=False,\n",
119+
" )\n",
120+
"\n",
120121
"\n",
121122
"interact(interactive_plot_transit, date_time=date_time)\n",
122123
"plt.show()"
@@ -136,25 +137,24 @@
136137
"outputs": [],
137138
"source": [
138139
"date_time = DatetimePicker(\n",
139-
" value=datetime.now(timezone.utc),\n",
140-
" description='Select a datetime',\n",
141-
" disabled=False\n",
140+
" value=datetime.now(timezone.utc), description=\"Select a datetime\", disabled=False\n",
142141
")\n",
143142
"\n",
144-
"def plot_alt(date_time):\n",
145143
"\n",
144+
"def plot_alt(date_time):\n",
146145
" print(date_time)\n",
147146
"\n",
148147
" plot_altitude_airmass(\n",
149-
" config,\n",
150-
" source_name,\n",
151-
" target_source,\n",
152-
" observer,\n",
153-
" time=Time(date_time).utc,\n",
154-
" brightness_shading=True,\n",
155-
" airmass_yaxis=True,\n",
156-
" savefig=False,\n",
157-
" )\n",
148+
" config,\n",
149+
" source_name,\n",
150+
" target_source,\n",
151+
" observer,\n",
152+
" time=Time(date_time).utc,\n",
153+
" brightness_shading=True,\n",
154+
" airmass_yaxis=True,\n",
155+
" savefig=False,\n",
156+
" )\n",
157+
"\n",
158158
"\n",
159159
"interact(plot_alt, date_time=date_time)\n",
160160
"plt.show()"
@@ -174,13 +174,13 @@
174174
"outputs": [],
175175
"source": [
176176
"plot_spectrum(\n",
177-
" config,\n",
178-
" plot_energy_bounds,\n",
179-
" assumed_spectrum,\n",
180-
" source_name,\n",
181-
" plotting_options,\n",
182-
" savefig=False,\n",
183-
" )"
177+
" config,\n",
178+
" plot_energy_bounds,\n",
179+
" assumed_spectrum,\n",
180+
" source_name,\n",
181+
" plotting_options,\n",
182+
" savefig=False,\n",
183+
")"
184184
]
185185
},
186186
{
@@ -204,9 +204,7 @@
204204
" energy_bins, gamma_rate, background_rate, config, assumed_spectrum\n",
205205
")\n",
206206
"\n",
207-
"combined_significance = source_detection(\n",
208-
" sigmas, u.Quantity(config[\"observation_time\"])\n",
209-
")"
207+
"combined_significance = source_detection(sigmas, u.Quantity(config[\"observation_time\"]))"
210208
]
211209
},
212210
{
@@ -215,33 +213,42 @@
215213
"metadata": {},
216214
"outputs": [],
217215
"source": [
218-
"annotation_options = {\"rotation\": 45,\n",
219-
" \"xytext\": (10, 10),\n",
220-
" \"size\": 15}\n",
216+
"annotation_options = {\"rotation\": 45, \"xytext\": (10, 10), \"size\": 15}\n",
221217
"\n",
222218
"with quantity_support():\n",
223219
" plot_sed(\n",
224-
" config,\n",
225-
" sigmas,\n",
226-
" combined_significance,\n",
227-
" source_name,\n",
228-
" assumed_spectrum,\n",
229-
" en,\n",
230-
" sed,\n",
231-
" dsed,\n",
232-
" detected,\n",
233-
" savefig=False,\n",
234-
" annotation_options=annotation_options,\n",
235-
" )\n",
236-
" plt.ylim(1.e-12, 2.e-10)"
220+
" config,\n",
221+
" sigmas,\n",
222+
" combined_significance,\n",
223+
" source_name,\n",
224+
" assumed_spectrum,\n",
225+
" en,\n",
226+
" sed,\n",
227+
" dsed,\n",
228+
" detected,\n",
229+
" savefig=False,\n",
230+
" annotation_options=annotation_options,\n",
231+
" )\n",
232+
" plt.ylim(1.0e-12, 2.0e-10)"
237233
]
238234
},
239235
{
240236
"cell_type": "code",
241237
"execution_count": null,
242238
"metadata": {},
243239
"outputs": [],
244-
"source": []
240+
"source": [
241+
"instrument_fov = u.Quantity(config[\"fov\"])\n",
242+
"wobble_offsets, wobble_angles = load_wobbles(config[\"wobbles\"])\n",
243+
"plot_skymap_with_wobbles(\n",
244+
" target_source,\n",
245+
" observer,\n",
246+
" instrument_fov,\n",
247+
" wobble_angles,\n",
248+
" wobble_offsets,\n",
249+
" config,\n",
250+
")"
251+
]
245252
}
246253
],
247254
"metadata": {

0 commit comments

Comments
 (0)