As our package ‘photobiologyInOut’ (versions >= 0.4.15) supports the automatic import of the files returned by the Quick TUV Calculator, we show here how to produce such files, and link to an example showing how to import and plot them in R.

## photobiology 0.9.27

This update is in part the result of comparing the values returned by functions `sun_angles()`

and `day_night()`

to those returned by equivalent functions from other R packages and to the online NOAA Solar Calculator (considered the best implementation of Meuus astronomical algirithms, which are currently the most precise available). To see the whole story as it develops, please, have a look at my post describing these tests.

Changes from version 0.9.26, the most recent CRAN release, are:

- Improve performance of
`sun_angles()`

and`day_night()`

and implement Meuus algorithm for julian day. End result is slightly slower performance but higher precision and broader range of dates that are handled correctly. - Make sure functions work correctly when a tibble is passed as argument to parameter geocode. In addition tolerate
`address`

column being a factor. - Values returned by
`sun_angles()`

and`day_night()`

have changed very slightly as a result of the improved julian day calculation.

Documentation web site at http://docs.r4photobiology.info/photobiology/ includes all help pages, with output from all examples, and vignettes in HTML format.

**NOTE: The updated package is on its way to CRAN.
**

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

## R 3.6.0 is coming

A new version of R will be released on 2019-04-26. One significant change is the support of HCL colour definitios and palettes. Some defaults for colour palettes are changing (for the better) but small differences may visible in how plots look compared to earlier R versions. There is a post with a summary at the R blog, and a paper arXiv:1903.0649 describing why better palettes for data plotting can be defined.

Another significant change is that serialization format 3 becomes the default. As this format can be read only by R (>= 3.5.0) when sharing files created with `save()`

or `saveRDS()`

, and when sharing saved workspaces one needs to make sure the recipient is using a recent version of R or override this new default to create the files to be shared using the older serialization format 2.

All the packages I maintain should work correctly under R (= 3.6.0), but if you discover a problem, please, raise an issue at bitbucket within the repository of the affected package.

## Benchmarking function sun_angles() [updated]

As far as I know there are in CRAN four R packages implementing the computations for the position of the sun and times of sunrise and sunset: ‘photobiology’, ‘fishmethods’, ‘solartime’ and ‘suncalc’.

The functions `sun_angles()`

and `day_night()`

from package ‘photobiology’ use Meeus equations as used by NOAA Solar Calculator https://www.esrl.noaa.gov/gmd/grad/solcalc/ which could be more precise than those in NOAA’s Excel worksheet which implement a simplified version of the Meeus equations especially for far into the past or far into the future calculations. The approximations based on Meuus equations are very good for years between 1800 and 2100 and results should still be sufficiently accurate for the range from -1000 to 3000 as long as the computation of Julian dates is correct. The Excel implementation is only valid for dates between 1901 and 2099 because of how Julian dates are computed in Excel.

Function `astrocalc4r()`

from package ‘fishmethods’ also implements Meeus equations (the authors work at NOAA). Function `computeSunPosition()`

from package ‘solartime’ uses unspecified equations and function `getSunlightPosition()`

is an R interface to the ‘suncalc.js’ library, part of the ‘SunCalc.net’ project <http://suncalc.net>.

Function `computeSunPosition()`

from package ‘solartime’ uses unspecified equations and function `getSunlightPosition()`

is an R interface to the ‘suncalc.js’ library, part of the ‘SunCalc.net’ project <http://suncalc.net>.

UPDATED on 2019-04-24

I have noticed significant differences in the values returned by equivalent functions from different packages. Up to now the tests on the functions of my own package ‘photobiology’ have revealed only very small mismatches to the NOAA Solar Calculator. These small errors, noticeable for dates far from the present, were due to the use of base R’s `julian()`

function, which is not designed to be precise enough for astronomical calculations. The code now in the repository at Bitbucket has been revised to use Meuus’ algorithm for the calculation of Julian days removing this source of small discrepancies.

In contrast, while testing ‘photobiology’ against other packages, I seem to have found a bug in function `astrocalc4r()`

from R package ‘fishmethods’.

A minimal example follows:

By only changing the hour passed as argument different times for sunrise, sunset and daylength are returned even though the day is the same. The differences are larger at high than at low latitudes. The maximum difference for the example above is 1/4 h for daylength. Comparison against the NOAA Solar Calculator shows even larger differences.

(The bug has been reported to the maintainer of package ‘fishmethods’.)

## ggpmisc 0.3.1

After the previous major update to ‘ggpmisc’ (0.3.0), a follow up (0.3.1) with multiple new features and smoothed rough edges for some of the features added in version 3.0.0. Package documentation is available at https://docs.r4photobiology.info/ggpmisc/ as a web site.

The enhancements in this and the previous update to ‘ggpmisc’ are made possible by changes to ‘ggplot2’ (>= 3.0.0) made while adding support for sf (*simple features*).

The functions in ‘ggpmisc’ (>= 0.3.1) are related to different kinds of annotations and insets in ggplots. Annotations of plots with fitted-model equations, fit diagnosis, ANOVA and summary tables, highlighting and labelling of peaks and valleys in curves, and local density-based highlighting or labelling in scatter plots. Additionally specializations of the `ggplot()`

constructor allow on-the-fly conversion of time-series. Two new *geoms *join `geom_table()`

added in version 0.3.0, `geom_plot()`

and `geom_grob()`

. These three *geoms *make it possible to add tables, ggplots and arbitrary graphical objects (grobs) as insets to plots respecting the the Grammar of Graphics paradigm.

A set of new *geometries *produce marginal annotations: `geom_x_margin_point()`

, `geom_y_margin_point()`

, `geom_x_margin_arrow()`

, `geom_y_margin_arrow()`

, `geom_x_margin_grob()`

and `geom_y_margin_grob()`

.

Another novel feature is based on the addition of two new *aesthetics *`npcx`

and `npcy`

, the corresponding *scales *`scale_npcx_continuous()`

and `scale_npcy_continuous()`

, and several new *geometries *that make use of then: `geom_text_npc()`

, `geom_label_npc()`

, `geom_table_npc()`

, `geom_plot_npc()`

and `geom_grob_npc()`

. These allow to position insets and annotations relative to the dimensions of the plotting area instead of using native data units. Using `"npc"`

units is more natural for labels or insets that are not directly related to data but that look better if positioned consistently across multiple panels or multiple separately produced plots. One improvement to the *stats *from earlier versions of ‘ggpmisc’ is the use of these new *geoms *to achieve more consistent location for insets and labels.

As in the announcement of the previous version, I have included some example plots taken from the documentation of the package. In all cases annotations are generated automatically, but formatting is flexible.

NOTE: The new version of ‘ggpmisc’ will be soon submitted to **CRAN** .