Degrees of freedom of Hcurl space of type 1

I am using NGSolve to solve Maxwell’s equations in time-harmonic form. I created a finite element space as:
fes = HCurl(mesh, order=3, type1=True, dirichlet=“outer")
which is the Nedelec space of first type of order 3.

Based on Nedelec’s definition of the first kind elements, the number of DOF is given by:
N_DOF=(Edges *3)+(Faces 6)+(Cells3).
In the initial mesh, I got an identical number of the DOF, but when I refine the mesh the resulted DOF number doesn’t match the number calculated by the above formula.
Here is the outputs:
Initial mesh:
#nedge= 19
#nface= 18
#ne= 6
fes.ndof = 183
calculated_ndof = 183
calculated_ndof-fes_ndof = 0

First refinement:
#nedge= 117
#nface= 138
#ne= 48
fes.ndof = 1177
calculated_ndof = 1323
calculated_ndof-fes_ndof = 146

Second refinement:
#nedge= 721
#nface= 1002
#ne= 384
fes.ndof = 8265
calculated_ndof = 9327
calculated_ndof-fes_ndof = 1062

I am grateful for any explanation

Find attached my python script.

Attachment: DOF_Check.py

when we refine the mesh, we keep also coarse edges and faces (needed for some multigrid versions). There are no degrees of freedom assigned to the coarse grid faces, as you can check like this:

    for face in mesh.faces:
        print (fes.GetDofNrs(face))

Thank you Joachim.