Giter Club home page Giter Club logo

exoplanets's Introduction

exoplanets

R build status Codecov test coverage Peer review CRAN status CRAN_Download_Badge

The goal of exoplanets is to provide access to NASA’s Exoplanet Archive TAP Service. The functionality of this package is minimal and is simply an R interface to access exoplanet data.

Exoplanets color coded by discovery method

Installation

Install the released version of exoplanets from CRAN:

install.packages("exoplanets")

Or you can install from GitHub with:

# install.packages("devtools")
devtools::install_github("ropensci/exoplanets")

Example

This is a basic example which shows you how to access data from the k2names table:

library(exoplanets)

options(
  exoplanets.progress = FALSE, # hide progress
  readr.show_types = FALSE     # hide col spec, requires readr 2.0.0 >=
)

exoplanets("k2names")
#> • https://exoplanetarchive.ipac.caltech.edu/TAP/sync?query=select+*+from+k2names&format=csv
#> # A tibble: 449 x 3
#>    epic_id        k2_name  pl_name     
#>    <chr>          <chr>    <chr>       
#>  1 EPIC 246199087 K2-112 f TRAPPIST-1 f
#>  2 EPIC 246199087 K2-112 h TRAPPIST-1 h
#>  3 EPIC 211331236 K2-117 c K2-117 c    
#>  4 EPIC 212398486 K2-125 b K2-125 b    
#>  5 EPIC 217941732 K2-130 b K2-130 b    
#>  6 EPIC 228754001 K2-132 b K2-132 b    
#>  7 EPIC 247887989 K2-133 d K2-133 d    
#>  8 EPIC 247589423 K2-136 b K2-136 b    
#>  9 EPIC 247589423 K2-136 d K2-136 d    
#> 10 EPIC 201912552 K2-18 c  K2-18 c     
#> # … with 439 more rows

If you wish, you can select only the columns you need:

exoplanets("ps", c("pl_name", "hostname"))
#> • https://exoplanetarchive.ipac.caltech.edu/TAP/sync?query=select+pl_name,hostname+from+ps&format=csv
#> # A tibble: 29,683 x 2
#>    pl_name      hostname  
#>    <chr>        <chr>     
#>  1 Kepler-11 c  Kepler-11 
#>  2 Kepler-11 f  Kepler-11 
#>  3 HAT-P-1 b    HAT-P-1   
#>  4 OGLE-TR-10 b OGLE-TR-10
#>  5 TrES-2 b     TrES-2    
#>  6 WASP-3 b     WASP-3    
#>  7 HD 210702 b  HD 210702 
#>  8 BD-08 2823 b BD-08 2823
#>  9 BD-08 2823 c BD-08 2823
#> 10 HAT-P-30 b   HAT-P-30  
#> # … with 29,673 more rows

You can also specify the number of rows returned using limit:

exoplanets("keplernames", limit = 5)
#> • https://exoplanetarchive.ipac.caltech.edu/TAP/sync?query=select+*+from+keplernames+top+5&format=csv
#> # A tibble: 5 x 4
#>     kepid koi_name  kepler_name   pl_name      
#>     <dbl> <chr>     <chr>         <chr>        
#> 1 7515212 K00679.02 Kepler-212 b  Kepler-212 b 
#> 2 8210018 K02762.01 Kepler-1341 b Kepler-1341 b
#> 3 9008737 K02768.01 Kepler-404 b  Kepler-404 b 
#> 4 4833421 K00232.05 Kepler-122 f  Kepler-122 f 
#> 5 9963524 K00720.02 Kepler-221 d  Kepler-221 d

Information on the tables and columns available can be found with:

