mikejohnson51 / climateR

An R 📦 for getting point and gridded climate data by AOI
https://mikejohnson51.github.io/climateR/
MIT License
168 stars 40 forks source link

Error in { : task 2 failed - "NetCDF: Access failure" #15

Closed crestedcaracaryn closed 1 year ago

crestedcaracaryn commented 3 years ago

Trying to pull gridmet data with the following code:

AOI = aoi_get(c(45.3988,-95.7885,100,100),km=TRUE)

gm_hist = getGridMET(AOI, param=c('pet_grass','palmer','prcp'), startDate = "2009-01-01", endDate = "2019-12-31")

resulting in error: Error in { : task 2 failed - "NetCDF: Access failure"

mikejohnson51 commented 3 years ago

Hi,

Unfortunately this is an issue with the palmer index stored on that thredds server. They only retain 2969 days of data for palmer compared to 15233 for the rest of the variables.

See here (PDSI) http://thredds.northwestknowledge.net:8080/thredds/dodsC/agg_met_pdsi_1979_CurrentYear_CONUS.nc.html

VS here (tmin) http://thredds.northwestknowledge.net:8080/thredds/dodsC/agg_met_tmmn_1979_CurrentYear_CONUS.nc.html

I haven't put an error catch in yet because I am hoping it will change.

I do have an update coming and try to work it so that one variable wont kill the query. See #16

The other two variables in your query work well,

Mike

mikejohnson51 commented 1 year ago

Hi @crestedcaracaryn,

Sorry for the long delay on this. The package has been completely re-written to supply greater flexibility, more datasets, and easier use. In this example, the multiple time horizons between the rainfall and PDSI grids can now be captured correctly:

library(AOI); library(climateR);library(terra)
#> Using GDAL version 3.6.0 which was retracted because it cannot write large GPKG files
#> terra 1.7.8

AOI = aoi_get(c(45.3988,-95.7885,100,100),km=TRUE)

gm_hist = getGridMET(AOI,
                     varname=c('pet','pdsi','pr'),
                     startDate = "2009-01-01",
                     endDate = "2009-01-10")

str(gm_hist, max.level = 3)
#> List of 4
#>  $ precipitation_amount                         :S4 class 'SpatRaster' [package "terra"]
#>  $ category                                     :S4 class 'SpatRaster' [package "terra"]
#>  $ daily_mean_palmer_drought_severity_index     :S4 class 'SpatRaster' [package "terra"]
#>  $ daily_mean_reference_evapotranspiration_grass:S4 class 'SpatRaster' [package "terra"]

plot(gm_hist$daily_mean_palmer_drought_severity_index)


plot(gm_hist$precipitation_amount)

Created on 2023-02-15 by the reprex package (v2.0.1)

I hope the package rewrite proves useful to you if you are still using it and pursuing simular research/data questions.

Mike