def data_for_ray_slice(radar, ray_sl, fieldnames=None):
    """ Given a slice object ray_sl, return r,az,el,t,data
        corresponding to the fieldnames. If fieldname is None,
        no data will be returned. Fieldnames should be a sequence of field
        names. A data dictionary is returned with a key for each of the field names.
        
        ray_sl is typically found from the radar's sweep index record.
        For some sweep id N, this is:
        ray_sl = slice( radar.sweep_start_ray_index['data'][N], 
                        radar.sweep_end_ray_index['data'][N] + 1)
    """
    r = radar.range['data']
    az = radar.azimuth['data'][ray_sl]
    el = radar.elevation['data'][ray_sl]
    t = radar.time['data'][ray_sl]
    data_dict = {}
    if fieldnames is not None:
        for fieldname in fieldnames:
            try:
                data = radar.fields[fieldname]['data'][ray_sl, :]
            except KeyError:
                data = None
                print("Couldn't find {1} data in {0}".format(radar,fieldname))
            data_dict[fieldname] = data
            
    return r,az,el,t,data_dict