File:Slushball earth temperature s 1p0sol co2 2.5ppm 2.png

Original file(1,011 × 574 pixels, file size: 163 KB, MIME type: image/png)

Captions

Captions

Temperature of snowball Earth throughout the year if CO2 1 ppmv and S=1 sol

Summary edit

Description
English: Temperature of snowball Earth throughout the year if CO2 1 ppmv and S=1 sol
Date
Source Own work
Author Merikanto
Python climlab source code
####################################3
#
## slushball Earth
#
## seasonal climlab energy balance model
# python3/climlab code
#
# 23.10.2023 0000.0004a
#
##########################3

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import climlab
from climlab import constants as const
from climlab.process.diagnostic import DiagnosticProcess
from climlab.domain.field import Field, global_mean

 

numyears=10
plotvar=0 ## 1,2,3 lot temp, ice, mean albedo

S1=1365.2*1
#S1=1361*0.93

co2=2.5


orbit={'ecc': 0.0167643, 'long_peri': 280.32687, 'obliquity': 23.459277, 'S0':S1}

#orbit={'ecc': 0.0, 'long_peri': 0.0, 'obliquity': 0.0, 'S0':S1}

title0='       Slushball Earth '
title1='Temperatures throughout the year °C \n if S0 = '+ str(S1) +' W m-2 , pressure of CO2 = '+str(co2)+' ppm volume'


class tanalbedo(DiagnosticProcess):

    def __init__(self, **kwargs):
        super(tanalbedo, self).__init__(**kwargs)

        self.add_diagnostic('albedo')
        Ts = self.state['Ts']
        self._compute_fixed()

    def _compute_fixed(self):
        Ts = self.state['Ts']
        try:
            lon, lat = np.meshgrid(self.lon, self.lat)
        except:
            lat = self.lat
        phi = lat

        try:
            albedo=np.zeros(len(phi));
            albedo=0.42-0.20*np.tanh(0.052*(Ts-3))

        except:
            albedo = np.zeros_like(phi)

        dom = next(iter(self.domains.values()))
        self.albedo = Field(albedo, domain=dom)

    def _compute(self):
        self._compute_fixed()

        return {}


# creating EBM model

#ebm= climlab.EBM(CO2=co2,orbit={'ecc': 0.0167643, 'long_peri': 280.32687, 'obliquity': 23.459277, 'S0':S1})
ebm0= climlab.EBM_seasonal(water_depth=10.0, a0=0.3, num_lat=90, lum_lon=None, num_lev=10,num_lon=None
, orbit=orbit)


ebm=climlab.process_like(ebm0)


#ebm.step_forward()
#print(ebm.diagnostics)


#quit(-1)

surface = ebm.domains['Ts']
# define new insolation and SW process



ebm.remove_subprocess('insolation')
insolation = climlab.radiation.DailyInsolation(domains=surface, orb = orbit, **ebm.param)
insolation.S0=S1

##sun = climlab.radiation.DailyInsolation(domains=model.Ts.domain)
ebm.add_subprocess('insolation', insolation)

#ebm.step_forward()


#print(insolation.diagnostics)

#print (insolation.insolation)
#print (np.max(insolation.insolation))


##print(insolation.S0)

#quit(-1)

ebm.remove_subprocess('albedo')
alb = climlab.surface.albedo.StepFunctionAlbedo(state=ebm.state, Tf=-10, **ebm.param)
#alb = climlab.surface.albedo.ConstantAlbedo(domains=surface, **ebm.param)
#alb = tanalbedo(state=ebm.state, **ebm.param)
ebm.add_subprocess('albedo', alb)
ebm.remove_subprocess('SW')
SW = climlab.radiation.absorbed_shorwave.SimpleAbsorbedShortwave(insolation=insolation.insolation, state = ebm.state, albedo = alb.albedo, **ebm.param)
ebm.add_subprocess('SW', SW)
ebm.remove_subprocess('Lw')
LW = climlab.radiation.aplusbt.AplusBT_CO2(CO2=co2,state=ebm.state, **ebm.param)
ebm.add_subprocess('LW', LW)


#print(SW.diagnostics)




#quit(-1)

#ebm.CO2=co2
ebm.remove_subprocess('diffusion')
diff = climlab.dynamics.MeridionalMoistDiffusion(state=ebm.state, timestep=ebm.timestep)
ebm.add_subprocess('diffusion', diff)


#print (ebm)


ebm.step_forward()

#ebm.diagnostics

#ebm.integrate_years(numyears)
ebm.integrate_converge()

#print(ebm.Ts)

#plt.plot(ebm.Ts)

#plt.show()

