用户d的基本for循环问题

2024-09-28 22:24:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我的目标是创建一个温度(Te)曲线图,作为太阳常数(S0)的函数,范围从500到3000。使用行星反照率(αp)值0.16(火星)、0.29(地球)和0.71(金星)。你知道吗

我正在尝试使用for循环来插入我的太阳常数(从500到3000),并将值保存到Te,这样我就可以绘图了。但是我在运行for循环时遇到了问题。你知道吗

# Plot Planetary emission temperature as a function of solar constant
# ranging from 500 to 3000 W m^-2
# Define known variables

index = 'Mars'; # user-input planet name

sigma = 5.67 * 10**-8;
solar_flux = np.arange(500,3001,1);
df = pd.DataFrame({'planet_albedo': [0.16, 0.29, 0.71]}, 
                  index=['Mars', 'Earth', 'Venus'])


save_temp_e = []; # empty list to append values to

for i in range(len(solar_flux)): 
    Temp_e = np.array(((solar_flux[i]/(sigma*4))(1-df.planet_albedo[index]))/sigma)**(1/4);
    save_temp_e.append(Temp_e)

我不断出现错误,例如:

TypeError: 'int' object is not iterable.


Tags: todfforindexsavenp常数temp
1条回答
网友
1楼 · 发布于 2024-09-28 22:24:54

我尝试了你的代码,但我得到了一个错误'numpy.float64' object is not callable。你知道吗

您的公式不正确,可能缺少*符号:

Temp_e = np.array(((solar_flux[i]/(sigma*4)) * (1-df.planet_albedo[index]))/sigma)**(1/4)

相关问题 更多 >