2424 help = "file to convert to a spherical mesh convention" )
2525parser .add_argument ("-r" , dest = "radius" , type = float , default = 6371220. ,
2626 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" )
2736args = parser .parse_args ()
2837
2938
@@ -45,7 +54,17 @@ def compute_xyz(latCell_deg, lonCell_deg, radius):
4554latCell = np .degrees (ds .variables ["latCell" ][:])
4655lonCell = np .degrees (ds .variables ["lonCell" ][:])
4756
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 = thickness + np .minimum (bedTopography , 0.0 ) * 1028.0 / 910.0
64+ radius = args .radius + np .maximum (sfc , 0.0 ) * args .scale
65+ else :
66+ radius = args .radius
67+ xCell , yCell , zCell = compute_xyz (latCell , lonCell , radius )
4968
5069# Add to NetCDF file (assumes variables already exist)
5170ds .variables ["xCell" ][:] = xCell
0 commit comments