swirlspy.rad package

Submodules

swirlspy.rad.ascii_mm module

swirlspy.rad.ascii_mm.read_ascii_mm(file, xllcenter, yllcenter, nrows, ncols, valid_time, time_step_size, radar_radius, proj='aeqd')

Reads ascii radar file and returns in xarray.DataArray.

Parameters
  • file (str) – Name of ascii file to read. Data contained by this file should already be in cartesian coordinates.

  • xllcenter (float) – longitude of radar site.

  • yllcenter (float) – latitude of radar site.

  • nrows (int) – Number of rows of the output interpolated cartesian grid.

  • ncols (int) – Number of columns of the output interpolated cartesian grid.

  • valid_time (str) – [YYYYMMDDhhmm] of the first-timestep radar file.

  • time_step_size (int) – Seperation time between 2 input radar files in minutes.

  • radar_radius (int) – Radar radius in km.

  • proj (str) – PROJ.4 parameters, proj4-string. Default is ‘aeqd’.

Returns

xr_dataarray – A 2D xarray.DataArray. Reflectivity data is in “.values” attribute.

Return type

xarray.DataArray

swirlspy.rad.cinrad module

swirlspy.rad.cinrad.read_cinrad(file, xllcenter, yllcenter, nrows, ncols, valid_time, time_step_size, proj, radar_radius, band_name)

Reads cinrad radar data (either in c-band or s-band) and returns reflectivity data in xarray.DataArray.

@author: qzhang

Parameters
  • file (str) – Name of cinrad file to read. Reflectivity data contained by this file should be in spherical coordinates.

  • xllcenter (float) – longitude of radar site.

  • yllcenter (float) – latitude of radar site.

  • nrows (int) – Number of rows of the output interpolated cartesian grid.

  • ncols (int) – Number of columns of the output interpolated cartesian grid.

  • valid_time (str) – [YYYYMMDDhhmm] of the first-timestep radar file.

  • time_step_size (int) – Seperation time between 2 input radar files in minutes.

  • proj (str) – PROJ.4 parameters, proj4-string.

  • radar_radius (int) – Radar radius in km.

  • band_name (str) – Band name, either “c-band” or “s-band”

Returns

xr_dataarray – A 2D xarray.DataArray. Reflectivity data is in “.values” attribute.

Return type

xarray.DataArray

swirlspy.rad.grid_obj_creator module

swirlspy.rad.grid_obj_creator.grid_obj_creator(end_time, duration, x_ll, y_ll, x_ur, y_ur, lon_0, lat_0, proj, data, nx, ny)

Create a grid object.

end_time: str

The time when the grid stops accumulating.

duration: str

The period of time the grid has accumulated.

x_ll: int

projection x coordinate of lower left corner of lower left pixel.

y_ll: int

projection y coordinate of lower left corner of lower left pixel.

x_ur: int

projection x coordinate of upper right corner of upper right pixel.

y_ur: int

projection y coordinate of upper right corner of upper right pixel.

lon_0: float

PROJ.4 parameters, longitude of center.

lat_0: float

PROJ.4 parameters, latitude of center.

proj: str

PROJ.4 parameters, proj4-string.

data: ndarray

Array containing data to be put into the grid object. Default=None.

nx: Optional, int

Number of grids in the x-direction. Default=480.

ny: Optional, int

Number of grids in the y-direction. Default=480.

grid_obj: Class Grid from module “grid”

A cartesian grid object. Reflectivity data is in “data” attribute.

swirlspy.rad.hdf5 module

swirlspy.rad.hdf5.read_hdf5(file, nrows, ncols, valid_time, time_step_size, proj, radar_radius)

Reads hdf5 radar file and returns reflectivity data in xarray.DataArray.

Parameters
  • file (str) – Name of hdf5 file to read. Reflectivity data contained by this file should be in cartesian coordinates.

  • nrows (int) – Number of rows of the output interpolated cartesian grid.

  • ncols (int) – Number of columns of the output interpolated cartesian grid.

  • valid_time (str) – [YYYYMMDDhhmm] of the first-timestep radar file.

  • time_step_size (int) – Seperation time between 2 input radar files in minutes.

  • proj (str) – PROJ.4 parameters, proj4-string.

  • radar_radius (int) – Radar radius in km.

Returns

xr_dataarray – A 2D xarray.DataArray. Reflectivity data is in “.values” attribute.

Return type

xarray.DataArray

swirlspy.rad.irisraw module

swirlspy.rad.irisraw.read_irisraw(file, nrows, ncols, valid_time, time_step_size, proj, radar_radius)

Reads sigmet RAW file.

