def extract_samples(data, header, nsamples=2000):
    """ Extract a set of samples from a fits image and
    return a sorted numpy array of results
    """
    flat_data = data.flatten()
    sample_stride = header.get('NAXIS1') * header.get('NAXIS2') / nsamples
    samples = flat_data[int(sample_stride)::int(sample_stride)]
    samples.sort()
    return samples
