|
21 | 21 | "import math\n", |
22 | 22 | "\n", |
23 | 23 | "import numpy as np\n", |
| 24 | + "import matplotlib as mpl\n", |
24 | 25 | "import matplotlib.pyplot as plt\n", |
25 | 26 | "import pandas as pd\n", |
26 | 27 | "from pytest import approx\n", |
|
60 | 61 | "# Plot image pixels in cartesian ordering (i.e. y-positive == upwards):\n", |
61 | 62 | "plt.rcParams['image.origin'] = 'lower'\n", |
62 | 63 | "# Make plots bigger\n", |
63 | | - "plt.rcParams['figure.figsize'] = 8, 8" |
| 64 | + "plt.rcParams['figure.figsize'] = 6, 6" |
64 | 65 | ] |
65 | 66 | }, |
66 | 67 | { |
|
164 | 165 | "outputs": [], |
165 | 166 | "source": [ |
166 | 167 | "import gc\n", |
167 | | - "import stp_python\n", |
| 168 | + "\n", |
| 169 | + "\n", |
168 | 170 | "def time_ceres_sourcefinding(image):\n", |
169 | 171 | " \n", |
170 | 172 | "\n", |
171 | 173 | " ceres_diffmethod = stp_python.CeresDiffMethod.AnalyticDiff\n", |
172 | 174 | " ceres_solvertype = stp_python.CeresSolverType.TrustRegion_DenseQR\n", |
| 175 | + " median_method = stp_python.MedianMethod.ZEROMEDIAN\n", |
173 | 176 | " \n", |
174 | | - " pars = dict(image_data=image,\n", |
| 177 | + " pars = dict(image_data=np.asfortranarray(image),\n", |
175 | 178 | " detection_n_sigma=detection_n_sigma,\n", |
176 | 179 | " analysis_n_sigma=analysis_n_sigma,\n", |
177 | 180 | " rms_est=rms_est,\n", |
178 | 181 | " find_negative_sources=False,\n", |
179 | 182 | " sigma_clip_iters=0,\n", |
180 | | - " binapprox_median=True,\n", |
| 183 | + " median_method=median_method,\n", |
181 | 184 | " gaussian_fitting=False,\n", |
182 | 185 | " generate_labelmap=False,\n", |
183 | 186 | " ceres_diffmethod=ceres_diffmethod,\n", |
|
196 | 199 | " stp_python.source_find_wrapper(**pars)\n", |
197 | 200 | " end2=datetime.datetime.now()\n", |
198 | 201 | "\n", |
199 | | - " extraction_duration=(end2 - start2).total_seconds()\n", |
200 | | - " fitting_duration=(end1 - start1).total_seconds() - extraction_duration\n", |
| 202 | + " extraction_duration=(end1 - start1).total_seconds()\n", |
| 203 | + " fitting_duration=(end2 - start2).total_seconds() - extraction_duration\n", |
201 | 204 | "\n", |
202 | 205 | " return extraction_duration, fitting_duration\n", |
203 | 206 | "\n" |
|
254 | 257 | "time_ceres_sourcefinding(image)" |
255 | 258 | ] |
256 | 259 | }, |
| 260 | + { |
| 261 | + "cell_type": "code", |
| 262 | + "execution_count": null, |
| 263 | + "metadata": {}, |
| 264 | + "outputs": [], |
| 265 | + "source": [ |
| 266 | + "2**13" |
| 267 | + ] |
| 268 | + }, |
257 | 269 | { |
258 | 270 | "cell_type": "code", |
259 | 271 | "execution_count": null, |
260 | 272 | "metadata": {}, |
261 | 273 | "outputs": [], |
262 | 274 | "source": [ |
263 | 275 | "# %%time\n", |
264 | | - "small_sizes = (512, 1024, 2048, 4096)\n", |
265 | | - "large_sizes = (512, 1024, 2048, 4096, 8192, 12000, 16384)\n", |
| 276 | + "small_sizes = (2**9, 2**10, 2**11, 2**12)\n", |
| 277 | + "large_sizes = small_sizes+(2**13, int(2**13.5), 2**14)\n", |
266 | 278 | "# images_w_64_sources = ( generate_test_image(image_size=sz, n_sources=64)\n", |
267 | 279 | "# for sz in (512, 1024, 2048, 4096, 8192)]\n", |
268 | 280 | "def image_set(image_sizes):\n", |
269 | 281 | " return (generate_test_image(sz, n_sources=n_sources) for sz in image_sizes)" |
270 | 282 | ] |
271 | 283 | }, |
| 284 | + { |
| 285 | + "cell_type": "code", |
| 286 | + "execution_count": null, |
| 287 | + "metadata": {}, |
| 288 | + "outputs": [], |
| 289 | + "source": [ |
| 290 | + "large_sizes" |
| 291 | + ] |
| 292 | + }, |
272 | 293 | { |
273 | 294 | "cell_type": "code", |
274 | 295 | "execution_count": null, |
|
405 | 426 | "metadata": {}, |
406 | 427 | "outputs": [], |
407 | 428 | "source": [ |
408 | | - "native = results_to_dataframe(native_results)\n", |
409 | | - "ceres = results_to_dataframe(ceres_results)\n", |
410 | | - "pyse = results_to_dataframe(pyse_results)\n", |
411 | | - "sep = results_to_dataframe(sep_results)\n", |
| 429 | + "ticklabels = np.round(np.log2(large_sizes),decimals=1)\n", |
| 430 | + "simple_ticklabels = []\n", |
| 431 | + "for tl in ticklabels:\n", |
| 432 | + " simple_ticklabels.append(int(tl) if tl==int(tl) else tl)\n", |
| 433 | + "simple_ticklabels = [\"$2^{{{}}}$\".format(power) for power in simple_ticklabels]\n", |
| 434 | + "simple_ticklabels" |
| 435 | + ] |
| 436 | + }, |
| 437 | + { |
| 438 | + "cell_type": "code", |
| 439 | + "execution_count": null, |
| 440 | + "metadata": {}, |
| 441 | + "outputs": [], |
| 442 | + "source": [ |
| 443 | + "native_df = results_to_dataframe(native_results)\n", |
| 444 | + "ceres_df = results_to_dataframe(ceres_results)\n", |
| 445 | + "pyse_df = results_to_dataframe(pyse_results)\n", |
| 446 | + "sep_df = results_to_dataframe(sep_results)\n", |
412 | 447 | "\n", |
413 | | - "native['total']=native.extraction+native.fitting\n", |
| 448 | + "native_df['total']=native_df.extraction+native_df.fitting\n", |
| 449 | + "ceres_df['total'] = ceres_df.extraction + ceres_df.fitting\n", |
414 | 450 | "\n", |
415 | 451 | "ax = plt.gca()\n", |
416 | 452 | "\n", |
417 | | - "native.plot(ax=ax, y='extraction', label='native_ex')\n", |
418 | | - "native.plot(ax=ax, y='fitting', label='native_fit')\n", |
| 453 | + "# native_df.plot(ax=ax, y='extraction', label='native_ex')\n", |
| 454 | + "# native_df.plot(ax=ax, y='fitting', label='native_fit')\n", |
| 455 | + "native_df.plot(ax=ax, y='total', label='Python ref. code (ex.+fit)')\n", |
419 | 456 | "# native.plot(ax=ax, y='total', label='native_ex+fit')\n", |
420 | | - "pyse.plot(ax=ax, y='extraction', label='pyse_ex+fit')\n", |
421 | | - "ceres.plot(y='extraction',ax=ax, label='ceres_ex')\n", |
422 | | - "ceres.plot(y='fitting',ax=ax, label='ceres_fit')\n", |
423 | | - "sep.plot(y='extraction',ax=ax, label='sep_ex')\n", |
| 457 | + "pyse_df.plot(ax=ax, y='extraction', label='PySE (ex.+fit)')\n", |
| 458 | + "ceres_df.plot(y='extraction',ax=ax, label='Ceres (ex.)')\n", |
| 459 | + "ceres_df.plot(y='total',ax=ax, label='Ceres (ex.+fit)')\n", |
| 460 | + "# ceres.plot(y='fitting',ax=ax, label='ceres_fit')\n", |
| 461 | + "sep_df.plot(y='extraction',ax=ax, label='SEP (ex.)')\n", |
424 | 462 | "ax.set_ylabel('Time [s]')\n", |
425 | | - "plt.savefig('performance_64_sources_2.pdf')" |
| 463 | + "for sz in large_sizes:\n", |
| 464 | + " ax.axvline(sz, ls=':', alpha=0.3)\n", |
| 465 | + "xax = ax.get_xaxis()\n", |
| 466 | + "xax.set_ticks(large_sizes)\n", |
| 467 | + "# xax.set_ticklabels(large_sizes, rotation=45)\n", |
| 468 | + "xax.set_ticklabels(simple_ticklabels, rotation=30)\n", |
| 469 | + "plt.savefig('extraction_64_sources_all.pdf')" |
426 | 470 | ] |
427 | 471 | }, |
428 | 472 | { |
|
0 commit comments