prysm.coordinates

Coordinate conversions.

prysm.coordinates.cart_to_polar(x, y)

Return the (rho,phi) coordinates of the (x,y) input points.

Parameters
  • x (numpy.ndarray or number) – x coordinate

  • y (numpy.ndarray or number) – y coordinate

Returns

  • rho (numpy.ndarray or number) – radial coordinate

  • phi (numpy.ndarray or number) – azimuthal coordinate

prysm.coordinates.polar_to_cart(rho, phi)

Return the (x,y) coordinates of the (rho,phi) input points.

Parameters
  • rho (numpy.ndarray or number) – radial coordinate

  • phi (numpy.ndarray or number) – azimuthal coordinate

Returns

  • x (numpy.ndarray or number) – x coordinate

  • y (numpy.ndarray or number) – y coordinate

prysm.coordinates.uniform_cart_to_polar(x, y, data)

Interpolate data uniformly sampled in cartesian coordinates to polar coordinates.

Parameters
  • x (numpy.ndarray) – sorted 1D array of x sample pts

  • y (numpy.ndarray) – sorted 1D array of y sample pts

  • data (numpy.ndarray) – data sampled over the (x,y) coordinates

Returns

  • rho (numpy.ndarray) – samples for interpolated values

  • phi (numpy.ndarray) – samples for interpolated values

  • f(rho,phi) (numpy.ndarray) – data uniformly sampled in (rho,phi)

prysm.coordinates.resample_2d(array, sample_pts, query_pts)

Resample 2D array to be sampled along queried points.

Parameters
  • array (numpy.ndarray) – 2D array

  • sample_pts (tuple) – pair of numpy.ndarray objects that contain the x and y sample locations, each array should be 1D

  • query_pts (tuple) – points to interpolate onto, also 1D for each array

Returns

array resampled onto query_pts via bivariate spline

Return type

numpy.ndarray

prysm.coordinates.resample_2d_complex(array, sample_pts, query_pts, bounds_error=True, fill_value=0)

Resamples a 2D complex array.

Works by interpolating the magnitude and phase independently and merging the results into a complex value.

Parameters
  • array (numpy.ndarray) – complex 2D array

  • sample_pts (tuple) – pair of numpy.ndarray objects that contain the x and y sample locations, each array should be 1D

  • query_pts (tuple) – points to interpolate onto, also 1D for each array

  • bounds_error (bool, optional) – if True, raise if query point outside of domain of sample points

  • fill_value (float) – value to fill with in the case of out-of-bound values

Returns

array resampled onto query_pts via bivariate spline

Return type

numpy.ndarray

prysm.coordinates.make_xy_grid(samples_x, samples_y=None, radius=1)

Create an x, y grid from -1, 1 with n number of samples.

Parameters
  • samples_x (int) – number of samples in x direction

  • samples_y (int) – number of samples in y direction, if None, copied from sample_x

  • radius (float) – radius of the output array, will span -radius, radius

Returns

  • xx (numpy.ndarray) – x meshgrid

  • yy (numpy.ndarray) – y meshgrid

prysm.coordinates.make_rho_phi_grid(samples_x, samples_y=None, aligned='x', radius=1)

Create an rho, phi grid from -1, 1 with n number of samples.

Parameters
  • samples_x (int) – number of samples in x direction

  • samples_y (int) – number of samples in y direction, if None, copied from sample_x

  • radius (float) – radius of the output array

Returns

  • rho (numpy.ndarray) – radial meshgrid

  • phi (numpy.ndarray) – angular meshgrid