tableinfo
#> # A tibble: 546 x 13
#>    table database_column_… table_label description  in_ps_table in_ps_comp_pars…
#>    <chr> <chr>             <chr>       <chr>        <lgl>       <lgl>           
#>  1 ps    default_flag      Default Pa… Boolean fla… TRUE        FALSE           
#>  2 ps    soltype           Solution T… Disposition… TRUE        FALSE           
#>  3 ps    pl_controv_flag   Controvers… Flag indica… TRUE        TRUE            
#>  4 ps    pl_name           Planet Name Planet name… TRUE        TRUE            
#>  5 ps    hostname          Host Name   Stellar nam… TRUE        TRUE            
#>  6 ps    pl_letter         Planet Let… Letter assi… TRUE        TRUE            
#>  7 ps    hd_name           HD ID       Name of the… TRUE        TRUE            
#>  8 ps    hip_name          HIP ID      Name of the… TRUE        TRUE            
#>  9 ps    tic_id            TIC ID      Name of the… TRUE        TRUE            
#> 10 ps    gaia_id           GAIA ID     Name of the… TRUE        TRUE            
#> # … with 536 more rows, and 7 more variables:
#> #   uncertainties_column_positive_negative <chr>, limit_column <chr>,
#> #   default <lgl>, notes <chr>, displayed_string_name <chr>, flag_column <lgl>,
#> #   number_of_measurements <lgl>

Capabilities

At one time, this package used the Exoplanet Archive Application Programming Interface (API). Since then, a handful of tables have been transitioned to the Table Access Protocol (TAP) service. More tables will be transitioned to TAP and as such, this package only supports queries from TAP. For more information, you can read https://exoplanetarchive.ipac.caltech.edu/docs/exonews_archive.html#29April2021.

Contributing

Please note that this package is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

exoplanets's People

Contributors

maelle avatar tylerlittlefield avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mathidachuk

exoplanets's Issues

Release exoplanets 0.2.2

Prepare for release:

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()

Add function to clear cache

The exoplanets() function is memoized so give the user an easy option to forget past results and clear the functions cache with forget_exoplanets().

library(exoplanets)

# first try
exoplanets("k2names")

# second try, cached
exoplanets("k2names")

# third try, forgotten
memoise::forget(exoplanets)
exoplanets("k2names")

Add dplyr/dbplyr style interface

Since this API use sql in the URL, it would be cool if we could do something like:

tbl(con, "ps") %>% 
  filter(pl_name == "foo") %>% 
  collect()

It sounds cool but I'm not sure if it would work. Part of what is so fun with databases is being able to manipulate the data, see the results (lazily), and then collect when you're ready. But doing this via an API, it sounds like we would need to make a request each time, which could defeat the purpose, and take even longer (the tables offered in TAP right now aren't very large, they will be as more are migrated however).

More: https://twitter.com/tyluRp/status/1390773696860770304?s=20

Release exoplanets 0.2.1

Prepare for release:

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()

Release exoplanets 0.2.0

First release:

Prepare for release:

  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • Review pkgdown reference index for, e.g., missing topics

Submit to CRAN:

  • devtools::release()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Update install instructions in README
  • Tweet

Possible improvements to the tableinfo dataset

The tableinfo dataset is pretty much a raw representation of the tables found at each individual link shown here: https://exoplanetarchive.ipac.caltech.edu/docs/TAP/usingTAP.html

There could be some possible areas of improvement such as replacing "X" with TRUE, i.e. something more familiar to R users. Below are some ideas:

library(dplyr)

tableinfo %>% 
  # remove all trailing/leading whitespace
  mutate(across(
    .cols = where(is.character), 
    .fns = stringr::str_squish
  )) %>% 
  # replace all empty character values with NA
  mutate(across(
    .cols = where(is.character), 
    .fns = dplyr::na_if, 
    ""
  )) %>% 
  # if "X" return TRUE
  mutate(across(
    .cols = where(is.character), 
    .fns = ~ ifelse(
      test = .x == "X", 
      yes = TRUE, 
      no = .x
    )
  ))

Make quiet/progress parameters an option instead

People will probably either want progress/messages from the function or not want it at all. We should allow the user to define this with something like:

options(exoplanets.progress = FALSE)

So that they don't need to keep providing progress = FALSE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.