A General Approach to Domain Adaptation with Applications in Astronomy. (9th September 2019)