Converts reflectivity data from spherical coordinates to cartesian coordinates by interpolation.

Masked values and negative values in are replaced by 0. Returns in xarray.DataArray.

Parameters
  • file (str) – Name of Sigmet (IRIS) RAW file to read. Reflectivity data contained by this file should be in spherical coordinates.

  • nrows (int) – Number of rows of the output interpolated cartesian grid.

  • ncols (int) – Number of columns of the output interpolated cartesian grid.

  • valid_time (str) – [YYYYMMDDhhmm] of the first-timestep radar file.

  • time_step_size (int) – Seperation time between 2 input radar files in minutes.

  • proj (str) – PROJ.4 parameters, proj4-string.

  • radar_radius (int) – Radar radius in km.

Returns

xr_dataarray – A 2D xarray.DataArray. Reflectivity data is in “.values” attribute.

Return type

xarray.DataArray

swirlspy.rad.irisref module

swirlspy.rad.irisref.read_irisref(file, xllcenter, yllcenter, nrows, ncols, valid_time, time_step_size, proj, radar_radius)

Reads sigmet REF file and returns reflectivity data in xarray.DataArray (Reflectivity = binary_data[i]-64.0)/2.0).

Parameters
  • file (str) – Name of Sigmet (IRIS) REF file to read.

  • xllcenter (float) – longitude of radar site.

  • yllcenter (float) – latitude of radar site.

  • nrows (int) – Number of rows of the output interpolated cartesian grid.

  • ncols (int) – Number of columns of the output interpolated cartesian grid.

  • valid_time (str) – [YYYYMMDDhhmm] of the first-timestep radar file.

  • time_step_size (int) – Seperation time between 2 input radar files in minutes.

  • proj (str) – PROJ.4 parameters, proj4-string.

  • radar_radius (int) – Radar radius in km.

Returns

xr_dataarray – A 2D xarray.DataArray. Reflectivity data is in “.values” attribute.

Return type

xarray.DataArray

swirlspy.rad.netcdf_ph module

swirlspy.rad.netcdf_ph.read_netcdf_ph(file, nrows, ncols, valid_time, time_step_size, proj, radar_radius)

Reads philippines netcdf radar file and returns reflectivity data in xarray.DataArray.

Parameters
  • file (str) – Name of netcdf radar file to read. Reflectivity data contained by this file should be already in cartesian coordinates.

  • nrows (int) – Number of rows of the output interpolated cartesian grid.

  • ncols (int) – Number of columns of the output interpolated cartesian grid.

  • valid_time (str) – [YYYYMMDDhhmm] of the first-timestep radar file.

  • time_step_size (int) – Seperation time between 2 input radar files in minutes.

  • proj (str) – PROJ.4 parameters, proj4-string.

  • radar_radius (int) – Radar radius in km.

Returns

xr_dataarray – A 2D xarray.DataArray. Reflectivity data is in “.values” attribute.

Return type

xarray.DataArray

swirlspy.rad.netcdf_vn_dh module

swirlspy.rad.netcdf_vn_dh.read_netcdf_vn_dh(file, nrows, ncols, valid_time, time_step_size, proj, radar_radius)

Reads vietnam netcdf radar file (file name begins with “DH”) and returns reflectivity data in xarray.DataArray.

Parameters
  • file (str) – Name of netcdf radar file to read(file name begins with “DH”). Reflectivity data contained by this file should be already in cartesian coordinates.

  • nrows (int) – Number of rows of the output interpolated cartesian grid.

  • ncols (int) – Number of columns of the output interpolated cartesian grid.

  • valid_time (str) – [YYYYMMDDhhmm] of the first-timestep radar file.

  • time_step_size (int) – Seperation time between 2 input radar files in minutes.

  • proj (str) – PROJ.4 parameters, proj4-string.

  • radar_radius (int) – Radar radius in km.

Returns

xr_dataarray – A 2D xarray.DataArray. Reflectivity data is in “.values” attribute. Negative values are removed.

Return type

xarray.DataArray

swirlspy.rad.netcdf_vn_don module

swirlspy.rad.netcdf_vn_don.read_netcdf_vn_don(file, nrows, ncols, valid_time, time_step_size, proj, radar_radius)

Reads vietnam netcdf radar file (file name begins with “DON”).

Then converts reflectivity data from spherical coordinates to cartesian coordinates by interpolation.

Masked values and negative values are replaced by 0.

Returns in xarray.DataArray.

