aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-08-13 21:36:38 +0800
committerAaron LI <aly@aaronly.me>2017-08-13 21:39:41 +0800
commitd1cc715fc64a9d47d65e39a7bd851dee88b748d8 (patch)
treec9a441775e766eb64a1271163106751314921789 /fg21sim
parent8221ece7a7d18dc0f76f3c0bbf25371eedd1e33f (diff)
downloadfg21sim-d1cc715fc64a9d47d65e39a7bd851dee88b748d8.tar.bz2
sky.py: Fix the "pixelsize" property
Signed-off-by: Aaron LI <aly@aaronly.me>
Diffstat (limited to 'fg21sim')
-rw-r--r--fg21sim/sky.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/fg21sim/sky.py b/fg21sim/sky.py
index 167444e..e0d4a4a 100644
--- a/fg21sim/sky.py
+++ b/fg21sim/sky.py
@@ -51,6 +51,9 @@ class SkyBase:
frequency_ : float
The frequency of the input/output sky image.
Unit: [MHz]
+ pixelsize_ : float
+ The pixel size of the sky image.
+ Unit: [arcsec]
creator_ : str
The creator of the (output) sky image.
Default: ``__name__``
@@ -70,7 +73,8 @@ class SkyBase:
def __init__(self, float32=True, clobber=False, checksum=False):
self.type_ = None
self.data = None
- self.frequency_ = None
+ self.frequency_ = None # [MHz]
+ self.pixelsize_ = None # [arcsec]
self.creator_ = __name__
self.header_ = fits.Header()
self.float32_ = float32
@@ -163,6 +167,14 @@ class SkyBase:
self.frequency_ = value
@property
+ def pixelsize(self):
+ """
+ Pixel size of the sky image.
+ Unit: [arcsec]
+ """
+ return self.pixelsize_
+
+ @property
def creator(self):
"""
The creator of the sky image.
@@ -254,14 +266,6 @@ class SkyBase:
"""
raise NotImplementedError
- @property
- def pixelsize(self):
- """
- Pixel size of the sky image.
- Unit: [arcsec]
- """
- raise NotImplementedError
-
def random_points(self, n=1):
"""
Generate uniformly distributed random points within the
@@ -332,7 +336,7 @@ class SkyPatch(SkyBase):
self.xsize, self.ysize = size
# Initialize an empty image
self.data = np.zeros(shape=(self.ysize, self.xsize))
- self.pixelsize = pixelsize
+ self.pixelsize_ = pixelsize
self.xcenter, self.ycenter = center
if infile is not None:
@@ -661,6 +665,8 @@ class SkyHealpix(SkyBase):
self.type_ = "healpix"
self.nside = nside
+ self.pixelsize_ = (hp.nside2resol(self.nside, arcmin=True) *
+ AUC.arcmin2arcsec)
self.data = np.zeros(shape=hp.nside2npix(self.nside))
if infile is not None:
@@ -674,12 +680,6 @@ class SkyHealpix(SkyBase):
"""
return 4*np.pi * AUC.rad2deg**2
- @property
- def pixelsize(self):
- ps = hp.nside2resol(self.nside, arcmin=True)
- ps *= AUC.arcmin2arcsec
- return ps
-
def read(self, infile, frequency=None):
"""
Read input HEALPix all-sky map.