arguslib.misc package

Submodules

arguslib.misc.geo module

arguslib.misc.geo.haversine(lon1, lat1, lon2, lat2)[source]

Computes the Haversine distance between two points in km. This version is vectorized to handle numpy arrays.

arguslib.misc.geo.bearing(lon1, lat1, lon2, lat2)[source]

Calculates the bearing between two points NOTE: switched lon/lat order to match TASIC code

All arguments in degrees

Code from: https://www.igismap.com/formula-to-find-bearing-or-heading-angle-between-two-points-latitude-longitude/

arguslib.misc.geo.xy_offset_to_ll(lon1, lat1, xoff, yoff)[source]
arguslib.misc.geo.destination_point(lon, lat, bearing_deg, distance_km)[source]

Calculates a destination point given a starting point, bearing, and distance along a great-circle path on a sphere.

arguslib.misc.geo.calculate_bearing(lat1, lon1, lat2, lon2)[source]
arguslib.misc.geo.hPa_to_ft(press)[source]
arguslib.misc.geo.ft_to_km(ft)[source]
arguslib.misc.geo.hPa_to_km(press)[source]
arguslib.misc.geo.ft_to_hPa(ft)[source]
arguslib.misc.geo.km_to_hPa(km)[source]
arguslib.misc.geo.xr_add_cyclic_points(da)[source]

Add cyclic points at start and end of lon dimension of data array.

From StackExchange.

Inputs da: xr.DataArray including dimensions (lat,lon)

arguslib.misc.interpolation module

arguslib.misc.interpolation.interpolate_to_intersection(offsets, coords_to_interpolate, data_to_interpolate)[source]

Finds where a path crosses a plane (where offset is zero) and linearly interpolates associated coordinate and data values at that point.

Parameters:
  • offsets (ndarray) – An array of distances from the intersection plane. The function looks for sign changes in this array.

  • coords_to_interpolate (Dict[str, ndarray]) – A dictionary of coordinate arrays (e.g., {‘x’: xs, ‘y’: ys}) that define the path’s position in some space.

  • data_to_interpolate (Dict[str, ndarray]) – A dictionary of other data arrays (e.g., {‘time’: times}) associated with the path.

Return type:

List[Dict[str, Any]]

Returns:

A list of dictionaries, where each dictionary represents one intersection and contains the interpolated values for all provided coordinates and data.

arguslib.misc.met module

arguslib.misc.met.download_era5_winds(dtime)[source]

arguslib.misc.plotting module

class arguslib.misc.plotting.TimestampedFigure(*args, **kwargs)[source]

Bases: Figure

set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, canvas=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, constrained_layout=<UNSET>, constrained_layout_pads=<UNSET>, dpi=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, figheight=<UNSET>, figwidth=<UNSET>, frameon=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, layout_engine=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, size_inches=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, tight_layout=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)

Set multiple properties at once.

Supported properties are

Properties:

agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: scalar or None animated: bool canvas: FigureCanvas clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None constrained_layout: unknown constrained_layout_pads: unknown dpi: float edgecolor: :mpltype:`color` facecolor: :mpltype:`color` figheight: float figure: unknown figwidth: float frameon: bool gid: str in_layout: bool label: object layout_engine: {‘constrained’, ‘compressed’, ‘tight’, ‘none’, .LayoutEngine, None} linewidth: number mouseover: bool path_effects: list of .AbstractPathEffect picker: None or bool or float or callable rasterized: bool size_inches: (float, float) or float sketch_params: (scale: float, length: float, randomness: float) snap: bool or None tight_layout: unknown transform: ~matplotlib.transforms.Transform url: str visible: bool zorder: float

arguslib.misc.plotting.plot_range_rings(plotting_instrument, center_instrument, dt, ranges=[10, 20, 30], alt=10, ax=None, **kwargs)[source]

Plots range rings on a plottable instrument’s axes.

Each ring is plotted in a separate call to ensure they are not connected.

Parameters:
  • plotting_instrument (PlottableInstrument) – The instrument to plot on (e.g., MapInstrument, Camera).

  • center_instrument (Instrument) – The instrument providing the center position for the rings.

  • dt (datetime) – The datetime for the plot.

  • ranges (list) – List of ranges in km.

  • alt (float) – Altitude for the ring positions.

  • ax (Axes) – The axes to plot on.

  • **kwargs – Keyword arguments for plotting.

arguslib.misc.plotting.plot_beam(plotting_instrument, radar, elev_azi, dt=None, ax=None, markers=False, **kwargs)[source]
arguslib.misc.plotting.get_pixel_transform(camera, ax, lr_flip=True)[source]
arguslib.misc.plotting.make_camera_axes(camera, theta_behaviour='bearing', fig=None, pos=111, replace_ax=None, dt=None)[source]
arguslib.misc.plotting.get_timestamp_from_ax(ax)[source]

arguslib.misc.thermo module

arguslib.misc.thermo.hPa_to_hft(press)[source]
arguslib.misc.thermo.hPa_to_km(press)[source]
arguslib.misc.thermo.hft_to_hPa(alt)[source]
arguslib.misc.thermo.km_to_hPa(alt)[source]
arguslib.misc.thermo.psat_liq(T)[source]
arguslib.misc.thermo.dpsat_liq(T)[source]
arguslib.misc.thermo.psat_ice(T)[source]
arguslib.misc.thermo.dpsat_ice(T)[source]
arguslib.misc.thermo.psat_ice2(T)[source]
arguslib.misc.thermo.rhl_to_rhi(rhl, T)[source]
arguslib.misc.thermo.rhi_to_rhl(rhi, T)[source]
arguslib.misc.thermo.sac_temp_slow(RH, p, eta=0.35)[source]

RH as fraction over liquid p in hPa

arguslib.misc.thermo.sac_temp(RH, p, eta=0.35)[source]

RH as fraction p in hPa

arguslib.misc.times module

arguslib.misc.times.convert_to_london_naive(dt)[source]

Converts a datetime object to a naive datetime in the ‘Europe/London’ timezone.

Parameters:

dt (datetime) – The input datetime object. If naive, it’s assumed to be in UTC. If aware, it’s converted from its current timezone.

Return type:

datetime

Returns:

A naive datetime object representing the equivalent time in London.