From c36c990656133dc0b7c159aad4f7faaa6ecc7e18 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sun, 13 Aug 2017 11:40:48 +0800 Subject: sky.py: Add new properties to SkyBase Signed-off-by: Aaron LI --- fg21sim/sky.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'fg21sim') diff --git a/fg21sim/sky.py b/fg21sim/sky.py index eb9f824..99de963 100644 --- a/fg21sim/sky.py +++ b/fg21sim/sky.py @@ -9,6 +9,7 @@ maps. import os import logging import copy +from datetime import datetime, timezone import numpy as np from scipy import ndimage @@ -85,7 +86,10 @@ class SkyBase: The frequency of the sky image. Unit: [MHz] """ - return self.frequency_ + if self.frequency_ is not None: + return self.frequency_ + else: + return self.header_.get("FREQ", None) @frequency.setter def frequency(self, value): @@ -95,6 +99,36 @@ class SkyBase: """ self.frequency_ = value + @property + def creator(self): + """ + The creator of the sky image. + """ + if self.creator_ is not None: + return self.creator_ + else: + return self.header_.get("CREATOR", None) + + @creator.setter + def creator(self, value): + """ + Set the creator of the sky image. + """ + self.creator_ = value + + @property + def header(self): + """ + The FITS header of the current sky. + """ + hdr = self.header_.copy() + hdr["SkyType"] = (self.type_, "Patch / HEALPix") + hdr["PixSize"] = (self.pixelsize, "Pixel size [arcsec]") + hdr["CREATOR"] = (self.creator, "Sky Creator") + hdr["DATE"] = (datetime.now(timezone.utc).astimezone().isoformat(), + "File creation date") + return hdr + def copy(self): """ Return a (deep) copy of this instance. -- cgit v1.2.2