NREL / developer.nrel.gov

An issue tracker for NREL's APIs available at https://developer.nrel.gov
43 stars 39 forks source link

PSM3 interval error message #298

Closed AdamRJensen closed 1 year ago

AdamRJensen commented 1 year ago

@PjEdwards

When specifying an incorrect interval during a request for PSM3 data, the following error message is returned: "The optional 'interval' parameter must be an integer in the set [30,60]"

Unlike what the error message states, the interval parameter can also be 5 or 15, thus I suggest changing the set to [5,15,30,60].

An example of the error message generation is easily done using the pvlib library:

import pvlib

pvlib.iotools.get_psm3(
    latitude=28.6413,
    longitude=-81.1797, 
    api_key='DEMO_KEY',
    email='dummy@email.com',
    names=2020,
    interval='incorrect_interval',
    )
kandersolar commented 1 year ago

I think that error message from the API is actually correct and, if anything is to be blamed for presenting the user with a confusing error message, it is pvlib. Because the PSM3 API has different endpoints for different data frequencies, pvlib.iotools.get_psm3 examines the interval parameter and infers the appropriate URL, with the endpoint that serves 30/60 minute data as the fallback:

https://github.com/pvlib/pvlib-python/blob/v0.9.4/pvlib/iotools/psm3.py#L192-L197

Maybe that decision logic in pvlib.iotools.get_psm3 should be improved. In any case I don't think there is anything to change over here on the API side.