|
53 | 53 | "from astroquery.vizier import Vizier\n",
|
54 | 54 | "import scipy.optimize\n",
|
55 | 55 | "# Make plots display in notebooks\n",
|
56 |
| - "%matplotlib inline " |
| 56 | + "%matplotlib inline" |
57 | 57 | ]
|
58 | 58 | },
|
59 | 59 | {
|
|
85 | 85 | "cell_type": "markdown",
|
86 | 86 | "metadata": {},
|
87 | 87 | "source": [
|
88 |
| - "This catalog has a lot of information, but for this tutorial we are going to work only with periods and magnitudes. Let's grab them using the keywords `'Period'` and `__Ksmag__`. Note that `'e__Ksmag_'` refers to the error bars in the magnitude measurements." |
| 88 | + "This catalog has a lot of information, but for this tutorial we are going to work only with periods and magnitudes. Let's grab them using the keywords `'Period'` and `<Ksmag>`. Note that `'e_<Ksmag>'` refers to the error bars in the magnitude measurements." |
89 | 89 | ]
|
90 | 90 | },
|
91 | 91 | {
|
|
94 | 94 | "metadata": {},
|
95 | 95 | "outputs": [],
|
96 | 96 | "source": [
|
97 |
| - "period = np.array(catalog[0]['Period']) \n", |
| 97 | + "period = np.array(catalog[0]['Period'])\n", |
98 | 98 | "log_period = np.log10(period)\n",
|
99 |
| - "k_mag = np.array(catalog[0]['__Ksmag_'])\n", |
100 |
| - "k_mag_err = np.array(catalog[0]['e__Ksmag_'])" |
| 99 | + "k_mag = np.array(catalog[0]['<Ksmag>'])\n", |
| 100 | + "k_mag_err = np.array(catalog[0]['e_<Ksmag>'])" |
101 | 101 | ]
|
102 | 102 | },
|
103 | 103 | {
|
|
214 | 214 | "metadata": {},
|
215 | 215 | "outputs": [],
|
216 | 216 | "source": [
|
217 |
| - "fitter = fitting.LinearLSQFitter() " |
| 217 | + "fitter = fitting.LinearLSQFitter()" |
218 | 218 | ]
|
219 | 219 | },
|
220 | 220 | {
|
|
257 | 257 | "outputs": [],
|
258 | 258 | "source": [
|
259 | 259 | "plt.errorbar(log_period,k_mag,k_mag_err,fmt='k.')\n",
|
260 |
| - "plt.plot(log_period, best_fit(log_period), color='g', linewidth=3) \n", |
| 260 | + "plt.plot(log_period, best_fit(log_period), color='g', linewidth=3)\n", |
261 | 261 | "plt.xlabel(r'$\\log_{10}$(Period [days])')\n",
|
262 | 262 | "plt.ylabel('Ks')"
|
263 | 263 | ]
|
|
318 | 318 | "source": [
|
319 | 319 | "N = 100\n",
|
320 | 320 | "x1 = np.linspace(0, 4, N) # Makes an array from 0 to 4 of N elements\n",
|
321 |
| - "y1 = x1**3 - 6*x1**2 + 12*x1 - 9 \n", |
| 321 | + "y1 = x1**3 - 6*x1**2 + 12*x1 - 9\n", |
322 | 322 | "# Now we add some noise to the data\n",
|
323 | 323 | "y1 += np.random.normal(0, 2, size=len(y1)) #One way to add random gaussian noise\n",
|
324 | 324 | "sigma = 1.5\n",
|
325 |
| - "y1_err = np.ones(N)*sigma " |
| 325 | + "y1_err = np.ones(N)*sigma" |
326 | 326 | ]
|
327 | 327 | },
|
328 | 328 | {
|
|
339 | 339 | "outputs": [],
|
340 | 340 | "source": [
|
341 | 341 | "plt.errorbar(x1, y1, yerr=y1_err,fmt='k.')\n",
|
342 |
| - "plt.xlabel('$x_1$') \n", |
| 342 | + "plt.xlabel('$x_1$')\n", |
343 | 343 | "plt.ylabel('$y_1$')"
|
344 | 344 | ]
|
345 | 345 | },
|
|
357 | 357 | "outputs": [],
|
358 | 358 | "source": [
|
359 | 359 | "model_poly = models.Polynomial1D(degree=3)\n",
|
360 |
| - "fitter_poly = fitting.LinearLSQFitter() \n", |
| 360 | + "fitter_poly = fitting.LinearLSQFitter()\n", |
361 | 361 | "best_fit_poly = fitter_poly(model_poly, x1, y1, weights = 1.0/y1_err)"
|
362 | 362 | ]
|
363 | 363 | },
|
|
477 | 477 | "outputs": [],
|
478 | 478 | "source": [
|
479 | 479 | "plt.errorbar(x1, y1, yerr=y1_err,fmt='k.')\n",
|
480 |
| - "plt.plot(x1, best_fit_poly(x1), color='r', linewidth=3, label='LinearLSQFitter()') \n", |
| 480 | + "plt.plot(x1, best_fit_poly(x1), color='r', linewidth=3, label='LinearLSQFitter()')\n", |
481 | 481 | "plt.plot(x1, best_fit_poly_2(x1), color='g', linewidth=3, label='SimplexLSQFitter()')\n",
|
482 | 482 | "plt.xlabel(r'$\\log_{10}$(Period [days])')\n",
|
483 | 483 | "plt.ylabel('Ks')\n",
|
|
753 | 753 | "y3 = 5.0 * np.sin(2 * np.pi * x3)\n",
|
754 | 754 | "y3 = np.array([y_point + np.random.normal(0, 1) for y_point in y3])\n",
|
755 | 755 | "sigma = 1.5\n",
|
756 |
| - "y3_err = np.ones(N)*sigma " |
| 756 | + "y3_err = np.ones(N)*sigma" |
757 | 757 | ]
|
758 | 758 | },
|
759 | 759 | {
|
|
0 commit comments