File:Temperature of gliese 12b as locked desert planet 1.png
Original file (1,018 × 480 pixels, file size: 187 KB, MIME type: image/png)
Captions
Summary
[edit]DescriptionTemperature of gliese 12b as locked desert planet 1.png |
English: Temperature of gliese 12b as locked desert planet |
Date | |
Source | Own work |
Author | Merikanto |
Output image before simulation crashed
Python climt source code
- tidally locked desert planet temperature simulation python3 climt code
-
- Important note:
- uses Ubuntu Anaconda Python 3.10.11 and sometimes gfs_dynamical_core
-
- 27.05.2023 v 0000.0005
-
-
- if you use gfs_dynamical_core
-
- must create Python 3.10 enviroment in conda, ant then: pip install gfs-dynamical-core
- maybe not function in other python versions!
- gfs_dynamical_core
- pip install gfs_dynamical core
- of from source download sit source tree
- https://github.com/Ai33L/gfs_dynamical_core
- and mote to its directory "gfs_dynamical_core-develop"
- and then in python 3.9 ## pip install .
- 3
import matplotlib as mpl
import math
import numpy as np
import scipy.ndimage
from datetime import timedelta
from datetime import datetime
from netCDF4 import Dataset
- import sympl
- import gfs_dynamical_core
import climt
from sympl import (
DataArray, PlotFunctionMonitor,NetCDFMonitor,
AdamsBashforth
)
from climt import (
EmanuelConvection, RRTMGShortwave, RRTMGLongwave, SlabSurface,
DryConvectiveAdjustment, SimplePhysics, BucketHydrology, get_default_state
)
- basic params
steppi=4 # timestep hours
- dimx=16 ## dim of grid
- dimy=8
dimz=8
dimx=16 ## dim of grid
dimy=8
dimz=0
- pix=8 ## temperature et al specimen point insige grid
- piy=4
- piz=3
- S1=1.0
S1=1.63 ## solar constant coeff
co2coeff=1.0 ## co2 x330
- albedo=0.07 ## basalt surface like Moon
- albedo=0.30 ## like Earth
albedo=0.3
qq=0
qqlimit=int(24/steppi)
hourticks1=np.arange(0,24, steppi)
- print (hourticks1)
- quit(-1)
caption1="Desert S0 = "+str(S1)
tempcache=np.zeros(qqlimit)+15
def save_netcdf_x(name1, blok1):
sheip1=np.shape(blok1)
dimx=sheip1[1]
dimy=sheip1[0]
ds = Dataset(name1, 'w', format='NETCDF4')
lat = ds.createDimension('lat', dimy)
lon = ds.createDimension('lon', dimx)
lats = ds.createVariable('lat', 'f4', ('lat',))
lons = ds.createVariable('lon', 'f4', ('lon',))
Tempe = ds.createVariable('Temperature', 'f4', ('lat', 'lon',))
Tempe.units = 'deg C'
lats[:] = np.arange(90, -90, -180/(dimy+0))
lons[:] = np.arange(-180.0, 180, 360/(dimx+0))
Tempe[:, :] = blok1
ds.close()
def plot_function(fig, state):
global qq, qqlimit
global tempcache
global pix, piy
global hourticks1
vmin1=-100
vmax1=100
Tsurf=np.array(state['surface_temperature']-273.15)
lons1=np.mean(state['longitude'], axis=0)
lats1=np.mean(state['latitude'], axis=1)
zonetemps=np.array(np.mean( Tsurf, axis=1))
lats2=np.array(np.mean( state['latitude'], axis=1))
print(zonetemps)
print(lats2)
lats3=lats2*math.pi/10
coslats=np.cos(lats2)
weightemps=zonetemps*np.abs(coslats)*np.abs(coslats)
meantemp=np.mean(weightemps)
print(" T mean ",meantemp)
ax = fig.add_subplot(2, 2, 1)
ax.contourf(state['longitude'], state['latitude'],
Tsurf, cmap=mpl.colormaps['turbo'], origin='lower',levels=10,extent=[0,360,-90,90])
#ax.imshow(Tsurf, origin='lower', vmin=vmin1, vmax=vmax1, cmap=mpl.colormaps['turbo'],extent=[0,360,-90,90])
cs1=ax.contour(state['longitude'], state['latitude'],
state['surface_temperature']-273.15, colors="k",levels=10, origin='lower', vmin=vmin1, vmax=vmax1, extent=[0,360,-90,90])
ax.clabel(cs1, cs1.levels, inline=True, fmt="%.1f", fontsize=16)
ax.set_xlabel('Longitude')
ax.set_ylabel('Latitude')
fig.suptitle('Surface temperature '+str(round(meantemp,2))+' at time: '+str(state['time']))
fig.canvas.draw()
fig.canvas.flush_events()
ax2 = fig.add_subplot(2, 2, 2)
#fig.suptitle('Tsurf lon profile: '+str(state['time']))
ax2.plot(lons1, np.mean(Tsurf, axis=0))
fig.canvas.draw()
fig.canvas.flush_events()
ax3 = fig.add_subplot(2, 2, 3)
#fig.suptitle('Tsurf lat profile: '+str(state['time']))
ax3.plot(lats1,np.mean( Tsurf, axis=1))
ax3.plot(lats1,zonetemps)
fig.canvas.draw()
fig.canvas.flush_events()
qq=qq+1
if(qq>=qqlimit): qq=0
tempcache[qq]=Tsurf[piy, pix]
ax4 = fig.add_subplot(2, 2, 4)
#fig.suptitle('Tsurf time profile: '+str(qq) )
ax4.plot(hourticks1, tempcache)
fig.canvas.draw()
fig.canvas.flush_events()
def plot_function_2(fig, state):
global qq, qqlimit
global tempcache
global pix, piy
global hourticks1
global caption1
vmin1=-50
vmax1=50
Tsurf=np.array(state['surface_temperature']-273.15)
lons1=np.mean(state['longitude'], axis=0)
lats1=np.mean(state['latitude'], axis=1)
zonetemps=np.array(np.mean( Tsurf, axis=1))
lats2=np.array(np.mean( state['latitude'], axis=1))
#print(zonetemps)
#print(lats2)
lats3=lats2*math.pi/10
coslats=np.cos(lats2)
weightemps=zonetemps*np.abs(coslats)*np.abs(coslats)
meantemp1=round(np.mean(weightemps),2)
meantemp0=round(np.mean(Tsurf),2)
maxtemp0=round(np.max(Tsurf),2)
mintemp0=round(np.min(Tsurf),2)
deltemp0=maxtemp0-mintemp0
#print(" T mean min max ",meantemp0, mintemp0, maxtemp0)
ax = fig.add_subplot(1, 1, 1)
levels1=np.array([-250,-220,-200,-150,-120,-100,-80,-60,-40,-30,-20,-10,-5,0,5,10,15,20,25,30,35,40,45,50,60,70,80,90,100,120,150,180,200,250,300,400,500])
Tsurf2 = scipy.ndimage.zoom(Tsurf, 4)
#ax.contourf(state['longitude'], state['latitude'],Tsurf, cmap=mpl.colormaps['turbo'], origin='lower',levels=5,extent=[0,360,-90,90])
ax.imshow(Tsurf2,interpolation="bicubic", origin='lower', vmin=vmin1, vmax=vmax1, cmap='turbo',extent=[0,360,-90,90])
cs1=ax.contour(Tsurf2, alpha=0.5,colors="k",levels=levels1, origin='lower', vmin=vmin1, vmax=vmax1, extent=[0,360,-90,90])
ax.clabel(cs1, cs1.levels, inline=True, fmt="%.1f", fontsize=16)
ax.set_xlabel('Longitude', fontsize=16)
ax.set_ylabel('Latitude', fontsize=16)
ax.set_xticklabels(labels=ax.get_xticklabels(),fontsize=12)
ax.set_yticklabels(labels=ax.get_yticklabels(),fontsize=12)
#ax.set_xticklabels(labels=list(range(0,360, 45)),fontsize=16)
#fig.suptitle('Surface temperature '+str(round(meantemp,2))+' at time: '+str(state['time']))
fig.suptitle(caption1,fontsize=18)
#fig.subtitle('maxtemp '+str(maxtemp),fontsize=11)
fig.canvas.draw()
fig.canvas.flush_events()
- climt.list_available_constants()
- quit(-1)
climt.set_constants_from_dict({
'stellar_irradiance': {'value': S1*1365.2, 'units': 'W m^-2'}})
climt.set_constants_from_dict({
'obliquity': {'value': 0, 'units': 'degree'}})
climt.set_constants_from_dict({
'omega_tilde': {'value': 0, 'units': 'degree'}})
climt.set_constants_from_dict({
'lambda_m0': {'value': 0, 'units': 'degree'}})
- gravitational_acceleration: 9.80665 m s^-2
- planetary_radius: 6371000.0 m
- planetary_rotation_rate: 7.292e-05 s^-1
- seconds_per_day: 86400.0
- NON setting this 10 days
- climt.set_constants_from_dict({'planetary_rotation_rate:': {'value': 7.292e-6/365.25, 'units': 's^-1'}})
- climt.set_constants_from_dict({'seconds_per_day:': {'value': 864000*365.25, 'units': }})
- climt.list_available_constants()
- quit(-1)
- 4 subwin
- monitor = PlotFunctionMonitor(plot_function)
- one lat, lon subwin
monitor = PlotFunctionMonitor(plot_function_2)
instellation = climt.Instellation()
berger=climt.BergerSolarInsolation()
- print(instellation)
- quit(-1)
timestep = timedelta(hours=steppi)
convection = EmanuelConvection()
radiation_sw = RRTMGShortwave()
radiation_lw = RRTMGLongwave()
slab = SlabSurface()
simple_physics = SimplePhysics()
dry_convection = DryConvectiveAdjustment()
hydrology=BucketHydrology()
opticaldepth=climt.Frierson06LongwaveOpticalDepth()
gray=climt.GrayLongwaveRadiation()
condensation=climt.GridScaleCondensation()
- dcmip=climt.DcmipInitialConditions()
heldsuarez=climt.HeldSuarez()
ice = climt.IceSheet(maximum_snow_ice_height=30.) ## 30
- state = get_default_state(
- [simple_physics, convection, dry_convection,
- radiation_lw, radiation_sw, slab]
- )
- state = get_default_state(
- [instellation,
- radiation_lw, radiation_sw,simple_physics,convection, dry_convection,hydrology, slab],
- grid_state=climt.get_grid(nx=dimx, ny=dimy,latitude_grid='regular')
- )
state = get_default_state(
[instellation,berger,
radiation_lw, radiation_sw,simple_physics,convection, dry_convection,hydrology, slab, ice],
grid_state=climt.get_grid(nx=dimx, ny=dimy,latitude_grid='regular')
)
- dycore
- dycore code ....
- convection = climt.EmanuelConvection()
- simple_physics = TimeDifferencingWrapper(climt.SimplePhysics())
- radiation_step = timedelta(hours=1)
- radiation_lw = UpdateFrequencyWrapper(
- climt.RRTMGLongwave(), radiation_step)
- radiation_sw = UpdateFrequencyWrapper(
- climt.RRTMGShortwave(), radiation_step)
- slab_surface = climt.SlabSurface()
- dycore = gfs_dynamical_core.GFSDynamicalCore([simple_physics, slab_surface, radiation_sw,radiation_lw, convection], number_of_damped_levels=5)
- grid = climt.get_grid(nx=32, ny=16, nz=8)
- Create model state
- state = climt.get_default_state([dycore], grid_state=grid)
-
co2=state['mole_fraction_of_carbon_dioxide_in_air'].values[:]
print("Co2 ", round(np.mean(co2)*1e6,3))
- quit(-1)
co2=co2*co2coeff
- quit(-1)
state['mole_fraction_of_carbon_dioxide_in_air'].values[:]=co2
state['air_temperature'].values[:] = 288
state['surface_albedo_for_direct_shortwave'].values[:] = albedo
state['surface_albedo_for_direct_near_infrared'].values[:] = albedo
state['surface_albedo_for_diffuse_shortwave'].values[:] = albedo
state['surface_albedo_for_diffuse_near_infrared'].values[:] = albedo
- state['zenith_angle'].values[:] = np.pi/2.5
state['surface_temperature'].values[:] = 288.
state['ocean_mixed_layer_thickness'].values[:] = 0
state['heat_capacity_of_soil'][:]=750
state['surface_thermal_capacity'][:]=750
state['soil_layer_thickness'][:]=10
state['surface_material_density'][:]=1600 ## sand ## clay loam 1280
- state['surface_material_density'][:]=2700 ## stone, basalt 2900
state['area_type'].values[:] = 'land'
- state['area_type'].values[:] = 'sea'
- state['area_type'].values[:] = 'sea_ice'
- state['sea_ice_thickness'].values[:] = 2.
- state['surface_snow_thickness'].values[:] = 2.
- state['surface_temperature'].values[:] = 260.
- state['surface_upward_sensible_heat_flux'].values[:] = -0.5
- clouds, testing!
- state['mass_content_of_cloud_liquid_water_in_atmosphere_layer'].loc[dict(mid_levels=slice(4, 8))] = 0.03
- state['cloud_area_fraction_in_atmosphere_layer'].loc[dict(mid_levels=slice(4, 8))] = 0.15.
- clouds, testing!
state['mass_content_of_cloud_liquid_water_in_atmosphere_layer'][:]= 0.1
- state['cloud_area_fraction_in_atmosphere_layer'][:] = 1.0
state['cloud_area_fraction_in_atmosphere_layer'][:] = 0.0
print(state)
- quit(-1)
- print(state['time'])
- datetime(year, month, day, hour, minute, second, microsecond)
- newtime = datetime(2023, 7, 1, 11, 55, 59, 0)
- newtime = datetime(2023, 6, 14, 11, 55, 59, 0) ## near mid summer
newtime = datetime(1, 3, 20, 0, 0, 0, 0) ## near spring equinox
state['time']=newtime
print(state['time'])
- quit(-1)
diag = instellation(state)
print("Instellation")
print(diag)
- quit(-1)
fields_to_store = ['air_temperature', 'air_pressure', 'eastward_wind',
'northward_wind', 'air_pressure_on_interface_levels',
'surface_pressure', 'upwelling_longwave_flux_in_air',
'specific_humidity', 'surface_temperature',
'latitude', 'longitude',
'convective_heating_rate']
netcdf_monitor = NetCDFMonitor('climt_out.nc',
write_on_store=True,
store_names=fields_to_store)
time_stepper = AdamsBashforth([radiation_lw, radiation_sw, slab])
- dycore runner
- for i in range(1500*24):
- diag, state = dycore(state, model_time_step)
- state.update(diag)
- state['time'] += model_time_step
- if i % (20) == 0:
- #netcdf_monitor.store(state)
- monitor.store(state)
- print('max. zonal wind: ', np.amax(state['eastward_wind'].values))
- print('max. humidity: ', np.amax(state['specific_humidity'].values))
- print('max. surf temp: ', np.amax(state['surface_temperature'].values))
- print(state['time'])
print("Runnin simulation, insolation")
for i in range(32000000):
diagnostics, state = time_stepper(state, timestep)
state.update(diagnostics)
diag=berger(state)
state.update(diag)
diag, out = simple_physics(state, timestep)
state.update(diag)
state.update(out)
#diag, out = hydrology(state, timestep)
#state.update(diag)
#state.update(out)
diag, out = dry_convection(state, timestep)
state.update(diag)
state.update(out)
diag = instellation(state)
if(i==0): czenit=diag['zenith_angle'].values[:]
#if(i>0): state['zenith_angle'].values[:]=czenit
if(i>0): diag['zenith_angle'].values[:]=czenit
state.update(diag)
diag, out = ice(state, timestep)
state.update(diag)
state.update(out)
if((i%10)==0):
tempslice1=state['air_temperature'][0]
save_netcdf_x("temperature1.nc", tempslice1)
monitor.store(state)
netcdf_monitor.store(state)
state['time'] += timestep
Licensing
[edit]This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. | |
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 05:14, 27 May 2024 | 1,018 × 480 (187 KB) | Merikanto (talk | contribs) | Update | |
17:58, 25 May 2024 | 1,053 × 480 (202 KB) | Merikanto (talk | contribs) | Uploaded own work with UploadWizard |
You cannot overwrite this file.
File usage on Commons
There are no pages that use this file.
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Software used | |
---|---|
Horizontal resolution | 39.37 dpc |
Vertical resolution | 39.37 dpc |