Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no more srad data from TerraClim? #90

Closed
urskalbitzer opened this issue Dec 8, 2023 · 9 comments
Closed

no more srad data from TerraClim? #90

urskalbitzer opened this issue Dec 8, 2023 · 9 comments

Comments

@urskalbitzer
Copy link

Hi,
As usual: thanks a lot for the development and maintenance of this great package!

6-12 months ago, I used the following code without issues.

library(sf)
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(climateR)
kan.location <- st_as_sf(data.frame(x = 30.356, y = .562),
                            coords = c("x", "y"), crs = 4326)
srad.kan = getTerraClim(kan.location,
                        param = "srad",
                        startDate = "1970-01-01",
                        endDate = "2020-12-31")

Now, however, I get the following issue:

#> Error in getTerraClim(kan.location, param = "srad", startDate = "1970-01-01", : unused argument (param = "srad")

I tried to use the new argument name varname instead of param but also got an error:

srad.kan = getTerraClim(kan.location,
                        varname = "srad",
                        startDate = "1970-01-01",
                        endDate = "2020-12-31")
#> Error: 'srad' not availiable varname for 'terraclim'. Try: 
#>  > aet [mm] (water_evaporation_amount)
#>  > def [mm] (water_potential_evaporation_amount_minus_water_evaporation_amount)
#>  > PDSI [unitless] (palmer_drought_severity_index)
#>  > pet [mm] (water_potential_evaporation_amount)
#>  > ppt [mm] (precipitation_amount)
#>  > q [mm] (runoff_amount)
#>  > soil [mm] (soil_moisture_content)
#>  > tmax [degC] (air_temperature)
#>  > tmin [degC] (air_temperature)
#>  > vap [kPa] (water_vapor_partial_pressure_in_air)
#>  > vpd [kPa] (vapor_pressure_deficit)
#>  > ws [m/s] (wind_speed)

According to this webpage, "downward surface shortwave radiation" should still be part of that dataset:
https://www.climatologylab.org/terraclimate.html

Do you know what the issue is?

Thanks!

Created on 2023-12-08 with reprex v2.0.2

@mikejohnson51
Copy link
Owner

mikejohnson51 commented Dec 9, 2023

Hi @urskalbitzer,

As always thanks for the questions!!... this one is quite annoying... Looking at there server, they chose to use a "-" delimiter rather then a "_" on 2 of their files! srad is one of them... We can get this fixed.

Thanks for the note!

image

@mikejohnson51
Copy link
Owner

To add to the fun the OPeNDAP URL is underscore deliminated:

http://thredds.northwestknowledge.net:8080/thredds/dodsC/agg_terraclimate_srad_1958_CurrentYear_GLOBE.nc

@urskalbitzer
Copy link
Author

Thanks for the quick response. Glad to hear that the dataset is in principle available and it looks like a relatively easy fix. I will wait for the updated catalog.

@urskalbitzer
Copy link
Author

Until this issue is fixed, is there an easy workaround to download the data?

I tried to manually add a respective line to the catalog. However, in this process, the catalog was copied to the global environment and getTerraClim still uses the original one (which is not in the global environment).

Thanks!

mikejohnson51 added a commit to mikejohnson51/climateR-catalogs that referenced this issue Dec 18, 2023
mikejohnson51 added a commit that referenced this issue Dec 18, 2023
@mikejohnson51
Copy link
Owner

Sorry for the delay - just getting caught up after AGU. Looks like it should now work after a reinstall:

library(sf)
library(climateR)

system.time({
  srad <-
    data.frame(x = 30.356, y = .562) |>
    st_as_sf(coords = c("x", "y"), crs = 4326) |>
    getTerraClim(varname = "srad",
                 startDate = "1970-01-01",
                 endDate = "2020-12-31")
})
#>    user  system elapsed 
#>   0.625   0.077  16.400

plot(srad$date, srad$srad_total, type = "o", pch = 16)
lines(srad$date, predict(lm(srad$srad_total~srad$date)),col='red', lwd = 4)

Created on 2023-12-18 by the reprex package (v2.0.1)

@mikejohnson51
Copy link
Owner

Hi @urskalbitzer for now I am going to close this but feel free to reopen if its not working for you!

@urskalbitzer
Copy link
Author

Hi @mikejohnson51 ,
thanks again for fixing this.
And apologies that my response took a bit longer. I think in the sf- and/or climateR-package some things have changed so that they now interact in a slightly different way (e.g., before I only provided $geometry from a sf-object as the AOI to getTerraClim(), now I have to provide the entire sf object as AOI) . Thus, I had to adapt some additional code to get to the same values as before, but it all worked out well.

@mikejohnson51
Copy link
Owner

Hey @urskalbitzer! Thanks. Please see 09fd28b. sfc AOI's should be ok again.

Happy holidays!

@urskalbitzer
Copy link
Author

Thanks for the quick fix.

Happy holidays to you as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants