matplotlib.testing.jpl_units

A sample set of units for use with testing unit conversion of Matplotlib routines. These are used because they use very strict enforcement of unitized data which will test the entire spectrum of how unitized data might be used (it is not always meaningful to convert to a float without specific units given).

UnitDbl is essentially a unitized floating point number. It has a minimal set of supported units (enough for testing purposes). All of the mathematical operation are provided to fully test any behaviour that might occur with unitized data. Remember that unitized data has rules as to how it can be applied to one another (a value of distance cannot be added to a value of time). Thus we need to guard against any accidental “default” conversion that will strip away the meaning of the data and render it neutered.

Epoch is different than a UnitDbl of time. Time is something that can be measured where an Epoch is a specific moment in time. Epochs are typically referenced as an offset from some predetermined epoch.

A difference of two epochs is a Duration. The distinction between a Duration and a UnitDbl of time is made because an Epoch can have different frames (or units). In the case of our test Epoch class the two allowed frames are ‘UTC’ and ‘ET’ (Note that these are rough estimates provided for testing purposes and should not be used in production code where accuracy of time frames is desired). As such a Duration also has a frame of reference and therefore needs to be called out as different that a simple measurement of time since a delta-t in one frame may not be the same in another.

Submodules

Functions

  • register(): Register the unit conversion classes with matplotlib.

matplotlib.testing.jpl_units.register()

Register the unit conversion classes with matplotlib.

Classes

class matplotlib.testing.jpl_units.Duration(frame, seconds)

Class Duration in development.

Inheritance

digraph inheritance6c4a89085d { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Duration" [URL="#matplotlib.testing.jpl_units.Duration",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Class Duration in development."]; }
checkSameFrame(rhs, func)

Check to see if frames are the same.

= ERROR CONDITIONS - If the frame of the rhs Duration is not the same as our frame,

an error is thrown.

= INPUT VARIABLES - rhs The Duration to check for the same frame - func The name of the function doing the check.

frame()

Return the frame the duration is in.

seconds()

Return the number of seconds in the Duration.

class matplotlib.testing.jpl_units.Epoch(frame, sec=None, jd=None, daynum=None, dt=None)

Inheritance

digraph inheritance084ebeeca8 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Epoch" [URL="#matplotlib.testing.jpl_units.Epoch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; }
static range(start, stop, step)

Generate a range of Epoch objects.

Similar to the Python range() method. Returns the range [ start, stop) at the requested step. Each element will be a Epoch object.

= INPUT VARIABLES - start The starting value of the range. - stop The stop value of the range. - step Step to use.

= RETURN VALUE - Returns a list containing the requested Epoch values.

class matplotlib.testing.jpl_units.UnitDbl(value, units)

Class UnitDbl in development.

Inheritance

digraph inheritance185375e104 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "UnitDbl" [URL="#matplotlib.testing.jpl_units.UnitDbl",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Class UnitDbl in development."]; }
checkSameUnits(rhs, func)

Check to see if units are the same.

= ERROR CONDITIONS - If the units of the rhs UnitDbl are not the same as our units,

an error is thrown.

= INPUT VARIABLES - rhs The UnitDbl to check for the same units - func The name of the function doing the check.

convert(units)

Convert the UnitDbl to a specific set of units.

= ERROR CONDITIONS - If the input units are not in the allowed list, an error is thrown.

= INPUT VARIABLES - units The string name of the units to convert to.

= RETURN VALUE - Returns the value of the UnitDbl in the requested units as a floating

point number.

static range(start, stop, step=None)

Generate a range of UnitDbl objects.

Similar to the Python range() method. Returns the range [ start, stop) at the requested step. Each element will be a UnitDbl object.

= INPUT VARIABLES - start The starting value of the range. - stop The stop value of the range. - step Optional step to use. If set to None, then a UnitDbl of

value 1 w/ the units of the start is used.

= RETURN VALUE - Returns a list containing the requested UnitDbl values.

type()

Return the type of UnitDbl data.

class matplotlib.testing.jpl_units.UnitDblFormatter(useOffset=None, useMathText=None, useLocale=None)

The formatter for UnitDbl data types.

This allows for formatting with the unit string.

Inheritance

digraph inheritance847a310666 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Formatter" [URL="matplotlib.ticker.html#matplotlib.ticker.Formatter",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Create a string based on a tick value and location."]; "TickHelper" -> "Formatter" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ScalarFormatter" [URL="matplotlib.ticker.html#matplotlib.ticker.ScalarFormatter",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Format tick values as a number."]; "Formatter" -> "ScalarFormatter" [arrowsize=0.5,style="setlinewidth(0.5)"]; "TickHelper" [URL="matplotlib.ticker.html#matplotlib.ticker.TickHelper",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "UnitDblFormatter" [URL="matplotlib.testing.jpl_units.UnitDblFormatter.html#matplotlib.testing.jpl_units.UnitDblFormatter.UnitDblFormatter",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="The formatter for UnitDbl data types."]; "ScalarFormatter" -> "UnitDblFormatter" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
format_data(value)

Return the full string representation of the value with the position unspecified.

format_data_short(value)

Return a short string version of the tick value.

Defaults to the position-independent long value.