def replicate_and_weight_split_child_dataset_new(parent_data, split_child_dataset,
        parent_id='lutevent_id', split_child_parent_id='split_event_parent_event_id',
        names=['lutevent_id', 'lutevent_energy', 'lutevent_time_offset',
               'lutevent_count', 'lutevent_flash_count', 'lutevent_group_count',
               'lutevent_total_flash_area', 'lutevent_total_group_area'],
        weights={'lutevent_energy':'split_event_area_fraction',
                 'lutevent_count': 'split_event_mesh_area_fraction',
                 'lutevent_flash_count': 'split_event_mesh_area_fraction',
                 'lutevent_group_count': 'split_event_mesh_area_fraction',
                 'lutevent_total_flash_area':'split_event_mesh_area_fraction',
                 'lutevent_total_group_area':'split_event_mesh_area_fraction',
                }
        ):
    """
    Replicate variables from parents to their children. The children in this case
    correspond to some fraction of the total area covered by parents, i.e., the children
    are the centroids of polygons resulting from subdivision of a parent polygon.
    Optionally, weight each parent variable by some variable included in the split
    child data.

    The default arguments show how to accumulate and weight event data that have been
    pre-aggregated using an event lookup table approach (glmtools.io.glm.get_lutevents).

    Arguments:
    parent_data -- xarray dataset, containing data variables for the parent
    split_child_dataset -- xarray dataset, for children resulting from splitting the
        parent polygon. Includes centroids and fractional coverage of the parent.

    Keyword arguemnts:
    parent_id -- variable name in parent_data corresponding to replicated parent_ids in
        split_child_parent_event_id within split_child_dataset
    split_child_parent_event_id -- variable name in split_child_dataset (foreign key)
        corresponding to parent_id in parent_data
    names -- the variables in parent_data to replicate and weight
    weights -- dictionary with key giving a variable in parent_data and value giving the
        variable in split_child_dataset to use for weighting that variable. Only the
        names in weights will be weighted.

    For data such as parent energy, it is typical to weight with the fraction of the
    original parent's area covered by the split child, so that the total energy is
    conserved. This is usually named 'split_event_area_fraction' or similar.

    For count data, such as that used for calculating extent density, it is typical to
    weight with the fraction of the coverage of the target grid cell. Imagine a grid cell
    covered 40 percent by one parent (with a count of "3") and another 60 percent by an
    adjacent parent, also with a count of "3". The desired result is that the target grid
    cell have a final count of three. This is usually named something like
    'split_event_mesh_area_fraction'.
    """

    split_dims = getattr(split_child_dataset, split_child_parent_id).dims

    # We have a bunch of split events, but the original dataset only has data
    # from the parent once for each event. Need to replicate those data by
    # using the split_child_parent_id to index the original dataset.
    replicated_event_ids = getattr(split_child_dataset, split_child_parent_id)

    replicated_data = parent_data.loc[{parent_id:replicated_event_ids}]

    for name in names:
        new_name = 'split_' + name
        new_var = getattr(replicated_data, name).data
        if name in weights:
            weight_var = getattr(split_child_dataset, weights[name])
            # dimension names won't match, but lengths should.
            new_var = new_var*weight_var.data # should ensure copy, not view
        # add variable to the dataset
        split_child_dataset[new_name] = (split_dims, new_var) #{'dims':split_dims, 'data':new_var}

    return split_child_dataset