Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ApplyJitter class #249

Open
maxecharles opened this issue Sep 4, 2023 · 1 comment
Open

Update ApplyJitter class #249

maxecharles opened this issue Sep 4, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@maxecharles
Copy link
Collaborator

maxecharles commented Sep 4, 2023

Update the generate_kernel method of the existing class. Perhaps add in the ApplyLinearJitter class I wrote for Toliman work.

e.g.

class ApplyJitter(...):

...

  def generate_kernel(self: DetectorLayer, pixel_scale: Array) -> Array:
          """
          Generates the normalised Gaussian kernel.
  
          Returns
          -------
          kernel : Array
              The Gaussian kernel.
          """
          
          extent = self.kernel_size * pixel_scale
          x = np.linspace(0, extent, self.kernel_size) - 0.5*extent
          kernel = norm.pdf(x, scale=self.sigma) * norm.pdf(x[:, None], scale=self.sigma)
          return kernel / np.sum(kernel)

and turn this func into a DetectorLayer

def jitter_psf(rad: float, angle: float = 0, centre: tuple = (0,0), npsf: int = 10):
    """
    Returns a jittered PSF by summing a number of shifted PSFs.

    Parameters
    ----------
    rad : float
        The radius of the jitter in pixels.
    angle : float, optional
        The angle of the jitter in degrees, by default 0
    centre : tuple, optional
        The centre of the jitter in pixels, by default (0,0)
    npsf : int, optional
        The number of PSFs to sum, by default 10

    Returns
    -------
    np.ndarray
        The jittered PSF.
    """

    angle = np.deg2rad(angle) # converting to radius

    # converting to cartesian coordinates
    x = rad/2 * np.cos(angle)
    y = rad/2 * np.sin(angle)
    xs = np.linspace(-x, x, npsf)  # pixels
    ys = np.linspace( -y, y, npsf)  # pixels
    positions = pscale * (np.stack([xs, ys], axis=1) + np.array(centre))  # arcseconds

    psfs = vmap_prop(optics, source, positions)
    jit_psf = psfs.sum(0) / npsf  # adding and renormalising

    return jit_psf
@maxecharles
Copy link
Collaborator Author

maxecharles commented Sep 13, 2023

Have created branch jitter (#253) and added the ApplyAsymmetricJitter class I wrote for TOLIMAN jitter fisher analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants