'Tests fitting a 1D Chebyshev polynomial to some real world data.'

def test_chebyshev1D(self):

    test_file = get_pkg_data_filename(os.path.join(u'data', u'idcompspec.fits'))
    with open(test_file) as f:
        lines = f.read()
        reclist = lines.split(u'begin')
    record = irafutil.IdentifyRecord(reclist[1])
    coeffs = record.coeff
    order = int(record.fields[u'order'])
    initial_model = models.Chebyshev1D((order - 1), domain=record.get_range())
    fitter = LinearLSQFitter()
    fitted_model = fitter(initial_model, record.x, record.z)
    assert_allclose(fitted_model.parameters, np.array(coeffs), rtol=0.1)
