24
24
help = "file to convert to a spherical mesh convention" )
25
25
parser .add_argument ("-r" , dest = "radius" , type = float , default = 6371220. ,
26
26
help = "sphere radius to use (m)" )
27
+ parser .add_argument ("-w" , dest = "warp_surface" , action = 'store_true' ,
28
+ help = "warp surface by upperSurface variable. " \
29
+ "Uses scale factor from -s" \
30
+ "If upperSurface is not in file, will attempt " \
31
+ "to calculate it from thickness and bedTopography. " \
32
+ "Uses geometry from first time level only; it is not " \
33
+ "possible to have scaling evolve in time with this method." )
34
+ parser .add_argument ("-s" , dest = "scale" , type = float , default = 100. ,
35
+ help = "scale factor for warping surface" )
27
36
args = parser .parse_args ()
28
37
29
38
@@ -45,7 +54,19 @@ def compute_xyz(latCell_deg, lonCell_deg, radius):
45
54
latCell = np .degrees (ds .variables ["latCell" ][:])
46
55
lonCell = np .degrees (ds .variables ["lonCell" ][:])
47
56
48
- xCell , yCell , zCell = compute_xyz (latCell , lonCell , args .radius )
57
+ if args .warp_surface :
58
+ if 'upperSurface' in ds .variables :
59
+ sfc = ds .variables ['upperSurface' ][0 ,:]
60
+ else :
61
+ thickness = ds .variables ['thickness' ][0 ,:]
62
+ bedTopography = ds .variables ['bedTopography' ][0 ,:]
63
+ sfc = np .maximum (bedTopography + thickness ,
64
+ (1.0 - 910.0 / 1028.0 ) * thickness )
65
+ #sfc = thickness + np.minimum(bedTopography, 0.0) * 1028.0 / 910.0
66
+ radius = args .radius + np .maximum (sfc , 0.0 ) * args .scale
67
+ else :
68
+ radius = args .radius
69
+ xCell , yCell , zCell = compute_xyz (latCell , lonCell , radius )
49
70
50
71
# Add to NetCDF file (assumes variables already exist)
51
72
ds .variables ["xCell" ][:] = xCell
0 commit comments