MCPcopy Create free account
hub / github.com/NCAR/wrf-python / latlon_coordvars

Function latlon_coordvars

src/wrf/util.py:275–306  ·  view source on GitHub ↗

Return the first found latitude and longitude coordinate names from a NetCDF variable dictionary. This function searches the dictionary structure for NetCDF variables and returns the first found latitude and longitude coordinate names (typically 'XLAT' and 'XLONG'). Args:

(ncvars)

Source from the content-addressed store, hash-verified

273
274
275def latlon_coordvars(ncvars):
276 """Return the first found latitude and longitude coordinate names from a
277 NetCDF variable dictionary.
278
279 This function searches the dictionary structure for NetCDF variables
280 and returns the first found latitude and longitude coordinate
281 names (typically 'XLAT' and 'XLONG').
282
283 Args:
284
285 ncvars (:obj:`dict`): A NetCDF variable dictionary object.
286
287 Returns:
288
289 :obj:`tuple`: The latitude and longitude coordinate name pairs as
290 (lat_coord_name, lon_coord_name).
291
292 """
293 lat_coord = None
294 lon_coord = None
295
296 for name in _LAT_COORDS:
297 if name in viewkeys(ncvars):
298 lat_coord = name
299 break
300
301 for name in _LON_COORDS:
302 if name in viewkeys(ncvars):
303 lon_coord = name
304 break
305
306 return lat_coord, lon_coord
307
308
309def is_coordvar(varname):

Callers 2

_set_cross_metaFunction · 0.85
_set_line_metaFunction · 0.85

Calls 1

viewkeysFunction · 0.85

Tested by

no test coverage detected