0

I have produced a contour image in python using contourf, shown below. However, there is a problem with the quality of the image as can be seen by the white threading which covers almost all of it. Has anyone an idea as to why this occurs and how to fix it?

enter image description here

The code that i have used to produce such an image is shown below. Note that the code produces four images because of the initial 'for' loop, but all the images show this white haze on top and therefore I show only one. The part in which I create the contour plots is at the end, so one can look at that only:

import numpy as np
import matplotlib.pyplot as plt

pressure, altitude=np.loadtxt('/home/rb453/information.txt', unpack=True, usecols=[1,3])
altitude=altitude/altitude[0]
Rpl_array=[30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570, 600, 630, 660, 690, 720, 750, 780, 810, 840, 870, 900, 930, 960, 1000]
vel_array=[10000, 12000, 14000, 16000, 18000, 20000, 22000, 24000, 26000, 28000, 30000, 32000, 34000, 36000, 38000, 40000, 42000, 44000, 46000, 48000, 50000]



pressure_thresh=1e5*np.array([10,100,1000, 10000])
pressures = pressure_thresh
max_ablations=[0.175, 0.8, 0.8, 0.9]
dic = dict(zip(pressures, max_ablations))
for p_val in pressure_thresh:
    mass_loss_values=[]
    for i in range(len(Rpl_array)):
    print 'i', i
    mass_loss_values_each_rpl=[]
    for j in range(len(vel_array)):
        altitude_vel_file=np.loadtxt('Rpl_'+str(Rpl_array[i])+'/vel_'+str(vel_array[j])+'.txt', unpack=True, usecols=[2])
        x1=np.log10(altitude_vel_file)
        y0=np.log10(altitude)
        x0=np.log10(pressure)
        interpolated_alt=10**(np.interp(np.log10(p_val), x0, y0))
        index_value_for_mass_ablation=min(range(len(altitude_vel_file)), key=lambda w: abs(altitude_vel_file[w]-interpolated_alt))
        total_mass_ablation_to_p=np.loadtxt('Rpl_'+str(Rpl_array[i])+'/vel_'+str(vel_array[j])+'.txt', unpack=True, usecols=[3])[index_value_for_mass_ablation]

        mass_loss_values_each_rpl.append(total_mass_ablation_to_p) 
        mass_loss_values.append(1-np.array(mass_loss_values_each_rpl))

    # produce relvent contour plot
    levs = np.linspace(0, dic[p_val], 10000)
    fig=plt.figure(p_val)
    ax=fig.add_subplot(111)
    vel_array=np.array(vel_array)
    Rpl_array=np.array(Rpl_array)
    XX,YY=np.meshgrid(vel_array, Rpl_array)
    mass_loss_values=np.array(mass_loss_values)
    cp=ax.contourf(np.array(XX)/1000,YY,mass_loss_values, levels=levs)
    fig.colorbar(cp, ax=None)
    ax.set_ylabel('Radius (m)')
    ax.set_xlabel('Velocity (km/s)')
    fig.savefig('outputs/phi0_to_p'+str(int(p_val/1e5))+'bar.pdf')
    plt.show()
inquiries
  • 385
  • 2
  • 7
  • 20

0 Answers0