  For many transitions, atomic data, such as the oscillator strength (log(gf))
and the central wavelength of the line, are poorly constrained or even unknown.
We present and test a new inversion method that infers atomic line parameters
and the height stratification of the atmospheric parameters from spatially
resolved spectropolarimetric observations of the Sun. This method is
implemented in the new inversion code $\texttt{globin}$. The new method imposes
a spatial coupling in inversion parameters common to all pixels, such as the
atomic parameters of the observed spectral lines, and infers atmospheric
parameters for each spatial pixel individually. The uniqueness of this method
lies in its ability to retrieve reliable atomic parameters even for heavily
blended spectral lines. We tested the method by applying it to a set of 18
spectral lines between 4015 \r{A} and 4017 \r{A}, synthesized from a 3D
magnetohydrodynamic simulation containing a sunspot and the quiet Sun region
around it. The results were then compared with a previously used inversion
method where atomic parameters were determined for every pixel independently
(pixel-by-pixel method). The new method was able to retrieve the log(gf) values
of all lines to an accuracy of 0.004 dex, while the pixel-by-pixel method
retrieved the same parameter to an accuracy of only 0.025 dex. The largest
differences between the two methods are evident for the heavily blended lines,
with the former method performing better than the latter. In addition, the new
method is also able to infer reliable atmospheric parameters in all the
inverted pixels by successfully disentangling the degeneracies between the
atomic and atmospheric parameters. The new method is well suited for the
reliable determination of both atomic and atmospheric parameters and works well
on all spectral lines, including those that are weak and/or severely blended.
