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

'palmer' param throwing this error though 'prcp' works for gridmet #7

Closed jhammondusgs closed 1 year ago

jhammondusgs commented 5 years ago

AOI = getAOI(state = 'CO') %>% AOI::bbox_st()

Generate Random Points

n = 10 pts = data.frame(lat = runif(n, AOI$ymin, AOI$ymax), lon = runif(n, AOI$xmin, AOI$xmax))

test <- getGridMET(AOI = pts[1,], param = c('prcp'), startDate = "1980-01-01", endDate = "2018-12-31")

test <- getGridMET(AOI = pts[1,], param = c('palmer'), startDate = "1980-01-01", endDate = "2018-12-31")

" Error in { : task 1 failed - "NetCDF: Access failure" "

jhammondusgs commented 5 years ago

Same also appears to be true for "palmer" parameter with Terraclimate data

mikejohnson51 commented 5 years ago

Hi John,

This seems to be caused by a few issues I still need to write error catches around, but I can explain:

1) The issue with the palmer index from gridMET is on the University of Idaho's end. When we look at their prcp catoloug, it shows that they have 14,770 days archived:

image

But for the Palmder Index, there are only 1,455 days archived:

image

These kind of issues will be a little harder to write an error catch for, and I will reach out to them about this.

The issues with the Palmer Index/TerraClim is that they only archive data up to 2017. If you change the endDate to "2017-12-31", it should run fine.

A catch for this was added in the most recent update.

Thanks!

Mike

jhammondusgs commented 5 years ago

Thank you so much for getting to this so quickly Mike,

Really enjoying your package!

Best,

John

On Wed, Jun 12, 2019 at 4:04 AM Mike Johnson notifications@github.com wrote:

Hi John,

This seems to be caused by a few issues I still need to write error catches around, but I can explain:

  1. The issue with the palmer index from gridMET is on the University of Idaho's end. When we look at their prcp catoloug, it shows that they have 14,770 days archived:

[image: image] https://user-images.githubusercontent.com/30052272/59332239-0ed20880-8cf6-11e9-80d7-59349e21dc63.png

But for the Palmder Index, there are only 1,455 days archived:

[image: image] https://user-images.githubusercontent.com/30052272/59332341-4476f180-8cf6-11e9-96fa-39190475a1cb.png

These kind of issues will be a little harder to write an error catch for, and I will reach out to them about this.

The issues with the Palmer Index/TerraClim is that they only archive data up to the current 2017. If you change the endDate to "2017-12-31", it should run fine.

A catch for this was added in the most recent update.

Thanks!

Mike

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mikejohnson51/climateR/issues/7?email_source=notifications&email_token=ALTYA6PES7HVWYHHFDL5X6LP2CUWXA5CNFSM4HXDWRP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXPSYNA#issuecomment-501165108, or mute the thread https://github.com/notifications/unsubscribe-auth/ALTYA6MGHBBWEXNBUZNO7SLP2CUWXANCNFSM4HXDWRPQ .

-- John C. Hammond, PhD Surface water hydrologist U.S. Geological Survey MD-DE-DC Water Science Center 5522 Research Park Drive Baltimore, MD, 21228 443-498-5568

mikejohnson51 commented 5 years ago

Great! I am glad it's proving useful, please let me know if anything else comes up.

Mike

pjgoodling commented 4 years ago

Hi Mike,

Thanks for your hard work!

I know this one is closed, but I seem to have a similar issue to the one above.

Getting precipitation data for Maryland works just fine:

g = getAOI(state = "md") %>% getGridMET(param = 'pcp', startDate = "2017-06-29")

But trying to get palmer indices from GridMet doesn't seem to work:

