miscellaneous: Utilities

This module contains functions for: 1- legend insertion to figures (put_legend, put_legend_fnt) 2- combining images (combine_horizontal, combine_vertical) 3- marking specific times on map(mark_on_map, mark_beginning_on_map)

and altitude plots(mark_beginning, mark_altitude_plots)

4- plotting the direction of the spacecraft 5- finding index of desired values in parameters: find_index

@author: ceren

miscellaneous.combine_horizontal(f, fnew)

Horizontally combines images with arbitrary image size as a new image and saves the new image with the given file name.

f: Name of image files, list fnew: Output file name

Saves horizontally combined image as fnew to the directory Reference: https://stackoverflow.com/a/30228789/15165141

miscellaneous.combine_vertical(f, fnew)

Vertically combines images with arbitrary image size as a new image and saves the new image with the given file name.

f: Name of image files, list fnew: Output file name

Saves vertically combined image as fnew to the directory Reference: https://stackoverflow.com/a/30228789/15165141

miscellaneous.coverage(extent)

Generates the plot parameters

extent: list

[Lon_min, Lon_max, Lat_min, Lat_max]

central_lonfloat

Central longitude (degrees)

central latfloat

Central latitude (degrees)

pre-definedfloat

left (.01), width (.5), bottom (.01), height (.5)

miscellaneous.find_index(data, closeto, tol, verbose='off')

Finds the index of numbers that are close to the value we are searching for with a tolerance ‘tol’.

data: np.ndarray[float]

input data for inspection, array

closeto: float

The value we are searching for

tol: float

Amount of tolerance

verbosestring, optional

Verbose. The default is ‘off’.

ind_close: list

Index of the close values

miscellaneous.indices_and_intervals(start_time, time_data, intval)

Generates date for usage with plot titles and output filenames, determines the index of the last used data row and finds the number of intervals for cases we do not use the complete data set.

start_time: datetime.datetime

The beginning of the passage

time_datadatetime.datetime

Time array for the whole passage

intvalint

how many seconds do we want for intervals

datestr

date as a string.

last_data_index: int

index of the last used data row

number_of_intervals: int

number of intervals for cases

seconds: int

tick locator for seconds

miscellaneous.mark_altitude_plots(ax, Px, Py, color='cyan', edgecolor='k', marker='*', **kwargs)

Function to mark locations on altitude plots.

axAxes

axes.

Pxfloat

Longitude of the point to be marked (degrees).

Pyfloat

Altitude of the point to be marked (km).

colorstr, optional

Color of the point to be marked. Default is ‘cyan’.

edgecolorstr, optional

Edge color of the point to be marked. Default is ‘black’.

markerstr, optional

Marker symbol. The default is start ‘*’.

**kwargsdict

Additional keyword arguments for scatter plot.

None.

miscellaneous.mark_beginning(ax, x, y, z)

Plot to mark the beginning of the pass and show the direction of the spacecraft with an arrow for altitude plots.

axAxes

axes.

xfloat

Longitude of the beginning of the trajectory (degrees).

yfloat

Latitude of the beginning of the trajectory (degrees).

zfloat

Altitude of the beginning of the trajectory (km).

None.

miscellaneous.mark_beginning_on_map(ax, x, y, z, transform=cartopy.crs.PlateCarree)

Function to mark the beginning of the pass and tp show the direction of the spacecraft with an arrow on map projections.

axAxes

axes.

xfloat

Longitude of the beginning of the trajectory (degrees).

yfloat

Latitude of the beginning of the trajectory (degrees).

zfloat, optional

Latitude of the beginning of the trajectory (km).

transformobject, optional

cartopy projection. The default is ccrs.PlateCarree().

None.

miscellaneous.mark_on_map(ax, Px, Py, color='cyan', edgecolor='black', marker='*', transform=cartopy.crs.PlateCarree, **kwargs)

Function to mark locations on maps.

axAxes

axes.

Pxfloat

Longitude of the point to be marked (degrees).

Pyfloat

Latitude of the point to be marked (degrees).

colorstr, optional

Color of the point to be marked. Default is ‘cyan’.

edgecolorstr, optional

Edge color of the point to be marked. Default is ‘black’.

transformobject, optional

cartopy projection. The default is ccrs.PlateCarree().

**kwargsdict

Additional keyword arguments for scatter plot.

None.

miscellaneous.put_legend_fnt(ax, n, location, labelspace, anchorx, anchory, fontsize, labels={}, linestyles={}, markers={}, colors={}, edgecolors={})

Inserts legend to figure for cases, which need customized symbols.

ax: str

axis

n: float

how many columns should the legend have

location: str

location of the legend

labelspace: float

space between the labels (values can be between 0 and 1).

anchorx, anchory: float

coordinate of the lower left corner of legend box (values can be between 0 and 1)

The following are for the customization of the symbols we want to display:

labels: str

labels to display in the legend

linestyles: str

linestyles used in plotting the parameters

markers: str

markers used in plotting the parameters

colors: str

colors used in plotting the parameters. can be also given in RGB

edgecolors: str

edgecolors used in plotting the parameters

None

miscellaneous.sc_direction_plotter(ax, Lon, Lat, Alt)

Plots an arrow to depict the direction of the spacecraft velocity. Prints out trajectory information: altitude increasing/decreasing, going towards SE, NW, SW, NE.

axaxes

Axes object of matplotlib.

Lonnumpy.ndarray[float]

Longitude of the beginning of the trajectory (degrees).

Latnumpy.ndarray[float]

Latitude of the beginning of the trajectory (degrees).

Altnumpy.ndarray[float]

Altitude of the beginning of the trajectory (km).

None.

miscellaneous.set_3Dplot_limits(P, coord, how_far)

Generates the limit of axes wrt the selected point on the ground for 3D plots.

P: float

coordinate of the ground point at x, y or z

coord: float

lat, lon or alt

how_far: float

how far is the axis limit from the point on the ground

coord_min: float coord_max: float

xmin, xmax = set_3Dplot_limits(Px, x)