Magnetic field dependence of thermal excitations in Josephson junctions