WattTime / pyiso

Python client libraries for ISO and other power grid data sources.
http://pyiso.readthedocs.org/
Other
238 stars 110 forks source link

Issues with get_generation() #25

Open mbonvini opened 9 years ago

mbonvini commented 9 years ago

Hi

I am using Pyiso to understand the CO2 associated to the production of electric energy. I would like to do this for California This is the script I have

from pyiso import client_factory
import pandas as pd

caiso = client_factory("CAISO")
data_caiso = caiso.get_generation(latest = True)
df_caiso = pd.DataFrame(data_caiso)
print df_caiso

and this is the results I get

  ba_name freq  fuel_name    gen_MW market                  timestamp
0   CAISO  10m  renewable   1706.00   RT5M  2015-05-27 17:00:00+00:00
1   CAISO  10m      solar   5342.00   RT5M  2015-05-27 17:00:00+00:00
2   CAISO  10m       wind    939.00   RT5M  2015-05-27 17:00:00+00:00
3   CAISO  10m      other  21534.32   RT5M  2015-05-27 17:00:00+00:00

Unfortunately I'd like to have more information and not only other in terms of fuel description.

I tried with other ISOs ("ISONE", "ERCOT" and "PJM") in order to see if they had more info. Here's an example of script

from pyiso import client_factory
import pandas as pd
from datetime import datetime

isone = client_factory("ISONE")
data_isone = isone.get_generation(latest = True)
df_isone = pd.DataFrame(data_isone)
print df_isone

however I get this error

No handlers could be found for logger "pyiso.base"
Traceback (most recent call last):
  File "get_carbon_footprint.py", line 10, in <module>
    data_isone = isone.get_generation(latest = True)
  File "/usr/local/lib/python2.7/dist-packages/pyiso/isone.py", line 63, in get_generation
    data = self.fetch_data(endpoint, self.auth)
  File "/usr/local/lib/python2.7/dist-packages/pyiso/isone.py", line 35, in fetch_data
    return response.json()
  File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 819, in json
    return json.loads(self.text, **kwargs)
  File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 413, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 402, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 420, in raw_decode
    raise JSONDecodeError("No JSON object could be decoded", s, idx)
simplejson.decoder.JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)

any suggestions?

Thanks

aschn commented 9 years ago

Did we resolve this issue by email? Happy to help if you still have questions. If not, let's close this issue.

mbonvini commented 9 years ago

I was able to get the data I wanted using the following API

# Define parameters
pars =  {
"ba": "CAISO",
"start_at": d2_start.strftime("%Y-%m-%dT%H:%M:%S%z"), \
"end_at": d2_end.strftime("%Y-%m-%dT%H:%M:%S%z"), \
"freq": "10m",
"market": "RT5M",
"page_size":100}

# Create request
res = requests.get("http://api.watttime.org:80/api/v1/datapoints/",
params = pars,
headers = {'Authorization': 'Token <my_token>'})

and I haven't checked if this error is still present or not. By the way, this API provides the following documentation

API endpoint that allows a single grid data point to be viewed. All times are in UTC. 'carbon' is in lb CO2/MW. 'pk' is a unique numeric identifier for a data point.

is the mass of CO2 per power averaged over the time period associated to the frequency selected in the API call? in this case

lb CO2 / MW / 600 s

while in an other could be different? Or is it always averaged with respect a standard period (e.g. 1hour)?

JacquelineGarrido commented 4 years ago

I am running the following code caiso = client_factory('CAISO') data=caiso.get_generation(latest=True) df= pd.DataFrame(data) df

and I am not getting any real time data(Empty DataFrame). This works fine when I change to "Yesterday=True" or "Forecast=True". Can anyone help me with this? When I checked the CAISO website there is data there http://www.caiso.com/TodaysOutlook/Pages/supply.aspx

rajkumarks7 commented 3 years ago

I am running the following code caiso = client_factory('CAISO') data=caiso.get_generation(latest=True) df= pd.DataFrame(data) df

and I am not getting any real time data(Empty DataFrame). This works fine when I change to "Yesterday=True" or "Forecast=True". Can anyone help me with this? When I checked the CAISO website there is data there http://www.caiso.com/TodaysOutlook/Pages/supply.aspx

i am also facing the same problem with the CAISO did you get any solution?