ICOS-Carbon-Portal / pylib

Python library for direct access to ICOS time series data.
12 stars 3 forks source link

stilt module crashes due to packaged stilt results #149

Closed ukarst closed 1 year ago

ukarst commented 1 year ago

stilt module crashes due to packaged stilt results stored in /data/stiltweb/stations/ As listing all stations in __get_stations relies on the directory structure, the new zip archives with packed results need to be excluded to get the list of available years. Replacing os.path.exists with os.path.isdir in the part of the code below should help.

       # set years and month of available data
        years = [y for y in os.listdir(CPC.STILTPATH + '/' + ist) if
                 os.path.exists(CPC.STILTPATH + '/' + ist + '/' + y)]
        stations[ist]['years'] = years
        for yy in sorted(stations[ist]['years']):
            stations[ist][yy] = {}
            months = [m for m in os.listdir(CPC.STILTPATH + '/' + ist + '/' + yy) if
                      os.path.exits(CPC.STILTPATH + '/' + ist + '/' + yy + '/' + m)]
            # remove cache txt entry
            sub = 'cache'
            months = sorted([m for m in months if not sub.lower() in m.lower()])
            stations[ist][yy]['months'] = months
            stations[ist][yy]['nmonths'] = len(stations[ist][yy]['months'])