\n",
350 | " Science\n",
351 | " \n",
352 | " Template\n",
353 | " \n",
354 | " Difference\n",
355 | "
\n",
356 | "
\n",
357 | "
\n",
358 | "
\n",
359 | "
\n",
360 | " "
361 | ],
362 | "text/plain": [
363 | "
"
364 | ]
365 | },
366 | "metadata": {},
367 | "output_type": "display_data"
368 | },
369 | {
370 | "data": {
371 | "text/html": [
372 | "\n",
373 | " ZTF oid: ZTF20aacbijc, candid: 1097444403615015104
\n",
374 | " \n",
375 | " Science\n",
376 | " \n",
377 | " Template\n",
378 | " \n",
379 | " Difference\n",
380 | "
\n",
381 | "
\n",
382 | "
\n",
383 | "
\n",
384 | "
\n",
385 | " "
386 | ],
387 | "text/plain": [
388 | "
"
389 | ]
390 | },
391 | "metadata": {},
392 | "output_type": "display_data"
393 | },
394 | {
395 | "data": {
396 | "text/html": [
397 | "\n",
398 | " ZTF oid: ZTF20aaehjjm, candid: 1100451663615015164
\n",
399 | " \n",
400 | " Science\n",
401 | " \n",
402 | " Template\n",
403 | " \n",
404 | " Difference\n",
405 | "
\n",
406 | "
\n",
407 | "
\n",
408 | "
\n",
409 | "
\n",
410 | " "
411 | ],
412 | "text/plain": [
413 | "
"
414 | ]
415 | },
416 | "metadata": {},
417 | "output_type": "display_data"
418 | },
419 | {
420 | "data": {
421 | "text/html": [
422 | "\n",
423 | " ZTF oid: ZTF20aaebiae, candid: 1100187173615015124
\n",
424 | " \n",
425 | " Science\n",
426 | " \n",
427 | " Template\n",
428 | " \n",
429 | " Difference\n",
430 | "
\n",
431 | "
\n",
432 | "
\n",
433 | "
\n",
434 | "
\n",
435 | " "
436 | ],
437 | "text/plain": [
438 | "
"
439 | ]
440 | },
441 | "metadata": {},
442 | "output_type": "display_data"
443 | },
444 | {
445 | "data": {
446 | "text/html": [
447 | "\n",
448 | " ZTF oid: ZTF20aaejaax, candid: 1101179013615015179
\n",
449 | " \n",
450 | " Science\n",
451 | " \n",
452 | " Template\n",
453 | " \n",
454 | " Difference\n",
455 | "
\n",
456 | "
\n",
457 | "
\n",
458 | "
\n",
459 | "
\n",
460 | " "
461 | ],
462 | "text/plain": [
463 | "
"
464 | ]
465 | },
466 | "metadata": {},
467 | "output_type": "display_data"
468 | }
469 | ],
470 | "source": [
471 | "for oid, row in df.iterrows():\n",
472 | " client.plot_stamps(oid, row.candid)"
473 | ]
474 | },
475 | {
476 | "cell_type": "markdown",
477 | "metadata": {},
478 | "source": [
479 | "# Display in Aladin"
480 | ]
481 | },
482 | {
483 | "cell_type": "code",
484 | "execution_count": 8,
485 | "metadata": {
486 | "ExecuteTime": {
487 | "end_time": "2022-01-18T21:37:07.653627Z",
488 | "start_time": "2022-01-18T21:37:07.647075Z"
489 | }
490 | },
491 | "outputs": [
492 | {
493 | "data": {
494 | "application/vnd.jupyter.widget-view+json": {
495 | "model_id": "990acb2ecae248bcbf75be1e3c38484f",
496 | "version_major": 2,
497 | "version_minor": 0
498 | },
499 | "text/plain": [
500 | "Aladin(fov=0.15, options=['allow_full_zoomout', 'coo_frame', 'fov', 'full_screen', 'log', 'overlay_survey', 'o…"
501 | ]
502 | },
503 | "metadata": {},
504 | "output_type": "display_data"
505 | }
506 | ],
507 | "source": [
508 | "aladin= ipyal.Aladin(target='%s %s' % (df.iloc[0].ra, df.iloc[0].dec), fov=0.15, survey='P/PanSTARRS/DR1/color-z-zg-g')\n",
509 | "aladin"
510 | ]
511 | },
512 | {
513 | "cell_type": "markdown",
514 | "metadata": {},
515 | "source": [
516 | "Add all the candidates to Aladin"
517 | ]
518 | },
519 | {
520 | "cell_type": "code",
521 | "execution_count": 9,
522 | "metadata": {
523 | "ExecuteTime": {
524 | "end_time": "2022-01-18T21:37:10.841388Z",
525 | "start_time": "2022-01-18T21:37:10.785579Z"
526 | }
527 | },
528 | "outputs": [],
529 | "source": [
530 | "cand = Table.from_pandas(pd.DataFrame(\n",
531 | " data={\"MAIN_ID\": df.index.tolist(), \"ra\": df.ra.to_list(), \"dec\": df.dec.to_list()}))\n",
532 | "aladin.add_table(cand)"
533 | ]
534 | },
535 | {
536 | "cell_type": "markdown",
537 | "metadata": {},
538 | "source": [
539 | "Note that you can click in individual candidates to see their object ids."
540 | ]
541 | },
542 | {
543 | "cell_type": "code",
544 | "execution_count": null,
545 | "metadata": {},
546 | "outputs": [],
547 | "source": []
548 | }
549 | ],
550 | "metadata": {
551 | "kernelspec": {
552 | "display_name": "Python 3",
553 | "language": "python",
554 | "name": "python3"
555 | },
556 | "language_info": {
557 | "codemirror_mode": {
558 | "name": "ipython",
559 | "version": 3
560 | },
561 | "file_extension": ".py",
562 | "mimetype": "text/x-python",
563 | "name": "python",
564 | "nbconvert_exporter": "python",
565 | "pygments_lexer": "ipython3",
566 | "version": "3.8.8"
567 | },
568 | "toc": {
569 | "base_numbering": 1,
570 | "nav_menu": {},
571 | "number_sections": true,
572 | "sideBar": true,
573 | "skip_h1_title": false,
574 | "title_cell": "Table of Contents",
575 | "title_sidebar": "Contents",
576 | "toc_cell": false,
577 | "toc_position": {},
578 | "toc_section_display": true,
579 | "toc_window_display": false
580 | },
581 | "varInspector": {
582 | "cols": {
583 | "lenName": 16,
584 | "lenType": 16,
585 | "lenVar": 40
586 | },
587 | "kernels_config": {
588 | "python": {
589 | "delete_cmd_postfix": "",
590 | "delete_cmd_prefix": "del ",
591 | "library": "var_list.py",
592 | "varRefreshCmd": "print(var_dic_list())"
593 | },
594 | "r": {
595 | "delete_cmd_postfix": ") ",
596 | "delete_cmd_prefix": "rm(",
597 | "library": "var_list.r",
598 | "varRefreshCmd": "cat(var_dic_list()) "
599 | }
600 | },
601 | "types_to_exclude": [
602 | "module",
603 | "function",
604 | "builtin_function_or_method",
605 | "instance",
606 | "_Feature"
607 | ],
608 | "window_display": false
609 | }
610 | },
611 | "nbformat": 4,
612 | "nbformat_minor": 2
613 | }
614 |
--------------------------------------------------------------------------------
/notebooks/ALeRCE_ML_Light_Curve_Classifier.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# ALeRCE light curve classifier\n",
8 | "Author: Ignacio Reyes, Last updated: 10/08/2021\n",
9 | "### **Notebook under development**"
10 | ]
11 | },
12 | {
13 | "cell_type": "markdown",
14 | "metadata": {},
15 | "source": [
16 | "## Table of contents:\n",
17 | "* [Required libraries](#Required-libraries)\n",
18 | "* [The classifier](#The-classifier)\n",
19 | " * [Brief explanation of the data](#Brief-explanation-of-the-data)\n",
20 | " * [Model description](#Model-description)\n",
21 | " * [Results](#Results)\n",
22 | " * [ALeRCE Explorer](#ALeRCE-Explorer)\n",
23 | "* [Query model predictions](#Query-model-predictions)\n",
24 | " * [Which objects have we found?](#Which-objects-have-we-found?)\n",
25 | "* [Spatial distribution of the predictions](#Spatial-distribution-of-the-predictions)\n",
26 | " * [Galactic sources](#Galactic-sources-(LPV,-CEP,-YSO))\n",
27 | " * [Extragalactic sources](#Extragalactic-sources-(QSO,-AGN,-Blazar,-SNe))\n",
28 | "* [Visualizing a sample of predicted objects](#Visualizing-a-sample-of-predicted-objects)"
29 | ]
30 | },
31 | {
32 | "cell_type": "markdown",
33 | "metadata": {},
34 | "source": [
35 | "## Required libraries"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": null,
41 | "metadata": {},
42 | "outputs": [],
43 | "source": [
44 | "!pip install alerce"
45 | ]
46 | },
47 | {
48 | "cell_type": "code",
49 | "execution_count": null,
50 | "metadata": {},
51 | "outputs": [],
52 | "source": [
53 | "from IPython.core.display import display, HTML\n",
54 | "display(HTML(\"\"))\n",
55 | "import numpy as np\n",
56 | "import pandas as pd\n",
57 | "import matplotlib.pyplot as plt\n",
58 | "from alerce.core import Alerce\n",
59 | "import psycopg2\n",
60 | "import json"
61 | ]
62 | },
63 | {
64 | "cell_type": "markdown",
65 | "metadata": {},
66 | "source": [
67 | "# The classifier\n",
68 | "This notebook shows the light curve classifier from ALeRCE, described in detail in \"Alert Classification for the ALeRCE Broker System: The Light Curve Classifier\" by Sánchez-Sáez et. al (2020, under review). The goal of this notebook is to show how to access the predictions made by the model from ALeRCE's database. The code to replicate the results from the paper is contained in another GitHub repository."
69 | ]
70 | },
71 | {
72 | "cell_type": "markdown",
73 | "metadata": {},
74 | "source": [
75 | "## Brief explanation of the data\n",
76 | "ALeRCE's database contains all the alerts generated by the Zwicky Transient Facility (ZTF) public stream. An alert is generated by ZTF each time an area of the sky is observed and a difference in brightness is detected. All alerts from the same coordinates are grouped into the same object with an object id (oid). Up to this date, the database contains more than 100 million alerts and 35 million objects.\n",
77 | "\n",
78 | "Most ZTF detections come from two filters, g and r. Let's see an example of a light curve from ZTF."
79 | ]
80 | },
81 | {
82 | "cell_type": "code",
83 | "execution_count": null,
84 | "metadata": {},
85 | "outputs": [],
86 | "source": [
87 | "alerce_client = Alerce()"
88 | ]
89 | },
90 | {
91 | "cell_type": "code",
92 | "execution_count": null,
93 | "metadata": {},
94 | "outputs": [],
95 | "source": [
96 | "def plot_light_curve(df, title='', period=None):\n",
97 | " def colormap(i):\n",
98 | " if i == 1:\n",
99 | " return '#56e03a'\n",
100 | " elif i == 2:\n",
101 | " return '#d42f4b'\n",
102 | " else:\n",
103 | " return '#000000'\n",
104 | " for fid in [1, 2]:\n",
105 | " fid_df = df[df.fid == fid]\n",
106 | " if len(fid_df) == 0:\n",
107 | " continue\n",
108 | " if period is not None:\n",
109 | " mjd = (fid_df.mjd % period) / period\n",
110 | " else:\n",
111 | " mjd = fid_df.mjd\n",
112 | " plt.errorbar(\n",
113 | " mjd,\n",
114 | " fid_df.magpsf,\n",
115 | " yerr=fid_df.sigmapsf,\n",
116 | " fmt='*',\n",
117 | " c=colormap(fid))\n",
118 | " plt.gca().invert_yaxis()\n",
119 | " if period is not None:\n",
120 | " plt.xlabel(f'Phase (period={period:.3f})')\n",
121 | " else:\n",
122 | " plt.xlabel('Date [mjd]')\n",
123 | " plt.ylabel('Apparent magnitude [mag]')\n",
124 | " plt.title(title)"
125 | ]
126 | },
127 | {
128 | "cell_type": "code",
129 | "execution_count": null,
130 | "metadata": {},
131 | "outputs": [],
132 | "source": [
133 | "fig = plt.figure(figsize=(14, 10))\n",
134 | "fig.patch.set_facecolor('white')\n",
135 | "oid = 'ZTF20aaelulu'\n",
136 | "light_curve = alerce_client.query_detections(oid, format='pandas')\n",
137 | "plot_light_curve(light_curve, title=f'Light curve example {oid}')"
138 | ]
139 | },
140 | {
141 | "cell_type": "markdown",
142 | "metadata": {},
143 | "source": [
144 | "The training set for the light curve classifier was built by cross matching ZTF with many astronomical catalogs with objects from known categories. The current training set of ALeRCE contains more than 1700 supernovae from many subclasses, almost 35k stochastic sources (QSO, AGN, Blazar, YSO, CV/Nova) and 87k light curves from periodic stars."
145 | ]
146 | },
147 | {
148 | "cell_type": "markdown",
149 | "metadata": {},
150 | "source": [
151 | "## Model description\n",
152 | "When a light curve has more than 5 alerts in any of its bands it's classified by our light curve classifier. The model uses Machine Learning, combining feature extraction of the light curves and a model build of 4 Random Forest classifiers. Each object is classified in 15 astrophysical categories according to the following taxonomy.\n",
153 | "\n",
154 | ""
155 | ]
156 | },
157 | {
158 | "cell_type": "markdown",
159 | "metadata": {},
160 | "source": [
161 | "Our classifier takes the light curve of an object, information about non-detections (previous ZTF observations where no alerts were generated), the metadata available from ZTF (e.g. coordinates) and cross match data from WISE if available. Using that data, more than 150 features are computed.\n",
162 | "\n",
163 | "Some of the computed features are:\n",
164 | "* Irregular autoregressive model from Eyheramendy et al. (2018).\n",
165 | "* Mexican hat power spectrum from Arévalo et al. (2012).\n",
166 | "* Parameters from a damped random walk model from Graham et al. (2017).\n",
167 | "* Structure function from Schmidt et al. (2010).\n",
168 | "* Multiband periodogram from Mondrik et al. (2015)."
169 | ]
170 | },
171 | {
172 | "cell_type": "markdown",
173 | "metadata": {},
174 | "source": [
175 | "Once the features are computed they are classified by 4 Random Forest models, grouped in a hierarchy with two levels. The random forest on the top level classifies each object into 3 main categories: stochastic, transient and periodic sources. After that, each object is processed by 3 random forest classifiers in the bottom level, each one specialized in one category of objects.\n",
176 | "\n",
177 | "For example, the Transient Random Forest provides as output a vector with 4 probabilities, which corresponds to the probability of being a SN type Ia, SN type Ibc, SN type II or superluminous supernova.\n",
178 | "\n",
179 | "Finally, the outputs of the 4 classsifiers are combined using the total probabilities rule. That means that the probability of an object being a cepheid according to our classifier is the product of the object being a periodic star (computed by the random forest of the top level) and the probability of the object being a cepheid (computed by the periodic random forest).\n",
180 | "\n",
181 | ""
182 | ]
183 | },
184 | {
185 | "cell_type": "markdown",
186 | "metadata": {},
187 | "source": [
188 | "## Results\n",
189 | "\n",
190 | "The following confusion matrix is a summary of the performance of the model over the test set. This figure shows that the classifier is able to separate among the different classes. Of course some classes are difficult to distinguish, but the mistakes are \"reasonable\" in the sense that most of them choose a similar class. For example, most misclassified supernovae type Ia are labeled as another kind of supernova.\n",
191 | "\n",
192 | "The black boxes in the figure indicate the confusion inside of one of the three main categories: transient sources, periodic stars and stochastic objects.\n",
193 | ""
194 | ]
195 | },
196 | {
197 | "cell_type": "markdown",
198 | "metadata": {},
199 | "source": [
200 | "## ALeRCE Explorer\n",
201 | "All the data in ALeRCE's database, including model predictions, can be seen using the ALeRCE Explorer. The explorer is available in https://alerce.online\n",
202 | "\n",
203 | "This webpage is currently being updated, so the shown predictions can be out of date.\n",
204 | "\n",
205 | ""
206 | ]
207 | },
208 | {
209 | "cell_type": "markdown",
210 | "metadata": {},
211 | "source": [
212 | "Once an object is selected, all available information about it is shown. The figure in the bottom center shows the probabilities given by the light curve classifier.\n",
213 | "\n",
214 | ""
215 | ]
216 | },
217 | {
218 | "cell_type": "code",
219 | "execution_count": null,
220 | "metadata": {},
221 | "outputs": [],
222 | "source": [
223 | "!wget https://github.com/alercebroker/usecases/raw/master/alercereaduser_v4.json\n",
224 | "!mv alercereaduser_v4.json ..\n",
225 | "credentials_file = \"../alercereaduser_v4.json\"\n",
226 | "with open(credentials_file) as jsonfile:\n",
227 | " params = json.load(jsonfile)[\"params\"]\n",
228 | "conn = psycopg2.connect(\n",
229 | " dbname=params['dbname'], \n",
230 | " user=params['user'], \n",
231 | " host=params['host'], \n",
232 | " password=params['password'])"
233 | ]
234 | },
235 | {
236 | "cell_type": "code",
237 | "execution_count": null,
238 | "metadata": {},
239 | "outputs": [],
240 | "source": [
241 | "# Heavy query (~ 2 min)\n",
242 | "query = \"select * from probability where classifier_name = 'lc_classifier' and ranking = 1;\"\n",
243 | "bhrf_predictions = pd.read_sql_query(query, conn)\n",
244 | "bhrf_predictions"
245 | ]
246 | },
247 | {
248 | "cell_type": "markdown",
249 | "metadata": {},
250 | "source": [
251 | "# Query model predictions\n",
252 | "## Which objects have we found?"
253 | ]
254 | },
255 | {
256 | "cell_type": "code",
257 | "execution_count": null,
258 | "metadata": {},
259 | "outputs": [],
260 | "source": [
261 | "pred_classes_count = bhrf_predictions.groupby('class_name').count()['oid']\n",
262 | "pred_classes_count = pred_classes_count.sort_values(ascending=False)\n",
263 | "fig = plt.figure(figsize=(14, 10))\n",
264 | "fig.patch.set_facecolor('white')\n",
265 | "plt.bar(pred_classes_count.index.values, pred_classes_count.values)\n",
266 | "plt.gca().set_yscale('log')\n",
267 | "plt.title('Predicted class frequency')"
268 | ]
269 | },
270 | {
271 | "cell_type": "markdown",
272 | "metadata": {},
273 | "source": [
274 | "## Spatial distribution of the predictions\n",
275 | "### Galactic sources (LPV, CEP, YSO)"
276 | ]
277 | },
278 | {
279 | "cell_type": "code",
280 | "execution_count": null,
281 | "metadata": {},
282 | "outputs": [],
283 | "source": [
284 | "galactic_sources = bhrf_predictions[bhrf_predictions['class_name'].isin(\n",
285 | " ['LPV', 'CEP', 'YSO'])]\n",
286 | "galactic_sources"
287 | ]
288 | },
289 | {
290 | "cell_type": "code",
291 | "execution_count": null,
292 | "metadata": {},
293 | "outputs": [],
294 | "source": [
295 | "# Heavy query (~ 8 min)\n",
296 | "query = \"select oid, name, value from feature where name = 'gal_l' or name = 'gal_b';\"\n",
297 | "features = pd.read_sql_query(query, conn)\n",
298 | "features"
299 | ]
300 | },
301 | {
302 | "cell_type": "code",
303 | "execution_count": null,
304 | "metadata": {},
305 | "outputs": [],
306 | "source": [
307 | "gal_l = features[features.name == 'gal_l'].copy()\n",
308 | "gal_l.rename(columns={'value': 'gal_l'}, inplace=True)\n",
309 | "gal_l.drop(columns=['name'], inplace=True)\n",
310 | "gal_l.set_index('oid', inplace=True)\n",
311 | "\n",
312 | "gal_b = features[features.name == 'gal_b'].copy()\n",
313 | "gal_b.rename(columns={'value': 'gal_b'}, inplace=True)\n",
314 | "gal_b.drop(columns=['name'], inplace=True)\n",
315 | "gal_b.set_index('oid', inplace=True)\n",
316 | "\n",
317 | "coordinates = pd.concat([gal_l, gal_b], sort=True, axis=1)\n",
318 | "coordinates"
319 | ]
320 | },
321 | {
322 | "cell_type": "code",
323 | "execution_count": null,
324 | "metadata": {},
325 | "outputs": [],
326 | "source": [
327 | "n_per_class = 1000 # sample size\n",
328 | "replace = False # with replacement\n",
329 | "fn = lambda obj: obj.loc[np.random.choice(obj.index, n_per_class, replace),:]\n",
330 | "galactic_sources_subset = galactic_sources.groupby('class_name', as_index=False).apply(fn)\n",
331 | "galactic_sources_subset = galactic_sources_subset.droplevel(level=0)\n",
332 | "galactic_sources_subset\n"
333 | ]
334 | },
335 | {
336 | "cell_type": "code",
337 | "execution_count": null,
338 | "metadata": {},
339 | "outputs": [],
340 | "source": [
341 | "coordinates_subset = coordinates.loc[galactic_sources_subset.oid]\n",
342 | "fig = plt.figure(figsize=(14, 10))\n",
343 | "fig.patch.set_facecolor('white')\n",
344 | "plt.scatter(\n",
345 | " coordinates_subset.values[:, 0],\n",
346 | " coordinates_subset.values[:, 1],\n",
347 | " alpha=0.2,\n",
348 | " s=galactic_sources_subset.probability*100\n",
349 | ")\n",
350 | "plt.xlabel('Galactic latitude [deg]')\n",
351 | "plt.ylabel('Galactic longitude [deg]')\n",
352 | "plt.title('Spatial distribution of predictions: LPV, CEP, YSO')"
353 | ]
354 | },
355 | {
356 | "cell_type": "markdown",
357 | "metadata": {},
358 | "source": [
359 | "### Extragalactic sources (QSO, AGN, Blazar, SNe)"
360 | ]
361 | },
362 | {
363 | "cell_type": "code",
364 | "execution_count": null,
365 | "metadata": {},
366 | "outputs": [],
367 | "source": [
368 | "extragalactic_sources = bhrf_predictions[bhrf_predictions['class_name'].isin(\n",
369 | " ['QSO', 'Blazar', 'SNIa', 'SNII', 'AGN', 'SNIbc', 'SLSN'])]\n",
370 | "extragalactic_sources"
371 | ]
372 | },
373 | {
374 | "cell_type": "code",
375 | "execution_count": null,
376 | "metadata": {},
377 | "outputs": [],
378 | "source": [
379 | "n_per_class = 100 # sample size\n",
380 | "replace = False # with replacement\n",
381 | "fn = lambda obj: obj.loc[np.random.choice(obj.index, n_per_class, replace),:]\n",
382 | "extragalactic_sources_subset = extragalactic_sources.groupby('class_name', as_index=False).apply(fn)\n",
383 | "extragalactic_sources_subset = extragalactic_sources_subset.droplevel(level=0)\n",
384 | "extragalactic_sources_subset"
385 | ]
386 | },
387 | {
388 | "cell_type": "code",
389 | "execution_count": null,
390 | "metadata": {},
391 | "outputs": [],
392 | "source": [
393 | "coordinates_subset = coordinates.loc[extragalactic_sources_subset.oid]\n",
394 | "fig = plt.figure(figsize=(14, 10))\n",
395 | "fig.patch.set_facecolor('white')\n",
396 | "plt.scatter(\n",
397 | " coordinates_subset.values[:, 0],\n",
398 | " coordinates_subset.values[:, 1],\n",
399 | " alpha=0.4,\n",
400 | " s=extragalactic_sources_subset.probability*100\n",
401 | ")\n",
402 | "plt.xlabel('Galactic latitude [deg]')\n",
403 | "plt.ylabel('Galactic longitude [deg]')\n",
404 | "plt.title('Spatial distribution of extragalactic pred. sources')"
405 | ]
406 | },
407 | {
408 | "cell_type": "markdown",
409 | "metadata": {},
410 | "source": [
411 | "## Visualizing a sample of predicted objects"
412 | ]
413 | },
414 | {
415 | "cell_type": "code",
416 | "execution_count": null,
417 | "metadata": {},
418 | "outputs": [],
419 | "source": [
420 | "n_per_class = 1 # sample size\n",
421 | "minimum_probability = 0.3\n",
422 | "replace = False # with replacement\n",
423 | "fn = lambda obj: obj.loc[np.random.choice(obj.index, n_per_class, replace),:]\n",
424 | "filtered_bhrf_predictions = bhrf_predictions[bhrf_predictions.probability >= minimum_probability]\n",
425 | "sample_per_class = filtered_bhrf_predictions.groupby('class_name', as_index=False).apply(fn)\n",
426 | "sample_per_class = sample_per_class.droplevel(level=0)\n",
427 | "sample_per_class"
428 | ]
429 | },
430 | {
431 | "cell_type": "code",
432 | "execution_count": null,
433 | "metadata": {},
434 | "outputs": [],
435 | "source": [
436 | "fig = plt.figure(figsize=(14, 25))\n",
437 | "fig.patch.set_facecolor('white')\n",
438 | "for index in range(len(sample_per_class)):\n",
439 | " astro_class = sample_per_class['class_name'].values[index]\n",
440 | " oid = sample_per_class['oid'].values[index]\n",
441 | " light_curve = alerce_client.query_detections(oid, format='pandas')\n",
442 | " plt.subplot(8, 2, index+1)\n",
443 | " period = None\n",
444 | " if astro_class in ['CEP', 'E', 'DSCT', 'LPV', 'Periodic-Other', 'RRL']:\n",
445 | " query = f\"select oid, name, value from feature where name = 'Multiband_period' and oid = '{oid}';\"\n",
446 | " period_df = pd.read_sql_query(query, conn)\n",
447 | " if len(period_df) > 0:\n",
448 | " period = float(period_df.value.values[0])\n",
449 | " plot_light_curve(light_curve, title=f'{astro_class} candidate {oid}', period=period)\n",
450 | "plt.tight_layout()"
451 | ]
452 | },
453 | {
454 | "cell_type": "code",
455 | "execution_count": null,
456 | "metadata": {},
457 | "outputs": [],
458 | "source": []
459 | }
460 | ],
461 | "metadata": {
462 | "colab": {
463 | "name": "ALeRCE_ZTF_light_curve_classifier_newDB.ipynb",
464 | "provenance": []
465 | },
466 | "kernelspec": {
467 | "display_name": "Python 3 (ipykernel)",
468 | "language": "python",
469 | "name": "python3"
470 | },
471 | "language_info": {
472 | "codemirror_mode": {
473 | "name": "ipython",
474 | "version": 3
475 | },
476 | "file_extension": ".py",
477 | "mimetype": "text/x-python",
478 | "name": "python",
479 | "nbconvert_exporter": "python",
480 | "pygments_lexer": "ipython3",
481 | "version": "3.8.10"
482 | }
483 | },
484 | "nbformat": 4,
485 | "nbformat_minor": 1
486 | }
487 |
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Other_Watchlist.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# Watchlist example notebook\n",
8 | "\n",
9 | "`Author: Francisco Förster, Last update: 20210411`"
10 | ]
11 | },
12 | {
13 | "cell_type": "markdown",
14 | "metadata": {},
15 | "source": [
16 | "Here we will do a xmatch against a list of positions in the sky, given in the file ```watchlist.csv```"
17 | ]
18 | },
19 | {
20 | "cell_type": "code",
21 | "execution_count": 1,
22 | "metadata": {
23 | "ExecuteTime": {
24 | "end_time": "2021-04-11T21:19:05.153813Z",
25 | "start_time": "2021-04-11T21:19:04.813677Z"
26 | }
27 | },
28 | "outputs": [],
29 | "source": [
30 | "import pandas as pd\n",
31 | "import psycopg2\n",
32 | "import requests"
33 | ]
34 | },
35 | {
36 | "cell_type": "markdown",
37 | "metadata": {},
38 | "source": [
39 | "# Get credentials to open a direct connection with the database"
40 | ]
41 | },
42 | {
43 | "cell_type": "code",
44 | "execution_count": 2,
45 | "metadata": {
46 | "ExecuteTime": {
47 | "end_time": "2021-04-11T21:19:05.271345Z",
48 | "start_time": "2021-04-11T21:19:05.155531Z"
49 | }
50 | },
51 | "outputs": [],
52 | "source": [
53 | "credentials_file = \"https://raw.githubusercontent.com/alercebroker/usecases/master/alercereaduser_v4.json\"\n",
54 | "params = requests.get(credentials_file).json()[\"params\"]"
55 | ]
56 | },
57 | {
58 | "cell_type": "code",
59 | "execution_count": 3,
60 | "metadata": {
61 | "ExecuteTime": {
62 | "end_time": "2021-04-11T21:19:06.380633Z",
63 | "start_time": "2021-04-11T21:19:05.279776Z"
64 | }
65 | },
66 | "outputs": [],
67 | "source": [
68 | "conn = psycopg2.connect(dbname=params[\"dbname\"], user=params[\"user\"], host=params[\"host\"], password=params[\"password\"])"
69 | ]
70 | },
71 | {
72 | "cell_type": "markdown",
73 | "metadata": {},
74 | "source": [
75 | "# Get watchlist of object positions"
76 | ]
77 | },
78 | {
79 | "cell_type": "code",
80 | "execution_count": 4,
81 | "metadata": {
82 | "ExecuteTime": {
83 | "end_time": "2021-04-11T21:19:08.246902Z",
84 | "start_time": "2021-04-11T21:19:06.382781Z"
85 | }
86 | },
87 | "outputs": [
88 | {
89 | "data": {
90 | "text/html": [
91 | "\n",
92 | "\n",
105 | "
\n",
106 | " \n",
107 | " \n",
108 | " | \n",
109 | " id_source | \n",
110 | " ra | \n",
111 | " dec | \n",
112 | "
\n",
113 | " \n",
114 | " \n",
115 | " \n",
116 | " 0 | \n",
117 | " source_1 | \n",
118 | " 160.183014 | \n",
119 | " 33.016467 | \n",
120 | "
\n",
121 | " \n",
122 | " 1 | \n",
123 | " source_2 | \n",
124 | " 174.215249 | \n",
125 | " 44.837895 | \n",
126 | "
\n",
127 | " \n",
128 | "
\n",
129 | "
"
130 | ],
131 | "text/plain": [
132 | " id_source ra dec\n",
133 | "0 source_1 160.183014 33.016467\n",
134 | "1 source_2 174.215249 44.837895"
135 | ]
136 | },
137 | "execution_count": 4,
138 | "metadata": {},
139 | "output_type": "execute_result"
140 | }
141 | ],
142 | "source": [
143 | "df = pd.read_csv(\"https://github.com/alercebroker/usecases/blob/master/example_data/watchlist.csv?raw=True\")\n",
144 | "df.head()"
145 | ]
146 | },
147 | {
148 | "cell_type": "markdown",
149 | "metadata": {},
150 | "source": [
151 | "# Prepare the query string for watchlist for object within 1 degress of given positions, and happening within the last 10 days"
152 | ]
153 | },
154 | {
155 | "cell_type": "code",
156 | "execution_count": 5,
157 | "metadata": {
158 | "ExecuteTime": {
159 | "end_time": "2021-04-11T21:19:08.255447Z",
160 | "start_time": "2021-04-11T21:19:08.248711Z"
161 | }
162 | },
163 | "outputs": [
164 | {
165 | "data": {
166 | "text/plain": [
167 | "\"('source_1', 160.18301441363647, 33.0164673528409),\\n('source_2', 174.21524897555543, 44.83789535222221)\""
168 | ]
169 | },
170 | "execution_count": 5,
171 | "metadata": {},
172 | "output_type": "execute_result"
173 | }
174 | ],
175 | "source": [
176 | "objects = []\n",
177 | "for _,row in df.iterrows():\n",
178 | " objects.append(f\"(\\'{row.id_source}\\', {row.ra}, {row.dec})\")\n",
179 | "objects_str = \",\\n\".join(objects)\n",
180 | "objects_str"
181 | ]
182 | },
183 | {
184 | "cell_type": "markdown",
185 | "metadata": {
186 | "ExecuteTime": {
187 | "end_time": "2021-04-02T17:36:00.076713Z",
188 | "start_time": "2021-04-02T17:36:00.067559Z"
189 | }
190 | },
191 | "source": [
192 | "Create query string"
193 | ]
194 | },
195 | {
196 | "cell_type": "code",
197 | "execution_count": 6,
198 | "metadata": {
199 | "ExecuteTime": {
200 | "end_time": "2021-04-11T21:19:08.759189Z",
201 | "start_time": "2021-04-11T21:19:08.257235Z"
202 | }
203 | },
204 | "outputs": [],
205 | "source": [
206 | "from astropy.time import Time\n",
207 | "nt = Time.now()\n",
208 | "last_mjd_discovery = nt.mjd - 10"
209 | ]
210 | },
211 | {
212 | "cell_type": "code",
213 | "execution_count": 7,
214 | "metadata": {
215 | "ExecuteTime": {
216 | "end_time": "2021-04-11T21:19:08.763613Z",
217 | "start_time": "2021-04-11T21:19:08.760570Z"
218 | }
219 | },
220 | "outputs": [],
221 | "source": [
222 | "search_radius = 1 # degrees\n",
223 | "query = \"\"\"\n",
224 | "WITH catalog ( source_id, ra, dec) AS (\n",
225 | " VALUES\n",
226 | " {values}\n",
227 | ")\n",
228 | "SELECT \n",
229 | " c.source_id, c.ra, c.dec, o.oid, o.meanra, o.meandec, q3c_dist(c.ra,c.dec,o.meanra,o.meandec), \n",
230 | " o.firstmjd\n",
231 | "\n",
232 | "FROM object o, catalog c\n",
233 | " /*\n",
234 | " * It is REALLY important to first use the catalog then the object ra,dec for speed. The radius is in degrees.\n",
235 | " */\n",
236 | "WHERE\n",
237 | " q3c_join(c.ra, c.dec,o.meanra, o.meandec, {radius})\n",
238 | " AND o.firstmjd > %s\n",
239 | "\"\"\" % (last_mjd_discovery)\n",
240 | "query_str = query.format(values = objects_str, radius = search_radius) # radius in degrees"
241 | ]
242 | },
243 | {
244 | "cell_type": "code",
245 | "execution_count": 8,
246 | "metadata": {
247 | "ExecuteTime": {
248 | "end_time": "2021-04-11T21:19:10.736640Z",
249 | "start_time": "2021-04-11T21:19:08.765726Z"
250 | }
251 | },
252 | "outputs": [
253 | {
254 | "name": "stdout",
255 | "output_type": "stream",
256 | "text": [
257 | "(235, 8)\n"
258 | ]
259 | },
260 | {
261 | "data": {
262 | "text/html": [
263 | "\n",
264 | "\n",
277 | "
\n",
278 | " \n",
279 | " \n",
280 | " | \n",
281 | " source_id | \n",
282 | " ra | \n",
283 | " dec | \n",
284 | " oid | \n",
285 | " meanra | \n",
286 | " meandec | \n",
287 | " q3c_dist | \n",
288 | " firstmjd | \n",
289 | "
\n",
290 | " \n",
291 | " \n",
292 | " \n",
293 | " 0 | \n",
294 | " source_1 | \n",
295 | " 160.183014 | \n",
296 | " 33.016467 | \n",
297 | " ZTF21aarnexs | \n",
298 | " 160.062296 | \n",
299 | " 33.670591 | \n",
300 | " 0.661852 | \n",
301 | " 59306.251771 | \n",
302 | "
\n",
303 | " \n",
304 | " 1 | \n",
305 | " source_1 | \n",
306 | " 160.183014 | \n",
307 | " 33.016467 | \n",
308 | " ZTF21aarnfde | \n",
309 | " 159.650987 | \n",
310 | " 32.392743 | \n",
311 | " 0.767755 | \n",
312 | " 59306.251771 | \n",
313 | "
\n",
314 | " \n",
315 | " 2 | \n",
316 | " source_1 | \n",
317 | " 160.183014 | \n",
318 | " 33.016467 | \n",
319 | " ZTF21aarnfdl | \n",
320 | " 160.053760 | \n",
321 | " 33.204848 | \n",
322 | " 0.217276 | \n",
323 | " 59306.251771 | \n",
324 | "
\n",
325 | " \n",
326 | " 3 | \n",
327 | " source_1 | \n",
328 | " 160.183014 | \n",
329 | " 33.016467 | \n",
330 | " ZTF21aarnfdp | \n",
331 | " 160.960105 | \n",
332 | " 33.015154 | \n",
333 | " 0.651606 | \n",
334 | " 59306.251771 | \n",
335 | "
\n",
336 | " \n",
337 | " 4 | \n",
338 | " source_1 | \n",
339 | " 160.183014 | \n",
340 | " 33.016467 | \n",
341 | " ZTF21aarnfdj | \n",
342 | " 159.557127 | \n",
343 | " 32.924597 | \n",
344 | " 0.533065 | \n",
345 | " 59306.251771 | \n",
346 | "
\n",
347 | " \n",
348 | " ... | \n",
349 | " ... | \n",
350 | " ... | \n",
351 | " ... | \n",
352 | " ... | \n",
353 | " ... | \n",
354 | " ... | \n",
355 | " ... | \n",
356 | " ... | \n",
357 | "
\n",
358 | " \n",
359 | " 230 | \n",
360 | " source_2 | \n",
361 | " 174.215249 | \n",
362 | " 44.837895 | \n",
363 | " ZTF21aauhmmw | \n",
364 | " 174.132976 | \n",
365 | " 44.515377 | \n",
366 | " 0.327782 | \n",
367 | " 59315.238819 | \n",
368 | "
\n",
369 | " \n",
370 | " 231 | \n",
371 | " source_2 | \n",
372 | " 174.215249 | \n",
373 | " 44.837895 | \n",
374 | " ZTF21aauhmrg | \n",
375 | " 173.903485 | \n",
376 | " 45.697832 | \n",
377 | " 0.887486 | \n",
378 | " 59315.238819 | \n",
379 | "
\n",
380 | " \n",
381 | " 232 | \n",
382 | " source_2 | \n",
383 | " 174.215249 | \n",
384 | " 44.837895 | \n",
385 | " ZTF21aauhprj | \n",
386 | " 174.667906 | \n",
387 | " 44.081964 | \n",
388 | " 0.822074 | \n",
389 | " 59315.239282 | \n",
390 | "
\n",
391 | " \n",
392 | " 233 | \n",
393 | " source_2 | \n",
394 | " 174.215249 | \n",
395 | " 44.837895 | \n",
396 | " ZTF21aauhpri | \n",
397 | " 174.260736 | \n",
398 | " 44.197326 | \n",
399 | " 0.641390 | \n",
400 | " 59315.239282 | \n",
401 | "
\n",
402 | " \n",
403 | " 234 | \n",
404 | " source_2 | \n",
405 | " 174.215249 | \n",
406 | " 44.837895 | \n",
407 | " ZTF21aauhprk | \n",
408 | " 174.005997 | \n",
409 | " 43.924748 | \n",
410 | " 0.925312 | \n",
411 | " 59315.239282 | \n",
412 | "
\n",
413 | " \n",
414 | "
\n",
415 | "
235 rows × 8 columns
\n",
416 | "
"
417 | ],
418 | "text/plain": [
419 | " source_id ra dec oid meanra meandec \\\n",
420 | "0 source_1 160.183014 33.016467 ZTF21aarnexs 160.062296 33.670591 \n",
421 | "1 source_1 160.183014 33.016467 ZTF21aarnfde 159.650987 32.392743 \n",
422 | "2 source_1 160.183014 33.016467 ZTF21aarnfdl 160.053760 33.204848 \n",
423 | "3 source_1 160.183014 33.016467 ZTF21aarnfdp 160.960105 33.015154 \n",
424 | "4 source_1 160.183014 33.016467 ZTF21aarnfdj 159.557127 32.924597 \n",
425 | ".. ... ... ... ... ... ... \n",
426 | "230 source_2 174.215249 44.837895 ZTF21aauhmmw 174.132976 44.515377 \n",
427 | "231 source_2 174.215249 44.837895 ZTF21aauhmrg 173.903485 45.697832 \n",
428 | "232 source_2 174.215249 44.837895 ZTF21aauhprj 174.667906 44.081964 \n",
429 | "233 source_2 174.215249 44.837895 ZTF21aauhpri 174.260736 44.197326 \n",
430 | "234 source_2 174.215249 44.837895 ZTF21aauhprk 174.005997 43.924748 \n",
431 | "\n",
432 | " q3c_dist firstmjd \n",
433 | "0 0.661852 59306.251771 \n",
434 | "1 0.767755 59306.251771 \n",
435 | "2 0.217276 59306.251771 \n",
436 | "3 0.651606 59306.251771 \n",
437 | "4 0.533065 59306.251771 \n",
438 | ".. ... ... \n",
439 | "230 0.327782 59315.238819 \n",
440 | "231 0.887486 59315.238819 \n",
441 | "232 0.822074 59315.239282 \n",
442 | "233 0.641390 59315.239282 \n",
443 | "234 0.925312 59315.239282 \n",
444 | "\n",
445 | "[235 rows x 8 columns]"
446 | ]
447 | },
448 | "execution_count": 8,
449 | "metadata": {},
450 | "output_type": "execute_result"
451 | }
452 | ],
453 | "source": [
454 | "matches = pd.read_sql(query_str,conn)\n",
455 | "print(matches.shape)\n",
456 | "matches"
457 | ]
458 | },
459 | {
460 | "cell_type": "markdown",
461 | "metadata": {},
462 | "source": [
463 | "# Query objects within 10 degress of given positions, first detected within the last 10 days, with SN probabilities > 0.4, and ranking=1 in the stamp classifier"
464 | ]
465 | },
466 | {
467 | "cell_type": "code",
468 | "execution_count": 9,
469 | "metadata": {
470 | "ExecuteTime": {
471 | "end_time": "2021-04-11T21:19:10.741996Z",
472 | "start_time": "2021-04-11T21:19:10.738665Z"
473 | }
474 | },
475 | "outputs": [],
476 | "source": [
477 | "search_radius = 10 # degrees\n",
478 | "query = \"\"\"\n",
479 | "WITH catalog ( source_id, ra, dec) AS (\n",
480 | " VALUES\n",
481 | " {values}\n",
482 | "),\n",
483 | "sn (oid, classifier_name, class_name, probability, ranking) AS (\n",
484 | " SELECT\n",
485 | " o.oid, p.classifier_name, p.class_name, p.probability, p.ranking\n",
486 | " FROM\n",
487 | " probability p\n",
488 | " INNER JOIN \n",
489 | " object o\n",
490 | " ON \n",
491 | " o.oid=p.oid\n",
492 | " WHERE\n",
493 | " p.classifier_name='stamp_classifier'\n",
494 | " AND p.class_name IN ('SN')\n",
495 | " AND p.ranking=1\n",
496 | " AND p.probability > 0.4\n",
497 | " AND o.firstmjd > {last_mjd_discovery}\n",
498 | ")\n",
499 | "\n",
500 | "SELECT \n",
501 | " c.source_id, c.ra, c.dec, o.oid, o.meanra, o.meandec, q3c_dist(c.ra,c.dec,o.meanra,o.meandec), \n",
502 | " o.firstmjd, sn.classifier_name, sn.class_name, sn.probability, sn.ranking\n",
503 | "\n",
504 | "FROM object o INNER JOIN sn ON sn.oid=o.oid, catalog c\n",
505 | " /*\n",
506 | " * It is REALLY important to first use the catalog then the object ra,dec for speed. The radius is in degrees.\n",
507 | " */\n",
508 | "WHERE\n",
509 | " q3c_join(c.ra, c.dec,o.meanra, o.meandec, {radius})\n",
510 | " AND o.firstmjd > {last_mjd_discovery}\n",
511 | "ORDER BY\n",
512 | " c.source_id\n",
513 | "\"\"\"\n",
514 | "query_str = query.format(values = objects_str, radius = search_radius, last_mjd_discovery=last_mjd_discovery) # radius in degrees"
515 | ]
516 | },
517 | {
518 | "cell_type": "code",
519 | "execution_count": 10,
520 | "metadata": {
521 | "ExecuteTime": {
522 | "end_time": "2021-04-11T21:19:18.998801Z",
523 | "start_time": "2021-04-11T21:19:10.743634Z"
524 | }
525 | },
526 | "outputs": [
527 | {
528 | "name": "stdout",
529 | "output_type": "stream",
530 | "text": [
531 | "(23, 12)\n"
532 | ]
533 | },
534 | {
535 | "data": {
536 | "text/html": [
537 | "\n",
538 | "\n",
551 | "
\n",
552 | " \n",
553 | " \n",
554 | " | \n",
555 | " source_id | \n",
556 | " ra | \n",
557 | " dec | \n",
558 | " oid | \n",
559 | " meanra | \n",
560 | " meandec | \n",
561 | " q3c_dist | \n",
562 | " firstmjd | \n",
563 | " classifier_name | \n",
564 | " class_name | \n",
565 | " probability | \n",
566 | " ranking | \n",
567 | "
\n",
568 | " \n",
569 | " \n",
570 | " \n",
571 | " 0 | \n",
572 | " source_1 | \n",
573 | " 160.183014 | \n",
574 | " 33.016467 | \n",
575 | " ZTF21aasvhwh | \n",
576 | " 166.770659 | \n",
577 | " 32.800088 | \n",
578 | " 5.533925 | \n",
579 | " 59306.372836 | \n",
580 | " stamp_classifier | \n",
581 | " SN | \n",
582 | " 0.707814 | \n",
583 | " 1 | \n",
584 | "
\n",
585 | " \n",
586 | " 1 | \n",
587 | " source_1 | \n",
588 | " 160.183014 | \n",
589 | " 33.016467 | \n",
590 | " ZTF21aasuggn | \n",
591 | " 166.212813 | \n",
592 | " 31.622934 | \n",
593 | " 5.281848 | \n",
594 | " 59308.227685 | \n",
595 | " stamp_classifier | \n",
596 | " SN | \n",
597 | " 0.430196 | \n",
598 | " 1 | \n",
599 | "
\n",
600 | " \n",
601 | " 2 | \n",
602 | " source_1 | \n",
603 | " 160.183014 | \n",
604 | " 33.016467 | \n",
605 | " ZTF21aastzsn | \n",
606 | " 148.786835 | \n",
607 | " 35.379685 | \n",
608 | " 9.711189 | \n",
609 | " 59310.249132 | \n",
610 | " stamp_classifier | \n",
611 | " SN | \n",
612 | " 0.793107 | \n",
613 | " 1 | \n",
614 | "
\n",
615 | " \n",
616 | " 3 | \n",
617 | " source_1 | \n",
618 | " 160.183014 | \n",
619 | " 33.016467 | \n",
620 | " ZTF21aappwvm | \n",
621 | " 165.757943 | \n",
622 | " 31.974741 | \n",
623 | " 4.815426 | \n",
624 | " 59308.227685 | \n",
625 | " stamp_classifier | \n",
626 | " SN | \n",
627 | " 0.661527 | \n",
628 | " 1 | \n",
629 | "
\n",
630 | " \n",
631 | " 4 | \n",
632 | " source_1 | \n",
633 | " 160.183014 | \n",
634 | " 33.016467 | \n",
635 | " ZTF21aatuynj | \n",
636 | " 154.108685 | \n",
637 | " 24.817833 | \n",
638 | " 9.766739 | \n",
639 | " 59312.234653 | \n",
640 | " stamp_classifier | \n",
641 | " SN | \n",
642 | " 0.816249 | \n",
643 | " 1 | \n",
644 | "
\n",
645 | " \n",
646 | " 5 | \n",
647 | " source_1 | \n",
648 | " 160.183014 | \n",
649 | " 33.016467 | \n",
650 | " ZTF21aasuhnu | \n",
651 | " 160.418486 | \n",
652 | " 26.539921 | \n",
653 | " 6.479763 | \n",
654 | " 59308.269213 | \n",
655 | " stamp_classifier | \n",
656 | " SN | \n",
657 | " 0.754478 | \n",
658 | " 1 | \n",
659 | "
\n",
660 | " \n",
661 | " 6 | \n",
662 | " source_1 | \n",
663 | " 160.183014 | \n",
664 | " 33.016467 | \n",
665 | " ZTF21aalwdzx | \n",
666 | " 151.070306 | \n",
667 | " 38.973164 | \n",
668 | " 9.469663 | \n",
669 | " 59314.267894 | \n",
670 | " stamp_classifier | \n",
671 | " SN | \n",
672 | " 0.412541 | \n",
673 | " 1 | \n",
674 | "
\n",
675 | " \n",
676 | " 7 | \n",
677 | " source_1 | \n",
678 | " 160.183014 | \n",
679 | " 33.016467 | \n",
680 | " ZTF21aatxuyp | \n",
681 | " 157.572440 | \n",
682 | " 37.975224 | \n",
683 | " 5.394375 | \n",
684 | " 59314.277234 | \n",
685 | " stamp_classifier | \n",
686 | " SN | \n",
687 | " 0.771551 | \n",
688 | " 1 | \n",
689 | "
\n",
690 | " \n",
691 | " 8 | \n",
692 | " source_1 | \n",
693 | " 160.183014 | \n",
694 | " 33.016467 | \n",
695 | " ZTF21aardzlu | \n",
696 | " 155.949496 | \n",
697 | " 42.275894 | \n",
698 | " 9.843950 | \n",
699 | " 59306.248542 | \n",
700 | " stamp_classifier | \n",
701 | " SN | \n",
702 | " 0.651708 | \n",
703 | " 1 | \n",
704 | "
\n",
705 | " \n",
706 | " 9 | \n",
707 | " source_1 | \n",
708 | " 160.183014 | \n",
709 | " 33.016467 | \n",
710 | " ZTF21aaroydq | \n",
711 | " 163.573451 | \n",
712 | " 34.238847 | \n",
713 | " 3.076112 | \n",
714 | " 59306.304271 | \n",
715 | " stamp_classifier | \n",
716 | " SN | \n",
717 | " 0.524896 | \n",
718 | " 1 | \n",
719 | "
\n",
720 | " \n",
721 | " 10 | \n",
722 | " source_1 | \n",
723 | " 160.183014 | \n",
724 | " 33.016467 | \n",
725 | " ZTF21aardzpu | \n",
726 | " 158.150706 | \n",
727 | " 38.960262 | \n",
728 | " 6.166557 | \n",
729 | " 59308.225984 | \n",
730 | " stamp_classifier | \n",
731 | " SN | \n",
732 | " 0.435725 | \n",
733 | " 1 | \n",
734 | "
\n",
735 | " \n",
736 | " 11 | \n",
737 | " source_1 | \n",
738 | " 160.183014 | \n",
739 | " 33.016467 | \n",
740 | " ZTF21aarowtc | \n",
741 | " 161.390183 | \n",
742 | " 39.823360 | \n",
743 | " 6.875642 | \n",
744 | " 59306.248542 | \n",
745 | " stamp_classifier | \n",
746 | " SN | \n",
747 | " 0.570181 | \n",
748 | " 1 | \n",
749 | "
\n",
750 | " \n",
751 | " 12 | \n",
752 | " source_1 | \n",
753 | " 160.183014 | \n",
754 | " 33.016467 | \n",
755 | " ZTF21aarnbox | \n",
756 | " 154.133940 | \n",
757 | " 39.014253 | \n",
758 | " 7.736225 | \n",
759 | " 59306.303229 | \n",
760 | " stamp_classifier | \n",
761 | " SN | \n",
762 | " 0.431122 | \n",
763 | " 1 | \n",
764 | "
\n",
765 | " \n",
766 | " 13 | \n",
767 | " source_1 | \n",
768 | " 160.183014 | \n",
769 | " 33.016467 | \n",
770 | " ZTF21aasgnqa | \n",
771 | " 150.838518 | \n",
772 | " 38.408163 | \n",
773 | " 9.299792 | \n",
774 | " 59308.264919 | \n",
775 | " stamp_classifier | \n",
776 | " SN | \n",
777 | " 0.471552 | \n",
778 | " 1 | \n",
779 | "
\n",
780 | " \n",
781 | " 14 | \n",
782 | " source_2 | \n",
783 | " 174.215249 | \n",
784 | " 44.837895 | \n",
785 | " ZTF21aarohyu | \n",
786 | " 180.167057 | \n",
787 | " 51.840932 | \n",
788 | " 8.036995 | \n",
789 | " 59307.262998 | \n",
790 | " stamp_classifier | \n",
791 | " SN | \n",
792 | " 0.836388 | \n",
793 | " 1 | \n",
794 | "
\n",
795 | " \n",
796 | " 15 | \n",
797 | " source_2 | \n",
798 | " 174.215249 | \n",
799 | " 44.837895 | \n",
800 | " ZTF21aarwlht | \n",
801 | " 163.528353 | \n",
802 | " 45.612058 | \n",
803 | " 7.561045 | \n",
804 | " 59307.238032 | \n",
805 | " stamp_classifier | \n",
806 | " SN | \n",
807 | " 0.677232 | \n",
808 | " 1 | \n",
809 | "
\n",
810 | " \n",
811 | " 16 | \n",
812 | " source_2 | \n",
813 | " 174.215249 | \n",
814 | " 44.837895 | \n",
815 | " ZTF21aatwunv | \n",
816 | " 175.477111 | \n",
817 | " 35.881612 | \n",
818 | " 9.007417 | \n",
819 | " 59315.197338 | \n",
820 | " stamp_classifier | \n",
821 | " SN | \n",
822 | " 0.489751 | \n",
823 | " 1 | \n",
824 | "
\n",
825 | " \n",
826 | " 17 | \n",
827 | " source_2 | \n",
828 | " 174.215249 | \n",
829 | " 44.837895 | \n",
830 | " ZTF21aarxsfm | \n",
831 | " 174.668285 | \n",
832 | " 41.758295 | \n",
833 | " 3.097186 | \n",
834 | " 59307.261493 | \n",
835 | " stamp_classifier | \n",
836 | " SN | \n",
837 | " 0.878125 | \n",
838 | " 1 | \n",
839 | "
\n",
840 | " \n",
841 | " 18 | \n",
842 | " source_2 | \n",
843 | " 174.215249 | \n",
844 | " 44.837895 | \n",
845 | " ZTF21aarovmb | \n",
846 | " 170.254855 | \n",
847 | " 53.174650 | \n",
848 | " 8.728681 | \n",
849 | " 59306.298993 | \n",
850 | " stamp_classifier | \n",
851 | " SN | \n",
852 | " 0.461672 | \n",
853 | " 1 | \n",
854 | "
\n",
855 | " \n",
856 | " 19 | \n",
857 | " source_2 | \n",
858 | " 174.215249 | \n",
859 | " 44.837895 | \n",
860 | " ZTF21aardszu | \n",
861 | " 175.154267 | \n",
862 | " 36.669955 | \n",
863 | " 8.198687 | \n",
864 | " 59307.233808 | \n",
865 | " stamp_classifier | \n",
866 | " SN | \n",
867 | " 0.697391 | \n",
868 | " 1 | \n",
869 | "
\n",
870 | " \n",
871 | " 20 | \n",
872 | " source_2 | \n",
873 | " 174.215249 | \n",
874 | " 44.837895 | \n",
875 | " ZTF21aasyydo | \n",
876 | " 174.845187 | \n",
877 | " 42.118591 | \n",
878 | " 2.757429 | \n",
879 | " 59311.175648 | \n",
880 | " stamp_classifier | \n",
881 | " SN | \n",
882 | " 0.717340 | \n",
883 | " 1 | \n",
884 | "
\n",
885 | " \n",
886 | " 21 | \n",
887 | " source_2 | \n",
888 | " 174.215249 | \n",
889 | " 44.837895 | \n",
890 | " ZTF21aaszaoy | \n",
891 | " 176.276831 | \n",
892 | " 53.616035 | \n",
893 | " 8.879774 | \n",
894 | " 59311.179491 | \n",
895 | " stamp_classifier | \n",
896 | " SN | \n",
897 | " 0.484196 | \n",
898 | " 1 | \n",
899 | "
\n",
900 | " \n",
901 | " 22 | \n",
902 | " source_2 | \n",
903 | " 174.215249 | \n",
904 | " 44.837895 | \n",
905 | " ZTF21aarxuih | \n",
906 | " 182.877322 | \n",
907 | " 41.887535 | \n",
908 | " 6.949494 | \n",
909 | " 59307.235220 | \n",
910 | " stamp_classifier | \n",
911 | " SN | \n",
912 | " 0.572513 | \n",
913 | " 1 | \n",
914 | "
\n",
915 | " \n",
916 | "
\n",
917 | "
"
918 | ],
919 | "text/plain": [
920 | " source_id ra dec oid meanra meandec \\\n",
921 | "0 source_1 160.183014 33.016467 ZTF21aasvhwh 166.770659 32.800088 \n",
922 | "1 source_1 160.183014 33.016467 ZTF21aasuggn 166.212813 31.622934 \n",
923 | "2 source_1 160.183014 33.016467 ZTF21aastzsn 148.786835 35.379685 \n",
924 | "3 source_1 160.183014 33.016467 ZTF21aappwvm 165.757943 31.974741 \n",
925 | "4 source_1 160.183014 33.016467 ZTF21aatuynj 154.108685 24.817833 \n",
926 | "5 source_1 160.183014 33.016467 ZTF21aasuhnu 160.418486 26.539921 \n",
927 | "6 source_1 160.183014 33.016467 ZTF21aalwdzx 151.070306 38.973164 \n",
928 | "7 source_1 160.183014 33.016467 ZTF21aatxuyp 157.572440 37.975224 \n",
929 | "8 source_1 160.183014 33.016467 ZTF21aardzlu 155.949496 42.275894 \n",
930 | "9 source_1 160.183014 33.016467 ZTF21aaroydq 163.573451 34.238847 \n",
931 | "10 source_1 160.183014 33.016467 ZTF21aardzpu 158.150706 38.960262 \n",
932 | "11 source_1 160.183014 33.016467 ZTF21aarowtc 161.390183 39.823360 \n",
933 | "12 source_1 160.183014 33.016467 ZTF21aarnbox 154.133940 39.014253 \n",
934 | "13 source_1 160.183014 33.016467 ZTF21aasgnqa 150.838518 38.408163 \n",
935 | "14 source_2 174.215249 44.837895 ZTF21aarohyu 180.167057 51.840932 \n",
936 | "15 source_2 174.215249 44.837895 ZTF21aarwlht 163.528353 45.612058 \n",
937 | "16 source_2 174.215249 44.837895 ZTF21aatwunv 175.477111 35.881612 \n",
938 | "17 source_2 174.215249 44.837895 ZTF21aarxsfm 174.668285 41.758295 \n",
939 | "18 source_2 174.215249 44.837895 ZTF21aarovmb 170.254855 53.174650 \n",
940 | "19 source_2 174.215249 44.837895 ZTF21aardszu 175.154267 36.669955 \n",
941 | "20 source_2 174.215249 44.837895 ZTF21aasyydo 174.845187 42.118591 \n",
942 | "21 source_2 174.215249 44.837895 ZTF21aaszaoy 176.276831 53.616035 \n",
943 | "22 source_2 174.215249 44.837895 ZTF21aarxuih 182.877322 41.887535 \n",
944 | "\n",
945 | " q3c_dist firstmjd classifier_name class_name probability ranking \n",
946 | "0 5.533925 59306.372836 stamp_classifier SN 0.707814 1 \n",
947 | "1 5.281848 59308.227685 stamp_classifier SN 0.430196 1 \n",
948 | "2 9.711189 59310.249132 stamp_classifier SN 0.793107 1 \n",
949 | "3 4.815426 59308.227685 stamp_classifier SN 0.661527 1 \n",
950 | "4 9.766739 59312.234653 stamp_classifier SN 0.816249 1 \n",
951 | "5 6.479763 59308.269213 stamp_classifier SN 0.754478 1 \n",
952 | "6 9.469663 59314.267894 stamp_classifier SN 0.412541 1 \n",
953 | "7 5.394375 59314.277234 stamp_classifier SN 0.771551 1 \n",
954 | "8 9.843950 59306.248542 stamp_classifier SN 0.651708 1 \n",
955 | "9 3.076112 59306.304271 stamp_classifier SN 0.524896 1 \n",
956 | "10 6.166557 59308.225984 stamp_classifier SN 0.435725 1 \n",
957 | "11 6.875642 59306.248542 stamp_classifier SN 0.570181 1 \n",
958 | "12 7.736225 59306.303229 stamp_classifier SN 0.431122 1 \n",
959 | "13 9.299792 59308.264919 stamp_classifier SN 0.471552 1 \n",
960 | "14 8.036995 59307.262998 stamp_classifier SN 0.836388 1 \n",
961 | "15 7.561045 59307.238032 stamp_classifier SN 0.677232 1 \n",
962 | "16 9.007417 59315.197338 stamp_classifier SN 0.489751 1 \n",
963 | "17 3.097186 59307.261493 stamp_classifier SN 0.878125 1 \n",
964 | "18 8.728681 59306.298993 stamp_classifier SN 0.461672 1 \n",
965 | "19 8.198687 59307.233808 stamp_classifier SN 0.697391 1 \n",
966 | "20 2.757429 59311.175648 stamp_classifier SN 0.717340 1 \n",
967 | "21 8.879774 59311.179491 stamp_classifier SN 0.484196 1 \n",
968 | "22 6.949494 59307.235220 stamp_classifier SN 0.572513 1 "
969 | ]
970 | },
971 | "execution_count": 10,
972 | "metadata": {},
973 | "output_type": "execute_result"
974 | }
975 | ],
976 | "source": [
977 | "matches = pd.read_sql(query_str,conn)\n",
978 | "print(matches.shape)\n",
979 | "matches.head(100)"
980 | ]
981 | },
982 | {
983 | "cell_type": "markdown",
984 | "metadata": {},
985 | "source": [
986 | "Close the connection"
987 | ]
988 | },
989 | {
990 | "cell_type": "code",
991 | "execution_count": 11,
992 | "metadata": {
993 | "ExecuteTime": {
994 | "end_time": "2021-04-11T21:19:19.003542Z",
995 | "start_time": "2021-04-11T21:19:19.000766Z"
996 | }
997 | },
998 | "outputs": [],
999 | "source": [
1000 | "conn.close()"
1001 | ]
1002 | },
1003 | {
1004 | "cell_type": "markdown",
1005 | "metadata": {},
1006 | "source": [
1007 | "# Open the resulting objects in the ALeRCE explorer"
1008 | ]
1009 | },
1010 | {
1011 | "cell_type": "code",
1012 | "execution_count": 12,
1013 | "metadata": {
1014 | "ExecuteTime": {
1015 | "end_time": "2021-04-11T21:19:19.016548Z",
1016 | "start_time": "2021-04-11T21:19:19.005683Z"
1017 | }
1018 | },
1019 | "outputs": [
1020 | {
1021 | "name": "stdout",
1022 | "output_type": "stream",
1023 | "text": [
1024 | "https://alerce.online/?oid=ZTF21aasvhwh&oid=ZTF21aasuggn&oid=ZTF21aastzsn&oid=ZTF21aappwvm&oid=ZTF21aatuynj&oid=ZTF21aasuhnu&oid=ZTF21aalwdzx&oid=ZTF21aatxuyp&oid=ZTF21aardzlu&oid=ZTF21aaroydq&oid=ZTF21aardzpu&oid=ZTF21aarowtc&oid=ZTF21aarnbox&oid=ZTF21aasgnqa&oid=ZTF21aarohyu&oid=ZTF21aarwlht&oid=ZTF21aatwunv&oid=ZTF21aarxsfm&oid=ZTF21aarovmb&oid=ZTF21aardszu&oid=ZTF21aasyydo&oid=ZTF21aaszaoy&oid=ZTF21aarxuih&count=true&page=1&perPage=1000&sortDesc=false\n"
1025 | ]
1026 | }
1027 | ],
1028 | "source": [
1029 | "url = \"https://alerce.online/?\" + \"&\".join([\"oid=%s\" % oid for oid in matches.oid.values]) + \"&count=true&page=1&perPage=1000&sortDesc=false\"\n",
1030 | "print(url)"
1031 | ]
1032 | },
1033 | {
1034 | "cell_type": "code",
1035 | "execution_count": null,
1036 | "metadata": {},
1037 | "outputs": [],
1038 | "source": []
1039 | }
1040 | ],
1041 | "metadata": {
1042 | "kernelspec": {
1043 | "display_name": "Python 3",
1044 | "language": "python",
1045 | "name": "python3"
1046 | },
1047 | "language_info": {
1048 | "codemirror_mode": {
1049 | "name": "ipython",
1050 | "version": 3
1051 | },
1052 | "file_extension": ".py",
1053 | "mimetype": "text/x-python",
1054 | "name": "python",
1055 | "nbconvert_exporter": "python",
1056 | "pygments_lexer": "ipython3",
1057 | "version": "3.6.5"
1058 | },
1059 | "toc": {
1060 | "base_numbering": 1,
1061 | "nav_menu": {},
1062 | "number_sections": true,
1063 | "sideBar": true,
1064 | "skip_h1_title": false,
1065 | "title_cell": "Table of Contents",
1066 | "title_sidebar": "Contents",
1067 | "toc_cell": false,
1068 | "toc_position": {},
1069 | "toc_section_display": true,
1070 | "toc_window_display": true
1071 | }
1072 | },
1073 | "nbformat": 4,
1074 | "nbformat_minor": 4
1075 | }
1076 |
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/ALeRCE_Hands_On_Tutorial_newDB_collab.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {
6 | "colab_type": "text",
7 | "id": "aARiWZB804Yh"
8 | },
9 | "source": [
10 | "# ALeRCE Hands On Tutorial\n",
11 | "\n",
12 | "In this tutorial we will put in practice what we have learned in this workshop. The idea is that you try to use the tools we provide and adapt them to your specific science workflow.\n",
13 | "\n",
14 | "As a way to test your knowledge using ALeRCE's services we ask you to complete **3 challenges**.\n",
15 | "\n",
16 | "\n",
17 | "1. Plot lightcurve using *alerce* client\n",
18 | "2. Plot any combination of attributes from any table\n",
19 | "3. Download a dataframe as CSV and open it again with pandas"
20 | ]
21 | },
22 | {
23 | "cell_type": "markdown",
24 | "metadata": {
25 | "colab_type": "text",
26 | "id": "o48zzNVY0zo8"
27 | },
28 | "source": [
29 | "We are going to be using the alerce client so first we need to install it"
30 | ]
31 | },
32 | {
33 | "cell_type": "code",
34 | "execution_count": null,
35 | "metadata": {
36 | "colab": null,
37 | "colab_type": "code",
38 | "id": "cDYh15Vin1vZ"
39 | },
40 | "outputs": [],
41 | "source": [
42 | "!pip install git+https://git@github.com/alercebroker/alerce_client_new#alerce"
43 | ]
44 | },
45 | {
46 | "cell_type": "markdown",
47 | "metadata": {
48 | "colab_type": "text",
49 | "id": "KQd1JdMUtrZy"
50 | },
51 | "source": [
52 | "# First Challenge: Plot a light curve using the ALeRCE client"
53 | ]
54 | },
55 | {
56 | "cell_type": "markdown",
57 | "metadata": {
58 | "colab_type": "text",
59 | "id": "YGWC0LfSt8HX"
60 | },
61 | "source": [
62 | "# Second Challenge: Query a list of objects and plot some attributes"
63 | ]
64 | },
65 | {
66 | "cell_type": "markdown",
67 | "metadata": {
68 | "colab_type": "text",
69 | "id": "T_H86iLMzpKp"
70 | },
71 | "source": [
72 | "# Third Challenge: Save and download data using pandas"
73 | ]
74 | },
75 | {
76 | "cell_type": "markdown",
77 | "metadata": {
78 | "colab_type": "text",
79 | "id": "JTCG_nynIZSz"
80 | },
81 | "source": [
82 | "**Congratulations, you completed the challenge!**\n",
83 | "\n",
84 | "---\n",
85 | "\n"
86 | ]
87 | }
88 | ],
89 | "metadata": {
90 | "colab": {
91 | "collapsed_sections": null,
92 | "name": "ALeRCE_Hands_On_Tutorial_newDB_collab.ipynb",
93 | "provenance": null
94 | },
95 | "kernelspec": {
96 | "display_name": "Python 3",
97 | "language": "python",
98 | "name": "python3"
99 | },
100 | "language_info": {
101 | "codemirror_mode": {
102 | "name": "ipython",
103 | "version": 3
104 | },
105 | "file_extension": ".py",
106 | "mimetype": "text/x-python",
107 | "name": "python",
108 | "nbconvert_exporter": "python",
109 | "pygments_lexer": "ipython3",
110 | "version": "3.8.5"
111 | },
112 | "name": "ALeRCE_Hands_On_Tutorial_newDB_collab.ipynb"
113 | },
114 | "nbformat": 4,
115 | "nbformat_minor": 1
116 | }
117 |
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/README.md:
--------------------------------------------------------------------------------
1 | # ALeRCE Tutorial Workshop - 23,24 September 2020
2 |
3 | This was a two-day workshop with the aim of learning how to use the tools by the ALeRCE broker, as well as to learn to code a notebook focused on your own science case.
4 |
5 | Details on the workshop, the schedule and access to the slides can be found at:
6 |
7 | http://workshops.alerce.online/alerce-broker-tutorial/
8 |
9 | The talks were recorded and are available in Youtube:
10 |
11 | [https://www.youtube.com/playlist?list=PLFA428AMRhwAfmfgEc4MP8m4PiNeqbxZv](https://www.youtube.com/playlist?list=PLFA428AMRhwAfmfgEc4MP8m4PiNeqbxZv)
12 |
13 |
14 | Note that these notebooks work in Google Colab and the pipeline that was used was alercereaduser_v3.json
15 |
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/data/ephs_10586_20200101-20200102.pkl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/data/ephs_10586_20200101-20200102.pkl
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/dists_contours.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/dists_contours.png
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/alerce_explorer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/alerce_explorer.png
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/alerce_explorer_object.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/alerce_explorer_object.png
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/alerce_frontend.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/alerce_frontend.png
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/betas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/betas.png
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/class_samples.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/class_samples.png
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/cm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/cm.png
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/cnn_architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/cnn_architecture.png
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/cnn_table.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/cnn_table.png
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/hierarchical_rf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/hierarchical_rf.png
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/sanchez_paper_confusion_matrix.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/sanchez_paper_confusion_matrix.png
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/sn_hunter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/sn_hunter.png
--------------------------------------------------------------------------------
/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/taxonomy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/ALeRCE_Tutorial_workshop_Sep2020/figures/ml/taxonomy.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/SanchezSaez+2020_confusion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/SanchezSaez+2020_confusion.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/SanchezSaez+2020_recall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/SanchezSaez+2020_recall.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/Villar+19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/Villar+19.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/ml/alerce_explorer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/ml/alerce_explorer.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/ml/alerce_explorer_object.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/ml/alerce_explorer_object.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/ml/alerce_frontend.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/ml/alerce_frontend.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/ml/betas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/ml/betas.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/ml/class_samples.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/ml/class_samples.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/ml/cm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/ml/cm.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/ml/cnn_architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/ml/cnn_architecture.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/ml/cnn_table.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/ml/cnn_table.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/ml/hierarchical_rf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/ml/hierarchical_rf.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/ml/sanchez_paper_confusion_matrix.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/ml/sanchez_paper_confusion_matrix.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/ml/sn_hunter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/ml/sn_hunter.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/ml/taxonomy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/ml/taxonomy.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/recall_agn_qso_blazar_for_mag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/recall_agn_qso_blazar_for_mag.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/recall_agn_qso_blazar_for_ndet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/recall_agn_qso_blazar_for_ndet.png
--------------------------------------------------------------------------------
/notebooks/EVIC_Dec2022_tutorial/figures/taxonomy_tree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/EVIC_Dec2022_tutorial/figures/taxonomy_tree.png
--------------------------------------------------------------------------------
/notebooks/IAUS375_Dec2022_Blazars_tutorial/readme.md:
--------------------------------------------------------------------------------
1 | # IAUS 375: : The Multimessenger Chakra of Blazar Jets - ALeRCE Tutorial
2 |
3 | This tutorial will be focused on science that can be done with ALeRCE to study Blazars. After an introduction to ALeRCE and its general services,
4 | we will use the following Jupyter Notebook:
5 |
6 | [ALeRCE Blazar Starter notebook](https://colab.research.google.com/github/alercebroker/usecases/blob/master/notebooks/IAUS375_Dec2022_Blazars_tutorial/ALeRCE_Blazar_starter.ipynb)
7 |
8 | The notebook is focused on Blazars mostly using the results from the light curve classifier. After a brief introduction, we will use the ALeRCE client to retrieve the light curve for one particular Blazar, and then for a sample of sources. Then, we will learn how to use the ALeRCE database to retrieve large samples of Blazars and AGN, and to compare their properties.
9 |
--------------------------------------------------------------------------------
/notebooks/IAU_GA_2024/README.md:
--------------------------------------------------------------------------------
1 | # IAU GA 2024 ALeRCE tutorial
2 |
3 | Welcome to the ALeRCE tutorial github page. See the accompanying slides [here](https://docs.google.com/presentation/d/118kXeGJlyLVHVh_vFEVGCD15EYpN_C30GnWJHF_L0ms/edit?usp=sharing) and setup instructions [here](https://docs.google.com/presentation/d/1kXo-adiF8wSznCyAAa9_Dtv1jZs8ZZZ4fSs98SkClMI/edit?usp=sharing).
4 |
5 |
6 |
--------------------------------------------------------------------------------
/notebooks/IAU_GA_2024/alercereaduser_v4.json:
--------------------------------------------------------------------------------
1 | {
2 | "params" : {
3 | "dbname" : "ztf",
4 | "user" : "alerceread",
5 | "host": "54.205.99.47",
6 | "password" : "w*C*u8AXZ4e%d+zv"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/notebooks/LSSTC_Broker_workshop_Apr2021/README.md:
--------------------------------------------------------------------------------
1 | # ALeRCE notebooks for the LSSTC Broker Workshop 2021 - 13,14,15 April 2021
2 |
3 | The notebooks were presented in the LSSTC Broker Workshop 2021 (Part II) as part of the ALeRCE Broker presentations. During this workshop, ~70% tutorials and demos were focused on science cases and interfaces (filtering, machine-learning classifications and cross-matches, multi-messenger/wavelength analyses, APIs, batch processing). A very small number of talks on topics like LSST DR0 & cadence, ZTF II, PLAsTiCC 2, TOMs.
4 |
5 | All the information about the workshop, including the schedule are available at:
6 |
7 | * [LSSTC Enabling Science 2021 Broker Workshop Part II](http://workshops.alerce.online/lsstc-enabling-science-2020-broker-workshop-part-ii/)
8 |
9 | Available material for all the brokers involved in this workshop can be found at:
10 |
11 | * [Broker Workshop 2021 Tutorials](https://github.com/broker-workshop/tutorials)
12 |
13 | The full list of recorded talks can be found in the following link:
14 |
15 | * [Link to Youtube channel](https://www.youtube.com/playlist?list=PLFA428AMRhwADMFsNDC1dttTyIukPhADi)
16 |
17 | The ALeRCE notebooks work in Google Colab and the pipeline that was used is alercereaduser_v4.json
18 |
--------------------------------------------------------------------------------
/notebooks/README.md:
--------------------------------------------------------------------------------
1 | # ALeRCE notebooks
2 |
3 | These notebooks are tools to facilitate the use of the ALeRCE API and DB. These are based on different scientific cases, including Variable Stars (VS), Active Galactic Nuclei (AGN), Supernova (SN), Asteroids, as well as related tools (Other). There are also notebooks based on the ALeRCE stamp and light curve classifiers (ML).
4 |
--------------------------------------------------------------------------------
/notebooks/figures/SanchezSaez+2020_confusion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/figures/SanchezSaez+2020_confusion.png
--------------------------------------------------------------------------------
/notebooks/figures/SanchezSaez+2020_recall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/figures/SanchezSaez+2020_recall.png
--------------------------------------------------------------------------------
/notebooks/figures/Villar+19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/figures/Villar+19.png
--------------------------------------------------------------------------------
/notebooks/figures/recall_agn_qso_blazar_for_mag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/figures/recall_agn_qso_blazar_for_mag.png
--------------------------------------------------------------------------------
/notebooks/figures/recall_agn_qso_blazar_for_ndet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/figures/recall_agn_qso_blazar_for_ndet.png
--------------------------------------------------------------------------------
/notebooks/figures/taxonomy_tree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/figures/taxonomy_tree.png
--------------------------------------------------------------------------------
/notebooks/variablestars_figures/RRL_GAIA_VS_Notebook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/variablestars_figures/RRL_GAIA_VS_Notebook.png
--------------------------------------------------------------------------------
/notebooks/variablestars_figures/SanchezSaez+2020_confusion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/variablestars_figures/SanchezSaez+2020_confusion.png
--------------------------------------------------------------------------------
/notebooks/variablestars_figures/SanchezSaez+2020_rrl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/variablestars_figures/SanchezSaez+2020_rrl.png
--------------------------------------------------------------------------------
/notebooks/variablestars_figures/taxonomy_tree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alercebroker/usecases/991df543749ec02420ec693a4039fd32f05a2d5f/notebooks/variablestars_figures/taxonomy_tree.png
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | alerce_xmatch
2 | websocket-client
3 |
--------------------------------------------------------------------------------