num_steps_per_year = int(ebm.time['num_steps_per_year'])
mean_year = np.empty(num_steps_per_year)
for m in range(num_steps_per_year):
	ebm.step_forward()
	mean_year[m] = ebm.global_mean_temperature()
Tmean_year = np.mean(mean_year)

print(round(Tmean_year,2))



if(plotvar==0):
        num_steps_per_year = int(ebm.time['num_steps_per_year'])
        Tyear = np.empty((ebm.lat.size, num_steps_per_year))
        for m in range(num_steps_per_year):
            ebm.step_forward()
            Tyear[:,m] = np.squeeze(ebm.Ts)
        Tmin=np.min(Tyear)
        Tmax=np.max(Tyear)
        
        fig = plt.figure(figsize=(5,5))
        ax = fig.add_subplot(111)
        
        factor = 365. / num_steps_per_year
        #cmap1=plt.cm.seismic
        #cmap1=plt.cm.turbo
        cmap1=plt.cm.coolwarm
        #cmap1=plt.cm.winter
        #cmap1=plt.cm.cool_r
        #cmap1=plt.cm.cool
        #cmap1=cmap1.reversed()      
        #levels1=[-80,-70,-60,-50,-40,-30]
        levels2=[-200,-100,-70,-60,-50,-40,-30,-20,-10,0,10,20,30,40,50,60,80,100,200,300,500]
        Tminv=-100
        Tmaxv=120
        #cax = ax.contourf(factor * np.arange(num_steps_per_year),
        #              ebm.lat, Tyear[:,:], 
        #              cmap=cmap1, vmin=Tminv, vmax=Tmaxv, antialiased=False, levels=256)
        ax.imshow(Tyear[:,:],origin="lower", extent=[0,360,-90,90],cmap=cmap1, vmin=Tminv, vmax=Tmaxv, interpolation="bicubic")
        cs1 = ax.contour(factor * np.arange(num_steps_per_year),ebm.lat, Tyear[:,:],   origin="lower", extent=[0,360,-90,90],colors='#00005f', vmin=Tminv, vmax=Tmaxv, levels=levels2)
        ax.clabel(cs1, cs1.levels, inline=True, fontsize=14)                     
        #cbar1 = plt.colorbar(cax)
        ax.set_title(title1, fontsize=12)
        fig.suptitle(title0, fontsize=22)
        ##ax_set_suptitle(title0, fontsize=18)
        ax.tick_params(axis='x', labelsize=12)
        ax.tick_params(axis='y', labelsize=12)
        ax.set_xlabel('Days of year', fontsize=13)
        ax.set_ylabel('Latitude', fontsize=13)
        plt.tight_layout()
        plt.savefig('1000dpi.svg', dpi=1000)

if(plotvar==1):
        if 'Tf' in ebm.subprocess['albedo'].param.keys():
            Tf = ebm.subprocess['albedo'].param['Tf']
        else:
            print('No ice considered in this model. Can not plot.')

        num_steps_per_year = int(ebm.time['num_steps_per_year'])
        ice_year = np.empty((ebm.lat.size, num_steps_per_year))
        for m in range(num_steps_per_year):
            ebm.step_forward()
            ice_year[:,m] = np.where(np.squeeze(ebm.Ts) <= Tf, 0, 1)
        
        fig = plt.figure(figsize=(5,5))
        ax = fig.add_subplot(111)
        
        factor = 365. / num_steps_per_year
        cax = ax.contourf(factor * np.arange(num_steps_per_year),
                      ebm.lat, ice_year[:,:], 
                      cmap=plt.cm.seismic, vmin=0, vmax=1, levels=2)
        cbar1 = plt.colorbar(cax)
        
        ax.set_title('Ice throughout the year', fontsize=14)
        ax.set_xlabel('Days of year', fontsize=14)
        ax.set_ylabel('Latitude', fontsize=14)


if(plotvar==2):
        fig = plt.figure(figsize=(7.5,5))

        # Temperature plot
        ax2 = fig.add_subplot(111)
        ax2.plot(ebm.lat,ebm.albedo)

        ax2.set_title('Albedo', fontsize=14)
        ax2.set_xlabel('latitude', fontsize=10)
        ax2.set_ylabel('', fontsize=12)

        ax2.set_xticks([-90,-60,-30,0,30,60,90])
        ax2.set_xlim([-90,90])
        ax2.set_ylim([0,1])
        ax2.grid()

    
        plt.show()



plt.show()

Licensing edit

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current06:39, 23 October 2023Thumbnail for version as of 06:39, 23 October 20231,011 × 574 (163 KB)Merikanto (talk | contribs)Update of code
15:18, 17 May 2023Thumbnail for version as of 15:18, 17 May 20231,350 × 718 (163 KB)Merikanto (talk | contribs)Uploaded own work with UploadWizard

The following page uses this file:

Metadata