hsbadr / HiClimR

Hierarchical Climate Regionalization
https://hsbadr.github.io/HiClimR/
GNU General Public License v3.0
14 stars 8 forks source link

"mm "not found #1

Closed vladamihaesei closed 4 years ago

vladamihaesei commented 5 years ago

Hi, I want to create a regionalization on my data ( year precipitation) and I have this error ; "Error in HiClimR(list10$x, lon = longitud, lat = latid, lonStep = 1, latStep = 1, : object 'mm' not found " mm object is not found ? I have to have a object named mm ? If affirmative, where I must to write it ?

hsbadr commented 4 years ago

Hi, Could you provide a clean R script demonstrating the issue with the necessary data files? Also, please provide the info requested here.

fipoucat commented 4 years ago

Hi, I have netcdf file of precip and wishes to use your package HiClim. I can read my file using following code: nc <- nc_open("/Volumes/RUS5/CRU_TS401/cru_ts4.03.1961.1970.pre.dat.nc") print(nc)

lon <- ncvar_get(nc, "lon") lat <- ncvar_get(nc, "lat") time <- ncvar_get(nc, "time") pr<-ncvar_get(nc, "pre") How can I create the datframe compatible with HiClim? similar to the TesData in the package? Any help much appreciated for the urgent issue

hsbadr commented 4 years ago

HiClimR doesn't need a dataframe. You just need to create a matrix as described in the user manual. Simply, you can reshape the precip array to make the columns represent the time dimension where the rows represent all grid points (number of longitudes by number of latitudes). You may also need to transpose the array by permuting its dimensions. Something like the following code may work for you: pr1 <- aperm(pr, c(3,2,1)) x <- t(matrix(pr1, nrow=dim(pr1)[1], byrow=FALSE))

I plan to add a function to import data directly from NetCDF files in a future release.

fipoucat commented 4 years ago

Thank you very for the explanation very helpful, I'll exploit it for this case while waiting the next release with a function to import directly nc file. Thank you for maintaining this very useful package.