<jupyter_start><jupyter_text>Real-Time Energy-Balance Model (Interactive)  Interactive Model with SlidersThis code starts with the most normal Earth circumstances: albedo of 0.32, solar flux of 1373 watts per meter squared, and epsilon of 0.78. It then animates a line that acts as an active signal that can be adjsuted by sliders for those three properties. This serves to illustrate how the temperature is affected by changing properties.<jupyter_code>#Import libraries
%matplotlib widget
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button
import matplotlib.animation as animation

#constants
C = 2.08e8
alpha = 0.32
epsilon = 0.78 #key value
sigma = 5.67e-8
S = 1373
T_a = 242.4


#step array
step = []
temp = []


#Create figure and make space for sliders
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
plt.title('Energy Balance Model')
plt.subplots_adjust(left=0.25, bottom=0.25)

#Sliders
#Each slider has its own axis, and takes the 
#min val, max val, and initial val
axflux = plt.axes([0.1, 0.25, 0.0225, 0.63])
slider_flux = Slider(
    ax=axflux,
    label="Flux",
    valmin=900,
    valmax=1600,
    valinit=1373,
    orientation="vertical"
)

axalpha = plt.axes([0.25, 0.05, 0.65, 0.03])
slider_alpha = Slider(
    ax=axalpha,
    label="Albedo",
    valmin=0.1,
    valmax=0.6,
    valinit=0.32,
    orientation="horizontal"
)

axemis = plt.axes([0.25, 0.1, 0.65, 0.03])
slider_emis = Slider(
    ax = axemis,
    label = "Emissivity",
    valmin = 0.5,
    valmax = 0.9,
    valinit = 0.78,
    orientation= "horizontal"
)

#Animation function. Updates for each "i"
def animate(i):
    step.append(i)
    temp.append((((1 - slider_alpha.val)*(slider_flux.val) + (slider_emis.val*sigma*T_a**4))/(4*sigma))**(1/4))
    ax1.set_ylim(220,320)
    ax1.plot(step, temp, color = 'green')
    ax1.set_xlabel('Step')
    ax1.set_ylabel('Temperature (K)')


ani = animation.FuncAnimation(fig, animate, interval = 80)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1263681592039801, 'fraction_numerical': 0.05970149253731343, 'mean_word_length': 3.965432098765432, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '34780', 'license': 'MIT', 'n_tokens_mistral': 819, 'n_tokens_neox': 732, 'n_words': 207, 'path': 'EnergySlider_Interactive.ipynb', 'repo_name': 'CarlosECarrilloGallegos/EnergyBalanceModel', 'size': '2010'}