def canddata_feature(canddata, feature):
    """ Calculate a feature (or candloc) from a canddata instance.
    feature must be name from st.features or 'candloc'.
    """
    if feature == 'candloc':
        return canddata.loc
    elif feature == 'snr1':
        return canddata.snr1
    elif feature == 'snrarms':
        return canddata.snrarms
    elif feature == 'snrk':
        return canddata.snrk
    elif feature == 'cluster':
        return canddata.cluster
    elif feature == 'clustersize':
        return canddata.clustersize
    elif feature == 'specstd':
        return canddata.specstd
    elif feature == 'specskew':
        return canddata.specskew
    elif feature == 'speckur':
        return canddata.speckur
    elif feature == 'immax1':
        return canddata.immax1
    elif feature == 'l1':
        return canddata.l1
    elif feature == 'm1':
        return canddata.m1
    elif feature == 'imskew':
        return canddata.imskew
    elif feature == 'imkur':
        return canddata.imkur
    elif feature == 'tskew':
        return canddata.tskew
    elif feature == 'tkur':
        return canddata.tkur
    else:
        raise NotImplementedError('Feature {0} calculation not implemented'
            .format(feature))
