Пример #1
0
def main():

    #colors_techniques = plt.cm.viridis(np.linspace(0.,1.,len(techniques))) #BuPu
    lines = [':', '--', '-']
    n = 10
    color_gradient = plt.cm.inferno(np.linspace(0,1,4))

    fig, ax  = lp.newfig(0.6)
    """
    simrun1 = np.load('../sim/CM/time_sum_158_1_10.npy')
    simrun2 = np.load('../sim/CM/time_sum_158_1_300.npy')
    simrun3 = np.load('../sim/CM/time_sum_158_1_2000.npy')
    simrun4 = np.load('../sim/CM/time_sum_158_2_10.npy')
    simrun5 = np.load('../sim/CM/time_sum_158_2_300.npy')
    simrun6 = np.load('../sim/CM/time_sum_158_2_2000.npy')
    simrun7 = np.load('../sim/CM/time_sum_158_3_10.npy')
    simrun8 = np.load('../sim/CM/time_sum_158_3_300.npy')
    simrun9 = np.load('../sim/CM/time_sum_158_3_2000.npy')


    plt.plot(simrun1[0],simrun1[1], color=color_gradient[0], linestyle = lines[0], label = '10 secs')
    plt.plot(simrun2[0],simrun2[1], color = color_gradient[1], linestyle = lines[0], label = '5 mins')
    plt.plot(simrun3[0],simrun3[1], color = color_gradient[2], linestyle = lines[0], label = '30 mins')
    plt.plot(simrun4[0],simrun4[1], color = color_gradient[0], linestyle = lines[1], label = '10 secs')
    plt.plot(simrun5[0],simrun5[1], color = color_gradient[1], linestyle = lines[1], label = '5 mins')
    plt.plot(simrun6[0],simrun6[1], color = color_gradient[2], linestyle = lines[1], label = '30 mins')
    plt.plot(simrun7[0],simrun7[1], color = color_gradient[0], linestyle = lines[2], label = '10 secs')
    plt.plot(simrun8[0],simrun8[1], color = color_gradient[1], linestyle = lines[2], label = '5 mins')
    plt.plot(simrun9[0],simrun9[1], color = color_gradient[2], linestyle = lines[2], label = '30 mins')
    """
    m_simrun1 = np.load('../sim/mphage_sum_10.npy')
    m_simrun2 = np.load('../sim/mphage_sum_60.npy')
    m_simrun3 = np.load('../sim/mphage_sum_300.npy')
    m_simrun4 = np.load('../sim/mphage_sum_1800.npy')
    simrun1 = np.load('../sim/time_sum_10.npy')
    simrun2 = np.load('../sim/time_sum_60.npy')
    simrun3 = np.load('../sim/time_sum_300.npy')
    simrun4 = np.load('../sim/time_sum_1800.npy')

    plt.plot(simrun1[0],simrun1[1], color=color_gradient[0], linestyle = lines[0], label = '10 sec')
    plt.plot(simrun2[0],simrun2[1], color=color_gradient[1], linestyle = lines[0], label = '1 min')
    plt.plot(simrun3[0],simrun3[1], color=color_gradient[2], linestyle = lines[0], label = '5 min')
    plt.plot(simrun4[0],simrun4[1], color=color_gradient[3], linestyle = lines[0], label = '30 min')
    plt.plot(m_simrun1[0],m_simrun1[1], color=color_gradient[0], linestyle = lines[2])
    plt.plot(m_simrun2[0],m_simrun2[1], color=color_gradient[1], linestyle = lines[2])
    plt.plot(m_simrun3[0],m_simrun3[1], color=color_gradient[2], linestyle = lines[2])
    plt.plot(m_simrun4[0],m_simrun4[1], color=color_gradient[3], linestyle = lines[2])

    plt.legend()
    plt.title("Total gold nanoparticles")
    ax.set_xlabel(r"time (seconds)")
    ax.set_ylabel(r"total particles in tumor")
    ax.minorticks_off()
    filename = 'sum_mphage_hopping'
    lp.savefig(filename)
    plt.close(fig)

    #------------------------2A----------------------
    """
Пример #2
0
def main():
    def read_file(infile):
        with open(infile) as f:
            lines = f.readlines()
            # you may also want to remove whitespace characters like `\n` at the end of each line
            numbers = [float(line.rstrip('\n')) for line in lines]
        return numbers

    substance, period, cruise, name, N = sp.specify()

    input_parentdir = "/uio/hume/student-u17/sarahgj/Master/Data/VSLS_measurements/"
    entrained_mass = read_file(input_parentdir + "Entrained/" +
                               "entrained_mass_%s.dat" % name)
    entrained_traj = read_file(input_parentdir + "Entrained/" +
                               "entrained_traj_%s.dat" % name)
    released_mass = read_file(input_parentdir + "Released/" +
                              "released_%s.dat" % name)

    x = range(len(entrained_mass))
    micro = 1e-6
    nano = 1e-9
    molm = 0.14194  # Methyliodide, Molare Masse [kg/mol]

    entrained_mass = [x / (nano * molm) for x in entrained_mass]
    released_mass = [x / (micro * molm) for x in released_mass]

    corr = np.corrcoef(entrained_mass, released_mass)
    print corr

    #scatter plot
    fig = lp.newfig(1)
    plt.scatter(entrained_mass, released_mass)

    #add correlation line
    axes = plt.gca()
    m, b = np.polyfit(entrained_mass, released_mass, 1)
    X_plot = np.linspace(axes.get_xlim()[0], axes.get_xlim()[1], 100)
    plt.plot(X_plot, m * X_plot + b, '-')

    #title etc
    plt.title(cruise + ": " + substance + ", correlation %.2f" % corr[0, 1])
    plt.xlabel("Entrained mass [nmol]")
    plt.ylabel("Released mass [$\mu$mol]")

    destination_folder = "/uio/hume/student-u17/sarahgj/Master/Figures/VSLS/Entrainment/"
    filename = destination_folder + "entrained__released_corr%s" % name
    plt.savefig('{}.pdf'.format(filename))
    plt.savefig('{}.pgf'.format(filename))

    plt.show()
Пример #3
0
def main():
    astra = read_ASTRA()  #[0]=latitude, [1]=longitude, [2]=SST, [3]=T
    print "Done reading one"
    m91 = data = read_M91()  #[0]=latitude, [1]=longitude, [2]=SST, [3]=T
    print "Done reading two"

    fig = lp.newfig(1)
    m = make_map()
    plot_cruisetrack(astra, m, 'r')
    plot_cruisetrack(m91, m, 'b')

    destination_folder = "/uio/hume/student-u17/sarahgj/Master/Figures/DSHIP/"
    filename = destination_folder + "/cruisetrack"
    plt.savefig('{}.pgf'.format(filename))
    plt.savefig('{}.pdf'.format(filename))
Пример #4
0
def main(sim, run='', time=''):
    if time == '':
        time = np.load('../sim/' + sim + '/lastTime_seconds.npy')

    #colors_techniques = plt.cm.viridis(np.linspace(0.,1.,len(techniques))) #BuPu
    lines = [':', '-', ':', '-', ':', '-', '-']
    n = 10
    colors_gradient = plt.cm.inferno(np.linspace(0, 1, n))

    fig, ax = lp.newfig(0.6)
    nanoP = np.load('../sim/' + sim + '/diff_' + str(time) + 'sec' + str(run) +
                    '.npy')
    nanoP = nanoP / np.max(nanoP)  #in case max in not concentration
    #findmin = nanoP
    #findmin[findmin == 0.0 ] = 100.0
    #mini = np.min(findmin)
    #nanoP = nanoP - np.full(np.shape(nanoP), mini)
    print(np.min(nanoP))

    downsize = 1
    #cax = ax.contourf(range(0,np.shape(nanoP)[0],1)[::downsize], range(0,np.shape(nanoP)[2],1)[::downsize], nanoP[np.int(np.shape(nanoP)[1]/2),::downsize,::downsize], levels=np.logspace(-3, 0, 100), locator=mpl.ticker.LogLocator(50), cmap=plt.cm.inferno)
    cax = ax.contourf(range(0,
                            np.shape(nanoP)[0], 1)[::downsize],
                      range(0,
                            np.shape(nanoP)[1], 1)[::downsize],
                      nanoP[::downsize, ::downsize],
                      levels=np.logspace(-3, 0, 100),
                      locator=mpl.ticker.LogLocator(50),
                      cmap=plt.cm.inferno)
    cbar = fig.colorbar(cax, ticks=[10**0, 10**(-3), 10**(-6), 10**(-9)])
    #cbar = fig.colorbar(cax, ticks=[10**0, 10**(-1), 10**(-2), minimum])

    #cbar.ax.set_ylabel(r'$Concentration$')
    for c in ax.collections:
        c.set_edgecolor("face")
    plt.title("Normalized concentration of np")
    ax.set_xlabel(r"$z$-direction ($\mu m$)")
    ax.set_ylabel(r"$y$-direction ($\mu m$)")
    ax.minorticks_off()
    filename = sim + "_" + str(time) + str(run)
    lp.savefig(filename)
    plt.close(fig)
Пример #5
0
	def make_map(title):
		##Sets up a nice map for the figure, and adds a title.##
		#fig = plt.figure(1,figsize=(20,15))
		fig, ax  = lp.newfig(1)
		m = Basemap(projection='lcc',resolution='l',width=10000000,height=8000000,lon_0=-78.75,lat_0=-11.,urcrnrlat=2.) 	      
		m.drawparallels(np.arange(int(-50.),int(50.),15),labels=[1,0,0,0], linewidth=0.0)
		m.drawmeridians(np.arange(int(-120.),int(0.),15),labels=[0,0,0,1], linewidth=0.0)
		#m = Basemap(projection='lcc',resolution='l',width=30000000,height=15000000,lon_0=-78.75,lat_0=-11.,urcrnrlat=2.) 
		#The whole world:
		#m = Basemap(llcrnrlon=-180,llcrnrlat=-80,urcrnrlon=180,urcrnrlat=80,projection='mill')
                #m.drawparallels(np.arange(-80,81,20),labels=[1,1,0,0])
		#m.drawmeridians(np.arange(0,360,60),labels=[0,0,0,1])
		
		#m.shadedrelief()
		m.drawcountries(linewidth=1.2, linestyle='solid', color='k', antialiased=1, ax=None, zorder=None)
		m.drawcoastlines()
		#m.drawrivers(linewidth=0.2, linestyle='solid', color='b', antialiased=1, ax=None, zorder=None)
		#m.drawgreatcircle(lon1=0, lat1=0, lon2=-150, lat2=0, del_s=100.0, linewidth=1.5, color='r')
		m.drawmapboundary(fill_color='white')
		plt.title(title)
		return m, fig
Пример #6
0
]

# Conversion to days #
brom_mean = []
dibrom_mean = []
for i in range(0, 21):
    dibromomethane[i] = dibromomethane[i] / (24 * 60 * 60)
    bromoform[i] = bromoform[i] / (24 * 60 * 60)

print(np.mean(dibromomethane), np.mean(bromoform))

# Making a hight list
hight = range(0, 21)

## PLOTTING ##
lp.newfig(0.8)
host = host_subplot(111, axes_class=AA.Axes)
plt.subplots_adjust(right=0.75)

par1 = host.twinx()

#host.set_title("Lifetime Profiles", size=20)
host.set_xlabel("Height")
host.set_ylabel("Bromoform [days]")
par1.set_ylabel("Dibromomethane [days]")

p1, = host.plot(hight, bromoform, "k")
p2, = par1.plot(hight, dibromomethane, "b")

host.axis["left"].label.set_color(p1.get_color())
par1.axis["right"].label.set_color(p2.get_color())
Пример #7
0
def main():
    def read_file(infile):
        with open(infile) as f:
            lines = f.readlines()
            # you may also want to remove whitespace characters like `\n` at the end of each line
            numbers = [float(line.rstrip('\n')) for line in lines]
        return numbers

    substance, period, cruise, name, N = sp.specify()

    # reading information in to lists
    input_parentdir = "/uio/hume/student-u17/sarahgj/Master/Data/VSLS_measurements/Fluxes/"
    flux = read_file(input_parentdir + "fluxes_%s.dat" % name)
    lat = read_file(input_parentdir + "all_lats_%s.dat" % name)

    # arranging lists according to lat
    lat_arr = [
        x for (x, y) in sorted(zip(lat, flux), key=lambda pair: pair[0])
    ]
    flux_arr = [
        y for (x, y) in sorted(zip(lat, flux), key=lambda pair: pair[0])
    ]

    # reading dates to list
    with open(input_parentdir + "all_dates_%s.dat" % name, 'r') as myfile:
        dates_string = myfile.readlines()
        dates_string = [x.strip() for x in dates_string]
    datetimes = []
    for x in dates_string:
        datetimes.append(datetime.datetime.strptime(x, '%Y%m%dT%H%M%S'))
    dates = mpl.dates.date2num(datetimes)

    # make date figure
    fig, host = lp.newfig(1)
    host.plot(dates, flux)
    plt.axhspan(min(flux), 0, facecolor='r', alpha=0.3)
    host.set_ylim(min(flux), max(flux) * (1 + 0.1))

    host.set_title(cruise + ": " + substance)
    host.set_xlabel("Cruise")
    host.set_ylabel("Flux [pmol/(m**{2*}hr)]")

    daymonthFmt = mdates.DateFormatter('%d/%m')
    host.xaxis.set_major_formatter(daymonthFmt)

    # save date figure
    destination_folder = "/uio/hume/student-u17/sarahgj/Master/Figures/VSLS/Fluxes/"
    filename = destination_folder + "date_fluxes_%s" % name
    plt.savefig('{}.pdf'.format(filename))
    plt.savefig('{}.pgf'.format(filename))

    # make lat figure
    fig, host = lp.newfig(1)
    host.plot(lat_arr, flux_arr, 'b')
    plt.axhspan(min(flux_arr), 0, facecolor='r', alpha=0.3)
    host.set_ylim(min(flux_arr), max(flux_arr) * (1 + 0.1))

    host.set_title(cruise + ": " + substance)
    host.set_xlabel("Latitude")
    host.set_ylabel("Flux [pmol/(m$^{2*}$hr)]")

    # save lat figure
    destination_folder = "/uio/hume/student-u17/sarahgj/Master/Figures/VSLS/Fluxes/"
    filename = destination_folder + "lat_fluxes_%s" % name
    plt.savefig('{}.pdf'.format(filename))
    plt.savefig('{}.pgf'.format(filename))

    plt.show()
Пример #8
0
#============================FP QSD=============================

FPQSD_mean, FPQSD_var = comp.mean_var(ss.pdfFP_full_normalized, stochasticity,
                                      variability, capacity)
np.save("../data/heat_FPQSD_mean.npy", FPQSD_mean)
np.save("../data/heat_FPQSD_var.npy", FPQSD_var)

FPQSD_mean = np.load("../data/heat_FPQSD_mean.npy")
FPQSD_var = np.load("../data/heat_FPQSD_var.npy")

#FPQSD_var[FPQSD_var < 0.0] = 0.01 #Funky stuff happens, sometimes it's negative???
#FPQSD_mean[FPQSD_mean < 0.0] = 0.01

#------------------------------ A ------------------------------

fig, ax = lp.newfig(0.6)

cax = ax.contourf(
    stochasticity,
    variability,
    np.asarray(FPQSD_mean / exact_mean),
    100,
    cmap=plt.cm.inferno
)  #, norm=LogNorm(), levels=np.logspace(minimum, maximum, maximum))
cbar = fig.colorbar(cax,
                    ticks=[
                        np.min(FPQSD_mean / exact_mean), 1.0,
                        np.max(FPQSD_mean / exact_mean)
                    ])  #Should we useplt.cm.RdBu
for c in ax.collections:
    c.set_edgecolor("face")
##############################################################################