gcpy.grid_stretching_transforms

Functions to apply grid-stretching transforms.

Functions

cartesian_to_spherical(x, y, z)

Converts Cartesian coordinates to spherical (longitude, latitude) coordinates in radians.

rotate_vectors(x, y, z, k, theta)

Rotates 3D vectors about an arbitrary axis using Rodrigues' rotation formula.

schmidt_transform(x, y, s)

Applies the Schmidt transform to stretch a spherical grid toward a pole.

scs_transform(x, y, s, tx, ty)

Applies the Stretched Cubed-Sphere (SCS) transform to a longitude/latitude grid.

spherical_to_cartesian(x, y)

Converts spherical (longitude, latitude) coordinates in radians to Cartesian coordinates.

gcpy.grid_stretching_transforms.rotate_vectors(x, y, z, k, theta)[source]

Rotates 3D vectors about an arbitrary axis using Rodrigues’ rotation formula.

Parameters:
  • x (array-like) – X-components of the vectors to be rotated.

  • y (array-like) – Y-components of the vectors to be rotated.

  • z (array-like) – Z-components of the vectors to be rotated.

  • k (numpy.ndarray) – Unit vector defining the axis of rotation, shape (3,).

  • theta (float) – Angle of rotation in radians.

Returns:

gcpy.grid_stretching_transforms.cartesian_to_spherical(x, y, z)[source]

Converts Cartesian coordinates to spherical (longitude, latitude) coordinates in radians.

Parameters:
  • x (array-like) – X-components of the Cartesian coordinates.

  • y (array-like) – Y-components of the Cartesian coordinates.

  • z (array-like) – Z-components of the Cartesian coordinates.

Returns:

  • x_sph (numpy.ndarray) – Longitude in radians, in the range [-pi, pi].

  • y_sph (numpy.ndarray) – Latitude in radians, in the range [-pi/2, pi/2].

gcpy.grid_stretching_transforms.spherical_to_cartesian(x, y)[source]

Converts spherical (longitude, latitude) coordinates in radians to Cartesian coordinates.

Parameters:
  • x (array-like) – Longitude in radians.

  • y (array-like) – Latitude in radians.

Returns:

  • x_car (numpy.ndarray) – X-components of the Cartesian coordinates.

  • y_car (numpy.ndarray) – Y-components of the Cartesian coordinates.

  • z_car (numpy.ndarray) – Z-components of the Cartesian coordinates.

gcpy.grid_stretching_transforms.schmidt_transform(x, y, s)[source]

Applies the Schmidt transform to stretch a spherical grid toward a pole.

Parameters:
  • x (array-like) – Longitude in radians.

  • y (array-like) – Latitude in radians.

  • s (float) – Stretch factor. Values greater than 1 compress the grid near the south pole and expand it near the north pole.

Returns:

  • x (array-like) – Longitude in radians (unchanged by this transform).

  • y (numpy.ndarray) – Stretched latitude in radians.

Notes

The Schmidt parameter D is computed as (1 - s**2) / (1 + s**2).

gcpy.grid_stretching_transforms.scs_transform(x, y, s, tx, ty)[source]

Applies the Stretched Cubed-Sphere (SCS) transform to a longitude/latitude grid. This combines a Schmidt stretch with rotations about the x- and z-axes to relocate the high-resolution region to a target longitude and latitude.

Parameters:
  • x (array-like) – Longitude in degrees.

  • y (array-like) – Latitude in degrees.

  • s (float) – Stretch factor. Values greater than 1 increase the resolution near the target point.

  • tx (float) – Target longitude in degrees. The center of the high-resolution region will be placed at this longitude.

  • ty (float) – Target latitude in degrees. The center of the high-resolution region will be placed at this latitude.

Returns:

Notes

The transform proceeds in the following steps:

  1. Convert all angles from degrees to radians.

  2. Apply the Schmidt transform to stretch the grid.

  3. Convert to Cartesian coordinates.

  4. Rotate about the y-axis by (ty - y0) to shift the target latitude.

  5. Rotate about the z-axis by (tx - x0) to shift the target longitude.

  6. Convert back to spherical coordinates and then to degrees.