def _get_nds2_name(channel):
    """Returns the NDS2-formatted name for a channel

    Understands how to format NDS name strings from
    `gwpy.detector.Channel` and `nds2.channel` objects
    """
    if hasattr(channel, 'ndsname'):
        return channel.ndsname
    if hasattr(channel, 'channel_type'):
        return '%s,%s' % (channel.name, channel.channel_type_to_string(
            channel.channel_type))
    return str(channel)
