@@ -0,0 +1,1865 @@
+# coding: utf-8%0A%0A%22%22%22 Test the model atmosphere interpolator %22%22%22%0A%0A__author__ = %22Andy Casey %3Candy@astrowizici.st%3E%22%0A%0Aimport os%0Aimport logging%0A%0Aimport numpy as np%0Aimport matplotlib.pyplot as plt%0A%0Afrom atmosphere import  AtmosphereInterpolator as atmospheres, %5C%0A                        parsers %0A%0A%0Aatmosphere_type = %22MARCS (2011)%22%0Asolar_model_filename = %22sun.mod.gz%22%0A%0Afolder, parser = parsers%5Batmosphere_type%5D%0Ainterpolator = atmospheres(folder, parser())%0A%0A# Parse the solar atmosphere%0Asolar_thermal_structure = interpolator.parser.parse_thermal_structure(%0A    os.path.join(folder, solar_model_filename))%0A%0A# These were taken directly from sun.mod.gz%0Atruths = %5B5777, np.log10(2.7542e+04), 0., 0.%5D%0A%0A# Interpolate the thermal structure for the truth values%0Ainterpolated_thermal_structure = interpolator.interpolate_thermal_structure(*truths)%0A%0A# Generate comparisons%0Ax = %22k%22%0Ainterpolated_properties = set(interpolated_thermal_structure.dtype.names).difference(x)%0A%0AK = int(np.ceil(len(interpolated_properties)**0.5))%0Afig, axes = plt.subplots(K, K)%0A%0Afor i, (ax, y) in enumerate(zip(axes.flatten(), interpolated_properties)):%0A%0A    #ax.plot(solar_thermal_structure%5Bx%5D, solar_thermal_structure%5By%5D, 'k')%0A    #ax.plot(interpolated_thermal_structure%5Bx%5D, interpolated_thermal_structure%5By%5D, 'b')%0A%0A    # Ensure the relative difference is less than 5%25%0A    relative_difference = 100 * (solar_thermal_structure%5By%5D - interpolated_thermal_structure%5By%5D)/solar_thermal_structure%5By%5D%0A    finite = np.isfinite(relative_difference)%0A    if not np.all(relative_difference%5Bfinite%5D %3C 5.):%0A        logging.warn(%22Relative difference in %7B0%7D exceeds 5%25 (%7B1%7D %3E 5)!%22.format(y, int(np.max(relative_difference))))%0A%0A    ax.plot(solar_thermal_structure%5Bx%5D, relative_difference, 'k')%0A%0A    ax.set_xlabel(x)%0A    ax.set_ylabel(y)%0A%0A%5Beach.set_visible(False) for each in axes.flatten()%5Blen(interpolated_properties):%5D%5D%0A%0A

Test MARCS model atmosphere interpolator