import copy


def calc_mbstar(model, coefs, z):
    """Calculates $m_B^*$ for a supernova model with the given coefficients
    
    Args:
        model (sncosmo.Model): sncosmo Model object to use in calculation
        coefs (np.array): array of model coefficients
        z (float): redshift of object
        
    Returns:
        mbstart (float): AB magnitude in the Bessell B-band for a supernova with
        the given model coefficients
    """
    model = copy.copy(model)
    model.set(**dict(zip(model.source.param_names, coefs)))
    model.set(z=0)
    model.set(t0=0)
    mag = model.bandmag(band='bessellb', time=0, magsys='ab')
    return mag