Skip to content

Commit

Permalink
Docs (#29)
Browse files Browse the repository at this point in the history
* set up docs structure

* write up home page

* update docstrings from readme and clean up readme

* update travis for GH pages

* fix broken doc tests
  • Loading branch information
mileslucas authored and giordano committed Jan 3, 2020
1 parent f54596d commit 6872ec8
Show file tree
Hide file tree
Showing 8 changed files with 326 additions and 220 deletions.
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

# Created by https://www.gitignore.io/api/julia
# Edit at https://www.gitignore.io/?templates=julia

### Julia ###
# Files generated by invoking Julia with --code-coverage
*.jl.cov
*.jl.*.cov

# Files generated by invoking Julia with --track-allocation
*.jl.mem

# System-specific files and directories generated by the BinaryProvider and BinDeps packages
# They contain absolute paths specific to the host computer, and so should not be committed
deps/deps.jl
deps/build.log
deps/downloads/
deps/usr/
deps/src/

# Build artifacts for creating documentation generated by the Documenter package
docs/build/
docs/site/

# File generated by Pkg, the package manager, based on a corresponding Project.toml
# It records a fixed state of all packages used by the project. As such, it should not be
# committed for packages, but should be committed for applications that require a static
# environment.
Manifest.toml

# End of https://www.gitignore.io/api/julia
16 changes: 13 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,24 @@ julia:
- 1.3
- nightly
notifications:
email: false
email: false
git:
depth: 999999

## uncomment the following lines to allow failures on nightly julia
## (tests will run but not make your overall status red)
matrix:
allow_failures:
- julia: nightly
allow_failures:
- julia: nightly

coveralls: true
jobs:
include:
- stage: Documentation
julia: 1.2
script: julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(path=pwd()));
Pkg.instantiate();
include("docs/make.jl");'
after_success: skip
173 changes: 5 additions & 168 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Cosmology calculator for Julia
==============================
# Cosmology.jl

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliaastro.github.io/Cosmology.jl/stable)
[![Latest](https://img.shields.io/badge/docs-latest-blue.svg)](https://juliaastro.github.io/Cosmology.jl/latest)
[![Build Status](https://img.shields.io/travis/JuliaAstro/Cosmology.jl.svg?style=flat-square&label=build)](https://travis-ci.org/JuliaAstro/Cosmology.jl)
[![Coverage Status](http://img.shields.io/coveralls/JuliaAstro/Cosmology.jl.svg?style=flat-square)](https://coveralls.io/r/JuliaAstro/Cosmology.jl?branch=master)

A cosmology calculator for Julia.

Installation
------------
## Installation

To install the package:

Expand All @@ -20,167 +21,3 @@ Then, to load into your session:
julia> using Cosmology
```

`Cosmology.jl` uses [`Unitful.jl`](https://github.com/ajkeller34/Unitful.jl) and
[`UnitfulAstro.jl`](https://github.com/JuliaAstro/UnitfulAstro.jl) to handle units.

Cosmological Models
-------------------

First, pick a cosmological model using the `cosmology` function,
which takes the following options:

<table>
<tr>
<td>h = 0.69</td>
<td>Dimensionless Hubble constant</td>
</tr>
<tr>
<td>OmegaK = 0</td>
<td>Curvature density, Ω<sub>k</sub></td>
</tr>
<tr>
<td>OmegaM = 0.29</td>
<td>Matter density, Ω<sub>m</sub></td>
</tr>
<tr>
<td>OmegaR = Ω<sub>γ</sub> + Ω<sub>ν</sub></td>
<td>Radiation density, Ω<sub>r</sub></td>
</tr>
<tr>
<td>Tcmb = 2.7255</td>
<td>CMB temperature (K), used to compute Ω<sub>γ</sub></td>
</tr>
<tr>
<td>Neff = 3.04</td>
<td>Effective number of massless neutrino species, used to compute Ω<sub>ν</sub></td>
</tr>
<tr>
<td>w0 = -1</td>
<td>CPL dark energy equation of state, w = w0 + wa*(1-a)</td>
</tr>
<tr>
<td>wa = 0</td>
<td>CPL dark energy equation of state, w = w0 + wa*(1-a)</td>
</tr>
</table>

```julia
julia> using Cosmology

julia> c = cosmology()
FlatLCDM(0.69,0.7099122024007928,0.29,8.779759920715362e-5)

julia> c = cosmology(OmegaK=0.1)
OpenLCDM(0.69,0.1,0.6099122024007929,0.29,8.779759920715362e-5)

julia> c = cosmology(w0=-0.9, OmegaK=-0.1)
ClosedWCDM(0.69,-0.1,0.8099122024007929,0.29,8.779759920715362e-5,-0.9,0.0)
```

Distances
---------

<table>
<tr>
<td>angular_diameter_dist(cosmo,&nbsp;z)</td>
<td>Ratio of an object's proper transverse size (in Mpc) to its angular size (in radians)</td>
</tr>
<tr>
<td>angular_diameter_dist(cosmo,&nbsp;z<sub>1</sub>,&nbsp;z<sub>2</sub>)</td>
<td>Ratio of the proper transverse size (in Mpc) of an object at redshift z<sub>2</sub> to its
angular size (in radians), as seen by an observer at z<sub>1</sub></td>
</tr>
<tr>
<td>comoving_radial_dist(cosmo,&nbsp;z)</td>
<td>Comoving radial distance to redshift z, in Mpc</td>
</tr>
<tr>
<td>luminosity_dist(cosmo, z)</td>
<td>Bolometric luminosity distance, in Mpc</td>
</tr>
<tr>
<td>distmod(cosmo, z)</td>
<td>Distance modulus, in units of magnitude</td>
</tr>
</table>

```julia
julia> using Cosmology

julia> c = cosmology(OmegaM=0.26)
FlatLCDM(0.69,0.7399122024007928,0.26,8.779759920715362e-5)

julia> angular_diameter_dist(c, 1.2)
1784.0089227105113 Mpc

julia> angular_diameter_dist(c, 0.7, 1.2)
606.6521737365097 Mpc
```

For each function returning a unitful number, you can specify a different unit
for the result as first argument to the function:

```julia
julia> luminosity_dist(c, 1.5)
11420.338287150073 Mpc

julia> luminosity_dist(u"Gpc", c, 1.5)
11.420338287150074 Gpc
```

Volumes
-------

<table>
<tr>
<td>comoving_volume_element(cosmo,&nbsp;z)</td>
<td>Comoving volume element out to redshift z, in Gpc<sup>3</sup></td>
</tr>
<tr>
<td>comoving_volume(cosmo,&nbsp;z)</td>
<td>Comoving volume out to redshift z, in Gpc<sup>3</sup></td>
</tr>
</table>

```julia
julia> using Cosmology

julia> c = cosmology(OmegaM=0.26)
FlatLCDM(0.69,0.7399122024007928,0.26,8.779759920715362e-5)

julia> comoving_volume_element(c, 2.1)
46.74459228888612 Gpc^3

julia> comoving_volume(c, 0.6)
49.3633436631307 Gpc^3

julia> comoving_volume(u"ly^3", c, 0.6)
1.7127035381752994e30 ly^3
```

Times
-----

<table>
<tr>
<td>age(cosmo, z)</td>
<td>Age of the universe at redshift z, in Gyr</td>
</tr>
<tr>
<td>lookback_time(cosmo, z)</td>
<td>Difference between age at redshift 0 and age at redshift z, in Gyr</td>
</tr>
</table>

```julia
julia> using Cosmology

julia> c = cosmology(OmegaM=0.26)
FlatLCDM(0.69,0.7399122024007928,0.26,8.779759920715362e-5)

julia> age(c, 1.2)
5.445600787626434 Gyr

julia> lookback_time(u"yr", c, 1.2)
8.761660748088268e9 yr
```
7 changes: 7 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
UnitfulAstro = "6112ee07-acf9-5e0f-b108-d242c714bf9f"

[compat]
Documenter = "0.24"
23 changes: 23 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Documenter
using Cosmology


DocMeta.setdocmeta!(Cosmology, :DocTestSetup, :(using Cosmology); recursive = true)


makedocs(;
modules = [Cosmology],
authors = "Julia Astro",
repo = "https://github.com/JuliaAstro/Cosmology.jl/blob/{commit}{path}#L{line}",
sitename = "Cosmology.jl",
format = Documenter.HTML(;
prettyurls = get(ENV, "CI", "false") == "true",
canonical = "https://juliaastro.github.io/Cosmology.jl",
assets = String[],),
pages = [
"Home" => "index.md",
"API/Reference" => "api.md"
],)

deploydocs(;
repo = "github.com/JuliaAstro/Cosmology.jl",)
82 changes: 82 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
```@meta
DocTestSetup = :(using Cosmology, Unitful, UnitfulAstro)
```

# API/Reference

## Cosmological Models

```@docs
cosmology
```

## Distances

```@docs
angular_diameter_dist
comoving_radial_dist
luminosity_dist
distmod
```

### Examples

```jldoctest
julia> c = cosmology(OmegaM=0.26)
Cosmology.FlatLCDM{Float64}(0.69, 0.7399122024007928, 0.26, 8.77975992071536e-5)
julia> angular_diameter_dist(c, 1.2)
1784.0089227105113 Mpc
julia> angular_diameter_dist(c, 0.7, 1.2)
606.6521737365097 Mpc
julia> luminosity_dist(c, 1.5)
11420.338287150073 Mpc
julia> luminosity_dist(u"Gpc", c, 1.5) # Can convert to appropriate unit
11.420338287150074 Gpc
```


## Volumes

```@docs
comoving_volume_element
comoving_volume
```

### Examples

```jldoctest
julia> c = cosmology(OmegaM=0.26)
Cosmology.FlatLCDM{Float64}(0.69, 0.7399122024007928, 0.26, 8.77975992071536e-5)
julia> comoving_volume_element(c, 2.1)
46.74459228888612 Gpc^3
julia> comoving_volume(c, 0.6)
49.3633436631307 Gpc^3
julia> comoving_volume(u"ly^3", c, 0.6)
1.7127035381753e30 ly^3
```

## Times

```@docs
age
lookback_time
```

### Examples
```jldoctest
julia> c = cosmology(OmegaM=0.26)
Cosmology.FlatLCDM{Float64}(0.69, 0.7399122024007928, 0.26, 8.77975992071536e-5)
julia> age(c, 1.2)
5.445600787626434 Gyr
julia> lookback_time(u"yr", c, 1.2)
8.761660748088268e9 yr
```
26 changes: 26 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Cosmology.jl

[![Build Status](https://img.shields.io/travis/JuliaAstro/Cosmology.jl.svg?style=flat-square&label=build)](https://travis-ci.org/JuliaAstro/Cosmology.jl)
[![Coverage Status](http://img.shields.io/coveralls/JuliaAstro/Cosmology.jl.svg?style=flat-square)](https://coveralls.io/r/JuliaAstro/Cosmology.jl?branch=master)

`Cosmology.jl` provides functions for quick cosmological calculations, written in pure Julia.

## Installation

To install the package, enter `pkg` mode (`]`)

```julia-repl
pkg> add Cosmology
```

Then, to load the package

```julia-repl
julia> using Cosmology
```

## Contributing

If you would like to contribute to `Cosmology.jl`, head over to our [GitHub page](https://github.com/juliaastro/cosmology.jl) and open an issue or pull request!

For any new features, we ask the contributors to add any relevant unit tests and bump the package version by one minor version.
Loading

0 comments on commit 6872ec8

Please sign in to comment.