|
| 1 | +import numpy as np |
| 2 | +from numpy.random import Generator, PCG64 |
| 3 | +from astropy.wcs import WCS |
| 4 | + |
| 5 | +wcs = WCS(naxis=2) |
| 6 | +wcs.wcs.ctype = "RA---TAN", "DEC--TAN" |
| 7 | +wcs.wcs.crval = 30.0, 40.0 |
| 8 | +wcs.wcs.crpix = 10.0, 12.0 |
| 9 | +wcs.wcs.cdelt = 0.01, 0.01 |
| 10 | + |
| 11 | + |
| 12 | +class WCSTransformations: |
| 13 | + params = [1, 1_000, 1_000_000] |
| 14 | + |
| 15 | + def setup(self, size): |
| 16 | + np.random.seed(12345) |
| 17 | + gen = Generator(PCG64()) |
| 18 | + self.px = gen.uniform(0, 20, size) |
| 19 | + self.py = gen.uniform(0, 20, size) |
| 20 | + self.pxy = np.vstack([self.px, self.py]) |
| 21 | + self.wx, self.wy = wcs.wcs_pix2world(self.px, self.py, 0) |
| 22 | + self.wxy = np.vstack([self.wx, self.wy]) |
| 23 | + self.coord = wcs.pixel_to_world(self.px, self.py) |
| 24 | + |
| 25 | + def time_pix2world_x_y_0(self, size): |
| 26 | + wcs.wcs_pix2world(self.px, self.py, 0) |
| 27 | + |
| 28 | + def time_pix2world_x_y_1(self, size): |
| 29 | + wcs.wcs_pix2world(self.px, self.py, 1) |
| 30 | + |
| 31 | + def time_world2pix_x_y_0(self, size): |
| 32 | + wcs.wcs_world2pix(self.wx, self.wy, 0) |
| 33 | + |
| 34 | + def time_world2pix_x_y_1(self, size): |
| 35 | + wcs.wcs_world2pix(self.wx, self.wy, 1) |
| 36 | + |
| 37 | + def time_ape14_pixel_to_world(self, size): |
| 38 | + wcs.pixel_to_world(self.px, self.py) |
| 39 | + |
| 40 | + def time_ape14_world_to_pixel(self, size): |
| 41 | + wcs.world_to_pixel(self.coord) |
0 commit comments