Electronic structure and crystal field in REMg and RERh (RE = rare earth) intermetallics