Hello again,
I need help to convert a Matlab script to R script. I have already converted several things, but some functions or codes I can't understand them and I have searched without finding equivalences in R.
The whole script is based on a netCDF file with sea surface temperature data (sst). I managed to open it, load latitude, longitude, time, sst.
But at the moment of loading a mask to delimit the continents and to make maps only with the oceans in color, I get stuck in the conversion.
Could somebody explain me what these commands mean and how I could translate them?
I will put the Matlab code and the one I made for R. Please let me know if there is something wrong.
Mat lon=ncread('X164.73.83.146.280.11.37.37.nc','lon'); #no problem with this
R lon <- ncvar_get(datos_nc, "lon")
Mat lat=ncread('X164.73.83.146.280.11.37.37.nc','lat'); #no problem with this
R lat <- ncvar_get(datos_nc, "lat", verbose = F)
Mat sst=ncread('X164.73.83.146.280.11.37.37.nc','sst'); #no problem with this
R sst <- ncvar_get(datos_nc, "sst")
Mat sst=ncread('X164.73.83.146.280.11.37.37.nc','sst'); #no problem with this
R sst <- ncvar_get(datos_nc, "sst")
Mat mask=ncread('lsmask.nc','mask'); #no problem with this
R masc <- ncvar_get(mask_nc, "mask")
Mat ind=find(mask==0); #here I've started with problems.
R masc <- image(lon,lat2,masc==0)
After this I don't really know what to do. Spending today searching but have no clue what these steps mean:
mask(ind)=NaN;
sst=permute(sst,[3 1 2]);
mask_r=repmat(mask,1,1,360);mask_r=permute(mask_r,[3 1 2]);
sst=sst.*mask_r;
Thank you very much!