Skip to content

Should the Theory class know about the data bins already at the construction step, besides redshift bins? #16

@andreufont

Description

@andreufont

While reviewing lya_theory.get_Px_AA function, I noticed these lines around here:

        # compute input k, theta to emulator in Mpc
        
        Nk = 0
        Ntheta = 0
        if Nz > 1:
            for iz in range(Nz):
                if len(k_AA[iz]) > Nk:
                    Nk = len(k_AA[iz])
                if len(theta_deg[iz]) > Ntheta:
                    Ntheta = len(theta_deg[iz])
        else:
            
            if len(k_AA) == 1:
                k_AA = k_AA[0]
            if len(theta_deg) == 1:
                theta_deg = theta_deg[0]
            Nk = len(k_AA)
            k_AA = [k_AA]
            # if theta is just 1 float
            if np.isscalar(theta_deg):
                Ntheta = 1
            else:
                Ntheta = len(theta_deg)
            theta_deg = [theta_deg]

        kin_Mpc = np.zeros((Nz, Nk))
        theta_in_Mpc = np.zeros((Nz, Ntheta))
        for iz in range(Nz):
            kin_Mpc[iz, : Nk] = k_AA[iz] * M_AA_of_z[iz]
            theta_in_Mpc[iz, : Ntheta] = theta_deg[iz] / M_tdeg_of_z[iz]

It makes sense that the coordinate transformations have to be computed every time, but only when varying cosmology... otherwise, we are repeating these type of operations (and I believe similar ones in other places of the code) every time we evaluate a model.

But even if we do vary cosmology, the grid of theta and k bins, both fine and coarse, are constant properties of the data object that the theory could store (just like it stores the redshifts zs). One could consider setting all of these (in observed coordinates) at the moment we setup the theory class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions