Exemplo n.º 1
0
    def get_lims(self, t, temp_map=False, use_phase=False):
        if use_phase == True:
            t = self.t0 + self.per * t

        planet = sp.generate_planet(self, t)
        if temp_map == True:
            b_i = 17
        else:
            b_i = 16

        temps = planet[:, b_i]

        return [np.min(temps), np.max(temps)]
Exemplo n.º 2
0
    def get_lims(self,t,temp_map=False,use_phase=False):
        if use_phase == True:
            if self.t0 == None:
                self.t0 = 0.0
            if self.per == None:
                self.per = 1.0
            t = self.t0 + self.per*t

        planet = sp.generate_planet(self,t)
        if temp_map == True:
            b_i = 17
        else:
            b_i = 16

        temps = planet[:,b_i]

        return [np.min(temps),np.max(temps)]
Exemplo n.º 3
0
def plot_planet(spider_params,
                t,
                ax=False,
                min_temp=False,
                max_temp=False,
                temp_map=False,
                min_bright=0.2,
                scale_planet=1.0,
                planet_cen=[0.0, 0.0],
                mycmap=plt.cm.inferno,
                show_cax=True,
                theme='black',
                show_axes=False):

    if theme == 'black':
        bg = 'black'
        tc = ("#04d9ff")
    else:
        bg = 'white'
        tc = 'black'

    if ax == False:
        f, ax = plt.subplots(facecolor=bg)
        new_ax = True
    else:
        new_ax = False

    planet = sp.generate_planet(spider_params, t)

    if temp_map == True:
        b_i = 17
    else:
        b_i = 16

    if min_temp == False:
        temps = planet[:, b_i]
        min_temp = np.min(temps)
        max_temp = np.max(temps)

    dp = ((max_temp - min_temp) * min_bright)

    for j in range(0, len(planet)):
        val = (dp + planet[j][b_i] - min_temp) / (dp + max_temp - min_temp)
        c = mycmap(val)

        n = planet[j]

        r1 = n[13] * scale_planet
        r2 = n[14] * scale_planet
        radii = [r1, r2]

        thetas = np.linspace(n[10], n[11], 100)

        xs = np.outer(radii, np.cos(thetas)) + planet_cen[0]
        ys = np.outer(radii, np.sin(thetas)) + planet_cen[1]

        xs[1, :] = xs[1, ::-1]
        ys[1, :] = ys[1, ::-1]

        ax.fill(np.ravel(xs), np.ravel(ys), edgecolor=c, color=c, zorder=2)

    ax.set_axis_bgcolor(bg)

    if show_axes == False:
        ax.spines['bottom'].set_color(bg)
        ax.spines['left'].set_color(bg)
        ax.spines['top'].set_color(bg)
        ax.spines['right'].set_color(bg)
    else:
        ax.spines['bottom'].set_color(tc)
        ax.spines['left'].set_color(tc)
        ax.spines['top'].set_color(tc)
        ax.spines['right'].set_color(tc)

    ax.set(aspect=1)

    bs = 1.1
    ax.set_xlim(+bs, -bs)
    ax.set_ylim(-bs, +bs)

    if new_ax == True:
        bs = 1.1
        ax.set_xlim(+bs, -bs)
        ax.set_ylim(-bs, +bs)

    if show_axes == False:
        ax.get_xaxis().set_visible(False)
        ax.get_yaxis().set_visible(False)
    else:
        ax.get_xaxis().set_visible(True)
        ax.get_yaxis().set_visible(True)

    divider = make_axes_locatable(ax)
    # Append axes to the right of ax, with 20% width of ax

    #	zero_temp = min_temp - dp
    zero_temp = min_temp
    data = [np.linspace(zero_temp, max_temp, 1000)] * 2
    fake, fake_ax = plt.subplots()
    mycax = fake_ax.imshow(data, interpolation='none', cmap=mycmap)
    plt.close(fake)

    if show_cax == True:
        cax = divider.append_axes("right", size="20%", pad=0.05)
        #	cbar = plt.colorbar(mycax, cax=cax,ticks=[1100,1300,1500,1700,1900])
        cbar = plt.colorbar(mycax, cax=cax)
        cbar.ax.tick_params(colors=tc)

        if temp_map == True:
            cbar.set_label('T (K)', color=tc)  # horizontal colorbar
        else:
            cbar.set_label('Relative brightness',
                           color=tc)  # horizontal colorbar

    return ax
Exemplo n.º 4
0
    def phase_brightness(self,
                         phases,
                         stellar_grid=False,
                         reflection=False,
                         planet_radius=False):

        if self.thermal == True:
            if stellar_grid == False:
                stellar_grid = sp.stellar_grid.gen_grid(self.l1,
                                                        self.l2,
                                                        logg=4.5,
                                                        response=self.filter)
                teffs = stellar_grid[0]
                totals = stellar_grid[1]
            else:
                teffs = stellar_grid[0]
                totals = stellar_grid[1]
        else:
            teffs = []
            totals = []

        if type(phases) is not list: phases = [phases]

        brightness_params = self.format_bright_params()

        out_list = []
        for phase in phases:

            t = 0.0 + np.array([phase])

            if (self.t0 == None):
                self.t0 = 0.0

            if (self.per == None):
                self.per = 1.0

            if (self.inc == None):
                self.inc = 90.0

            if (self.p_u1 == None):
                self.p_u1 = 0.0

            if (self.p_u2 == None):
                self.p_u2 = 0.0

            if (self.a == None):
                self.a = 4.0

            if (self.w == None):
                self.w = 0.0

            if (self.ecc == None):
                self.ecc = 0.0

            if (self.a_abs == None):
                self.a_abs = 1.0

            planet = sp.generate_planet(self, t, stellar_grid=stellar_grid)

            brights = planet[:, 16]
            areas = planet[:, 15]
            inner = planet[:, 13]
            outer = planet[:, 14]

            avg_dist = ((inner + outer) / 2) * np.pi / 2
            avg_dist[0] = 0.0

            norm = np.sqrt(np.cos(avg_dist))

            min_bright = np.min(brights)
            max_bright = np.max(brights)

            if planet_radius == False:
                out = np.sum(brights * areas) / np.pi
            else:
                out = np.sum(brights * areas / norm) * planet_radius**2

            out_list += [out]

#			out = _web.lightcurve(self.n_layers,t,0.0,1.0,self.a_abs,self.inc,0.0,0.0,self.a,self.rp,self.p_u1,self.p_u2,self.brightness_type,brightness_params,teffs,totals,len(totals),0)[0] - 1.0
#			out_list += [out]

        if len(out_list) == 1:
            return out_list[0]

#		returns the total flux of the planet at each phase in the defined bandpass in Watts / m^2 / sr

        return out_list
Exemplo n.º 5
0
    def phase_brightness(self,phases,stellar_grid=False,reflection=False,planet_radius=False):

        if self.thermal == True:
            if stellar_grid == False:
                stellar_grid = sp.stellar_grid.gen_grid(self.l1,self.l2,logg=4.5,response=self.filter, stellar_model = self.stellar_model)
                teffs = stellar_grid[0]
                totals = stellar_grid[1]
            else:
                teffs = stellar_grid[0]
                totals = stellar_grid[1]
        else:
            teffs = []
            totals = []

        if type(phases) is not list: phases = [phases]

        brightness_params = self.format_bright_params()

        out_list = []
        for phase in phases:

            t = 0.0 + np.array([phase])

            if(self.t0 == None):
                self.t0 = 0.0

            if(self.per == None):
                self.per = 1.0

            if(self.inc == None):
                self.inc = 90.0

            if(self.p_u1 == None):
                self.p_u1 = 0.0

            if(self.p_u2 == None):
                self.p_u2 = 0.0

            if(self.a == None):
                self.a = 4.0

            if(self.w == None):
                self.w = 0.0

            if(self.ecc == None):
                self.ecc = 0.0


            if(self.a_abs == None):
                self.a_abs = 1.0


            planet = sp.generate_planet(self,t,stellar_grid=stellar_grid)

            brights = planet[:,16]
            areas = planet[:,15]
            inner = planet[:,13]
            outer = planet[:,14]

            avg_dist = ((inner + outer)/2)*np.pi/2
            avg_dist[0] = 0.0

            norm = np.sqrt(np.cos(avg_dist))

            min_bright = np.min(brights)
            max_bright = np.max(brights)

            if planet_radius == False:
                out = np.sum(brights*areas)/np.pi
            else:
                out = np.sum(brights*areas/norm)*planet_radius**2

            out_list += [out]

#            out = _web.lightcurve(self.n_layers,t,0.0,1.0,self.a_abs,self.inc,0.0,0.0,self.a,self.rp,self.p_u1,self.p_u2,self.brightness_type,brightness_params,teffs,totals,len(totals),0)[0] - 1.0
#            out_list += [out]


        if len(out_list) == 1:
            return out_list[0]

#        returns the total flux of the planet at each phase in the defined bandpass in Watts / m^2 / sr

        return out_list
Exemplo n.º 6
0
def plot_planet(spider_params,t,ax=False,min_temp=False,max_temp=False,temp_map=False,min_bright=0.2,scale_planet=1.0,planet_cen=[0.0,0.0],use_phase=False,show_cax=True,mycmap=plt.cm.inferno,theme='white',show_axes=False):

	if theme == 'black':
		bg = 'black'
		tc = ("#04d9ff")
	else:
		bg = 'white'
		tc = 'black'

	if use_phase == True:
		t = spider_params.t0 + spider_params.per*t

	if ax == False:
		f, ax = plt.subplots(facecolor=bg)
		new_ax = True
	else:
		new_ax = False

	planet = sp.generate_planet(spider_params,t)

	if temp_map == True:
		b_i = 17
	else:
		b_i = 16

	if min_temp == False:
		temps = planet[:,b_i]
		min_temp = np.min(temps)*0.9
		max_temp = np.max(temps)*1.1

	temps = planet[:,b_i]


	dp = ((max_temp-min_temp)*min_bright)


	if((max_temp - min_temp) < 1e-18):
		dp = 0
		min_temp = max_temp

	for j in range (0,len(planet)):


#		if dp == 0.0:
#			val = 1
#		else:
#			val = (dp + planet[j][b_i]-min_temp)/(dp + max_temp-min_temp)

#		print(val,(dp + planet[j][b_i]-min_temp),(dp + max_temp-min_temp))

		val = (planet[j][b_i]-min_temp)/(max_temp-min_temp)

		c = mycmap(val)

		n = planet[j]

		r1 = n[13]*scale_planet
		r2 = n[14]*scale_planet
		radii = [r1,r2]

		thetas = np.linspace(n[10],n[11],100)

		xs = np.outer(radii, np.cos(thetas)) + planet_cen[0]
		ys = np.outer(radii, np.sin(thetas)) + planet_cen[1]

		xs[1,:] = xs[1,::-1]
		ys[1,:] = ys[1,::-1]

		ax.fill(np.ravel(xs), np.ravel(ys), edgecolor=c,color=c,zorder=2)



	ax.set_axis_bgcolor(bg)

	if show_axes == False:
		ax.spines['bottom'].set_color(bg)
		ax.spines['left'].set_color(bg)
		ax.spines['top'].set_color(bg)
		ax.spines['right'].set_color(bg)
	else:
		ax.spines['bottom'].set_color(tc)
		ax.spines['left'].set_color(tc)
		ax.spines['top'].set_color(tc)
		ax.spines['right'].set_color(tc)

	ax.set(aspect=1)

	bs = 1.1
	ax.set_xlim(+bs,-bs)
	ax.set_ylim(-bs,+bs)

	if new_ax == True:
		bs = 1.1
		ax.set_xlim(+bs,-bs)
		ax.set_ylim(-bs,+bs)

	if show_axes == False:
		ax.get_xaxis().set_visible(False)
		ax.get_yaxis().set_visible(False)
	else:
		ax.get_xaxis().set_visible(True)
		ax.get_yaxis().set_visible(True)

	divider = make_axes_locatable(ax)
	# Append axes to the right of ax, with 20% width of ax

