def make_wcs(shape, galactic=False): """ Create a simple celestial WCS object in either the ICRS or Galactic coordinate frame. Parameters ---------- shape : 2-tuple of int The shape of the 2D array to be used with the output `~astropy.wcs.WCS` object. galactic : bool, optional If `True`, then the output WCS will be in the Galactic coordinate frame. If `False` (default), then the output WCS will be in the ICRS coordinate frame. Returns ------- wcs : `~astropy.wcs.WCS` object The world coordinate system (WCS) transformation. See Also -------- make_imagehdu Examples -------- >>> from photutils.datasets import make_wcs >>> shape = (100, 100) >>> wcs = make_wcs(shape) >>> print(wcs.wcs.crpix) # doctest: +FLOAT_CMP [50. 50.] >>> print(wcs.wcs.crval) # doctest: +FLOAT_CMP [197.8925 -1.36555556] """ wcs = WCS(naxis=2) rho = np.pi / 3. scale = 0.1 / 3600. if astropy_version < '3.1': wcs._naxis1 = shape[1] # nx wcs._naxis2 = shape[0] # ny else: wcs.pixel_shape = shape wcs.wcs.crpix = [shape[1] / 2, shape[0] / 2] # 1-indexed (x, y) wcs.wcs.crval = [197.8925, -1.36555556] wcs.wcs.cunit = ['deg', 'deg'] wcs.wcs.cd = [[-scale * np.cos(rho), scale * np.sin(rho)], [scale * np.sin(rho), scale * np.cos(rho)]] if not galactic: wcs.wcs.radesys = 'ICRS' wcs.wcs.ctype = ['RA---TAN', 'DEC--TAN'] else: wcs.wcs.ctype = ['GLON-CAR', 'GLAT-CAR'] return wcs
def make_wcs(shape): """ Create a simple celestial WCS object. Parameters ---------- shape : 2-tuple of int The shape of the 2D array to be used with the output `~astropy.wcs.WCS` object. Returns ------- wcs : `~astropy.wcs.WCS` object The world coordinate system (WCS) transformation. See Also -------- make_imagehdu Examples -------- >>> from photutils.datasets import make_wcs >>> shape = (100, 100) >>> wcs = make_wcs(shape) >>> print(wcs.wcs.crpix) [ 50. 50.] >>> print(wcs.wcs.crval) [ 197.8925 -1.36555556] """ wcs = WCS(naxis=2) rho = np.pi / 3. scale = 0.1 / 3600. wcs._naxis1 = shape[1] # nx wcs._naxis2 = shape[0] # ny wcs.wcs.crpix = [shape[1] / 2, shape[0] / 2] # 1-indexed (x, y) wcs.wcs.crval = [197.8925, -1.36555556] wcs.wcs.cunit = ['deg', 'deg'] wcs.wcs.radesys = 'ICRS' wcs.wcs.cd = [[-scale * np.cos(rho), scale * np.sin(rho)], [scale * np.sin(rho), scale * np.cos(rho)]] wcs.wcs.ctype = ['RA---TAN', 'DEC--TAN'] return wcs
def create_wcs(ra, dec, cenchan): """Creates a fake WCS header to generate a MWA primary beam response Arguments: ra {float} -- Observation pointing direction in degrees dec {float} -- Observation pointing direction in degrees cenchan {float} -- Central channel Returns: {astropy.wcs.WCS} -- WCS information describing the observation """ pixscale = 0.6 / float(cenchan) # print("pixscale: ", pixscale) # print("cenchan: ", cenchan) w = WCS(naxis=2) w.wcs.crpix = [4000, 4000] w.wcs.cdelt = np.array([-pixscale, pixscale]) w.wcs.crval = [ra, dec] w.wcs.ctype = ["RA---SIN", "DEC--SIN"] w.wcs.cunit = ["deg", "deg"] w._naxis1 = 8000 w._naxis2 = 8000 return w