Skip to content

Commit 8ae8405

Browse files
Add option to warp surface by upperSurface
1 parent 748a5df commit 8ae8405

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

landice/mesh_tools_li/convert_cell_coordinates_to_sphere.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
help="file to convert to a spherical mesh convention")
2525
parser.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")
2736
args = parser.parse_args()
2837

2938

@@ -45,7 +54,19 @@ def compute_xyz(latCell_deg, lonCell_deg, radius):
4554
latCell = np.degrees(ds.variables["latCell"][:])
4655
lonCell = 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 = 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)
4970

5071
# Add to NetCDF file (assumes variables already exist)
5172
ds.variables["xCell"][:] = xCell

0 commit comments

Comments
 (0)