Skip to content

Commit d21eef2

Browse files
committed
merge code for pooling figure
1 parent 8de5437 commit d21eef2

File tree

2 files changed

+20
-143
lines changed

2 files changed

+20
-143
lines changed

figure_pooling.ipynb

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@
6868
"# pl.savefig('test_fig1.pdf', bbox_inches='tight', transparent=True);"
6969
]
7070
},
71-
{
72-
"cell_type": "markdown",
73-
"metadata": {},
74-
"source": [
75-
"# make figure"
76-
]
77-
},
7871
{
7972
"cell_type": "code",
8073
"execution_count": null,
@@ -100,8 +93,7 @@
10093
"map_select_4[map_select_4!=hp.UNSEEN] = np.arange(n_filled, dtype=np.float64)/n_filled\n",
10194
"\n",
10295
"# map_select_2[map_select_2==hp.UNSEEN] = np.nan\n",
103-
"# map_select_4[map_select_4==hp.UNSEEN] = np.nan\n",
104-
"\n"
96+
"# map_select_4[map_select_4==hp.UNSEEN] = np.nan"
10597
]
10698
},
10799
{
@@ -129,7 +121,6 @@
129121
"filename_plot = os.path.join(pathfig,'figure_pooling1.svg')\n",
130122
"pl.savefig(filename_plot, bbox_inches='tight', transparent=True); print('saved {}'.format(filename_plot))\n",
131123
"\n",
132-
"\n",
133124
"# pl.axes(ax[1])\n",
134125
"pl.figure()\n",
135126
"# newax = pl.gcf().add_axes([0.1, 0.4, 0.8, 0.8],frameon=False)\n",
@@ -149,7 +140,6 @@
149140
"# , sub=(ny, nx, 3)\n",
150141
"# pl.subplots_adjust(wspace=0.01, hspace=0.01)\n",
151142
"\n",
152-
"\n",
153143
"# import matplotlib.pyplot as plt\n",
154144
"\n",
155145
"# newax = pl.gcf().add_axes([0.1, 0.1, 0.8, 0.8],frameon=False)\n",
@@ -163,7 +153,7 @@
163153
"# newax.axis('equal')\n",
164154
"# plt.show()\n",
165155
"filename_plot = os.path.join(pathfig,'figure_pooling.pdf')\n",
166-
"pl.savefig(filename_plot, bbox_inches='tight'); print('saved {}'.format(filename_plot))\n"
156+
"pl.savefig(filename_plot, bbox_inches='tight'); print('saved {}'.format(filename_plot))"
167157
]
168158
},
169159
{
@@ -210,8 +200,24 @@
210200
" )\n",
211201
"\n",
212202
"svg_fig.save(os.path.join(pathfig, \"figure_pooling_svg.svg\"))\n",
213-
"SVG(os.path.join(pathfig, 'figure_pooling_svg.svg'))\n",
214-
"# svg_fig.save(\"figure_pooling_svg.pdf\")"
203+
"SVG(os.path.join(pathfig, 'figure_pooling_svg.svg'))"
204+
]
205+
},
206+
{
207+
"cell_type": "code",
208+
"execution_count": null,
209+
"metadata": {},
210+
"outputs": [],
211+
"source": [
212+
"map_select_8 = hp.ud_grade(map_select_1, nside_out=8, order_in='NESTED', order_out='NESTED')\n",
213+
"n_filled = float(np.count_nonzero(map_select_8!=hp.UNSEEN))\n",
214+
"map_select_8[map_select_8!=hp.UNSEEN] = np.arange(n_filled, dtype=np.float64)/n_filled\n",
215+
"\n",
216+
"make_ball(map_select_8, cmap=plt.cm.RdYlBu)\n",
217+
"filename_plot = os.path.join(pathfig,'figure_pooling4.svg')\n",
218+
"plt.savefig(filename_plot, bbox_inches='tight', transparent=True); print('saved {}'.format(filename_plot))\n",
219+
"filename_plot = os.path.join(pathfig,'figure_pooling4.pdf')\n",
220+
"plt.savefig(filename_plot, bbox_inches='tight'); print('saved {}'.format(filename_plot))"
215221
]
216222
}
217223
],

figures.ipynb

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,135 +1475,6 @@
14751475
"plt.plot(x, np.sum(np.array(p[0:o])**2,axis=0))\n",
14761476
"plt.plot(x, (o+0.5)/2*(x**0))"
14771477
]
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-
]
16071478
}
16081479
],
16091480
"metadata": {

0 commit comments

Comments
 (0)