#	zero_temp = min_temp - dp
	zero_temp = min_temp
	data = [np.linspace(zero_temp,max_temp,1000)]*2
	fake, fake_ax = plt.subplots()
	mycax = fake_ax.imshow(data, interpolation='none', cmap=mycmap)
	plt.close(fake)

	if show_cax == True:
		cax = divider.append_axes("right", size="20%", pad=0.05)
	#	cbar = plt.colorbar(mycax, cax=cax,ticks=[1100,1300,1500,1700,1900])
		cbar = plt.colorbar(mycax, cax=cax)
		cbar.ax.tick_params(colors=tc)

		if temp_map == True:
			cbar.set_label('T (K)',color=tc)  # horizontal colorbar
		else:
			cbar.set_label('Relative brightness',color=tc)  # horizontal colorbar

	return ax
Exemplo n.º 7
0
def plot_dist(spider_params,temps,ax=False,min_temp=False,max_temp=False,temp_map=False,min_bright=0.2,scale_planet=1.0,planet_cen=[0.0,0.0],mycmap=plt.get_cmap('viridis_r'),show_cax=True,theme='black',show_axes=False):

	if theme == 'black':
		bg = 'black'
		tc = ("#04d9ff")
	else:
		bg = 'white'
		tc = 'black'

	if ax == False:
		f, ax = plt.subplots(facecolor=bg)
		new_ax = True
	else:
		new_ax = False

	planet = sp.generate_planet(spider_params,0,use_phase=True)

	if min_temp == False:
		min_temp = np.min(temps)
		max_temp = np.max(temps)


	dp = ((max_temp-min_temp)*min_bright)

	for j in range (0,len(planet)):
		val = (dp + temps[j]-min_temp)/(dp + max_temp-min_temp)
		c = mycmap(val)

		n = planet[j]

		r1 = n[13]*scale_planet
		r2 = n[14]*scale_planet
		radii = [r1,r2]

		thetas = np.linspace(n[10],n[11],100)

		xs = np.outer(radii, np.cos(thetas)) + planet_cen[0]
		ys = np.outer(radii, np.sin(thetas)) + planet_cen[1]

		xs[1,:] = xs[1,::-1]
		ys[1,:] = ys[1,::-1]

		ax.fill(np.ravel(xs), np.ravel(ys), edgecolor=c,color=c,zorder=2)


	ax.set_axis_bgcolor(bg)

	if show_axes == False:
		ax.spines['bottom'].set_color(bg)
		ax.spines['left'].set_color(bg)
		ax.spines['top'].set_color(bg)
		ax.spines['right'].set_color(bg)
	else:
		ax.spines['bottom'].set_color(tc)
		ax.spines['left'].set_color(tc)
		ax.spines['top'].set_color(tc)
		ax.spines['right'].set_color(tc)

	ax.set(aspect=1)

	bs = 1.1
	ax.set_xlim(+bs,-bs)
	ax.set_ylim(-bs,+bs)

	if new_ax == True:
		bs = 1.1
		ax.set_xlim(+bs,-bs)
		ax.set_ylim(-bs,+bs)

	if show_axes == False:
		ax.get_xaxis().set_visible(False)
		ax.get_yaxis().set_visible(False)
	else:
		ax.get_xaxis().set_visible(True)
		ax.get_yaxis().set_visible(True)

	divider = make_axes_locatable(ax)
	# Append axes to the right of ax, with 20% width of ax

#	zero_temp = min_temp - dp
	zero_temp = min_temp
	data = [np.linspace(zero_temp,max_temp,1000)]*2
	fake, fake_ax = plt.subplots()
	mycax = fake_ax.imshow(data, interpolation='none', cmap=mycmap)
	plt.close(fake)

	if show_cax == True:
		cax = divider.append_axes("right", size="20%", pad=0.05)
	#	cbar = plt.colorbar(mycax, cax=cax,ticks=[1100,1300,1500,1700,1900])
		cbar = plt.colorbar(mycax, cax=cax)
		cbar.ax.tick_params(colors=tc)
		cbar.ax.invert_yaxis()

		if temp_map == True:
			cbar.set_label(r'Temperature precision (\%)',color=tc)  # horizontal colorbar
		else:
			cbar.set_label(r'Flux precision (\%)',color=tc)  # horizontal colorbar

	return ax