Nonlinear waves in stratified Taylor--Couette flow. Part 1. Layer formation