ropensci / weatherOz

An API Client for Australian Weather and Climate Data Resources
https://docs.ropensci.org/weatherOz/
GNU General Public License v3.0
21 stars 7 forks source link

API Issue with evapotranspiration names between daily and other time intervals #80

Open bozaah opened 4 days ago

bozaah commented 4 days ago

In the DPIRD Weather API swagger page, all time intervals besides "daily" take etoShortCrop and etoTallCrop to source evapotranspiration values (in addition to evapotranspiration which fetches both). The "daily" timeframe only accepts evapotranspirationShortCrop and evapotranspirationTallCrop.

This is not problematic if not querying those variables by name, ie passing them to the values argument of get_dpird_summaries(), but it is an issue when a user passes values = "all" or queries those specific variables.

It gets a bit more complicated as there are internal checks for the variables passed to the values argument (weatherOz throws an error):

get_dpird_summaries(
  station_code = "KA",
  start_date = "20220501",
  end_date = "20220502",
  api_key = Sys.getenv("DPIRD_API_KEY"),
  interval = "daily",
  values = c(
    "rainfall",
    "evapotranspirationShortCrop"
  )
)

Error: You have specified invalid weather values.

And if you pass the short name, the API throws a HTTP 400 error:

get_dpird_summaries(
  station_code = "KA",
  start_date = "20220501",
  end_date = "20220502",
  api_key = Sys.getenv("DPIRD_API_KEY"),
  interval = "daily",
  values = c(
    "rainfall",
    "etoShortCrop"
  )
)

Error: HTTP (400) - Bad Request
Invalid select field specified: etoShortCrop

The opposite is true for the rest of the time intervals. I have reached out to the eConnect team in hope that the daily naming will match the other time intervals.

Perhaps as a temporary fix, I could add evapotranspirationShortCrop and evapotranspirationTallCrop to the dpird_summary_values dataset/vector as etoShortCrop, etoTallCrop are already included.

adamhsparks commented 4 days ago

Hmm. I thought we’d dealt with this already or it at least seems familiar. Your fix sounds right at least for now to me.