Yang-Yang thermometry and momentum distribution of a trapped one-dimensional Bose gas