Magnitude difference between primary star and BG stars

def dmag(self,band):
        """
        Magnitude difference between primary star and BG stars

        """
        if self.mags is None:
            raise ValueError('dmag is not defined because primary mags are not defined for this population.')
        return self.stars['{}_mag'.format(band)] - self.mags[band]