From 9b7f99bbd0eca0e611601dd936c1f7948f8cd58a Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Wed, 19 Jul 2017 16:34:40 +0800 Subject: Use [arcsec] as the unit for pixel size and resolution Signed-off-by: Aaron LI --- fg21sim/utils/units.py | 7 +++++++ fg21sim/utils/wcs.py | 14 +++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'fg21sim/utils') diff --git a/fg21sim/utils/units.py b/fg21sim/utils/units.py index aea0f92..bb8f670 100644 --- a/fg21sim/utils/units.py +++ b/fg21sim/utils/units.py @@ -50,6 +50,13 @@ class UnitConversions: keV2erg = au.keV.to(au.erg) # Angle rad2deg = au.rad.to(au.deg) + deg2rad = au.deg.to(au.rad) + arcmin2deg = au.arcmin.to(au.deg) + deg2arcmin = au.deg.to(au.arcmin) + arcsec2deg = au.arcsec.to(au.deg) + deg2arcsec = au.deg.to(au.arcsec) + arcmin2arcsec = au.arcmin.to(au.arcsec) + arcsec2arcmin = au.arcsec.to(au.arcmin) class Constants: diff --git a/fg21sim/utils/wcs.py b/fg21sim/utils/wcs.py index b4a9ed1..3cb76b9 100644 --- a/fg21sim/utils/wcs.py +++ b/fg21sim/utils/wcs.py @@ -8,6 +8,8 @@ Create WCS for sky projection. import numpy as np from astropy.wcs import WCS +from .units import UnitConversions as AUC + def make_wcs(center, size, pixelsize, frame="ICRS", projection="TAN"): """ @@ -16,11 +18,13 @@ def make_wcs(center, size, pixelsize, frame="ICRS", projection="TAN"): Parameters ---------- center : (xcenter, ycenter) float tuple - The equatorial/galactic coordinate of the sky/image center [ deg ]. + The equatorial/galactic coordinate of the sky/image center. + Unit: [deg] size : (xsize, ysize) int tuple The size (width, height) of the sky/image. pixelsize : float - The pixel size of the sky/image [ arcmin ] + The pixel size of the sky/image. + Unit: [arcsec] frame : str, "ICRS" or "Galactic" The coordinate frame, only one of ``ICRS`` or ``Galactic``. projection : str, "TAN" or "CAR" @@ -31,10 +35,14 @@ def make_wcs(center, size, pixelsize, frame="ICRS", projection="TAN"): ------- w : `~astropy.wcs.WCS` Created WCS header/object + + TODO/XXX + --------- + To support other projections, e.g., ``SIN`` (common in radio astronomy). """ xcenter, ycenter = center # [ deg ] xsize, ysize = size - delt = pixelsize / 60.0 # [ deg ] + delt = pixelsize * AUC.arcsec2deg # [ deg ] if projection.upper() not in ["TAN", "CAR"]: raise ValueError("unsupported projection: " % projection) if frame.upper() == "ICRS": -- cgit v1.2.2