Skip to content

Commit

Permalink
Added basic WCS benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed May 15, 2024
1 parent ba0d89f commit c741164
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions benchmarks/wcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import numpy as np
from numpy.random import Generator, PCG64
from astropy.wcs import WCS

wcs = WCS(naxis=2)
wcs.wcs.ctype = "RA---TAN", "DEC--TAN"
wcs.wcs.crval = 30.0, 40.0
wcs.wcs.crpix = 10.0, 12.0
wcs.wcs.cdelt = 0.01, 0.01


class WCSTransformations:
params = [1, 1_000, 1_000_000]

def setup(self, size):
np.random.seed(12345)
gen = Generator(PCG64())
self.px = gen.uniform(0, 20, size)
self.py = gen.uniform(0, 20, size)
self.pxy = np.vstack([self.px, self.py])
self.wx, self.wy = wcs.wcs_pix2world(self.px, self.py, 0)
self.wxy = np.vstack([self.wx, self.wy])
self.coord = wcs.pixel_to_world(self.px, self.py)

def time_pix2world_x_y_0(self, size):
wcs.wcs_pix2world(self.px, self.py, 0)

def time_pix2world_x_y_1(self, size):
wcs.wcs_pix2world(self.px, self.py, 1)

def time_world2pix_x_y_0(self, size):
wcs.wcs_world2pix(self.wx, self.wy, 0)

def time_world2pix_x_y_1(self, size):
wcs.wcs_world2pix(self.wx, self.wy, 1)

def time_ape14_pixel_to_world(self, size):
wcs.pixel_to_world(self.px, self.py)

def time_ape14_world_to_pixel(self, size):
wcs.world_to_pixel(self.coord)

0 comments on commit c741164

Please sign in to comment.