def x(self, dt, models):
        """Retrieve state variable from database."""
        data = {}
        db = dbio.connect(models.dbname)
        cur = db.cursor()
        for s in self.statevar:
            sql = "select ensemble,st_x(geom),st_y(geom),val from (select ensemble,(ST_PixelAsCentroids(rast)).* from {0}.{1} where fdate=date '{2}-{3}-{4}') foo group by ensemble,geom order by ensemble".format(
                models.name, s, dt.year, dt.month, dt.day)
            cur.execute(sql)
            e, lon, lat, vals = zip(*cur.fetchall())
            gid = [models[0].lgid[(l[0], l[1])] for l in zip(lat, lon)]
            nens = max(e)
            data[s] = np.array(vals).reshape((nens / len(vals), nens))
            lat = np.array(lat).reshape((len(lat) / nens, nens))
            lon = np.array(lon).reshape((len(lon) / nens, nens))
            gid = np.array(gid).reshape((len(gid) / nens, nens))
        cur.close()
        db.close()
        return data, lat, lon, gid
dataset/ETHPy150Open nasa/RHEAS/src/datasets/modscag.py/Modscag.x/swapped operands of `/`