PSFModel.py 1.09 KB
Newer Older
Fang Yuedong's avatar
Fang Yuedong committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import galsim
import sep
import numpy as np
from scipy.interpolate import interp1d
import pylab as pl
import os, sys

class PSFModel(object):
	def __init__(self, sigSpin=0., psfRa=0.15):
		# TODO: what are the nesseary fields in PSFModel class?
		pass

	def PSFspin(self, psf, sigSpin, sigGauss, dx, dy):
		"""
		The PSF profile at a given image position relative to the axis center

		Parameters:
		theta : spin angles in a given exposure in unit of [arcsecond]
		dx, dy: relative position to the axis center in unit of [pixels]

		Return:
		Spinned PSF: g1, g2 and axis ratio 'a/b'
		"""
		a2Rad = np.pi/(60.0*60.0*180.0)
		
		ff = sigGauss * 0.107 * (1000.0/10.0) # in unit of [pixels]
		rc = np.sqrt(dx*dx + dy*dy)
		cpix = rc*(sigSpin*a2Rad)

		beta = (np.arctan2(dy,dx) + np.pi/2)
		ell = cpix**2/(2.0*ff**2+cpix**2)
		#ell *= 10.0
		qr = np.sqrt((1.0+ell)/(1.0-ell))

		#psfShape = galsim.Shear(e=ell, beta=beta)
		#g1, g2 = psfShape.g1, psfShape.g2
		#qr = np.sqrt((1.0+ell)/(1.0-ell))

		#return ell, beta, qr
		PSFshear = galsim.Shear(e=ell, beta=beta*galsim.radians)
		return psf.shear(PSFshear), PSFshear