Earth Sciences

Earth Sciences Wiki

User Tools

Site Tools


tools:rtools

Table of Contents

The R tools can be used for postprocessing experiments: loading data, computing prediction scores, indices or calibrate experiments as well as plotting, formating data and saving data. Furthermore, by dividing the data in chunks, you can speed your execution by using startR.

You can join the Earth RTools mailing list to receive the latest updates about news.

A quarterly meeting is taking place in the department to discuss about the plans and priorities of the R tools (or any other topic we need to discuss). Here you can find a document were the minutes are being gathered:

2020

2019

Please, see specific information for each tool:

R Tips

General R solutions which are useful in the department but doesn't belong exclusively to an in-house R package will be listed here.

1. How to change a CDO version in your open R session

> system('module load CDO/1.5.3-foss-2015a')
The following have been reloaded with a version change:
1) CDO/1.6.3-foss-2015a => CDO/1.5.3-foss-2015a

In this case, CDO version has been changed from a newer to an older version.

Remember that you can see the full list of CDO version by running:

  module av CDO

in your terminal

2. How to load dependencies of R package sf

This package could be used by loading the following modules in this specific order:

  module load R/3.6.1-foss-2015a-bare    
  module load GDAL/2.2.1-foss-2015a-GEOS-3.8.0
  module load PROJ/6.1.1-foss-2015a
  module load GEOS/3.8.0-foss-2015a

Note: Avoid to include them in your bashrc, just load them when it is a requirement.

3. How to load dependencies of R package rgdal

This package could be used by loading the following modules in this specific order:

- for R 3.2.0:

  module load R/3.2.0-foss-2015a-bare
  module load GDAL/2.1.3-foss-2015a
  module load PROJ/4.8.0-foss-2015a

- for R 3.6.1:

  module load R/3.6.1-foss-2015a-bare
  module load GDAL/2.2.1-foss-2015a-GEOS-3.8.0

Note: Avoid to include them in your bashrc, just load them when it is a requirement.

4. How to avoid Load error in R 3.6.1: cdo -griddes core dumped

To avoid an error of Load because of the command CDO -griddes, a different version of HDF5 is required:

  module load HDF5/1.8.14-foss-2015a

5. How to use 'rmapshaper' library in Nord3

To correctly use the R library rmapshaper in Nord3, you need to load the following modules in advance:

  module load R protobuf/3.7.1-GCCcore-8.3.0 jq/1.5-GCCcore-8.3.0 nodejs/10.21.0-GCCcore-8.3.0 

6. How to avoid plotting issues (as fuzzy labels) in Nord3

To save good quality plots created in Nord3, the library 'ragg' is necessary. It is already installed, so, in your R code or R session, before generating the plot, load the library, and use agg_png() function to define the name, size and resolution of your plot. Then, create your plot and close the device. Here, there are two examples:

  library(CSTools)
  library(ragg)
  # Ex1:
  agg_png("fig1.png", width = 1000, height = 500, units = 'px',res = 144)
  fcst <- data.frame(fcst1=rnorm(mean=25,sd=3,n=30),fcst2=rnorm(mean=23,sd=4.5,n=30))
  PlotForecastPDF(fcst,tercile.limits=c(20,26))
  dev.off()
  # Ex2:
  agg_png("fig2.png", width = 1000, height = 1000, units = 'px',res = 144)
  PlotMostLikelyQuantileMap(list(a, b, c), lons, lats,
  toptitle = 'Most likely tercile map',
  bar_titles = paste('% of belonging to', c('a', 'b', 'c')),
  brks = 20)
  dev.off()

In case you want to save your plot in .ps format, you don't need this library. You can adapt the following lines to your ploting function:

  postscript(‘name_and_path_to_the_file.ps’)
  anyplotingfunction()
  dev.off()

7. Error * caught segfault * address 0x18, cause 'memory not mapped'

If this error appears, check that the partition `/dev/shm/` is empty. In case, trash files are occupying this partition, the process you are running may fail. Remove the files and re-run your code.

If the error persists, check your code with a smaller data sample to discard a problem with your code since this error message indicates that you are requesting more memory than the available.

tools/rtools.txt · Last modified: 2020/10/21 18:17 by nperez