def vectors_in_basis(expr, to_sys):
 vectors = list(expr.atoms(BaseVectorField))
 new_vectors = []
 for v in vectors:
  cs = v._coord_sys
  jac = cs.jacobian(to_sys, cs.coord_functions())
  new = (jac.T * Matrix(to_sys.base_vectors()))[v._index]
  new_vectors.append(new)
 return expr.subs(list(zip(vectors, new_vectors)))

def vectors_in_basis ( expr , to_sys ) : vectors = list ( expr . atoms ( BaseVectorField ) ) new_vectors = [ ] for v in vectors : cs = v . _coord_sys jac = cs . jacobian ( to_sys , cs . coord_functions ( ) ) new = ( jac . T * Matrix ( to_sys . base_vectors ( ) ) ) [ v . _index ] new_vectors . append ( new ) return expr . subs ( list ( zip ( vectors , new_vectors ) ) )
transform all base vectors in base vectors of a specified coord basis .