Parameters
  • file (str) – Name of netcdf file to read. File name should begins with DON. Reflectivity data contained by this file should be in spherical coordinates.

  • nrows (int) – Number of rows of the output interpolated cartesian grid.

  • ncols (int) – Number of columns of the output interpolated cartesian grid.

  • valid_time (str) – [YYYYMMDDhhmm] of the first-timestep radar file.

  • time_step_size (int) – Seperation time between 2 input radar files in minutes.

  • proj (str) – PROJ.4 parameters, proj4-string.

  • radar_radius (int) – Radar radius in km.

Returns

xr_dataarray – A 2D xarray.DataArray. Reflectivity data is in “.values” attribute.

Return type

xarray.DataArray

swirlspy.rad.sph2cart_interpolation module

swirlspy.rad.sph2cart_interpolation.sph2cart_interpolation(radius, azimuth, elevation, xllcenter, yllcenter, nrows, ncols, data)
Convert data from spherical coordinates to cartesian coordinates

by interpolation.

Masked values and negative values in the grid of cartesian coordinates are replaced by 0.

Parameters
  • radius (numpy.ndarray) – Contains the radial distances in meters.

  • azimuth (numpy.ndarray) – Contains the azimuthal angles in degree.

  • elevation (numpy.ndarray) – Contains the elevation angles in degree.

  • xllcenter (float) – Radar site longitude.

  • yllcenter (float) – Radar site latitude.

  • nrows (int) – Number of rows of the output interpolated cartesian grid.

  • ncols (int) – Number of columns of the output interpolated cartesian grid.

  • data (numpy.ndarray) – array of float, the data that should be interpolated on the cartesian grid.

Returns

Cartesian Grid – an array of float with a dimension of (nrows,ncols), the data that should be interpolated on the cartesian grid.

Return type

numpy.2darray

swirlspy.rad.time_update module

swirlspy.rad.time_update.time_update(initial, time_step_size)

Shift time by a certain amount.

Parameters
  • initial (str) – Base time, in YYYYMMDDhhmm.

  • time_step_size (str) – Amount of time to shift, in minutes.

Returns

end – Updated time, in YYYYMMDDhhmm.

Return type

str

swirlspy.rad.uf_ph module

swirlspy.rad.uf_ph.read_uf_ph(file, xllcenter, yllcenter, nrows, ncols, valid_time, time_step_size, proj, radar_radius)

Reads philippines UF radar file.

Converts reflectivity data from spherical coordinates to cartesian coordinates by interpolation.

Masked values and negative values are replaced by 0.

Returns in xarray.DataArray.

Parameters
  • file (str) – Name of .uf file to read. Reflectivity data contained by this file should be in spherical coordinates.

  • xllcenter (float) – longitude of radar site.

  • yllcenter (float) – latitude of radar site.

  • nrows (int) – Number of rows of the output interpolated cartesian grid.

  • ncols (int) – Number of columns of the output interpolated cartesian grid.

  • valid_time (str) – [YYYYMMDDhhmm] of the first-timestep radar file.

  • time_step_size (int) – Seperation time between 2 input radar files in minutes.

  • proj (str) – PROJ.4 parameters, proj4-string.

  • radar_radius (int) – Radar radius in km.

Returns

xr_dataarray – A 2D xarray.DataArray. Reflectivity data is in “.values” attribute.

Return type

xarray.DataArray

swirlspy.rad.xr2d module

swirlspy.rad.xr2d.xr2d(np_array, end_time, duration)

Transform numpy array to xarray.DataArray.

Parameters
np_array: np.2darray

Must be 2-dimensional, dimension will be hardcoded as ‘x’ and ‘y’.

end_time: str

End time when your data stops accumulating [YYYYMMDDhhmm].

duration: str

Accumulation period of your data, in minutes.

Return

xr2d: xarray.DataArray (2-dimensional, in ‘x’ ‘y’) .. attribute:: dims

tuple Tuple of dimension names associated with this array. Hardcoded as ‘x’ and ‘y’.

swirlspy.rad.xr2d.values

np.ndarray The array’s data as a numpy.ndarray.

swirlspy.rad.xr2d.coords

dict_like Dictionary-like container of coordinate arrays of ‘x’ and ‘y’.

swirlspy.rad.xr2d.attrs

OrderedDict Dictionary storing arbitrary metadata with this array, including ‘end_time’ and ‘duration’.

swirlspy.rad.xrnd module

swirlspy.rad.xrnd.xrnd(*arg)

Concatenate multiple ‘xr2d’ into a single xarray, along a new axis called ‘end_time’. Use this function to make an xarray for qpf.

Parameters

Any number of ‘xr2d’ (xarray.DataArray).

Return
ndxr: xarray.DataArray

Number of ‘xr2d’ concatenated along ‘end_time’ axis depends on number of input.