gginnards 0.0.2

This is a minor update, with the following enhancements compared to ‘gginnards’ 0.0.1.

  • Implement str() method for class "ggplot" as a wrapper with tweaked default arguments.
  • Add functions mapped_vars() and data_vars() to list variables in the default data member of objects of class "gg".
  • Add function data_attributes() to list the attributes of the default data member of objects of class "gg".

Documentation web site at http://docs.r4photobiology.info/gginnards/ includes all help pages, with output from all examples, and vignettes in HTML format.
NOTE: The package is on its way to CRAN CRAN.

Please raise issues concerning bugs or enhancements to this package through Bitbucket https://bitbucket.org/aphalo/gginnards/issues

Yoctopuce modules: Spectrometer

In the introduction to this series of post, I described the Yoctopuce library and told that R package ‘reticulate’ can be used to access the Python version of the yoctopuce library. Here I describe a simple and cheap “micro” spectrometer with a digital interface and its use together with R packages from the 'r4photobiology' suite.

I will use a miniature and low cost spectrometer, type AS7265X from ams. It does not used a grating as monochromator, but instead each of the 18 channels has a different interference filter deposited directly on the silicon chip. The FWHM is 20 nm, and the wavelength range from 410 nm to 940 nm. The spectrometer consists in three separate sensor units working together. The interface is digital, and temperature compensation and analogue to digital conversion takes place in the sensor modules. In spite of the number of channels communication between the spectrometer and a micro-processor requires only two wires. The spectrometer supports two different communication protocols, the specialized I2C and a generic serial communication (UART).

Continue reading

Yoctopuce modules: Introduction

Yoctopuce USB interface modules provide a very elegant solution to many different sensing and control problems, including measuring radiation. I have been interested in using them to acquire data directly from within R so as to be able to use the ‘r4photobiology’ suite of packages for real-time or near real time analysis and plotting of the acquired data.

The elegantly coded libraries supplied by Yoctopuce are available with interfaces in multiple computer programming and scripting languages. I have been trying different approaches to calling functions from these libraries in R scripts, but given the large number of functions needed to support the great variety of modules, writing an ad hoc interface for R was out of question. I first tried calling the command line version of the library functions from within R, but at least in Windows 10, the delay was too much and not consistent. Next I tried using the web server in the YoctoHub to send commands as http requests. This worked but it is a rather awkward approach, and not portable to accessing the modules directly through USB.

Two days ago, after reading about the ‘reticulate’ package I decided to test an approach similar to that I have used in package ‘rOmniDriver’ to access, with help from the ‘rJava’ package, Ocean Optics spectrometers through OmniDriver, a library written in Java. In the present case using ‘reticulate’ to access the Python version of the YoctoPuce library. It works extremely well, and the RStudio IDE provides in the editor even auto-completion and bubble help for functions and other objects defined in the Python library!

I have decided to describe here a few use cases for data acquisition or light source control using YoctoPuce models and R scripts. Most examples will be simple but useful, as they are real use cases rather than toy examples.

The YoctoPuce modules, hubs and the corresponding free libraries and the documentation are available at https://www.yoctopuce.com/. The ‘reticulate’ package is available through CRAN, and nicely formatted documentation can be found at https://rstudio.github.io/reticulate/. The first CRAN release of ‘reticulate’ appeared less than a year ago.

.


ggspectra 0.3.2

The changes from version 0.3.1, the current CRAN release, are:

  • Make autoplot() the recommended method and deprecate the use of plot(), which remains available for backwards compatibility.
  • Fix bug in autoplot() which failed to set the title to the name of the object when requested.
  • Add ‘ggplot2’ and ‘photobiology’ as required dependencies so that they are automatically loaded when ‘ggspectra’ is loaded.

The justification for renaming the plot() methods to autoplot() is that these methods defined in our package match better those of other specializations of autoplot() than of those of plot(), both in terms of the objects returned (ggplots) and in terms of their role as a fast way of plotting objects belonging to classes defined in independently developed packages. Some years ago, early in the development of ‘ggspectra’ it seemed more natural to use plot as the  method to specialize.

As most of the methods and functions defined take as input objects belonging to classes defined in package ‘photobiology’ and return objects belonging to classes defined in package ‘ggplot2’, these two packages need in most cases to be loaded for ‘ggspectra’ to work as intended.

Documentation web site at https://docs.r4photobiology.info/ggspectra/.

NOTE: The updated package is in CRAN.

Please raise issues concerning bugs or enhancements to this package through Bitbucket at https://bitbucket.org/aphalo/ggspectra/issues