the ideality factor can be estimted from the derivative of the open-circuit voltage with respect to the logarithm of the illumination intensity:
n_light = q/kT * d V_oc / d ln(phi_in)
where q is the elementary charge, k Boltzmann's constant, T the absolute temperature, V_oc the open-circuit voltage, and phi_in the light intensity.
Another possibility is to derive the ideality factor from the dark IV curve:
n_dark = q/kT * d V_ext / d ln(j_dark)
where V_ext ist the external voltage and j_dark is the diode current density in the dark.
In both cases, the ideality factor is a measure of how the voltage across the device is changing with the number of excess carriers. In the former case, excess carriers are created by illumination, whereas in the latter case, they are injected from the contacts. Ideally, both sceanrios should lead to the same magnitude of the ideality factor. However, for real devices, often differences between the light and dark ideality factor can be seen,