Exemplo n.º 1
0
def magnification_demo():

	param = [[None] * len(origins) for j in range(len(mass_ratios))]
	plot = [[None] * len(origins) for j in range(len(mass_ratios))]
	fig, ax = plt.subplots(len(mass_ratios), len(origins))

	for (i, q) in enumerate(mass_ratios):
		for (j, origin) in enumerate(origins):
			idx = 1 + j + len(origins)*i

			# Initialize each binary lens system with the BinaryLens class.
			param[i][j] = ({'s': s, 'q': q, 'res': res, 'origin': origin,
					'region': region, 'region_lim': region_lim, 
					'solver': solver, 'SFD': SFD, 'refine_region': refine_region})
			plot[i][j] = BL(**param[i][j])

			# Get the data for the plots.

			cmap = plt.cm.YlOrRd
			cmaplist = [cmap(i) for i in range(cmap.N)]
			cmap = cmap.from_list('Custom cmap', cmaplist, cmap.N)
			ticks = np.array([1,10,100])

			kwargs = plot[i][j].check_kwargs()
			kwargs['cmap'] = cmap
			kwargs['norm'] = colors.LogNorm()
			kwargs['s'] = 1
			kwargs['lw'] = 0
			plot[i][j].get_position_arrays()
			plot[i][j].get_magnification_array()
			(x, y, magnification) = (plot[i][j].x_array, plot[i][j].y_array,
						plot[i][j].magn_array)

			# Create and adjust the plots appropriately.
			ax[i][j] = plt.subplot(len(mass_ratios), len(origins), idx)
			sc = ax[i][j].scatter(x, y, c=magnification, vmin=1, vmax=100, **kwargs)
			get_plot_parameters(plot=plot[i][j], ax=ax[i][j], i=i, j=j)

	# Add an axis for the color bar.
	cbar = fig.add_axes([0.08, 0.89, 0.60, 0.05])
	magn_color = plt.colorbar(sc, cax=cbar, cmap=kwargs['cmap'], ticks=ticks,
							  orientation='horizontal')
	magn_color.set_label('Magnification', fontsize=15, labelpad=-66)
	cbar.axes.tick_params(labelsize=12)

	get_plot_text(plot, fig)

	# Save the plot as a .png file.
	if save_fig:
		file_name = '../../Tables/magn_origin_.png'
		save_png(file_name)

	if show_fig:
		plt.show()
Exemplo n.º 2
0
for solver in solvers:
    for origin in origins:
        for q in mass_ratios:
            param.append(({
                's': s,
                'q': q,
                'res': res,
                'origin': origin,
                'solver': solver,
                'plot_frame': plot_frame,
                'region': region,
                'region_lim': region_lim,
                'refine_region': refine_region,
                'SFD': SFD
            }))
            plot.append(BL(**param[-1]))

plot_types = []
plot_types.append('num_images')
#plot_types.append('magn')
#plot_types.append('num_iamges_coeff')
#plot_types.append('magn_coeff')
#plot_types.append('coeff')
#plot_types.append('fits')

#plot_types.append('coeff_tstat')
#plot_types.append('position_tstat')

