Skip to content

Commit d1a51fa

Browse files
committed
re-instate get_gridname subroutine
1 parent 6ee5312 commit d1a51fa

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pre/remap_restart/remap_utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,21 @@ def get_zoom(x):
362362
zoom_= str(int(zoom))
363363
return zoom_
364364

365+
def get_gridname(tilefile):
366+
gridname_ =''
367+
tmptile = os.path.realpath(tilefile)
368+
extension = os.path.splitext(tmptile)[1]
369+
if extension == '.domain':
370+
extension = os.path.splitext(tmptile)[0]
371+
if extension == '.til':
372+
gridname_ = linecache.getline(tmptile, 3).strip()
373+
else:
374+
nc_file = nc.Dataset(tmptile,'r')
375+
gridname_ = nc_file.getncattr('Grid_Name')
376+
# in case it is an old name: SMAP-EASEvx-Mxx
377+
gridname_ = gridname_.replace('SMAP-','').replace('-M','_M')
378+
return gridname_
379+
365380
def get_account():
366381
cmd = 'id -gn'
367382
p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE)

0 commit comments

Comments
 (0)