-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_and_get_params.py
51 lines (40 loc) · 2.12 KB
/
set_and_get_params.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import numpy as np
import pdb
import cell_area_2 as carea
def model_params_set(input_dir,res=42, delta_t=900., radius=6376.0e3, day_length=86400., ocean_rho=1.035e3, ocean_cp=3989.24495292815, ml_depth=10., sigma_sb=5.6734e-8, pref=1000.,kappa=2./7., g=9.8, rct=6376.0e3, omega=7.292e-5, rdgas=287.04, rvgas=461.50, l_v=2.500e6, lat_name='lat', lon_name='lon', latb_name='latb', lonb_name='lonb', roughness_length=3.21e-05):
model_params={}
model_params['input_dir']=input_dir
model_params['res']=res
model_params['delta_t']=delta_t
model_params['planet_radius']=radius
model_params['sigma_sb']=sigma_sb
model_params['day_length']=day_length
model_params['ocean_rho']=ocean_rho
model_params['ocean_cp']=ocean_cp
model_params['ml_depth']=ml_depth
model_params['pref']=pref
model_params['kappa']=kappa
model_params['g']=g #Graviational acceleration
model_params['rct']=rct # Rgct is the R/g constant
model_params['rgct']=model_params['rct']/model_params['g']
model_params['omega'] = omega #Planet rotation rate omega
model_params['rdgas']=rdgas
model_params['rvgas']=rvgas
model_params['cp_air']=rdgas/kappa
model_params['l_v'] = l_v
model_params['lat'] = lat_name
model_params['lon'] = lon_name
model_params['latb'] = latb_name
model_params['lonb'] = lonb_name
model_params['roughness_length'] = roughness_length
return model_params
def get_grid_sizes(dataset,model_params):
area,x,y = carea.cell_area_from_xar(dataset, lat_name=model_params['lat'], lon_name = model_params['lon'], latb_name=model_params['latb'], lonb_name=model_params['lonb'], radius = model_params['planet_radius'])
# area,x,y=carea.cell_area_all(model_params['res'],model_params['input_dir'])
# area=(model_params['planet_radius']**2.)*area
# x=(model_params['planet_radius'])*x
# y=(model_params['planet_radius'])*y
dataset['grid_cell_area']=(('lat','lon'),area)
dataset['grid_cell_area_unscaled']=(('lat','lon'),area/(model_params['planet_radius']**2.))
dataset['grid_cell_size_lon']=(('lat','lon'),x)
dataset['grid_cell_size_lat']=(('lat','lon'),y)