Utility Functions

radvel.utils.Msini(K, P, Mtotal, e, Msini_units='earth')[source]

Calculate Msini

Calculate Msini for a given K, P, stellar mass, and e

Parameters:
  • K (float) – Doppler semi-amplitude [m/s]
  • P (float) – Orbital period [days]
  • Mtotal (float) – Mass of star + mass of planet [Msun]
  • e (float) – eccentricity
  • = (Msini_units) –
Returns:

Msini [units = Msini_units]

Return type:

float

radvel.utils.date2jd(date)[source]

Convert datetime object to JD”

Parameters:date (datetime.datetime) – date to convert
Returns:Julian date
Return type:float
radvel.utils.density(mass, radius, MR_units='earth')[source]
Parameters:
  • mass (float) – mass, units = MR_units
  • radius (float) – radius, units = MR_units
  • MR_units – (optional) units of mass and radius. Must be ‘earth’, or ‘jupiter’ (default ‘earth’).
Returns:

density (g/cc)

radvel.utils.geterr(vec, angular=False)[source]

Calculate median, 15.9, and 84.1 percentile values for a given vector.”

Parameters:
  • vec (array) – vector, usually an MCMC chain for one parameter
  • angular (bool) – (optional) Is this an angular parameter? if True vec should be in radians. This will perform some checks to ensure proper boundary wrapping.
Returns:

50, 15.9 and 84.1 percentiles

Return type:

tuple

radvel.utils.jd2date(jd)[source]

Convert JD to datetime.datetime object

Parameters:jd (float) – Julian date
Returns:calendar date
Return type:datetime.datetime
radvel.utils.semi_amplitude(Msini, P, Mtotal, e, Msini_units='jupiter')[source]

Compute Doppler semi-amplitude

Parameters:
  • Msini (float) – mass of planet [Mjup]
  • P (float) – Orbital period [days]
  • Mtotal (float) – Mass of star + mass of planet [Msun]
  • e (float) – eccentricity
  • Msini_units (string) – Units of returned Msini. Must be ‘earth’, or ‘jupiter’ (default ‘jupiter’).
Returns:

Doppler semi-amplitude [m/s]

radvel.utils.sigfig(med, errlow, errhigh=None)[source]

Format values with errors into an equal number of signficant figures.

Parameters:
  • med (float) – median value
  • errlow (float) – lower errorbar
  • errhigh (float) – upper errorbar
Returns:

(med,errlow,errhigh) rounded to the lowest number of significant figures

Return type:

tuple

radvel.utils.working_directory(*args, **kwds)[source]

Do something in a directory

Function to use with with statements.

Parameters:dir (string) – name of directory to work in

Example

>>> with workdir('/temp'):
    # do something within the /temp directory