g = getAOI(state = "md") %>%  getGridMET(param = 'palmer', startDate = "2017-06-29")
Error in { : task 1 failed - "NetCDF: Access failure"

Is it still an issue on University of Idaho's end?

Thanks,

Phillip

mikejohnson51 commented 4 years ago

Hi Phillip,

For the Palmer Index, this is still a Idaho Server issue. The palmer index has about 1/10th the data stored as the other variables (like prcp). I am not even certain where in the timeline that data fits either. I had forgotten about this issue but will follow up. For now I am re-opening

mikejohnson51 commented 1 year ago

Hi @jhammondusgs and @pjgoodling,

Sorry for the loooonnnnngggggg wait on this! With the rewrite of this package the following works for both your examples:

library(AOI); library(sf); library(climateR);library(terra)
#> Linking to GEOS 3.11.1, GDAL 3.6.0, PROJ 9.1.1; sf_use_s2() is TRUE
#> Using GDAL version 3.6.0 which was retracted because it cannot write large GPKG files
#> terra 1.7.8

# 10 random points
pts = aoi_get(state = 'CO') %>% 
  st_sample(10) %>% 
  st_as_sf()

test <- getGridMET(AOI = pts[1,],
                   varname  = c('pr'), 
                   startDate = "1980-01-01", endDate = "2018-12-31")

plot(test$pr, type = "l")


# Working with PDSI
test <- getGridMET(AOI = pts[1,], 
                   varname  = c('pdsi'), 
                   startDate = "1980-01-01", endDate = "2018-12-31")

plot(test$pdsi.y)


g = aoi_get(state = "md") %>%  
  getGridMET(varname = 'pdsi', startDate = "2017-06-29")

plot(g$category)

plot(g$daily_mean_palmer_drought_severity_index)

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

I hope this rewrite proves useful and that the extra datasets and greater stability prove useful if you are still pursuing these types of data questions!

Mike

pjgoodling commented 1 year ago

Thanks so much!!!! Great work!

On Thu, Feb 16, 2023, 7:26 AM MikeJohnson-NOAA @.***> wrote:

Hi @jhammondusgs https://github.com/jhammondusgs and @pjgoodling https://github.com/pjgoodling,

Sorry for the loooonnnnngggggg wait on this! With the rewrite of this package the following works for both your examples:

library(AOI); library(sf); library(climateR);library(terra)#> Linking to GEOS 3.11.1, GDAL 3.6.0, PROJ 9.1.1; sf_use_s2() is TRUE#> Using GDAL version 3.6.0 which was retracted because it cannot write large GPKG files#> terra 1.7.8

10 random pointspts = aoi_get(state = 'CO') %>%

st_sample(10) %>% st_as_sf() test <- getGridMET(AOI = pts[1,], varname = c('pr'), startDate = "1980-01-01", endDate = "2018-12-31")

plot(test$pr, type = "l")

https://camo.githubusercontent.com/040d091598ac089613046ad7eb7b9880d6840dbc5628c7eae09afada55024198/68747470733a2f2f692e696d6775722e636f6d2f395a4a6e6f66612e706e67

Working with PDSItest <- getGridMET(AOI = pts[1,],

               varname  = c('pdsi'),
               startDate = "1980-01-01", endDate = "2018-12-31")

plot(test$pdsi.y)

https://camo.githubusercontent.com/38c1c77e4d52d8be7610b6c1c77266f05d0ac96009b4048a0648255cd9e3fa2d/68747470733a2f2f692e696d6775722e636f6d2f6d3066375367532e706e67

g = aoi_get(state = "md") %>% getGridMET(varname = 'pdsi', startDate = "2017-06-29")

plot(g$category)

https://camo.githubusercontent.com/e01966baa4cb8bd62b137527efe49bfd5f02486739a0a04b0699b2cd45ea3d9f/68747470733a2f2f692e696d6775722e636f6d2f45474e65336f362e706e67

plot(g$daily_mean_palmer_drought_severity_index)

https://camo.githubusercontent.com/484bf5f7b60ac3994695f47648b03e6cc228edb6a41053a1cb17daef90530f9c/68747470733a2f2f692e696d6775722e636f6d2f6f3149376936792e706e67

Created on 2023-02-15 by the reprex package https://reprex.tidyverse.org (v2.0.1)

I hope this rewrite proves useful and that the extra datasets and greater stability prove useful if you are still pursuing these types of data questions!

Mike

— Reply to this email directly, view it on GitHub https://github.com/mikejohnson51/climateR/issues/7#issuecomment-1432590092, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGIFBYVHJR22MONR5KM4ZBLWXXCA5ANCNFSM4HXDWRPQ . You are receiving this because you were mentioned.Message ID: @.***>