Last change
on this file was
28,
checked in by meynadie, 16 years ago
|
ajout scripts centrage
|
-
Property svn:executable set to
*
|
File size:
1.0 KB
|
Line | |
---|
1 | #!/bin/env python |
---|
2 | # encoding: utf-8 |
---|
3 | |
---|
4 | import pyfits |
---|
5 | from optparse import OptionParser |
---|
6 | |
---|
7 | import numpy |
---|
8 | from scipy import * |
---|
9 | |
---|
10 | parser = OptionParser() |
---|
11 | |
---|
12 | (options, args) = parser.parse_args () |
---|
13 | |
---|
14 | if (len(args) != 2): |
---|
15 | print "Usage : suppr_fond.py input.fits output.fits" |
---|
16 | exit(1) |
---|
17 | |
---|
18 | # E# Ouverture de l'image fits en argument |
---|
19 | hdulist = pyfits.open(args[0]) |
---|
20 | scidata = hdulist[0].data |
---|
21 | |
---|
22 | if (scidata.shape != (2048,2048)): |
---|
23 | print "Erreur ! l'image ne fait pas 2048 x 2048 !" |
---|
24 | exit(2) |
---|
25 | |
---|
26 | # Estimation fond (4 coins) |
---|
27 | tf = 256 # taille fenetre fond, en pix |
---|
28 | fond_bas = .5 * (mean(scidata[:tf,:tf]) + mean(scidata[:tf,2048-tf:])) |
---|
29 | fond_haut= .5 * (mean(scidata[2048-tf:,:tf]) + mean(scidata[2048-tf:,2048-tf:])) |
---|
30 | |
---|
31 | a = float(fond_haut - fond_bas) / (2048-tf) |
---|
32 | b = fond_haut - a * (2048 - tf/2.) |
---|
33 | |
---|
34 | fond=numpy.zeros((2048,2048)) |
---|
35 | |
---|
36 | for i in range(2048): |
---|
37 | fond[i,:] = a * i + b |
---|
38 | |
---|
39 | |
---|
40 | scidata -= fond |
---|
41 | |
---|
42 | prihdr = hdulist[0].header |
---|
43 | prihdr.add_history('Suppression fond gradient vertical') |
---|
44 | |
---|
45 | hdulist[0].data = scidata |
---|
46 | hdulist.writeto(args[1],clobber=True) |
---|
47 | |
---|
48 | |
---|
49 | hdulist.close() |
---|
Note: See
TracBrowser
for help on using the repository browser.