Skip to content

Commit

Permalink
Merge pull request #339 from sblunt/github-actions
Browse files Browse the repository at this point in the history
GitHub actions
  • Loading branch information
semaphoreP committed Jun 21, 2023
2 parents f4f795f + 2bd578b commit ad57c74
Show file tree
Hide file tree
Showing 16 changed files with 1,211 additions and 871 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package
name: CI tests

on:
push:
branches: [ "main" ]
branches:
- '*' # run on all
pull_request:
branches: [ "main" ]
branches:
- '*'

jobs:
build:

runs-on: ubuntu-latest
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
Expand Down
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

90 changes: 49 additions & 41 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('./../orbitize')) # location of orbitize files with docstrings

sys.path.insert(
0, os.path.abspath("./../orbitize")
) # location of orbitize files with docstrings


# -- General configuration ------------------------------------------------
Expand All @@ -35,38 +38,41 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx_rtd_theme',
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.todo',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon', # allows Google style-guide docs to render more prettily
'sphinx.ext.viewcode',
'nbsphinx'
]
"sphinx_rtd_theme",
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.todo",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon", # allows Google style-guide docs to render more prettily
"sphinx.ext.viewcode",
"nbsphinx",
]

# Disable notebook timeout
nbsphinx_timeout = -1

# Always re-run notebooks when building docss
nbsphinx_execute = "always"

# Allow notebook errors
nbsphinx_allow_errors = True
nbsphinx_allow_errors = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'orbitize'
copyright = '2018, Sarah Blunt, Jason Wang, Isabel Angelo, Henry Ngo, et al'
author = 'Sarah Blunt, Jason Wang, Isabel Angelo, Henry Ngo, et al'
project = "orbitize"
copyright = "2018, Sarah Blunt, Jason Wang, Isabel Angelo, Henry Ngo, et al"
author = "Sarah Blunt, Jason Wang, Isabel Angelo, Henry Ngo, et al"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -75,7 +81,7 @@
# The short X.Y version.
version = orbitize.__version__
# The full version, including alpha/beta/rc tags.
#release = '0.1'
# release = '0.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -90,7 +96,7 @@
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
Expand All @@ -101,7 +107,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -111,12 +117,12 @@

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = 'orbitize_logo_150.png'
# html_logo = 'orbitize_logo_150.png'

# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = 'favicon.ico'
html_favicon = "favicon.ico"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand All @@ -129,17 +135,17 @@
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
"**": [
"relations.html", # needs 'show_related': True theme option to display
"searchbox.html",
]
}


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'orbitizedoc'
htmlhelp_basename = "orbitizedoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -148,15 +154,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -166,19 +169,21 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'orbitize.tex', 'orbitize Documentation',
'Sarah Blunt, Jason Wang, Henry Ngo, et al.', 'manual'),
(
master_doc,
"orbitize.tex",
"orbitize Documentation",
"Sarah Blunt, Jason Wang, Henry Ngo, et al.",
"manual",
),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'orbitize', 'orbitize Documentation',
[author], 1)
]
man_pages = [(master_doc, "orbitize", "orbitize Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -187,10 +192,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'orbitize', 'orbitize Documentation',
author, 'orbitize', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"orbitize",
"orbitize Documentation",
author,
"orbitize",
"One line description of project.",
"Miscellaneous",
),
]



92 changes: 2 additions & 90 deletions orbitize/radvel_utils/compute_sep.py
Original file line number Diff line number Diff line change
@@ -1,90 +1,2 @@
import numpy as np
import pandas as pd
from astropy import units as u

from radvel.basis import Basis
from radvel.utils import Msini
from orbitize.basis import tp_to_tau
from orbitize.kepler import calc_orbit

def compute_sep(
df, epochs, basis, m0, m0_err, plx, plx_err, n_planets=1, pl_num=1
):
"""
Computes a sky-projected angular separation posterior given a
RadVel-computed DataFrame.
Args:
df (pd.DataFrame): Radvel-computed posterior (in any orbital basis)
epochs (np.array of astropy.time.Time): epochs at which to compute
separations
basis (str): basis string of input posterior (see
radvel.basis.BASIS_NAMES` for the full list of possibilities).
m0 (float): median of primary mass distribution (assumed Gaussian).
m0_err (float): 1sigma error of primary mass distribution
(assumed Gaussian).
plx (float): median of parallax distribution (assumed Gaussian).
plx_err: 1sigma error of parallax distribution (assumed Gaussian).
n_planets (int): total number of planets in RadVel posterior
pl_num (int): planet number used in RadVel fits (e.g. a RadVel label of
'per1' implies `pl_num` == 1)
Example:
>> df = pandas.read_csv('sample_radvel_chains.csv.bz2', index_col=0)
>> epochs = astropy.time.Time([2022, 2024], format='decimalyear')
>> seps, df_orb = compute_sep(
df, epochs, 'per tc secosw sesinw k', 0.82, 0.02, 312.22, 0.47
)
Returns:
tuple of:
np.array of size (len(epochs) x len(df)): sky-projected angular
separations [mas] at each input epoch
pd.DataFrame: corresponding orbital posterior in orbitize basis
"""

myBasis = Basis(basis, n_planets)
df = myBasis.to_synth(df)
chain_len = len(df)
tau_ref_epoch = 58849

# convert RadVel posteriors -> orbitize posteriors
m_st = np.random.normal(m0, m0_err, size = chain_len)
semiamp = df['k{}'.format(pl_num)].values
per_day = df['per{}'.format(pl_num)].values
period_yr = per_day / 365.25
ecc = df['e{}'.format(pl_num)].values
msini = (
Msini(semiamp, per_day, m_st, ecc, Msini_units='Earth') *
(u.M_earth / u.M_sun).to('')
)
cosi = (2. * np.random.random(size = chain_len)) - 1.
inc = np.arccos(cosi)
m_pl = msini / np.sin(inc)
mtot = m_st + m_pl
sma = (period_yr**2 * mtot)**(1/3)
omega_st_rad = df['w{}'.format(pl_num)].values
omega_pl_rad = omega_st_rad + np.pi
parallax = np.random.normal(plx, plx_err, size = chain_len)
lan = np.random.random_sample(size = chain_len) * 2. * np.pi
tp_mjd = df['tp{}'.format(pl_num)].values - 2400000.5
tau = tp_to_tau(tp_mjd, tau_ref_epoch, period_yr)

# compute projected separation in mas
raoff, deoff, _ = calc_orbit(
epochs.mjd, sma, ecc, inc,
omega_pl_rad, lan, tau,
parallax, mtot, tau_ref_epoch=tau_ref_epoch
)
seps = np.sqrt(raoff**2 + deoff**2)

df_orb = pd.DataFrame(
np.transpose([sma, ecc, inc, omega_pl_rad, lan, tau, parallax, m_st, m_pl]),
columns=[
'sma', 'ecc', 'inc_rad', 'omega_pl_rad', 'lan_rad', 'tau_58849',
'plx', 'm_st', 'mp'
]
)

return seps, df_orb
def compute_sep(df, epochs, basis, m0, m0_err, plx, plx_err, n_planets=1, pl_num=1):
raise ModuleNotFoundError("This functionaity is deprecated. See sblunt/orbitize_radvel_utils.")
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ deprecation
cython
pytest
pandas
radvel
pyerfa
astroquery
sphinx
Expand Down

0 comments on commit ad57c74

Please sign in to comment.