Skip to content

Commit

Permalink
update README and example function calls with most-tweaked arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
japhir committed Mar 5, 2024
1 parent 4df064b commit f86459b
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 22 deletions.
2 changes: 1 addition & 1 deletion R/snvec.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
#' @examples
#' \donttest{
#' # default call
#' snvec()
#' snvec(tend = -1e3, ed = 1, td = 0, tres = -0.4)
#'
#' # ignore the below, this is just to make CRAN builds happy!
#' # remove the directory with the cached astronomical solution to clean up
Expand Down
25 changes: 20 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,30 @@ Here's the main function that does the work in action:

```{r example}
library(snvecR)
solution <- snvec()
solution <- snvec(tend = -1000, ed = 1, td = 0,
astronomical_solution = "full-ZB18a",
tres = -0.4)
```

To quickly save out the results for further study to CSV[^1]:

[^1]: Actually I would recommend the [`readr` package](https://readr.tidyverse.org/) with `readr::write_csv()` instead.

```{r saveresults, eval = FALSE}
write.csv(solution, "ZB18a_ed-1.0_td-0.0.csv")
```

see `?snvec` for further documentation.

Here we create a quick plot of the calculated climatic precession with the
eccentricity envelope:
Here we create a quick plot of the obliquity:

```{r simpleplot, fig.width = 9, fig.height = 6}
plot(epl ~ time, data = solution, type = 'l')
```

Or if you want to make a slightly fancier plot of the calculated climatic precession with the eccentricity envelope:

```{r plot, fig.width = 9, fig.height = 7}
```{r plot, fig.width = 9, fig.height = 6}
library(ggplot2)
solution |>
ggplot(aes(x = time, y = cp)) +
Expand All @@ -73,7 +88,7 @@ solution |>
geom_line(aes(y = ee, colour = "Eccentricity"),
data = get_solution() |> dplyr::filter(time > -1000)) +
scale_color_discrete(type = c("skyblue", "black")) +
theme(legend.position.inside = c(.9, .95))
theme(legend.position = "inside", legend.position.inside = c(.9, .95))
```

# References
Expand Down
43 changes: 28 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,10 @@ Here’s the main function that does the work in action:

``` r
library(snvecR)
solution <- snvec()
#> ℹ The astronomical solution full-ZB18a has not been downloaded.
#> ℹ Reading 'full-ZB18a.dat' from website <http://www.soest.hawaii.edu/oceanography/faculty/zeebe_files/Astro/PrecTilt/OS/ZB18a/ems-plan3.dat>.
#> ℹ Calculating helper columns.
#> ℹ The cache directory is '/home/japhir/.cache/R/snvecR'.
#> ℹ Saved 'full-ZB18a.dat' to cache.
#> ℹ Saved cleaned-up 'full-ZB18a.csv' to cache.
#> → Saved solution with helper columns 'full-ZB18a.rds' to cache.
#> This is snvecR VERSION: 3.9.0 2024-02-29
solution <- snvec(tend = -1000, ed = 1, td = 0,
astronomical_solution = "full-ZB18a",
tres = -0.4)
#> This is snvecR VERSION: 3.9.1 2024-03-04
#> Richard E. Zeebe
#> Ilja J. Kocken
#>
Expand All @@ -69,21 +64,35 @@ solution <- snvec()
#> • `atol` = 1e-05
#> • `rtol` = 0
#> • `solver` = "vode"
#> ℹ started at "2024-03-04 13:39:55.132105"
#> ℹ started at "2024-03-05 20:58:24.795302"
#> Final values:
#> • s[1][2][3]: 0.404184487124565, -0.0537555129057148, and 0.913036138471423
#> • s-error = |s|-1: -5.51290422495798e-05
#> Final values:
#> • obliquity: 0.413060472710089 rad
#> • precession: -0.562357122261026 rad
#> ℹ stopped at "2024-03-04 13:40:00.516361"
#> ℹ total duration: 5.38s
#> ℹ stopped at "2024-03-05 20:58:29.453921"
#> ℹ total duration: 4.66s
```

To quickly save out the results for further study to CSV[^1]:

``` r
write.csv(solution, "ZB18a_ed-1.0_td-0.0.csv")
```

see `?snvec` for further documentation.

Here we create a quick plot of the calculated climatic precession with
the eccentricity envelope:
Here we create a quick plot of the obliquity:

``` r
plot(epl ~ time, data = solution, type = 'l')
```

<img src="man/figures/README-simpleplot-1.png" width="100%" />

Or if you want to make a slightly fancier plot of the calculated
climatic precession with the eccentricity envelope:

``` r
library(ggplot2)
Expand All @@ -96,7 +105,7 @@ solution |>
geom_line(aes(y = ee, colour = "Eccentricity"),
data = get_solution() |> dplyr::filter(time > -1000)) +
scale_color_discrete(type = c("skyblue", "black")) +
theme(legend.position.inside = c(.9, .95))
theme(legend.position = "inside", legend.position.inside = c(.9, .95))
```

<img src="man/figures/README-plot-1.png" width="100%" />
Expand All @@ -121,3 +130,7 @@ System Chaos. *The Astronomical Journal*, 164(3),

Wikipedia page on Orbital Elements:
<https://en.wikipedia.org/wiki/Orbital_elements>

[^1]: Actually I would recommend the [`readr`
package](https://readr.tidyverse.org/) with `readr::write_csv()`
instead.
Binary file modified man/figures/README-plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added man/figures/README-simpleplot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/snvec.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f86459b

Please sign in to comment.