def _getOrientation(orig_channel, orient):
    """
    Return a character representing the orientation of a channel.

    Args:
        orig_channel (string):
            String representing the seed channel (e.g. 'HNZ'). The
            final character is assumed to be the (uppercase) orientation.
        orient (str or None):
            Gives the orientation of the channel, overriding channel
            codes that end in numbers. Must be one of 'h' (horizontal)
            or 'v' (vertical), or None if the orientation has not been
            explicitly specified in the "comp" element.

    Returns:
        Character representing the channel orientation. One of 'N',
        'E', 'Z', 'H' (for horizontal), or 'U' (for unknown).
    """
    if orig_channel == 'mmi' or orig_channel == 'DERIVED':
        orientation = 'H'           # mmi is arbitrarily horizontal
    elif orig_channel[-1] in ('N', 'E', 'Z'):
        orientation = orig_channel[-1]
    elif orig_channel == "UNK":   # Channel is "UNK"; assume horizontal
        orientation = 'H'
    elif orig_channel == 'H1' or orig_channel == 'H2':
        orientation = 'H'
    elif orig_channel[-1].isdigit():
        if orient == 'h':
            orientation = 'H'
        elif orient == 'v':
            orientation = 'Z'
        else:
            orientation = 'U'
    else:
        orientation = 'U'  # this is unknown
    return orientation