def multi_den(dir_name, base_name, nproc, size): ntot, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, \ '0020', nproc) rc('font', size=15) fig = plt.figure() fig.set_figwidth(9) fig.set_figheight(8) fig.subplots_adjust(left = 0.10, right = 0.88, top = 0.95, bottom = 0.07, \ wspace = 0.0, hspace = 0.0) plt.figtext(0.5, 0.97, 'Multi density', ha='center', size='large') majorLocator = ticker.MultipleLocator(10) minorLocator = ticker.MultipleLocator(5) nullFormatter = ticker.NullFormatter() ################### DEN 1 #################################### ax = fig.add_subplot(221) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] den = arr['den'][:] idw = np.where(arr['type'] == mp.TYPE_WARM) idc = np.where(arr['type'] == mp.TYPE_COLD) ids = np.where(arr['type'] == mp.TYPE_STAR_PARAL) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') cmap = mpl.cm.jet norm = mpl.colors.LogNorm() plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-7, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) # cb = plt.colorbar(ticks = ticker.LogLocator(base = 10.0)) # cb.set_label('Density [cm$^{-3}$]') plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### DEN 2 #################################### ax = fig.add_subplot(222) # arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] den = arr['den'][:] idw = np.where(arr['type'] == mp.TYPE_WARM) idc = np.where(arr['type'] == mp.TYPE_COLD) ids = np.where(arr['type'] == mp.TYPE_STAR_PARAL) # plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') cmap = mpl.cm.jet norm = mpl.colors.LogNorm() plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-7, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) # cb = plt.colorbar(ticks = ticker.LogLocator(base = 10.0)) # cb.set_label('Density [cm$^{-3}$]') plt.xlim(-size, size) plt.ylim(-size, size) ################### DEN 3 #################################### ax = fig.add_subplot(223) # arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] den = arr['den'][:] idw = np.where(arr['type'] == mp.TYPE_WARM) idc = np.where(arr['type'] == mp.TYPE_COLD) ids = np.where(arr['type'] == mp.TYPE_STAR_PARAL) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') cmap = mpl.cm.jet norm = mpl.colors.LogNorm() plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-7, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # cb = plt.colorbar(ticks = ticker.LogLocator(base = 10.0)) # cb.set_label('Density [cm$^{-3}$]') plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### DEN 4 #################################### ax = fig.add_subplot(224) # arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] den = arr['den'][:] idw = np.where(arr['type'] == mp.TYPE_WARM) idc = np.where(arr['type'] == mp.TYPE_COLD) ids = np.where(arr['type'] == mp.TYPE_STAR_PARAL) plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') cmap = mpl.cm.jet norm = mpl.colors.LogNorm() mapable = plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-7, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size) plt.ylim(-size, size) # cb = plt.colorbar(ticks = ticker.LogLocator(base = 10.0)) cbaxes = fig.add_axes([0.89, 0.07, 0.02, 0.88]) cb = plt.colorbar(orientation='vertical', \ ticks = ticker.LogLocator(base = 10.0), cax = cbaxes) cb.set_label('Density [cm$^{-3}$]') ########################## save ###################################### figure_name = 'MultiDen-xz-' + dir_name + '.png' plt.savefig(figure_name)
import sys if len(sys.argv) < 6: print 'hist: not enough parameter!' print '\tUsage: histp.py dir_name base_name snap_num nproc radius' print '\tExample: histp.py hd-1 1E3 0001 1 20.0' sys.exit(1) dir_name = sys.argv[1] base_name = sys.argv[2] snap_num = sys.argv[3] nproc = int(sys.argv[4]) radius = float(sys.argv[5]) ntot = 0 ntot, time, arr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num, nproc) r = arr['pos'][:, 0] * arr['pos'][:, 0] + arr['pos'][:, 1] * arr['pos'][:, 1] \ + arr['pos'][:, 2] * arr['pos'][:, 2] r = np.sqrt(r) idc = np.where(arr['type'] == mp.TYPE_COLD) ml = 1E4 mh = 1E7 logml = log10(ml) logmh = log10(mh) mass = arr['mass'][idc]
def multi_den(dir_name, base_name, nproc, size): ntot, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, \ '0020', nproc) rc('font', size = 15) fig = plt.figure() fig.set_figwidth(9) fig.set_figheight(8) fig.subplots_adjust(left = 0.10, right = 0.88, top = 0.95, bottom = 0.07, \ wspace = 0.0, hspace = 0.0) plt.figtext(0.5, 0.97, 'Multi density', ha = 'center', size = 'large') majorLocator = ticker.MultipleLocator(10) minorLocator = ticker.MultipleLocator(5) nullFormatter = ticker.NullFormatter() ################### DEN 1 #################################### ax = fig.add_subplot(221) arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] den = arr['den'][:] idw = np.where(arr['type'] == mp.TYPE_WARM) idc = np.where(arr['type'] == mp.TYPE_COLD) ids = np.where(arr['type'] == mp.TYPE_STAR_PARAL) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') cmap = mpl.cm.jet norm = mpl.colors.LogNorm() plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-7, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) # cb = plt.colorbar(ticks = ticker.LogLocator(base = 10.0)) # cb.set_label('Density [cm$^{-3}$]') plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### DEN 2 #################################### ax = fig.add_subplot(222) # arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] den = arr['den'][:] idw = np.where(arr['type'] == mp.TYPE_WARM) idc = np.where(arr['type'] == mp.TYPE_COLD) ids = np.where(arr['type'] == mp.TYPE_STAR_PARAL) # plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') cmap = mpl.cm.jet norm = mpl.colors.LogNorm() plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-7, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) # cb = plt.colorbar(ticks = ticker.LogLocator(base = 10.0)) # cb.set_label('Density [cm$^{-3}$]') plt.xlim(-size, size) plt.ylim(-size, size) ################### DEN 3 #################################### ax = fig.add_subplot(223) # arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] den = arr['den'][:] idw = np.where(arr['type'] == mp.TYPE_WARM) idc = np.where(arr['type'] == mp.TYPE_COLD) ids = np.where(arr['type'] == mp.TYPE_STAR_PARAL) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') cmap = mpl.cm.jet norm = mpl.colors.LogNorm() plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-7, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # cb = plt.colorbar(ticks = ticker.LogLocator(base = 10.0)) # cb.set_label('Density [cm$^{-3}$]') plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### DEN 4 #################################### ax = fig.add_subplot(224) # arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] den = arr['den'][:] idw = np.where(arr['type'] == mp.TYPE_WARM) idc = np.where(arr['type'] == mp.TYPE_COLD) ids = np.where(arr['type'] == mp.TYPE_STAR_PARAL) plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') cmap = mpl.cm.jet norm = mpl.colors.LogNorm() mapable = plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-7, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size) plt.ylim(-size, size) # cb = plt.colorbar(ticks = ticker.LogLocator(base = 10.0)) cbaxes = fig.add_axes([0.89, 0.07, 0.02, 0.88]) cb = plt.colorbar(orientation='vertical', \ ticks = ticker.LogLocator(base = 10.0), cax = cbaxes) cb.set_label('Density [cm$^{-3}$]') ########################## save ###################################### figure_name = 'MultiDen-xz-' + dir_name + '.png' plt.savefig(figure_name)
def multi_cold_mass(dir_name, base_name, nproc, size, snap_num): title = dir_name # plt.figtext(0.5, 0.94, title, ha = 'center', size = 'large') majorLocator = ticker.MultipleLocator(20) minorLocator = ticker.MultipleLocator(4) nullFormatter = ticker.NullFormatter() cmap = mpl.cm.jet norm = mpl.colors.LogNorm() vmin = 1.0E4 vmax = 2.0E7 rc('font', size=18) fig = plt.figure() fig.set_figwidth(10) fig.set_figheight(9) fig.subplots_adjust(left = 0.10, right = 0.85, top = 0.95, bottom = 0.10, \ wspace = 0.0, hspace = 0.0) ############################### snap 0 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[0], nproc) ax = fig.add_subplot(221) arr = np.sort(rarr, order='mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') plt.scatter(x[idc], z[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################################# snap 1 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[1], nproc) ax = fig.add_subplot(222) arr = np.sort(rarr, order='mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idc], z[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################################# snap 2 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[2], nproc) ax = fig.add_subplot(223) arr = np.sort(rarr, order='mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') plt.scatter(x[idc], z[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################################ snap 3 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[3], nproc) ax = fig.add_subplot(224) arr = np.sort(rarr, order='mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idc], z[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ######################### color bar ################################## # [xcoord, ycoord, width, height] cbaxes = fig.add_axes([0.87, 0.10, 0.03, 0.85]) cb = plt.colorbar(orientation='vertical', \ ticks = ticker.LogLocator(base = 10.0), cax = cbaxes) cb.set_label('Cold cloud mass [M$_\odot$]') ######################## label ###################################### label = 't = 0.5 Gyr' plt.figtext(0.28, 0.9, label, ha='center', size=20) label = 't = 1 Gyr' plt.figtext(0.68, 0.9, label, ha='center', size=20) label = 't = 2 Gyr' plt.figtext(0.28, 0.47, label, ha='center', size=20) label = 't = 3 Gyr' plt.figtext(0.68, 0.47, label, ha='center', size=20) ########################## save ###################################### figure_name = 'McPanel-xz-' + dir_name + '.png' plt.savefig(figure_name) ###################################################################### ############################## X - Y ################################# ###################################################################### rc('font', size=18) plt.clf() fig = plt.figure() fig.set_figwidth(10) fig.set_figheight(9) fig.subplots_adjust(left = 0.10, right = 0.85, top = 0.95, bottom = 0.10, \ wspace = 0.0, hspace = 0.0) ############################### snap 0 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[0], nproc) ax = fig.add_subplot(221) arr = np.sort(rarr, order='mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') plt.ylabel('Y [kpc]') plt.scatter(x[idc], y[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################################# snap 1 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[1], nproc) ax = fig.add_subplot(222) arr = np.sort(rarr, order='mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Y [kpc]') plt.scatter(x[idc], y[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################################# snap 2 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[2], nproc) ax = fig.add_subplot(223) arr = np.sort(rarr, order='mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') plt.ylabel('Y [kpc]') plt.scatter(x[idc], y[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################################ snap 3 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[3], nproc) ax = fig.add_subplot(224) arr = np.sort(rarr, order='mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Y [kpc]') plt.scatter(x[idc], y[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ######################### color bar ################################## # [xcoord, ycoord, width, height] cbaxes = fig.add_axes([0.87, 0.10, 0.03, 0.85]) cb = plt.colorbar(orientation='vertical', \ ticks = ticker.LogLocator(base = 10.0), cax = cbaxes) cb.set_label('Cold cloud mass [M$_\odot$]') ######################## label ###################################### label = 't = 0.5 Gyr' plt.figtext(0.28, 0.9, label, ha='center', size=20) label = 't = 1 Gyr' plt.figtext(0.68, 0.9, label, ha='center', size=20) label = 't = 2 Gyr' plt.figtext(0.28, 0.47, label, ha='center', size=20) label = 't = 3 Gyr' plt.figtext(0.68, 0.47, label, ha='center', size=20) ########################## save ###################################### figure_name = 'McPanel-xy-' + dir_name + '.png' plt.savefig(figure_name)
def multi_den(snap_num, size): dir = [ '81-hd-3Hs2', '91-hd-3Hs2', '101-hd-3Hs2', '80-hd-3Hs2', '90-hd-3Hs2', '100-hd-3Hs2' ] proc_num = [2, 8, 8, 2, 8, 8] snap_name = '%04d' % snap_num title = 't = %d Myr' % (10 * snap_num) base_name = 'dwarf' rc('font', size=15) fig = plt.figure() fig.set_figwidth(10) fig.set_figheight(6.5) fig.subplots_adjust(left = 0.10, right = 0.88, top = 0.92, bottom = 0.10, \ wspace = 0.0, hspace = 0.0) # plt.figtext(0.5, 0.94, title, ha = 'center', size = 'large') majorLocator = ticker.MultipleLocator(10) minorLocator = ticker.MultipleLocator(5) nullFormatter = ticker.NullFormatter() cmap = mpl.cm.jet norm = mpl.colors.LogNorm() ################### hdc-81 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[0], base_name, snap_name, proc_num[0]) ax = fig.add_subplot(231) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-91 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[1], base_name, snap_name, proc_num[1]) ax = fig.add_subplot(232) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-101 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[2], base_name, snap_name, proc_num[2]) ax = fig.add_subplot(233) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) # boolarr = np.logical_and(den > 5.0E-5, boolarr) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-80 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[3], base_name, snap_name, proc_num[3]) ax = fig.add_subplot(234) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-90 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[4], base_name, snap_name, proc_num[4]) ax = fig.add_subplot(235) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-100 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[5], base_name, snap_name, proc_num[5]) ax = fig.add_subplot(236) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) # boolarr = np.logical_and(den > 5.0E-5, boolarr) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ######################### color bar ################################## # [xcoord, ycoord, width, height] cbaxes = fig.add_axes([0.89, 0.10, 0.02, 0.82]) cb = plt.colorbar(orientation='vertical', \ ticks = ticker.LogLocator(base = 10.0), cax = cbaxes) cb.set_label('Density [cm$^{-3}$]') ######################## label ###################################### label = '$2\\times10^8 \mathsf{M}_\odot$' plt.figtext(0.23, 0.87, label, ha='center', size='large') label = '$2\\times10^9 \mathsf{M}_\odot$' plt.figtext(0.49, 0.87, label, ha='center', size='large') label = '$2\\times10^{10} \mathsf{M}_\odot$' plt.figtext(0.75, 0.87, label, ha='center', size='large') ########################## save ###################################### figure_name = 'DPanel-xz-' + snap_name + '.png' plt.savefig(figure_name) ############################ X - Y ################################### snap_name = '%04d' % snap_num title = 't = %d Myr' % (10 * snap_num) base_name = 'dwarf' rc('font', size=15) fig = plt.figure() fig.set_figwidth(10) fig.set_figheight(6.5) fig.subplots_adjust(left = 0.10, right = 0.88, top = 0.92, bottom = 0.10, \ wspace = 0.0, hspace = 0.0) # plt.figtext(0.5, 0.94, title, ha = 'center', size = 'large') majorLocator = ticker.MultipleLocator(10) minorLocator = ticker.MultipleLocator(5) nullFormatter = ticker.NullFormatter() cmap = mpl.cm.jet norm = mpl.colors.LogNorm() ################### hdc-81 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[0], base_name, snap_name, proc_num[0]) ax = fig.add_subplot(231) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') plt.ylabel('Y [kpc]') plt.scatter(x[idw], y[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-91 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[1], base_name, snap_name, proc_num[1]) ax = fig.add_subplot(232) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idw], y[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-101 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[2], base_name, snap_name, proc_num[2]) ax = fig.add_subplot(233) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) # boolarr = np.logical_and(den > 5.0E-5, boolarr) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idw], y[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-80 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[3], base_name, snap_name, proc_num[3]) ax = fig.add_subplot(234) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') plt.ylabel('Y [kpc]') plt.scatter(x[idw], y[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-90 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[4], base_name, snap_name, proc_num[1]) ax = fig.add_subplot(235) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Y [kpc]') plt.scatter(x[idw], y[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-100 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[5], base_name, snap_name, proc_num[2]) ax = fig.add_subplot(236) arr = np.sort(rarr, order='den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) # boolarr = np.logical_and(den > 5.0E-5, boolarr) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Y [kpc]') plt.scatter(x[idw], y[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ######################### color bar ################################## # [xcoord, ycoord, width, height] cbaxes = fig.add_axes([0.89, 0.10, 0.02, 0.82]) cb = plt.colorbar(orientation='vertical', \ ticks = ticker.LogLocator(base = 10.0), cax = cbaxes) cb.set_label('Density [cm$^{-3}$]') ######################## label ###################################### label = '$2\\times10^8 \mathsf{M}_\odot$' plt.figtext(0.23, 0.87, label, ha='center', size='large') label = '$2\\times10^9 \mathsf{M}_\odot$' plt.figtext(0.49, 0.87, label, ha='center', size='large') label = '$2\\times10^{10} \mathsf{M}_\odot$' plt.figtext(0.75, 0.87, label, ha='center', size='large') ########################## save ###################################### figure_name = 'DPanel-xy-' + snap_name + '.png' plt.savefig(figure_name)
def multi_den(dir_name, base_name, nproc, size, snap_num): title = dir_name rc('font', size = 18) fig = plt.figure() fig.set_figwidth(10) fig.set_figheight(9) fig.subplots_adjust(left = 0.10, right = 0.85, top = 0.95, bottom = 0.10, \ wspace = 0.0, hspace = 0.0) # plt.figtext(0.5, 0.94, title, ha = 'center', size = 'large') majorLocator = ticker.MultipleLocator(2) minorLocator = ticker.MultipleLocator(1) nullFormatter = ticker.NullFormatter() cmap = mpl.cm.jet norm = mpl.colors.LogNorm() ############################### snap 0 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[0], nproc) ax = fig.add_subplot(221) arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################################# snap 1 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[1], nproc) ax = fig.add_subplot(222) arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################################# snap 2 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[2], nproc) ax = fig.add_subplot(223) arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################################ snap 3 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[3], nproc) ax = fig.add_subplot(224) arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ######################### color bar ################################## # [xcoord, ycoord, width, height] cbaxes = fig.add_axes([0.87, 0.10, 0.03, 0.85]) cb = plt.colorbar(orientation='vertical', \ ticks = ticker.LogLocator(base = 10.0), cax = cbaxes) cb.set_label('Density [cm$^{-3}$]') ######################## label ###################################### label = 't = 0.1 Gyr' plt.figtext(0.28, 0.9, label, ha = 'center', size = 20) label = 't = 0.5 Gyr' plt.figtext(0.68, 0.9, label, ha = 'center', size = 20) label = 't = 1.0 Gyr' plt.figtext(0.28, 0.47, label, ha = 'center', size = 20) label = 't = 1.5 Gyr' plt.figtext(0.68, 0.47, label, ha = 'center', size = 20) ########################## save ###################################### figure_name = 'DPanel-xz-' + dir_name + '.png' plt.savefig(figure_name) ####################################################################### ########################### X - Y #################################### ####################################################################### rc('font', size = 18) plt.clf() fig = plt.figure() fig.set_figwidth(10) fig.set_figheight(9) fig.subplots_adjust(left = 0.10, right = 0.85, top = 0.95, bottom = 0.10, \ wspace = 0.0, hspace = 0.0) # plt.figtext(0.5, 0.94, title, ha = 'center', size = 'large') ############################### snap 0 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[0], nproc) ax = fig.add_subplot(221) arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') plt.ylabel('Y [kpc]') plt.scatter(x[idw], y[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################################# snap 1 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[1], nproc) ax = fig.add_subplot(222) arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Y [kpc]') plt.scatter(x[idw], y[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################################# snap 2 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[2], nproc) ax = fig.add_subplot(223) arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') plt.ylabel('Y [kpc]') plt.scatter(x[idw], y[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################################ snap 3 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, snap_num[3], nproc) ax = fig.add_subplot(224) arr = np.sort(rarr, order = 'den') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) den = arr['den'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Y [kpc]') plt.scatter(x[idw], y[idw], s = 1, c = den[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e-6, vmax = 10, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ######################### color bar ################################## # [xcoord, ycoord, width, height] cbaxes = fig.add_axes([0.87, 0.10, 0.03, 0.85]) cb = plt.colorbar(orientation='vertical', \ ticks = ticker.LogLocator(base = 10.0), cax = cbaxes) cb.set_label('Density [cm$^{-3}$]') ######################## label ###################################### label = 't = 0.1 Gyr' plt.figtext(0.28, 0.9, label, ha = 'center', size = 20) label = 't = 0.5 Gyr' plt.figtext(0.68, 0.9, label, ha = 'center', size = 20) label = 't = 1.0 Gyr' plt.figtext(0.28, 0.47, label, ha = 'center', size = 20) label = 't = 1.5 Gyr' plt.figtext(0.68, 0.47, label, ha = 'center', size = 20) ########################## save ###################################### figure_name = 'DPanel-xy-' + dir_name + '.png' plt.savefig(figure_name)
sys.exit(1) dir_name = sys.argv[1] base_name = sys.argv[2] nproc = int(sys.argv[3]) size = float(sys.argv[4]) start = int(sys.argv[5]) end = int(sys.argv[6]) #for i in range(start, end + 1): i = start while i <= end: snap_num = '%04d' % i print '##################### snap ', snap_num, ' ######################' ntot = 0 ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir_name, base_name, \ snap_num, nproc) title = 't = %4d Myr' % int(time + 0.1) mp_snap.gen_snap_star_dm(rarr, dir_name, base_name, snap_num, size, \ title_name = title) print ' ' i += 10 ######################### end of main function ###########################
def multi_Mc(snap_num, size): dir = ['81-hd-3Hs1', '91-hd-3Hs1', '101-hd-3Hs1', '80-hd-3Hs1', '90-hd-3Hs1', '100-hd-3Hs1'] proc_num = [2, 8, 8, 2, 8, 8] vmin = 1.0E3 vmax = 1.0E7 snap_name = '%04d' % snap_num title = 't = %d Myr' % (10 * snap_num) base_name = 'dwarf' rc('font', size = 15) fig = plt.figure() fig.set_figwidth(10) fig.set_figheight(6.5) fig.subplots_adjust(left = 0.10, right = 0.88, top = 0.92, bottom = 0.10, \ wspace = 0.0, hspace = 0.0) # plt.figtext(0.5, 0.94, title, ha = 'center', size = 'large') majorLocator = ticker.MultipleLocator(5) minorLocator = ticker.MultipleLocator(2.5) nullFormatter = ticker.NullFormatter() cmap = mpl.cm.jet norm = mpl.colors.LogNorm() ################### hdc-81 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[0], base_name, snap_name, proc_num[0]) ax = fig.add_subplot(231) arr = np.sort(rarr, order = 'mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') plt.scatter(x[idc], z[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-91 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[1], base_name, snap_name, proc_num[1]) ax = fig.add_subplot(232) arr = np.sort(rarr, order = 'mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idc], z[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-101 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[2], base_name, snap_name, proc_num[2]) ax = fig.add_subplot(233) arr = np.sort(rarr, order = 'mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) # boolarr = np.logical_and(den > 5.0E-5, boolarr) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idc], z[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-80 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[3], base_name, snap_name, proc_num[3]) ax = fig.add_subplot(234) arr = np.sort(rarr, order = 'mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') plt.scatter(x[idc], z[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-90 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[4], base_name, snap_name, proc_num[1]) ax = fig.add_subplot(235) arr = np.sort(rarr, order = 'mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idc], z[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-100 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[5], base_name, snap_name, proc_num[2]) ax = fig.add_subplot(236) arr = np.sort(rarr, order = 'mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) # boolarr = np.logical_and(den > 5.0E-5, boolarr) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idc], z[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ######################### color bar ################################## # [xcoord, ycoord, width, height] cbaxes = fig.add_axes([0.89, 0.10, 0.02, 0.82]) cb = plt.colorbar(orientation='vertical', \ ticks = ticker.LogLocator(base = 10.0), cax = cbaxes) cb.set_label('Cloud mass [M$_\odot$]') ######################## label ###################################### label = '$2\\times10^8 \mathsf{M}_\odot$' plt.figtext(0.23, 0.87, label, ha = 'center', size = 'large') label = '$2\\times10^9 \mathsf{M}_\odot$' plt.figtext(0.49, 0.87, label, ha = 'center', size = 'large') label = '$2\\times10^{10} \mathsf{M}_\odot$' plt.figtext(0.75, 0.87, label, ha = 'center', size = 'large') ########################## save ###################################### figure_name = 'McPanel-xz-' + snap_name + '.png' plt.savefig(figure_name) ######################### X - Y ###################################### print "\n############## X - Y ###############\n" rc('font', size = 15) plt.clf() fig = plt.figure() fig.set_figwidth(10) fig.set_figheight(6.5) fig.subplots_adjust(left = 0.10, right = 0.88, top = 0.92, bottom = 0.10, \ wspace = 0.0, hspace = 0.0) # plt.figtext(0.5, 0.94, title, ha = 'center', size = 'large') ################### hdc-81 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[0], base_name, snap_name, proc_num[0]) ax = fig.add_subplot(231) arr = np.sort(rarr, order = 'mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') plt.ylabel('Y [kpc]') plt.scatter(x[idc], y[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-91 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[1], base_name, snap_name, proc_num[1]) ax = fig.add_subplot(232) arr = np.sort(rarr, order = 'mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Y [kpc]') plt.scatter(x[idc], y[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-101 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[2], base_name, snap_name, proc_num[2]) ax = fig.add_subplot(233) arr = np.sort(rarr, order = 'mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) # boolarr = np.logical_and(den > 5.0E-5, boolarr) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Y [kpc]') plt.scatter(x[idc], y[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-80 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[3], base_name, snap_name, proc_num[3]) ax = fig.add_subplot(234) arr = np.sort(rarr, order = 'mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') plt.ylabel('Y [kpc]') plt.scatter(x[idc], y[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-90 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[4], base_name, snap_name, proc_num[1]) ax = fig.add_subplot(235) arr = np.sort(rarr, order = 'mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Y [kpc]') plt.scatter(x[idc], y[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-100 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, dir[5], base_name, snap_name, proc_num[2]) ax = fig.add_subplot(236) arr = np.sort(rarr, order = 'mass') x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) mass = arr['mass'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) # boolarr = np.logical_and(den > 5.0E-5, boolarr) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Y [kpc]') plt.scatter(x[idc], y[idc], s = 1, c = mass[idc], marker = 'o', \ cmap = cmap, norm = norm, vmin = vmin, vmax = vmax, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ######################### color bar ################################## # [xcoord, ycoord, width, height] cbaxes = fig.add_axes([0.89, 0.10, 0.02, 0.82]) cb = plt.colorbar(orientation='vertical', \ ticks = ticker.LogLocator(base = 10.0), cax = cbaxes) cb.set_label('Cloud mass [M$_\odot$]') ######################## label ###################################### label = '$2\\times10^8 \mathsf{M}_\odot$' plt.figtext(0.23, 0.87, label, ha = 'center', size = 'large') label = '$2\\times10^9 \mathsf{M}_\odot$' plt.figtext(0.49, 0.87, label, ha = 'center', size = 'large') label = '$2\\times10^{10} \mathsf{M}_\odot$' plt.figtext(0.75, 0.87, label, ha = 'center', size = 'large') ########################## save ###################################### figure_name = 'McPanel-xy-' + snap_name + '.png' plt.savefig(figure_name)
def multi_hist(snap_num): dir = ['81-hd-3Hs2', '80-hd-3Hs2', '91-hd-3Hs2', '90-hd-3Hs2', \ '101-hd-3Hs2', '100-hd-3Hs2'] proc_num = [2, 8, 8] ml = 1.0E3 mh = 1.0E7 logml = log10(ml) logmh = log10(mh) snap_name = '%04d' % snap_num title = 't = %d Myr' % (10 * snap_num) base_name = 'dwarf' rc('font', size = 15) fig = plt.figure() fig.set_figwidth(10) fig.set_figheight(10) fig.subplots_adjust(left = 0.12, right = 0.95, top = 0.95, bottom = 0.08, \ wspace = 0.0, hspace = 0.0) plt.figtext(0.53, 0.96, title, ha = 'center', size = 'large') # majorLocator = ticker.MultipleLocator(5) # minorLocator = ticker.MultipleLocator(2.5) nullFormatter = ticker.NullFormatter() cmap = mpl.cm.jet norm = mpl.colors.LogNorm() nbin = 15 ymin = 1.1E-7 ymax = 1.0E1 ################################# 81 ################################# ntot, time, arr = mp.read_snap_paral(mp.prefix, dir[0], base_name, snap_name, proc_num[0]) xm, count = mp.calc_hist(arr, ml, mh, nbin) ax = fig.add_subplot(321) plt.xlabel('M$_\mathsf{COLD}$ [M$_\odot$]') plt.ylabel('dN / d(log M$_\mathsf{COLD}$) / M$_\mathsf{COLD}$') plt.xscale('log') plt.yscale('log') plt.plot(xm, count, drawstyle = 'steps-mid') plt.xlim(ml, mh) plt.ylim(ymin, ymax) ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) ################################# 80 ################################# ntot, time, arr = mp.read_snap_paral(mp.prefix, dir[1], base_name, snap_name, proc_num[0]) xm, count = mp.calc_hist(arr, ml, mh, nbin) ax = fig.add_subplot(322) plt.xlabel('M$_\mathsf{COLD}$ [M$_\odot$]') # plt.ylabel('dN / d(log M$_\mathsf{COLD}$) / M$_\mathsf{COLD}$') plt.xscale('log') plt.yscale('log') plt.plot(xm, count, drawstyle = 'steps-mid') plt.xlim(ml * 1.01, mh) plt.ylim(ymin, ymax) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) ymin = 2.0E-7 ymax = 9.0E1 ################################# 91 ################################# ntot, time, arr = mp.read_snap_paral(mp.prefix, dir[2], base_name, snap_name, proc_num[1]) xm, count = mp.calc_hist(arr, ml, mh, nbin) ax = fig.add_subplot(323) plt.xlabel('M$_\mathsf{COLD}$ [M$_\odot$]') plt.ylabel('dN / d(log M$_\mathsf{COLD}$) / M$_\mathsf{COLD}$') plt.xscale('log') plt.yscale('log') plt.plot(xm, count, drawstyle = 'steps-mid') plt.xlim(ml, mh) plt.ylim(ymin, ymax) ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) ################################# 90 ################################# ntot, time, arr = mp.read_snap_paral(mp.prefix, dir[3], base_name, snap_name, proc_num[1]) xm, count = mp.calc_hist(arr, ml, mh, nbin) ax = fig.add_subplot(324) plt.xlabel('M$_\mathsf{COLD}$ [M$_\odot$]') # plt.ylabel('dN / d(log M$_\mathsf{COLD}$) / M$_\mathsf{COLD}$') plt.xscale('log') plt.yscale('log') plt.plot(xm, count, drawstyle = 'steps-mid') plt.xlim(ml * 1.01, mh) plt.ylim(ymin, ymax) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) ymin = 5.0E-6 ymax = 9.0E1 ################################# 101 ################################# ntot, time, arr = mp.read_snap_paral(mp.prefix, dir[4], base_name, snap_name, 8) xm, count = mp.calc_hist(arr, ml, mh, nbin) ax = fig.add_subplot(325) plt.xlabel('M$_\mathsf{COLD}$ [M$_\odot$]') plt.ylabel('dN / d(log M$_\mathsf{COLD}$) / M$_\mathsf{COLD}$') plt.xscale('log') plt.yscale('log') plt.plot(xm, count, drawstyle = 'steps-mid') plt.xlim(ml, mh) plt.ylim(ymin, ymax) # ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) ################################# 100 ################################# ntot, time, arr = mp.read_snap_paral(mp.prefix, dir[5], base_name, snap_name, 8) xm, count = mp.calc_hist(arr, ml, mh, nbin) ax = fig.add_subplot(326) plt.xlabel('M$_\mathsf{COLD}$ [M$_\odot$]') # plt.ylabel('dN / d(log M$_\mathsf{COLD}$) / M$_\mathsf{COLD}$') plt.xscale('log') plt.yscale('log') plt.plot(xm, count, drawstyle = 'steps-mid') plt.xlim(ml * 1.01, mh) plt.ylim(ymin, ymax) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) figure_name = 'histPanel-' + snap_name + '.png' plt.savefig(figure_name) figure_name = 'histPanel-' + snap_name + '.eps' plt.savefig(figure_name)
def multi_T(snap_num, size): snap_name = '%04d' % snap_num title = 't = %d Myr' % (10 * snap_num) base_name = 'dwarf' rc('font', size = 15) fig = plt.figure() fig.set_figwidth(10) fig.set_figheight(6.5) fig.subplots_adjust(left = 0.10, right = 0.88, top = 0.92, bottom = 0.10, \ wspace = 0.0, hspace = 0.0) plt.figtext(0.5, 0.94, title, ha = 'center', size = 'large') majorLocator = ticker.MultipleLocator(20) minorLocator = ticker.MultipleLocator(4) nullFormatter = ticker.NullFormatter() cmap = mpl.cm.jet norm = mpl.colors.LogNorm() ################### hdc-81 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, '81-SG-4', base_name, snap_name, 1) ax = fig.add_subplot(231) arr = np.sort(rarr, order = 'T') # arr = arr[::-1] x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) T = arr['T'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = T[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e3, vmax = 1e7, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-91 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, '91-SG', base_name, snap_name, 1) ax = fig.add_subplot(232) arr = np.sort(rarr, order = 'T') # arr = arr[::-1] x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) T = arr['T'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = T[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e3, vmax = 1e7, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-101 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, '101-SG', base_name, snap_name, 8) ax = fig.add_subplot(233) arr = np.sort(rarr, order = 'T') # arr = arr[::-1] x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) T = arr['T'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) # plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = T[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e3, vmax = 1e7, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-80 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, '80-4', base_name, snap_name, 1) ax = fig.add_subplot(234) arr = np.sort(rarr, order = 'T') # arr = arr[::-1] x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) T = arr['T'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = T[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e3, vmax = 1e7, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) # ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-90 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, '90', base_name, snap_name, 1) ax = fig.add_subplot(235) arr = np.sort(rarr, order = 'T') # arr = arr[::-1] x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) T = arr['T'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = T[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e3, vmax = 1e7, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ################### hdc-100 #################################### ntot, time, rarr = mp.read_snap_paral(mp.prefix, '100', base_name, snap_name, 8) ax = fig.add_subplot(236) arr = np.sort(rarr, order = 'T') # arr = arr[::-1] x = arr['pos'][:, 0] y = arr['pos'][:, 1] z = arr['pos'][:, 2] type = arr['type'][:] r = np.sqrt(x * x + y * y + z * z) T = arr['T'][:] boolarr = np.logical_and(type == mp.TYPE_WARM, r < 50.0) # boolarr = np.logical_and(den > 5.0E-5, boolarr) idw = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_COLD, r < 50.0) idc = np.where(boolarr) boolarr = np.logical_and(type == mp.TYPE_STAR_PARAL, r < 50.0) ids = np.where(boolarr) width, height = rcParams['figure.figsize'] sz = min(width, height) plt.xlabel('X [kpc]') # plt.ylabel('Z [kpc]') plt.scatter(x[idw], z[idw], s = 1, c = T[idw], marker = 'o', \ cmap = cmap, norm = norm, vmin = 1e3, vmax = 1e7, edgecolors = 'none') ax.xaxis.set_major_locator(majorLocator) ax.xaxis.set_minor_locator(minorLocator) ax.yaxis.set_major_locator(majorLocator) ax.yaxis.set_minor_locator(minorLocator) # ax.xaxis.set_major_formatter(nullFormatter) ax.yaxis.set_major_formatter(nullFormatter) plt.xlim(-size, size * 0.99) plt.ylim(-size, size) ######################### color bar ################################## # [xcoord, ycoord, width, height] cbaxes = fig.add_axes([0.89, 0.10, 0.02, 0.82]) cb = plt.colorbar(orientation='vertical', \ ticks = ticker.LogLocator(base = 10.0), cax = cbaxes) cb.set_label('Temperature [K]') ######################## label ###################################### label = '$2\\times10^8 \mathsf{M}_\odot$' plt.figtext(0.23, 0.87, label, ha = 'center', size = 'large') label = '$2\\times10^9 \mathsf{M}_\odot$' plt.figtext(0.49, 0.87, label, ha = 'center', size = 'large') label = '$2\\times10^{10} \mathsf{M}_\odot$' plt.figtext(0.75, 0.87, label, ha = 'center', size = 'large') ########################## save ###################################### figure_name = 'TPanel-xz-' + snap_name + '.png' plt.savefig(figure_name)