  Following an approach developed by Gieseker, Kn\"orrer and Trubowitz for
discretized Schr\"odinger operators, we study the spectral theory of Harper
operators in dimension two and one, as a discretized model of magnetic
Laplacians, from the point of view of algebraic geometry. We describe the
geometry of an associated family of Bloch varieties and compute their density
of states. Finally, we also compute some spectral functions based on the
density of states.
  We discuss the difference between the cases with rational or irrational
parameters: for the two dimensional Harper operator, the compactification of
the Bloch variety is an ordinary variety in the rational case and an
ind-pro-variety in the irrational case. This gives rise, at the
algebro-geometric level of Bloch varieties, to a phenomenon similar to the
Hofstadter butterfly in the spectral theory. In dimension two, the density of
states can be expressed in terms of period integrals over Fermi curves, where
the resulting elliptic integrals are independent of the parameters.
  In dimension one, for the almost Mathieu operator, with a similar argument we
find the usual dependence of the spectral density on the parameter, which gives
rise to the well known Hofstadter butterfly picture.
