@@ -0,0 +1,1658 @@
+#!/usr/bin/env python%0A# encoding: utf-8%0A%22%22%22%0AHARPS-e2ds-to-order.py%0A%0ACreated by Jonathan Whitmore on 2011-10-14.%0ACopyright (c) 2011. All rights reserved.%0A%22%22%22%0A%0Aimport sys%0Aimport os%0Aimport argparse%0Aimport pyfits as pf%0Aimport numpy as np%0A%0Ahelp_message = '''%0ATakes reduced HARPS***e2ds_A.fits data and reads the header to output a fits file that has the wavelength per pixel per order.%0A'''%0A%0A%0Aclass Usage(Exception):%0A  def __init__(self, msg):%0A    self.msg = msg%0A%0A%0Adef main(argv=None):%0A  parser = argparse.ArgumentParser(description='Process input file.')%0A  parser.add_argument('f', type=str, help='input a filename')%0A  args = parser.parse_args()%0A  inputfile = vars(args)%5B'f'%5D%0A  outputFITSfile = str('order_' + inputfile)%0A  hdu = pf.open(inputfile)%0A  print len(hdu%5B0%5D.data)%0A  polynomialOrder = hdu%5B0%5D.header%5B'HIERARCH ESO DRS CAL TH DEG LL'%5D%0A  orders = hdu%5B0%5D.header%5B'HIERARCH ESO DRS CAL LOC NBO'%5D%0A  coefficients = (polynomialOrder + 1) * orders # number of coefficients in the file%0A  whatever = %5B%5D%0A  for x in xrange(coefficients):%0A    whatever.append(hdu%5B0%5D.header%5B'HIERARCH ESO DRS CAL TH COEFF LL' + str(x)%5D)%0A  A = %7B%7D%0A  for y in xrange(0,len(whatever),polynomialOrder+1):%0A    A%5By/(polynomialOrder+1)%5D = whatever%5By:y+polynomialOrder+1%5D%0A  for order in range(orders):%0A    print %22order: %22, order%0A    wavelength = %5B%5D%0A    for pixel in xrange(len(hdu%5B0%5D.data%5Border%5D)):%0A      temp = 0.0%0A      for x in range(polynomialOrder):%0A        temp += A%5Border%5D%5Bx%5D * pixel ** x%0A      wavelength.append(temp)%0A    pf.append(outputFITSfile, np.array(%5Bnp.array(wavelength), hdu%5B0%5D.data%5Border%5D, np.sqrt(np.abs(hdu%5B0%5D.data%5Border%5D))%5D))%0A  %0A%0Aif __name__ == %22__main__%22:%0A  sys.exit(main())%0A

Order by order of HARPS data