|
1475 | 1475 | "plt.plot(x, np.sum(np.array(p[0:o])**2,axis=0))\n",
|
1476 | 1476 | "plt.plot(x, (o+0.5)/2*(x**0))"
|
1477 | 1477 | ]
|
1478 |
| - }, |
1479 |
| - { |
1480 |
| - "cell_type": "markdown", |
1481 |
| - "metadata": {}, |
1482 |
| - "source": [ |
1483 |
| - "# Figure pooling" |
1484 |
| - ] |
1485 |
| - }, |
1486 |
| - { |
1487 |
| - "cell_type": "code", |
1488 |
| - "execution_count": null, |
1489 |
| - "metadata": {}, |
1490 |
| - "outputs": [], |
1491 |
| - "source": [ |
1492 |
| - "def make_ball(map_test1, cmap=plt.cm.gray_r, sub=None):\n", |
1493 |
| - " cmap.set_under('w')\n", |
1494 |
| - " cmap.set_bad('lightgray')\n", |
1495 |
| - " dot_size=10\n", |
1496 |
| - " rot = (0,30,345)\n", |
1497 |
| - " vmin, vmax = -0.5, 1.5\n", |
1498 |
| - " hp.visufunc.orthview(map=map_test1, half_sky=True, title='', rot=rot, cmap=cmap, cbar=False, hold=True, nest=True, min=vmin, max=vmax, notext=True, sub=sub);\n", |
1499 |
| - " theta, phi = hp.pix2ang(hp.npix2nside(len(map_test1)), range(len(map_test1)), nest=True);\n", |
1500 |
| - " hp.projscatter(theta, phi, c='k', s=dot_size);\n", |
1501 |
| - " hp.graticule();\n", |
1502 |
| - " hp.graticule(dmer=360,dpar=360,alpha=1, rot=(0,0,15), local=True);\n", |
1503 |
| - " hp.graticule(dmer=360,dpar=360,alpha=1, rot=(0,0,195), local=True); " |
1504 |
| - ] |
1505 |
| - }, |
1506 |
| - { |
1507 |
| - "cell_type": "code", |
1508 |
| - "execution_count": null, |
1509 |
| - "metadata": {}, |
1510 |
| - "outputs": [], |
1511 |
| - "source": [ |
1512 |
| - "npix = hp.nside2npix(16)\n", |
1513 |
| - "map_data = np.arange(npix)\n", |
1514 |
| - "\n", |
1515 |
| - "\n", |
1516 |
| - "npix = hp.nside2npix(1)\n", |
1517 |
| - "map_select_1 = (np.arange(npix)==0).astype(np.float)\n", |
1518 |
| - "map_select_1[map_select_1==0] = hp.UNSEEN\n", |
1519 |
| - "map_select_2 = hp.ud_grade(map_select_1, nside_out=2, order_in='NESTED', order_out='NESTED')\n", |
1520 |
| - "map_select_4 = hp.ud_grade(map_select_1, nside_out=4, order_in='NESTED', order_out='NESTED')\n", |
1521 |
| - "map_select_8 = hp.ud_grade(map_select_1, nside_out=8, order_in='NESTED', order_out='NESTED')\n", |
1522 |
| - "\n", |
1523 |
| - "n_filled = float(np.count_nonzero(map_select_2!=hp.UNSEEN))\n", |
1524 |
| - "map_select_2[map_select_2!=hp.UNSEEN] = np.arange(n_filled, dtype=np.float64)/n_filled\n", |
1525 |
| - "n_filled = float(np.count_nonzero(map_select_4!=hp.UNSEEN))\n", |
1526 |
| - "map_select_4[map_select_4!=hp.UNSEEN] = np.arange(n_filled, dtype=np.float64)/n_filled\n", |
1527 |
| - "n_filled = float(np.count_nonzero(map_select_8!=hp.UNSEEN))\n", |
1528 |
| - "map_select_8[map_select_8!=hp.UNSEEN] = np.arange(n_filled, dtype=np.float64)/n_filled\n" |
1529 |
| - ] |
1530 |
| - }, |
1531 |
| - { |
1532 |
| - "cell_type": "code", |
1533 |
| - "execution_count": null, |
1534 |
| - "metadata": {}, |
1535 |
| - "outputs": [], |
1536 |
| - "source": [ |
1537 |
| - "nx, ny = 3,1\n", |
1538 |
| - "\n", |
1539 |
| - "\n", |
1540 |
| - "plt.figure()\n", |
1541 |
| - "\n", |
1542 |
| - "make_ball(map_select_1, cmap=plt.cm.RdYlBu)\n", |
1543 |
| - "filename_plot = os.path.join(pathfig,'figure_pooling1.svg')\n", |
1544 |
| - "plt.savefig(filename_plot, bbox_inches='tight', transparent=True); print('saved {}'.format(filename_plot))\n", |
1545 |
| - "\n", |
1546 |
| - "\n", |
1547 |
| - "\n", |
1548 |
| - "plt.figure()\n", |
1549 |
| - "make_ball(map_select_2, cmap=plt.cm.RdYlBu)\n", |
1550 |
| - "filename_plot = os.path.join(pathfig,'figure_pooling2.svg')\n", |
1551 |
| - "plt.savefig(filename_plot, bbox_inches='tight', transparent=True); print('saved {}'.format(filename_plot))\n", |
1552 |
| - "\n", |
1553 |
| - "\n", |
1554 |
| - "plt.figure()\n", |
1555 |
| - "\n", |
1556 |
| - "make_ball(map_select_4, cmap=plt.cm.RdYlBu)\n", |
1557 |
| - "filename_plot = os.path.join(pathfig,'figure_pooling3.svg')\n", |
1558 |
| - "plt.savefig(filename_plot, bbox_inches='tight', transparent=True); print('saved {}'.format(filename_plot))\n", |
1559 |
| - "\n" |
1560 |
| - ] |
1561 |
| - }, |
1562 |
| - { |
1563 |
| - "cell_type": "code", |
1564 |
| - "execution_count": null, |
1565 |
| - "metadata": {}, |
1566 |
| - "outputs": [], |
1567 |
| - "source": [ |
1568 |
| - "lw=3\n", |
1569 |
| - "point2=(377,87)\n", |
1570 |
| - "point3=(603,72)\n", |
1571 |
| - "\n", |
1572 |
| - "svg_fig = sc.Figure(\"22.5cm\", \"6.75cm\", \n", |
1573 |
| - " sc.SVG(os.path.join(pathfig, \"figure_pooling3.svg\")).scale(0.83).move(0,0),\n", |
1574 |
| - " sc.SVG(os.path.join(pathfig, \"figure_pooling2.svg\")).scale(0.83).move(255, 0),\n", |
1575 |
| - " sc.SVG(os.path.join(pathfig, \"figure_pooling1.svg\")).scale(0.83).move(510, 0),\n", |
1576 |
| - " sc.Line( ((122,80), point2), width=lw, color='darkred'),\n", |
1577 |
| - " sc.Line( ((148,93), point2), width=lw, color='darkred'),\n", |
1578 |
| - " sc.Line( ((153,71), point2), width=lw, color='darkred'),\n", |
1579 |
| - " sc.Line( ((124,107), point2), width=lw, color='darkred'),\n", |
1580 |
| - " \n", |
1581 |
| - " sc.Line( ((384,87), point3), width=lw, color='darkblue'),\n", |
1582 |
| - " sc.Line( ((396,44), point3), width=lw, color='darkblue'),\n", |
1583 |
| - " sc.Line( ((348,55), point3), width=lw, color='darkblue'),\n", |
1584 |
| - " sc.Line( ((337,105), point3), width=lw, color='darkblue')\n", |
1585 |
| - " )\n", |
1586 |
| - "\n", |
1587 |
| - "svg_fig.save(os.path.join(pathfig, \"figure_pooling_svg.svg\"))\n", |
1588 |
| - "ipd.SVG(os.path.join(pathfig, 'figure_pooling_svg.svg'))\n", |
1589 |
| - "filename_plot = os.path.join(pathfig,'figure_pooling.pdf')\n", |
1590 |
| - "plt.savefig(filename_plot, bbox_inches='tight'); print('saved {}'.format(filename_plot))" |
1591 |
| - ] |
1592 |
| - }, |
1593 |
| - { |
1594 |
| - "cell_type": "code", |
1595 |
| - "execution_count": null, |
1596 |
| - "metadata": {}, |
1597 |
| - "outputs": [], |
1598 |
| - "source": [ |
1599 |
| - "plt.figure()\n", |
1600 |
| - "\n", |
1601 |
| - "make_ball(map_select_8, cmap=plt.cm.RdYlBu)\n", |
1602 |
| - "filename_plot = os.path.join(pathfig,'figure_pooling4.svg')\n", |
1603 |
| - "plt.savefig(filename_plot, bbox_inches='tight', transparent=True); print('saved {}'.format(filename_plot))\n", |
1604 |
| - "filename_plot = os.path.join(pathfig,'HEALpix.pdf')\n", |
1605 |
| - "plt.savefig(filename_plot, bbox_inches='tight'); print('saved {}'.format(filename_plot))" |
1606 |
| - ] |
1607 | 1478 | }
|
1608 | 1479 | ],
|
1609 | 1480 | "metadata": {
|
|
0 commit comments