def __init__(self, galaxies, image_plane_positions, cosmology=cosmo.Planck15):
plane_redshifts = lens_util.ordered_plane_redshifts_from_galaxies(galaxies=galaxies)<EOL>galaxies_in_redshift_ordered_lists =lens_util.galaxies_in_redshift_ordered_planes_from_galaxies(galaxies=galaxies,<EOL>plane_redshifts=plane_redshifts)<EOL>if not galaxies:<EOL><INDENT>raise exc.RayTracingException('<STR_LIT>')<EOL><DEDENT>planes = []<EOL>for plane_index in range(<NUM_LIT:0>, len(plane_redshifts)):<EOL><INDENT>if plane_index < len(plane_redshifts) - <NUM_LIT:1>:<EOL><INDENT>compute_deflections = True<EOL><DEDENT>elif plane_index == len(plane_redshifts) - <NUM_LIT:1>:<EOL><INDENT>compute_deflections = False<EOL><DEDENT>else:<EOL><INDENT>raise exc.RayTracingException('<STR_LIT>')<EOL><DEDENT>new_positions = image_plane_positions<EOL>if plane_index > <NUM_LIT:0>:<EOL><INDENT>for previous_plane_index in range(plane_index):<EOL><INDENT>scaling_factor = cosmology_util.scaling_factor_between_redshifts_from_redshifts_and_cosmology(<EOL>redshift_0=plane_redshifts[previous_plane_index], redshift_1=plane_redshifts[plane_index],<EOL>redshift_final=plane_redshifts[-<NUM_LIT:1>], cosmology=cosmology)<EOL>scaled_deflections = list(map(lambda deflections:<EOL>np.multiply(scaling_factor, deflections),<EOL>planes[previous_plane_index].deflections))<EOL>new_positions = list(map(lambda positions, deflections:<EOL>np.subtract(positions, deflections), new_positions, scaled_deflections))<EOL><DEDENT><DEDENT>planes.append(pl.PlanePositions(redshift=plane_redshifts[plane_index],<EOL>galaxies=galaxies_in_redshift_ordered_lists[plane_index],<EOL>positions=new_positions, compute_deflections=compute_deflections))<EOL><DEDENT>super(TracerMultiPlanesPositions, self).__init__(planes=planes, cosmology=cosmology)<EOL>
Positional ray-tracer for a lens system with any number of planes.

        To perform multi-plane ray-tracing, a cosmology must be supplied so that deflection-angles can be rescaled \
        according to the lens-geometry of the multi-plane system.

        Parameters
        ----------
        galaxies : [Galaxy]
            The list of galaxies in the ray-tracing calculation.
        image_plane_positions : [[[]]]
            The (y,x) arc-second coordinates of image-plane pixels which (are expected to) mappers to the same \
            location(s) in the final source-plane.
        cosmology : astropy.cosmology
            The cosmology of the ray-tracing calculation.