def _make_wcs_3D(shape, galactic=False): """ Create a simple celestial WCS object in either the ICRS or Galactic coordinate frame. Parameters ---------- shape : 3-tuple of int The shape of the 3D 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 = (1000, 100, 100) >>> wcs = make_wcs(shape) >>> print(wcs.wcs.crpix) # doctest: +FLOAT_CMP [50. 50. 500.] >>> print(wcs.wcs.crval) # doctest: +FLOAT_CMP [197.8925 -1.36555556 4861.] """ wcs = WCS(naxis=3) rho = np.pi / 3. scale = 0.1 / 3600. delta_wave = 0.5 wcs._naxis1 = shape[2] # nx wcs._naxis2 = shape[1] # ny wcs._naxis3 = shape[0] # nz wcs.wcs.crpix = [shape[2] / 2, shape[1] / 2, shape[0] / 2] # 1-indexed (x, y, z) wcs.wcs.crval = [197.8925, -1.36555556, 4861.] wcs.wcs.cunit = ['deg', 'deg', 'nm'] wcs.wcs.cd = [[-scale * np.cos(rho), scale * np.sin(rho), 0.], [ scale * np.sin(rho), scale * np.cos(rho), 0.], [ 0., 0., delta_wave]] if not galactic: wcs.wcs.radesys = 'ICRS' wcs.wcs.ctype = ['RA---TAN', 'DEC--TAN', 'WAVE'] else: wcs.wcs.ctype = ['GLON-CAR', 'GLAT-CAR', 'WAVE'] return wcs