def _downloadVariable(varname, dbname, dts, bbox):
    # FIXME: Grid is not rectangular, but 0.5 x 0.625 degrees
    res = 0.5
    for ts in [dts[0] + timedelta(dti) for dti in range((dts[1] - dts[0]).days + 1)]:
        try:
            runid = _merraRunid(ts.year)
            url = "http://goldsmr4.sci.gsfc.nasa.gov:80/opendap/MERRA2/M2T1NXSLV.5.12.4/{1}/{2:02d}/MERRA2_{0}.tavg1_2d_slv_Nx.{1:04d}{2:02d}{3:02d}.nc4".format(runid, ts.year, ts.month, ts.day)
            ds = netcdf.Dataset(url)
            lat = ds.variables["lat"][:]
            lon = ds.variables["lon"][:]
            lon[lon > 180] -= 360.0
            i1, i2, j1, j2 = datasets.spatialSubset(np.sort(lat)[::-1], np.sort(lon), res, bbox)
            data = np.zeros((i2-i1, j2-j1))
            lati = np.argsort(lat)[::-1][i1:i2]
            loni = np.argsort(lon)[j1:j2]
            if varname == "tmax":
                hdata = ds.variables["T2M"][:, lati, loni]
                data = np.amax(hdata, axis=0) - 273.15
            elif varname == "tmin":
                hdata = ds.variables["T2M"][:, lati, loni]
                data = np.amin(hdata, axis=0) - 273.15
            elif varname in ["wind"]:
                hdata = np.sqrt(ds.variables["U10M"][:, lati, loni]**2 + ds.variables["V10M"][:, lati, loni]**2)
                data = np.mean(hdata, axis=0)
            lat = np.sort(lat)[::-1][i1:i2]
            lon = np.sort(lon)[j1:j2]
            filename = dbio.writeGeotif(lat, lon, res, data)
            dbio.ingest(dbname, filename, ts, "{0}.merra".format(varname))
            os.remove(filename)
        except:
            print("Cannot import MERRA dataset for {0}!".format(ts.strftime("%Y-%m-%d")))
Disconnect from the Beanstalk server and stop polling.
dataset/ETHPy150Open nasa/RHEAS/src/datasets/merra.py/_downloadVariable--crossover with--dataset/ETHPy150Open mochi/vor/vor/beanstalk.py/BeanstalkGraphiteService.stopService