Ejemplo n.º 1
0
def load_src(name, fpath):
    import os, imp
    return imp.load_source(name, os.path.join(os.path.dirname(__file__), fpath))

load_src("torch", "../torchpack/torch.py")
load_src("hgspy", "../torchpack/hgspy.py")

import torch
import hgspy

DPI = 300
figformat = 'png'
plot_size = 5
fontsize = 16
torch.set_font_sizes(fontsize=16)

inputfile1 = "data/galsim/starpop-hm-a.txt"

data1 = np.genfromtxt(inputfile1, skip_header=1)

def plot_scatter(ax, dat, colormap):
    x = dat[:,12]
    y = dat[:,13]

    xy = np.vstack([x,y])
    z = scipy.stats.gaussian_kde(xy)(xy)

    idx = z.argsort()
    x, y, z = x[idx], y[idx], z[idx]
Ejemplo n.º 2
0
def load_src(name, fpath):
    import os, imp
    return imp.load_source(name, os.path.join(os.path.dirname(__file__), fpath))

load_src("torch", "../torchpack/torch.py")
load_src("hgspy", "../torchpack/hgspy.py")

import torch
import hgspy

DPI = 300
figformat = 'png'
plot_size = 5
fontsize = 16
outputfile_qlyc = "mass-vs-qlyc.png"
torch.set_font_sizes(fontsize)

data = np.genfromtxt("refdata/zams.txt", skip_header=1)

### Data set up.

mass = data[:,0]
qlyc = data[:,6]

### Plotting.
plotter = torch.Plotter(1, 1, plot_size, figformat, DPI)

###	Axes.
grid = plotter.axes1D((1,1), aspect_ratio=0.75)
grid[0].set_xlabel(plotter.format_label(torch.VarType('M_\star', units='M_{\odot}')))
grid[0].set_ylabel(plotter.format_label(torch.VarType('Q_\\mathrm{Lyc}', units='s^{-1}', isLog10=True)))
Ejemplo n.º 3
0
def plot():
	import warnings
	import sys
	def load_src(name, fpath):
		import os, imp
		return imp.load_source(name, os.path.join(os.path.dirname(__file__), fpath))

	load_src("torch", "../torchpack/torch.py")
	load_src("hgspy", "../torchpack/hgspy.py")

	import torch
	import hgspy

	DPI = 300
	figformat = 'png'
	plot_size = 5
	fontsize = 16
	plot_type = "ssw" # ["if", "hii", "ssw"]
	outputfile_qlyc = "henney-" + plot_type + ".png"

	torch.set_font_sizes(fontsize)

	### Data
	lmp = []
	lmn = []
	lhp = []
	lhn = []
	lcie = []
	lpdr = []
	ltot = []

	if plot_type == "ssw":
		nh = 1
	elif plot_type == "hii":
		nh = 1000
	else:
		nh = 10000

	hii = 1.0
	if plot_type == "if":
		hii = 0.5
	N = 1001
	minlogT = 4.0
	maxlogT = 8.0
	if plot_type == "if" or plot_type == "hii":
		minlogT = 3.8
		maxlogT = 4.0
	isLog = True

	nhii = hii * nh
	nhi = (1.0 - hii) * nh

	if not isLog:
		tem = np.linspace(10.0**minlogT, 10.0**maxlogT, N, endpoint=True)
	else:
		tem = np.linspace(minlogT, maxlogT, N, endpoint=True)

	for i in range(len(tem)):
		itemp = tem[i]
		if isLog:
			itemp = math.pow(10.0, itemp)
		lmp.append(coolCollExcIonMetals(nhii, itemp))
		lmn.append(coolCollExcNeuMetals(nhii, nhi, itemp))
		lhp.append(coolFreeFree(nhii, itemp))
		lhn.append(coolCollExcNeuHydrogen(nhii, nhi, itemp))
		lcie.append(coolCIE(nhii, itemp))
		lpdr.append(coolPDR(nhi, itemp))
		ltot.append(lmp[i] + lmn[i] + lhp[i] + lhn[i] + lcie[i] + lpdr[i])

	### Plotting.
	plotter = torch.Plotter(1, 1, plot_size, figformat, DPI)

	###	Axes.
	grid = plotter.axes1D((1,1), aspect_ratio=0.75)
	grid[0].set_xlabel(plotter.format_label(torch.VarType('T', units='K', isLog10=True)))
	grid[0].set_ylabel(plotter.format_label(torch.VarType('C', units='erg\\:s^{-1}\\:cm^{-3}', isLog10=False)))

	### Plot.
	if plot_type == "if":
		grid[0].plot(tem, lmn, label=r"$C_\mathrm{M^0}$", color='m')
		grid[0].plot(tem, lhn, label=r"$C_\mathrm{H^0}$", color='y')
		grid[0].plot(tem, lmp, label=r"$C_\mathrm{M^+}$", color='g')
		grid[0].plot(tem, lhp, label=r"$C_\mathrm{H^+}$", color='r')
		grid[0].plot(tem, ltot, label=r"$C_\mathrm{tot}$", color='k')
	elif plot_type == "hii":
		grid[0].plot(tem, lmp, label=r"$C_\mathrm{M^+}$", color='g')
		grid[0].plot(tem, lhp, label=r"$C_\mathrm{H^+}$", color='r')
		grid[0].plot(tem, ltot, label=r"$C_\mathrm{tot}$", color='k')
	elif plot_type == "ssw":
		grid[0].plot(tem, lmp, label=r"$C_\mathrm{M^+}$", color='g')
		grid[0].plot(tem, lhp, label=r"$C_\mathrm{H^+}$", color='r')
		grid[0].plot(tem, lcie, label=r"$C_\mathrm{CIE}$", color='b')
		grid[0].plot(tem, ltot, label=r"$C_\mathrm{tot}$", color='k')

	grid[0].set_xlim([minlogT, maxlogT])
	if plot_type == "ssw":
		grid[0].legend(loc='upper right')
	else:
		grid[0].legend(loc='upper left')

	###	Save figure.
	with warnings.catch_warnings():
		warnings.simplefilter("ignore")
		plotter.save_plot(outputfile_qlyc)

	print sys.argv[0] + ': plotted in ' + outputfile_qlyc