make_plot()
"""
causticMM = mm.Caustics(s=s, q=plot[0].q)
Exemplo n.º 3
0
def num_images_demo():

	param = [[None] * len(separations) for j in range(len(mass_ratios))]
	plot = [[None] * len(separations) for j in range(len(mass_ratios))]
	fig, ax = plt.subplots(len(mass_ratios), len(separations))

	for (i, q) in enumerate(mass_ratios):
		for (j, s) in enumerate(separations):
			idx = 1 + j + len(separations)*i

			# Initialize each binary lens system with the BinaryLens class.
			param[i][j] = ({'s': s, 'q': q, 'res': res, 'origin': origin,
					'region': region, 'region_lim': region_lim,
					'solver': solver, 'SFD': SFD, 'refine_region': refine_region})
			plot[i][j] = BL(**param[i][j])

			# Use our two base colormaps
			orng = plt.cm.Oranges
			blues = plt.cm.Blues

			# Get the list values from each colormap
			ornglist = [orng(i) for i in range(orng.N)] # This list contains 256 colors.
			blueslist = [blues(i) for i in range(blues.N)] # This list contains 256 colors.

			# Select the regions of the colormaps we want, and slice them together.
			start = 0
			jump = 24
			clist = np.linspace(start, start+8*jump, 6)	# Slicing points for merged list.
			clist = [int(val) for val in clist]		# Convert the list into integers.

			# Create the new list with segments of the Oranges and Blues colormaps.
			colorlist = (ornglist[clist[0]:clist[3]] + blueslist[clist[2]:clist[3]] +
						 ornglist[clist[4]:clist[5]] + blueslist[clist[4]:clist[5]])

			# Create new colormap.
			cmap_images = LinSegCmap.from_list('Custom cmap', colorlist, 256)

			# Discretize the colormap.
			bounds = np.linspace(-0.5, 5.5, 7)	# This is the discretized boundary.
			norm = colors.BoundaryNorm(bounds, cmap_images.N) # This is the scale.
			ticks = np.linspace(0,5,6)	# These are the tickmark locations.

			kwargs = plot[i][j].check_kwargs()
			kwargs['cmap'] = cmap_images
			kwargs['norm'] = norm
			kwargs['s'] = 1
			kwargs['lw'] = 0

			plot[i][j].get_position_arrays()
			plot[i][j].get_num_images_array()
			(x, y, num_images) = (plot[i][j].x_array, plot[i][j].y_array,
						plot[i][j].num_images)

			# Create and adjust the plots appropriately.
			ax[i][j] = plt.subplot(len(mass_ratios), len(separations), idx)
			sc = ax[i][j].scatter(x, y, c=num_images, vmin=0, vmax=5, **kwargs)
		#	caustic = caus(lens=plot[i][j], solver='SG12')
		#	caustic.plot_caustic(s=1, color='yellow', points=2000, lw=0)
			get_plot_parameters(plot=plot[i][j], ax=ax[i][j], i=i, j=j)

	# Add an axis for the color bar.
	cbar = fig.add_axes([0.12, 0.90, 0.60, 0.035])
	num_color = plt.colorbar(sc, cax=cbar, cmap=kwargs['cmap'], ticks=ticks,
				orientation='horizontal')
	num_color.set_label('Number of Images', fontsize=16, labelpad=-62)
	cbar.axes.tick_params(labelsize=12)
	get_plot_text(plot, fig)

	# Save the plot as a .png file.
	if save_fig:
		file_name = '../../Tables/images_plan_.png'
		save_png(file_name)

	if show_fig:
		plt.show()
Exemplo n.º 4
0
s1 = s
s2 = 1.2
q1 = q
q2 = 1e-3
phi = 0
system = 'SPM'

param = ({
    's': s,
    'q': q,
    'origin': originBL,
    'region': region,
    'solver': solver,
    'plot_frame': plot_frame
})
testBL = BL(**param)
causticBL = Caus(lens=testBL)

param = ({
    's1': s1,
    's2': s2,
    'q1': q1,
    'q2': q2,
    'phi': phi,
    'origin': originTL,
    'region': region,
    'solver': solver,
    'system': system,
    'plot_frame': plot_frame
})
testTL = TL(**param)
Exemplo n.º 5
0
def get_binary_lens_plot(save_fig=False,
                         show_fig=True,
                         arrow_on=True,
                         caustic_on=False):

    param = []
    plot = []

    param = (({
        's': s,
        'q': q,
        'origin': origin,
        'solver': solver,
        'plot_frame': plot_frame,
        'refine_region': refine_region,
        'SFD': SFD
    }))
    plot = (BL(**param))

    causticUL = caus(lens=plot)
    z1 = causticUL.z1
    z2 = causticUL.z2

    plt.scatter(z1.real, z1.imag, s=1000, color='blue')
    plt.scatter(z2.real, z2.imag, s=2000, color='red', marker='*')

    if arrow_on:
        ax = plt.axes()
        ax.arrow(z2.real + 0.05,
                 z2.imag,
                 z1.real - z2.real - 0.1,
                 z1.imag - z2.imag,
                 width=1e-6,
                 length_includes_head=True,
                 head_width=2e-2,
                 head_length=5e-2,
                 fc='k',
                 ec='k')
        ax.arrow(z1.real - 0.05,
                 z1.imag,
                 z2.real - z1.real + 0.1,
                 z1.imag - z2.imag,
                 width=1e-6,
                 length_includes_head=True,
                 head_width=2e-2,
                 head_length=5e-2,
                 fc='k',
                 ec='k')

    if caustic_on:
        caustic = caus(lens=plot)
        caustic.plot_caustic(s=1, lw=0, color='orange')

    title = 'Binary Lens System'
    got_plot_adjustments(title=title)

    if save_fig:
        name = 'BL_model'
        _save_fig(name, arrow_on, caustic_on)

    if show_fig:
        plt.show()
    else:
        plt.clf()
Exemplo n.º 6
0
# Zoey Samples
# Created: Jun 7, 2018
# test.py
# Last Updated: Jun 25, 2018

from BinaryLens import BinaryLens as BL
import MulensModel as mm
import matplotlib.pyplot as plt

solver = 'zroots'
origin = 'plan'

x = [0.0, 1.3219, 1.0799, 1.2489]
y = [0.0, -0.0771, 0.0985, 0.0209]
s = [1.0, 1.35, 1.1, 0.9357]
q = [1.0, 0.00578, 0.99, 0.99]

param = []
test = []
for i in range(len(x)):
	param.append({'x': x[i], 'y': y[i], 's': s[i], 'q': q[i], 'origin': origin,
					 'solver': solver}) 
	test.append(BL(**param[-1]))


for t in test:
	t.print_image_position(print_input=False)
	t.print_magnification(print_input=False)
	print('_'*40)