<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ratio(self, operand):
 """Calculate the ratio of this `Spectrogram` against a reference Parameters operand : `str`, `FrequencySeries`, `Quantity` a `~gwpy.frequencyseries.FrequencySeries` or `~astropy.units.Quantity` to weight against, or one of - ``'mean'`` : weight against the mean of each spectrum in this Spectrogram - ``'median'`` : weight against the median of each spectrum in this Spectrogram Returns ------- spectrogram : `Spectrogram` a new `Spectrogram` Raises ------ ValueError if ``operand`` is given as a `str` that isn't supported """

        if isinstance(operand, string_types):
            if operand == 'mean':
                operand = self.mean(axis=0)
            elif operand == 'median':
                operand = self.median(axis=0)
            else:
                raise ValueError("operand %r unrecognised, please give a "
                                 "Quantity or one of: 'mean', 'median'"
                                 % operand)
        out = self / operand
        return out