[2] | 1 | #!/bin/env python |
---|
| 2 | # coding: utf-8 |
---|
| 3 | |
---|
| 4 | VERSION='1.0' |
---|
| 5 | |
---|
| 6 | import pyfits |
---|
| 7 | from optparse import OptionParser |
---|
| 8 | |
---|
| 9 | import numpy |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | parser = OptionParser() |
---|
| 13 | |
---|
| 14 | (options, args) = parser.parse_args () |
---|
| 15 | |
---|
| 16 | if (len(args) !=2) : |
---|
| 17 | print "Usage : pre.py input.fits output.fits" |
---|
| 18 | |
---|
| 19 | # Ouverture de l'image fits en argument |
---|
| 20 | hdulist = pyfits.open(args[0]) |
---|
| 21 | scidata = hdulist[0].data |
---|
| 22 | |
---|
| 23 | # suppression prescan/overscan/bord de plage |
---|
| 24 | |
---|
| 25 | gauche = scidata[:2048,50:1074] |
---|
| 26 | droite = scidata[:2048,1087:2111] |
---|
| 27 | |
---|
| 28 | scidata = numpy.hstack((gauche,droite)) |
---|
| 29 | dim = scidata.shape |
---|
| 30 | |
---|
| 31 | # Remplacement bete des mauvaises colonnes du E0 |
---|
| 32 | # PremiÚre colonne indiquée, largeur 4 colonnes |
---|
| 33 | |
---|
| 34 | BadColumns = [92,119,431,715,842,1144,1160,1511] |
---|
| 35 | for c in BadColumns: |
---|
| 36 | scidata[:,c:c+4]=scidata[:,c-5:c-1] |
---|
| 37 | |
---|
| 38 | # Suppresion du fond (version brutale) |
---|
| 39 | |
---|
| 40 | scidata -= 7000 |
---|
| 41 | scidata = numpy.where(scidata<0,0,scidata) |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | prihdr = hdulist[0].header |
---|
| 45 | prihdr.add_history('Suppression os/ps') |
---|
| 46 | prihdr.add_history('Interpolation mauvaises colonnes') |
---|
| 47 | hdulist[0].data = scidata |
---|
| 48 | hdulist.writeto(args[1],clobber=True) |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | hdulist.close() |
---|