ropensci / nasapower

API Client for NASA POWER Global Meteorology, Surface Solar Energy and Climatology in R
https://docs.ropensci.org/nasapower
Other
98 stars 22 forks source link

IMERG Precipitation requires changing Time Standard to UTC #70

Closed daniel-althoff closed 2 years ago

daniel-althoff commented 2 years ago

Hey,

I have tried obtaining IMERG precipitation from the API, but it returns the following error:

Code to Reproduce

library(nasapower)
nasapower::get_power(community = "ag", 
                                     lonlat = c(-66.5, -33.5), 
                                     pars = 'PRECIPITATIONCAL', 
                                     dates = '2020-01-01',
                                     temporal_api = 'daily')

Erro: HTTP (422) - The request was well-formed but was unable to be followed due to semantic errors (WebDAV; RFC 4918)
  The IMERG Precipitation is not available at the Local Solar Time (LST) Standard: Remove the PRECIPITATIONCAL parameter or change Time Standard to UTC.

At the Tutorails-parameters page https://power.larc.nasa.gov/docs/tutorials/parameters/ it states the following: "If the parameter's time is not Local Solar Time (LST) it is suffixed to the end of the parameter name (e.g. ALLSKY_SFC_SW_DWN_00_GMT"

I have tried 'PRECIPITATIONCAL_00_GMT', but it returns the following;

Erro: PRECIPITATIONCAL_00_GMT is/are not valid in 'pars'.
Check that the 'pars', 'community' and 'temporal_api' align.

I also found the following: "to change the time standard please include time-standard=UTC or time-standard=LST in the API request URL"

It did work when I tried this page: https://power.larc.nasa.gov/api/temporal/daily/point?parameters=PRECIPITATIONCAL&community=SB&longitude=0&latitude=0&start=20170101&end=20170201&time-standard=UTC&format=JSON

Could this option be included to the package?

Thank you!

adamhsparks commented 2 years ago

Hi. Seems like a bug, I'd specified UTC by default but had the wrong format for the API parameter. I didn't realise it would affect the data values returned too, so I'd not investigated further and implemented the ability to change this.

Now UTC and LST (default and recreates the previous releases' behaviour) are options.

Can you try installing the version from the main branch of this repository, check it and report back to me if you get the values you expected, please? It seems to be working for me, no errors.

remotes::install_github("ropensci/nasapower")
daniel-althoff commented 2 years ago

I tried and it seems to be working properly. Once again, thank you!