def getErosionProfile(plan, profile):
    x = np.linspace(0, L, xRes)
    m, b = np.polyfit(x, convert(exposure(plan, profile)), 1)
    return m * x + b  #might need to round to a certain number of sigNIFICANT digits  -
    # DO NOT USE np.around IT CUTS OFF AFTER GIVEN NUMBER OF DECIMALS


## Plan = con, div, uni
## Profile = convex,parallel, concave
#def getErosionProfile(plan, profile):
#    return convert(exposure(plan, profile))
Пример #2
0
def pbpkModel(avector, time, BW, VFC):
    vols = volumes(BW, VFC)
    flow = flows(BW)
    exps = exposure(BW)

    # Create your models here.
    # Permeability surface area coefficients
    perm = {
        'fat': perms['fat'] * (vols['fat'] - vols['fatblood']),
        'muscle': perms['muscle'] * (vols['muscle'] - vols['muscleblood']),
        'slow': perms['slow'] * (vols['slow'] - vols['slowblood'])
    }

    maxi = min(len(avector), len(compartments))
    blood = {}
    tissue = {}
    A = {compartments[i]: max(avector[i], 0) for i in range(maxi)}
    d = {
        'arterial': 0,
        'liver': 0,
        'kidney': 0,
        'urine': 0,
        'muscleblood': 0, 'muscle': 0,
        'fatblood': 0, 'fat': 0,
        'rich': 0,
        'slowblood': 0, 'slow': 0
    }
    ###########################################################################
    # Concentration of the chemical in vein compartment
    rich = ('liver', 'kidney', 'rich')
    poor = ('fat', 'muscle', 'slow')
    bloodOut = 0;

    for r in rich:
        blood[r] = richBloodCalc(A[r], vols[r], flow[r], parts[r])
        bloodOut += blood[r].out
    for p in poor:
        pb = p + 'blood'
        blood[p] = poorBloodCalc(vols[p], flow[p], vols['blood'], A[pb], A[p])
        bloodOut += blood[p].out

    #########################################################################
    # OTC in blood compartment
    # con' of chemical in the vein
    CV = bloodOut / flow['total']

    CA = A['arterial'] / vols['blood']  # con' in artery = amount in artery / volume of blood
    RA = flow['total'] * (CV - CA)  # rate of change in amount in tissue of blood
    d['arterial'] = RA
    ###########################################################################
    # OTC in liver compartment
    tissue['liver'] = richTissueCalc(A['liver'], vols['liver'], flow['liver'], blood['liver'].conc, CA)
    d['liver'] = tissue['liver'].rate  # amount of chemical in liver
    CL = tissue['liver'].conc  # con' of chem in liver
    ###########################################################################
    # OTC in kidney compartment
    # Urinary excretion of OTC
    Rurine = exps['Kurine'] * blood['kidney'].conc
    d['urine'] = Rurine
    # kidney
    tissue['kidney'] = richTissueCalc(A['kidney'], vols['kidney'], flow['kidney'], blood['kidney'].conc, CA, -Rurine)
    d['kidney'] = tissue['kidney'].rate
    CK = tissue['kidney'].conc  # con' of chem in kidney
    ###########################################################################
    # OTC in RPT of body compartment
    tissue['rich'] = richTissueCalc(A['rich'], vols['rich'], flow['rich'], blood['rich'].conc, CA)
    d['rich'] = tissue['rich'].rate
    CR = tissue['rich'].conc

    ###########################################################################
    # OTC in muscle compartment
    tns = ('muscle', 'fat', 'slow')
    for tn in tns:
        tb = tn + 'blood'
        tissue[tn] = poorTissueCalc(vols[tn], flow[tn], A[tb], A[tn], blood[tn], CA, perm[tn], parts[tn])
        d[tb] = tissue[tn].brate  # amount of chemical in muscle
        d[tn] = tissue[tn].rate
    ###########################################################################
    # Mass balance
    # Qbal = flows(BW)['total'] - sum(flows.values())
    Tmass = A['arterial'] + A['liver'] + A['kidney'] + A['urine'] + A['rich'] + A['muscle'] + A['muscleblood'] + \
            A['fat'] + A['fatblood'] + A['slow'] + A['slowblood']
    #if Tmass > BW + 1:
    #    raise ValueError(sum(A.values()), A, sum(d.values()), d)

    for key in A:
        if A[key] < 0:
            raise ValueError(key, A[key], d[key])
    ld = list(d.values())
    return ld
Пример #3
0
# IPython log file

import exposure
exposure()
exposure.exposure()
import cloud
jid = cloud.call(exposure)
jid = cloud.call(exposure.exposure)
print jid
cloud.status()
cloud.status(jid)
cloud.result(jid)
exposure.exposure()
exposure.exposure(1024)
exposure.exposure(512)
exposure.exposure(1024)
args = 1024
N = 100
zip([args]*N)
jids = cloud.map(exposure.exposure, *zip(*([args]*N)))
zip(args*N)
zip([args]*N)
jids = cloud.map(exposure.exposure, zip(([args]*N)))
jids.status()
jids
cloud.status(jids)
cloud.result(jids)
jids = cloud.map(exposure.exposure, *zip(([args]*N)))
cloud.status(jids)
cloud.result(jids)
jids = cloud.map(exposure.exposure, *zip(*([args]*N)))
Пример #4
0
#plt.plot(x, y, color='k')
#prettify()
#plt.yticks([])
#plt.xticks([])
#plt.annotate('2', xy=(0,plotYMax), verticalalignment='top', fontsize=fontLarge)
#
#plt.subplot(3,3,3)
#y = convert(exposure('div', 'concave'))
#plt.plot(x, y, color='k')
#prettify()
#plt.yticks([])
#plt.xticks([])
#plt.annotate('3', xy=(0,plotYMax), verticalalignment='top', fontsize=fontLarge)

plt.subplot(1, 2, 1)
y = convert(exposure('con', 'planar'))
plt.plot(x, y, color='k')
prettify()
plt.xticks([])
#plt.annotate('4', xy=(0,plotYMax), verticalalignment='top', fontsize=fontLarge)
plt.ylabel('Chemical Denudation (mm)', fontsize=fontSmall)
prettify()

#plt.subplot(3,3,5)
#y = convert(exposure('uni', 'planar'))
#plt.plot(x, y, color='k')
#prettify()
#plt.yticks([])
#plt.xticks([])
#plt.annotate('5', xy=(0,plotYMax), verticalalignment='top', fontsize=fontLarge)
x = np.linspace(0, L, L)


def prettify():
    plt.xlim(plotXMin, plotXMax)
    plt.ylim(plotYMin, plotYMax)
    plt.yticks([0, 1.5 * 3600 * 24, 3 * 3600 * 24], [0, 1.5, 3],
               fontsize=fontSmall)
    plt.xticks([0, 50, 100], [0, 50, 100], fontsize=fontSmall)
    ax = plt.gca()
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)


plt.subplot(3, 3, 1)
plt.plot(x, exposure('con', 'concave'), color='k')
prettify()
plt.xticks([])
plt.annotate('1',
             xy=(0, plotYMax),
             fontsize=fontLarge,
             verticalalignment='top')

plt.subplot(3, 3, 2)
plt.plot(x, exposure('uni', 'concave'), color='k')
prettify()
plt.yticks([])
plt.xticks([])
plt.annotate('2',
             xy=(0, plotYMax),
             fontsize=fontLarge,
import matplotlib.pyplot as plt
from plotWaterTable import plotWaterTable
from plotWaterTablePlanar import plotWaterTablePlanar
from parameters import *
from exposure import exposure
from getDenudationRate import getDenudationRate
plt.figure(figsize=figDimSmall)

x = np.linspace(0,L,xRes)
#convert from 1 storm long exposure time to annual denudation (in meters)
timeLength = 1 #year
def convert(exp):
    return stormsPerYear*(exp + Tr)*getDenudationRate()*timeLength

plt.subplot(3,1,1)
yCon = convert(exposure('con','convex'))
plt.plot(x,yCon,color='k', linestyle='--', label='Actual')
m,b = np.polyfit(x,yCon,1)
plt.plot(x,m*x+b, color='k', linestyle='-', label='Linear Fit')
print('Convergent: m = ' + str(m) + ' and b = ' + str(b))
plt.annotate('Convergent', xy=(100,0), fontsize=fontSmall,
             horizontalalignment='right', verticalalignment='bottom')
plt.xticks([])
plt.legend(frameon=False, ncol=2, fontsize=fontXSmall)

plt.subplot(3,1,2)
yUni = convert(exposure('uni','convex'))
plt.plot(x,yUni,color='k', linestyle='--')
m,b = np.polyfit(x,yUni,1)
plt.plot(x,m*x+b, color='k', linestyle='-')
print('Uniform: m = ' + str(m) + ' and b = ' + str(b))
Пример #7
0
def pbpk(BW, VFC):
    # PBPK output

    out = odeint(pbpkModel, list(state.values()), time, args=(BW, VFC))
    return out


veces = np.linspace(1, 10, 10)
colors = ('#ffff00', '#00ffff', '#ff00ff', '#0000ff', '#ff0000', '#00ff00',
          '#000000', '#ff7f00', '#ff007f', '#7fff00', '#00ff7f')
for i in veces:
    vars = variableInput.randomize()
    BW = vars['BW']
    VFC = vars['VFC']
    exps = exposure(BW)
    state = {
        'arterial': exps['IV'],
        'liver': exps['ORAL'],
        'kidney': 0,
        'urine': 0,
        'muscleblood': 0,
        'muscle': exps['IM'],
        'fatblood': 0,
        'fat': 0,
        'rich': 0,
        'slowblood': 0,
        'slow': 0
    }
    output = pbpk(BW, VFC)
    putout = transpose(output)