source: trunk/UTIL/z2sig/build_sig_uneven.py @ 3664

Last change on this file since 3664 was 3651, checked in by afalco, 4 months ago

Script to create new z2sig with different number of layers

  • Property svn:executable set to *
File size: 1.0 KB
Line 
1#!/opt/canopy-1.3.0/Canopy_64bit/User/bin/python
2import numpy as np
3
4def compute_uneven_sigma(num_levels, N_scale_heights, surf_res, exponent, zero_top ):
5    """
6    Construct an initial array of sigma based on the number of levels, an exponent
7    Args:
8        num_levels: the number of levels
9        N_scale_heights: the number of scale heights to the top of the model (e.g scale_heights =12.5 ~102km assuming 8km scale height)
10        surf_res: the resolution at the surface
11        exponent: an exponent to increase th thickness of the levels
12        zero_top: if True, force the top pressure boundary (in N=0) to 0 Pa
13    Returns:
14        b: an array of sigma layers
15
16    """
17    b=np.zeros(int(num_levels)+1)
18    for k in range(0,int(num_levels)):
19        zeta = 1.-k/np.float_(num_levels) #zeta decreases with k
20        z  = surf_res*zeta + (1.0 - surf_res)*(zeta**exponent)
21        b[k] = np.exp(-z*N_scale_heights)
22    b[-1] = 1.0
23    if(zero_top):  b[0] = 0.0
24    return b
25
26sig=compute_uneven_sigma(47, 10, 5, 1, 0 )
27print(sig)
Note: See TracBrowser for help on using the repository browser.