def var_calcs(var, jday=0, latlon=(-90, 90, 40, 120), plevs=(850, 200),
              dp_vars=['U', 'OMEGA'], sector_lons=(60, 100)):
    """Process a single variable from a single day."""
    lat1, lat2, lon1, lon2 = latlon
    opts = merra.url_opts(var.name)
    vertical = opts['vertical']
    if vertical == 'X':
        plevs = [None]
    if dp_vars is not None and var.name in dp_vars:
        dp = True
    else:
        dp = False
    data = xray.Dataset()

    # Lat-lon data
    print('Lat-lon data')
    for plev in plevs:
        print('plev', plev)
        var_out = latlon_data(var, lat1, lat2, lon1, lon2, plev)
        data[var_out.name] = var_out
        if dp:
            print('Computing d/dp')
            var_out = pgradient(var, lat1, lat2, lon1, lon2, plev)
        data[var_out.name] = var_out

    # Sector and zonal mean data
    print('Computing zonal mean')
    var_out = sector_mean(var, 0, 360)
    data[var_out.name] = var_out
    if vertical == 'P':
        print('Computing sector mean')
        var_out = sector_mean(var, sector_lons[0], sector_lons[1])
        data[var_out.name] = var_out

    # Compute daily data from subdaily data
    nperday = len(atm.get_coord(data, 'time'))
    data = atm.daily_from_subdaily(data, nperday, dayname='day',
                                   dayvals=[jday])

    # Make sure output is in a Dataset
    if isinstance(data, xray.DataArray):
        data = data.to_dataset()

    return data
 def get_group(varnm, version):
     opts = merra.url_opts(varnm, version)
     group = '%s%s_%s_%s' % (opts['res'], opts['vertical'], opts['kind'],
                             opts['time_kind'])
     return group