heigeo / climata

Python library for loading and iterating over climate and flow time series data (from ACIS/NOAA RCCs, CoCoRaHS, Hydromet/USBR, CNRFC ESP/NWS, SNOTEL/AWDB/NRCS, and NWIS/USGS)
http://climata.houstoneng.net
MIT License
83 stars 14 forks source link

StationHourlyDataIO request thows attributeerror: 'hourlyDataValue' object has no attribute 'items' when running the example #14

Closed scottcha closed 7 years ago

scottcha commented 7 years ago

Example as documented in the snowtel code:

params = StationHourlyDataIO(
    station='302:OR:SNTL',
    start_date='2014-07-01',
    end_date='2014-07-02',
)

for param in params:
    print(param.element_name)
    for row in param.data:
        print("   ", row.datetime, row.value, param.storedunitcd)

OUTPUT:

BATTERY

Stack Trace:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-15-11de896be9bd> in <module>()
      7 for param in params:
      8     print(param.element_name)
----> 9     for row in param.data:
     10         print("   ", row.datetime, row.value, param.storedunitcd)

C:\Users\scott\Anaconda3\envs\python35\lib\site-packages\wq\io\base.py in __iter__(self)
    153     def __iter__(self):
    154         for item in self.data:
--> 155             uitem = self.usable_item(item)
    156             if uitem is None:
    157                 return

C:\Users\scott\Anaconda3\envs\python35\lib\site-packages\wq\io\mappers.py in usable_item(self, item)
    122 
    123     def usable_item(self, item):
--> 124         mapped = super(TupleMapper, self).usable_item(item)
    125         try:
    126             return self.tuple_prototype._replace(**mapped)

C:\Users\scott\Anaconda3\envs\python35\lib\site-packages\wq\io\mappers.py in usable_item(self, item)
     24     def usable_item(self, item):
     25         uitem = {}
---> 26         for key, val in item.items():
     27             field = self.map_field(key)
     28             value = self.map_value(field, val)

AttributeError: 'hourlyDataValue' object has no attribute 'items'

I tried looking in to figuring out how to resolve this in the code but I'm not familiar with wq or the design of the library. Thanks!

sheppard commented 7 years ago

Thanks, apparently the hourly class wasn't covered by a test case. It should now be working in master.