units Module

Physical units of plot axes and colorbar titles.

Readers store time, mass and radius in cgs; an axis divides by its display unit's UFAC. Colour-field units are labels only, from .kipp header or column-name suffix.



Variables

Type Visibility Attributes Name Initial
real(kind=real64), public, parameter :: SOLMASS = 1.9892d33

Solar mass (g), as used in KEPLER.

real(kind=real64), public, parameter :: SOLRAD = 6.9599d10

Solar radius (cm), as used in KEPLER.

real(kind=real64), public, parameter :: YR = 31556952.d0

Gregorian year (s).

integer(kind=int32), public, parameter :: DIM_TIME = 1

Dimension codes of UDIM: time, mass, length.

integer(kind=int32), public, parameter :: DIM_MASS = 2

Dimension codes of UDIM: time, mass, length.

integer(kind=int32), public, parameter :: DIM_LENGTH = 3

Dimension codes of UDIM: time, mass, length.

integer(kind=int32), public, parameter :: NUNITS = 15

Number of display units.

character(len=4), public, parameter :: UNAME(NUNITS) = [character(len=4)::'s', 'min', 'hr', 'd', 'yr', 'kyr', 'Myr', 'Gyr', 'g', 'kg', 'Msun', 'cm', 'm', 'km', 'Rsun']

Unit names as units command takes them (docs/commands.md).

integer(kind=int32), public, parameter :: UDIM(NUNITS) = [DIM_TIME, DIM_TIME, DIM_TIME, DIM_TIME, DIM_TIME, DIM_TIME, DIM_TIME, DIM_TIME, DIM_MASS, DIM_MASS, DIM_MASS, DIM_LENGTH, DIM_LENGTH, DIM_LENGTH, DIM_LENGTH]

Dimension code of each unit.

real(kind=real64), public, parameter :: UFAC(NUNITS) = [1.d0, 60.d0, 3600.d0, 86400.d0, YR, 1.d3*YR, 1.d6*YR, 1.d9*YR, 1.d0, 1.d3, SOLMASS, 1.d0, 1.d2, 1.d5, SOLRAD]

Size of each unit in cgs.

character(len=8), public, parameter :: ULABEL(NUNITS) = [character(len=8)::'s', 'min', 'hr', 'd', 'yr', 'kyr', 'Myr', 'Gyr', 'g', 'kg', 'M_\odot', 'cm', 'm', 'km', 'R_\odot']

Axis label of each unit in giza markup.

integer(kind=int32), private, parameter :: IYR = 5

UNAME indices of yr and Gyr.

Units yr to Gyr step by 1000, so an offset moves between them exactly.

integer(kind=int32), private, parameter :: IGYR = 8

UNAME indices of yr and Gyr.

Units yr to Gyr step by 1000, so an offset moves between them exactly.

integer(kind=int32), private, parameter :: NSUF = 8

Number of unit suffixes.

character(len=7), private, parameter :: SUF(NSUF) = [character(len=7)::'erg_g_s', 'erg_s', 'gcc', 'yr', 'cm', 'K', 'g', 's']

Column-name suffixes read as units when header states none.

Longest first, so _erg_g_s tried before _s.

character(len=7), private, parameter :: SUFUNIT(NSUF) = [character(len=7)::'erg/g/s', 'erg/s', 'g/cc', 'yr', 'cm', 'K', 'g', 's']

Unit of each suffix in SUF.

integer(kind=int32), private, parameter :: NGREEK = 47

Number of Greek-letter tokens.

character(len=7), private, parameter :: GREEK(NGREEK) = [character(len=7)::'nabla', 'alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi', 'rho', 'sigma', 'tau', 'phi', 'chi', 'psi', 'omega', 'Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Phi', 'Chi', 'Psi', 'Omega']

giza Greek-letter tokens (giza-token-remapper.h), written \<name>.


Interfaces

interface

  • private pure function c_fmod(x, y) result(r) bind(C, name='fmod'))

    Return floating-point remainder of x/y, via C fmod.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=c_double), value :: x

    Dividend.

    real(kind=c_double), value :: y

    Divisor.

    Return Value real(kind=c_double)


Functions

public pure function unit_id(name) result(k)

Return UNAME index of unit name, or 0 if unknown.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Unit name.

Return Value integer(kind=int32)

public pure function auto_time_unit(span_sec) result(k)

Return largest time unit in which span is at least 1.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: span_sec

Visible time span (s).

Return Value integer(kind=int32)

private pure function unit_tex(u) result(t)

Typeset unit w/ negative exponents.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: u

Unit as header or suffix gives it.

Return Value character(len=96)

private pure function floordiv(a, b) result(f)

Return Python float floor division a // b for a, b > 0.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: a

Dividend.

real(kind=real64), intent(in) :: b

Divisor.

Return Value real(kind=real64)

private pure function fmt_number(digits, p) result(s)

Format digits x 10^p as giza_format_number writes it in automatic form.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: digits

Decimal digits of the mantissa.

integer(kind=int32), intent(in) :: p

Power of ten.

Return Value character(len=64)

private pure function lower(s) result(t)

Return s w/ ASCII letters lower-cased.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: s

Input string.

Return Value character(len=len)


Subroutines

public pure subroutine quantity_label(name, unit, base, ulab)

Split column into the two parts of its colorbar title.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Column name.

character(len=*), intent(in) :: unit

Unit header states for column, blank if none.

character(len=*), intent(out) :: base

Title text of name, in giza markup.

character(len=*), intent(out) :: ulab

Typeset unit, blank if none.

public pure subroutine axis_offset(lo, hi, k, off, txt)

Find matplotlib ScalarFormatter offset of linear time axis.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: lo

Lower view limit, in tick unit.

real(kind=real64), intent(in) :: hi

Upper view limit, in tick unit.

integer(kind=int32), intent(in) :: k

UNAME index of the tick unit.

real(kind=real64), intent(out) :: off

Offset in tick unit, 0 if none applies.

character(len=*), intent(out) :: txt

Offset as matplotlib shows it (+... and unit label), blank if none applies.