def transform_grid_to_reference_frame(self, grid):
if self.__class__.__name__.startswith("<STR_LIT>"):<EOL><INDENT>return super().transform_grid_to_reference_frame(grid)<EOL><DEDENT>shifted_coordinates = np.subtract(grid, self.centre)<EOL>radius = np.sqrt(np.sum(shifted_coordinates ** <NUM_LIT>, <NUM_LIT:1>))<EOL>theta_coordinate_to_profile = np.arctan2(shifted_coordinates[:, <NUM_LIT:0>],<EOL>shifted_coordinates[:, <NUM_LIT:1>]) - self.phi_radians<EOL>transformed = np.vstack(<EOL>(radius * np.sin(theta_coordinate_to_profile), radius * np.cos(theta_coordinate_to_profile))).T<EOL>return transformed.view(TransformedGrid)<EOL>
Transform a grid of (y,x) coordinates to the reference frame of the profile, including a translation to \
        its centre and a rotation to it orientation.

        Parameters
        ----------
        grid : ndarray
            The (y, x) coordinates in the original reference frame of the grid.