A faster way to calculate Relative Humidity near-ground

Hi there,

I am using ERA5Land 2m temperature and dewpoint 2m temperature, in hourly measure, to calculate the near-ground or 2m Relative Humidity.

From this topic I can see that the formula to obtain the Relative Humidity will be basically the ratio between saturation vapor pressures:

RH = e/ES*100,

Where e is the saturation vapor pressure for the dewpoint temperature and Es is the saturation vapor pressure at temperature T.

I am processing the ERA5Land files in R, and it are ".nc" files, and I read them as RasterBricks objects, the problem is, to do this calculation is basically not practicable in a laptop.
My laptop is quite robust, it has 32 GB of RAM and 12 Threads, but even though it is still crashes all the time that I try to calculate the Relative Humidity for a whole year, I have to do this for 12 years.

I was able to do the calculation using this formulas for a bunch of layers like 1 day, 2 days or even a month, but it takes like 5 minutes to run for a month for example, the way I did it is basically doing the calculations
on each layer, even if I parallelized it is not speed up considerably. Trying to do this calculation all along crash my laptop due to intensive use of RAM, it simply not support the size of the final calculation for a year for example.

Any guesses or help to do this calculation faster? I am open to any other software or way to process it.


I am wondering how to calculate the relative humidity with temperature, dewpoint temperature and pressure, which is mentioned in ERA5-Land?