"""
GBTIDL SDFITS file
==================

GBTIDL SDFITS files representing GBT observing sessions can be read into
pyspeckit.  Additional documentation is needed.  Nodding reduction is
supported, frequency switching is not.

"""
from __future__ import print_function
from six import iteritems
try:
    import astropy.io.fits as pyfits
except ImportError:
    import pyfits
import pyspeckit
import numpy as np
try:
    import coords
except ImportError:
    coords = None

def unique_targets(sdfitsfile):
    bintable = _get_bintable(sdfitsfile)
    return uniq(bintable.data['OBJECT'])

def count_integrations(sdfitsfile, target):
    """
    Return the number of integrations for a given target
    (uses one sampler; assumes same number for all samplers)
    """
    bintable = _get_bintable(sdfitsfile)

    whobject = bintable.data['OBJECT'] == target
    any_sampler = bintable.data['SAMPLER'][whobject][0]
    whsampler = bintable.data['SAMPLER'][whobject] == any_sampler

    return (whsampler).sum()


def list_targets(sdfitsfile, doprint=True):
    """