We developed a method to compute the temperature and density structure along the line of sight by inversion of the differential emission measure (DEM), under the assumptions of stratification and hydrostatic equilibrium. We applied this method to the DEM obtained from AIA observations and used the results, together with potential extrapolations of the photosheric magnetic field, to compute the microwave emission of three sunspots, which we compared with observations from the RATAN-600 radio telescope and the Nobeyama Radioheliograph (NoRH). Our DEM based models reproduced very well the observations of the moderate-size spot on October 2011 and within 25% the data of a similar sized spot on March 2016, but predicted too low values for the big spot of April 14, 2016. The latter was better fitted by a constant conductive flux atmospheric model which, however, could not reproduce the peak brightness temperature of 4.7 × 10 6 K and the shape of the source at the NoRH frequency. We propose that these deviations could be due to low intensity non-thermal emission associated to a moving pore and to an opposite polarity light bridge. We also found that the double structure of the big spot at high RATAN-600 frequencies could be interpreted in terms of the variation of the angle between the magnetic field and the line of sight along the sunspot.