wrf.ll_to_xy

wrf.ll_to_xy(wrfin, latitude, longitude, timeidx=0, squeeze=True, meta=True, stagger=None, as_int=True)

Return the x,y coordinates for a specified latitude and longitude.

The latitude and longitude arguments can be a single value or a sequence of values.

The leftmost dimension of the returned array represents two different quantities:

  • return_val[0,…] will contain the X (west_east) values.
  • return_val[1,…] will contain the Y (south_north) values.
Parameters:
  • wrfin (netCDF4.Dataset, Nio.NioFile, or an iterable) – WRF-ARW NetCDF data as a netCDF4.Dataset, Nio.NioFile or an iterable sequence of the aforementioned types.
  • latitude (float or sequence) – A single latitude or a sequence of latitude values to be converted.
  • longitude (float or sequence) – A single longitude or a sequence of latitude values to be converted.
  • timeidx (int or wrf.ALL_TIMES, optional) – The desired time index. This value can be a positive integer, negative integer, or wrf.ALL_TIMES (an alias for None) to return all times in the file or sequence. The default is 0.
  • squeeze (bool, optional) – Set to False to prevent dimensions with a size of 1 from being automatically removed from the shape of the output. Default is True.
  • meta (bool, optional) – Set to False to disable metadata and return numpy.ndarray instead of xarray.DataArray. Default is True.
  • stagger (str) –

    By default, the latitude is returned on the mass grid, but a staggered grid can be chosen with the following options:

    • ’m’: Use the mass grid (default).
    • ’u’: Use the same staggered grid as the u wind component, which has a staggered west_east (x) dimension.
    • ’v’: Use the same staggered grid as the v wind component, which has a staggered south_north (y) dimension.
  • as_int (bool) – Set to False to return the x,y values as float, otherwise they will be returned as int.
Returns:

The x,y coordinate value(s) whose leftmost dimension is 2 (0=X, 1=Y). If xarray is enabled and the meta parameter is True, then the result will be a xarray.DataArray object. Otherwise, the result will be a numpy.ndarray object with no metadata.

Return type:

xarray.DataArray or numpy.ndarray