swirlspy.ltg package

Submodules

swirlspy.ltg.map module

swirlspy.ltg.map.gen_ltg_binary(ltg, area_def, coord_label=['x', 'y'], cloud_indicator='total')

A function to generate a grid of binary lightning signals.

Parameters:
  • ltg (swirlspy.obs.Lightning) – Lightning class.
  • area_def (pyresample.geometry.AreaDefinition) – AreaDefinition of the grid.
  • coord_label (list of strings) – The x and y coordinate labels. Defaults to ‘x’ and ‘y’ respectively.
  • cloud_indicator (str or int) – Type of lightning. 0 refers to cloud-to-ground lightning only. 1 refers to cloud-to-cloud lightning only. ‘total’ refers to both cloud-to-cloud and cloud-to-cloud lightning.
Returns:

ltg_bin – Gridded lightning observations. 0 refers to no lightning, 1 refers to lightning.

Return type:

xarray.DataArray

swirlspy.ltg.map.gen_ltg_density(ltg, area_def, start_time, end_time, tolerance=8000, coord_label=['x', 'y'], cloud_indicator='total', unit_dim=(1000000, Timedelta('0 days 01:00:00'), 'strikes/$km^2$/h'), shape='circle')

Computes lightning density in an area.

Parameters:
  • ltg (Lightning object) – Lightning object containing data of lightning strike.
  • area_def (pyresample.geometry.AreaDefinition) – AreaDefinition of the desired grid in coordinates of the data in the Lightning object.
  • start_time (pandas.Timestamp) – Start time of lightning observation period.
  • end_time (pandas.Timestamp) – End time of lightning observation period.
  • tolerance (float) – The radius of influence of a lightning strike.
  • coord_label (list of strings) – [‘x’, ‘y’] Coordinate labels.
  • cloud_indicator (int or str) – The cloud indicator. 0 for cloud-to-ground discharge. 1 for cloud-to-cloud discharge. ‘total’ for combined cloud-to-cloud and cloud-to-ground discharge.
  • unit_dim (tuple of float and str respectively) – The unit area expressed in the units of the projection the name of the unit area. Defaults to (1000000, pd.Timedelta(1, ‘h’), ‘strikes/$km^2$/h’), i.e. per square kilometer per hour assuming that the projection is expressed in meters. Change according to the unit of the projection system.
  • shape (str) – The shape of the searcher. Can either be a circle or a square. Choose square for less computational power. Defaults to circle.
Returns:

ltg_density – Gridded lightning density.

Return type:

xarray.DataArray

swirlspy.ltg.map.gen_ltgv(ltg, area_def, start_time, end_time, sigma, coord_label=['x', 'y'])

Generates lightning potential in an area. Lightning potential is calculated using a multivariate normal distribution.

Parameters:
  • ltg (Lightning object) – Lightning object containing data of lightning strike.
  • area_def (pyresample.geometry.AreaDefinition) – Areadefinition of the desired grid in coordinates of the data in the Lightning object.
  • start_time (pandas.Timestamp) – Start time of lightning observation period.
  • end_time (pandas.Timestamp) – End time of lightning observation period.
  • sigma (float) – Standard deviation of the Gaussian Distribution. Assume that distribution is symmetrical.
  • coord_label (list of strings) – Defaults to [‘x’, ‘y’].
Returns:

ltgv – Gridded lightning potential.

Return type:

xarray.DataArray

swirlspy.ltg.map.gen_mask_in_radius(x_coords, y_coords, center, radius)

Generate a mask for a meshgrid of coordinates.

Parameters:
  • x_coords (numpy.ndarray) – 1d x-coordinate array.
  • y_coords (numpy.1darray) – 1d y-coordinate array
  • center (tuple of scalar) – The (x, y) coordinates of the center of the circular region.
  • radius (scalar) – The radius of the circular region.
Returns:

mask – 2d mask of area within circular region.

Return type:

numpy.ndarray, shape (len(y_coords), len(y_coords))

swirlspy.ltg.map.in_radius(obs_site, center, radius)

Investigates whether an observation e.g. a lightning strikes lies within a circular region of radius radius centered at center. The units of all three parameters should be the same e.g. all in meters or all in degrees etc.

Parameters:
  • obs_site (array_like of scalar, shape (n, 2)) – The location of the observation(s).
  • center (array_like of scalar, shape (2,)) – The (x, y) coordinates of the center of the circular region.
  • radius (scalar) – The radius of the circular region.
Returns:

obs_in_radius – The boolean result of each site

Return type:

array_like, shape (n,) or scalar