This tutorial explains how to access to the first **phenomeapi** web service (PHIS system information). For this first web service, the available functions are: * getEnvironment() * getExperiments() * getImageAnalysis() * getProjects() * getVariableByCategory() * getWatering()
  library(phisWSClientR)

Creation of an identifier

Ask permission to request to the web service:

  # If you want to access to the public web service 
  connect(apiID="ws_public")
  # If you want to access to a private web service, you have to insert the address of the WS and the port
  connect(apiID="ws_private",url = "147.99.7.5:8080/phenomeapi/resources/")

aToken will be used in all the requests to the web service.

  aToken<-getToken("guestphis@supagro.inra.fr","guestphis")

Retrieves the available projects

  getProjects(aToken$data)$data

  getExperiments(aToken$data,projectName = "XYZ")

The user can define a variable with the experiment URI provided by the result of getExperiments() function that can be used in the call of each functions useful to retrieve the data:

  myExp<-getExperiments(aToken$data,projectName = "XYZ")$data$experimentURI
  print(myExp)

Retrieves the variables of an experiment by category

Different categories of variables are available in the phenomeapi web service:

* environment * imagery * watering * weighing

Environment

  vars <- getVariablesByCategory(aToken$data ,category = "environment",experimentURI = myExp)

  # Only the first rows of the data.frame containing the 'environment' variables...
  head(vars$data)

Imagery

  # first rows of 'imagery' variables
  head(getVariablesByCategory(aToken$data,category ="imagery",experimentURI=myExp)$data)

Watering

  # first rows of 'watering' variables
  head(getVariablesByCategory(aToken$data,category ="watering",experimentURI=myExp)$data)

Retrieves the imagery data of an experiment

  # first we count the number of observation in the dataset
  tpCount<-getImagesAnalysis(token=aToken$data, experimentURI=myExp,
                             variablesName = list("plantHeight"),
                             labelView ="side0",
                             verbose=FALSE)$totalCount
  # we retrieve this number with $totalcount
  # In this example, we set the pageSize to 10 for speed purpose but in real example, please use tpCount
  requetManip<-getImagesAnalysis(token=aToken$data, experimentURI=myExp,
                             variablesName = list("plantHeight"),
                             labelView ="side0",
                             pageSize=10)$data
  head(requetManip)

  # getPlants function allows the user to retrieve all the information for all the plants of an experiment
  # In this example, we set the pageSize to 10 for speed purpose but in real example, please use tpCount
  idManip<-getPlants(token=aToken$data, experimentURI=myExp,
                     pageSize=10)$data
  head(idManip)

Retrieves the environment data of an experiment

try the following code and explore the dataset

  myFacility<-"http://www.phenome-fppn.fr/m3p/es2"
  tpCount<-getEnvironment(token = aToken$data ,
                     experimentURI = myExp,
                     facility=myFacility,
                     variables = "air humidity_weather station_percentage")$totalCount
  #--- Air humidity
  # we retrieve this number with $totalcount
  # In this example, we set the pageSize to 10 for speed purpose but in real example, please use tpCount
  myMeteoHumidity<-getEnvironment(token = aToken$data,experimentURI=myExp,
                     facility=myFacility,
                     variables="air humidity_weather station_percentage",
                     pageSize=10)$data

Retrieves the watering data of an experiment

try the following code and explore the dataset

  tpCount<-getWatering(token=aToken$data,experimentURI=myExp,
                       variablesName = list("weightAfter"),
                       verbose=FALSE)$totalCount
  # we retrieve this number with $totalcount
  # In this example, we set the pageSize to 10 for speed purpose but in real example, please use tpCount
  requetIrrig<-getWatering(token=aToken$data,experimentURI=myExp,
                           variablesName = list("weightAfter"),
                           pageSize=10)$data

Session info

  sessionInfo()

References

  1. R Development Core Team (2015). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. ISBN 3-900051-07-0, URL http://www.R-project.org.


niio972/opensilex-ws-client-r documentation built on Nov. 4, 2019, 10:06 p.m.