def magma_prodction():
    mt = ip.read_data('D_melt', path, 4)
    mi_index = ip.read_data('D_melt', path, 5)
    mj_index = ip.read_data('D_melt', path, 6)

    magmaP = []
    Time = []
    column = 1
    for frame in range(1, vts):
        magmastep = 0
        time = fl.time[frame]
        countmarker = fl.read_countmarker(frame)
        x, z = fl.read_mesh(frame)
        for column_now in range(column, len(mt)):
            if mt[column_now] <= time:
                #=======every melted markers=====================

                area = read_area(x, z, mi_index[column_now],
                                 mj_index[column_now])
                magma = area * 0.25 / countmarker[mi_index[column_now],
                                                  mj_index[column_now]]
                ##print(column_now,time,mt[column_now])
                ##print(area,magma)
                magmastep = magmastep + magma

            #=========================================
            else:
                column = column_now
                #print('break')
                break
        magmaP.append(magmastep)
        Time.append(time)
    return magmaP, Time
def get_BASdata():
    BAST = []
    BASL = []

    for folderk in range(len(foldername)):
        path = inputpath + foldername[folderk]
        #os.chdir(path)
        #print(path)
        if os.path.isfile(path + '/D_rifting.txt'):
            kk = 0
            #print('exist')

            rt = ip.read_data('D_rifting', path, 3)
            time = ip.read_data1('D_time', path)
            Ltime = ip.read_data1('D_Ltime', path)

            BAST.append(round(rt[-1], 1))
            BASL.append(1000)
            #print(foldername[folderk],BAST[folderk],BASL[folderk])

            for kk in range(len(time)):
                if time[kk] >= BAST[folderk]:
                    BASL[folderk] = round(Ltime[kk], 1)
                    break
        else:
            print('no exist')
            BAST.append(1000)
            BASL.append(5000)

    #print(foldername[folderk],BAST[folderk],BASL[folderk])

    BAST = np.reshape(BAST, arraysize)
    BASL = np.reshape(BASL, arraysize)
    return BAST, BASL
def get_magmaP(time):

    magmaP = []
    time = np.reshape(time, (-1, 1))
    for folderk in range(len(foldername)):
        path = inputpath + foldername[folderk]
        os.chdir(path)

        import flac
        fl = flac.Flac()

        frame = time2vts(time[folderk], path)
        if frame != 1:
            production = 0
            for framek in range(frame - 10, frame + 10):
                countmarker = fl.read_countmarker(framek)
                meltingmarker = fl.read_meltingmarker(framek)
                x, z = fl.read_mesh(framek)

                mi = ip.read_data('D_melt', path, 5)
                mj = ip.read_data('D_melt', path, 6)
                mt = ip.read_data('D_melt', path, 4)

                for tkk in range(len(mt) - 1):
                    if mt[tkk] > fl.time[framek] and mt[tkk] < fl.time[framek +
                                                                       1]:
                        meltingmarker[mi[tkk],
                                      mj[tkk]] = meltingmarker[mi[tkk],
                                                               mj[tkk]] + 1

                for xk in range(fl.nx - 1):
                    for zk in range(fl.nz - 1):
                        production = production + (
                            0.25 *
                            (meltingmarker[xk, zk] / countmarker[xk, zk]) *
                            read_area(x, z, xk, zk))
            deltaT = fl.time[frame + 10] - fl.time[frame - 10]  #in Myrs
            magmaP.append(production / deltaT)
        else:
            magmaP.append(0.)
    magmaP = np.reshape(magmaP, arraysize)
    return magmaP
def get_magmaP(frame):

    frame = frame + 1
    import flac
    fl = flac.Flac()

    time = fl.time[frame]

    if frame > 10:
        production = 0

        for framek in range(frame - 5, frame + 5):
            x, z = fl.read_mesh(framek)
            countmarker = fl.read_countmarker(framek)
            meltingmarker = fl.read_meltingmarker(framek)

            mi = ip.read_data('D_melt', path, 5)
            mj = ip.read_data('D_melt', path, 6)
            mt = ip.read_data('D_melt', path, 4)

            for tkk in range(len(mt) - 1):
                if mt[tkk] > fl.time[framek] and mt[tkk] < fl.time[framek + 1]:
                    meltingmarker[mi[tkk],
                                  mj[tkk]] = meltingmarker[mi[tkk],
                                                           mj[tkk]] + 1

            for xk in range(1, fl.nx - 1):
                for zk in range(1, fl.nz - 1):
                    production = production + (
                        0.25 * (meltingmarker[xk, zk] / countmarker[xk, zk]) *
                        read_area(x, z, xk, zk))
        deltaT = fl.time[frame + 5] - fl.time[frame - 5]  #in Myrs
        magmaP = production / deltaT
    else:
        magmaP = 0

    return magmaP, time
if (legend >= 1):
   colorbar=plt.colorbar(dot,ax=ax)
   colorbar.set_label('M (%)', fontsize=10, color='black')
   colorbar.ax.tick_params(labelsize=8)
if (folderplot >=1):
    plt.text(490,1.5,foldername)

plt.savefig(results_dir+'/pic_MeltVol'+'.png') 
'''
# ===================================================
#      location of rifting and partial melting
# ===================================================
fig = plt.figure(figsize=(6, 5))
ax = fig.add_subplot(111)

mx = ip.read_data('D_melt', path, 2)
mt = ip.read_data('D_melt', path, 4)
mz = ip.read_data('D_melt', path, 8)

nrx = ip.read_data('D_rifting', path, 1)
nrz = ip.read_data('D_rifting', path, 2)
nrt = ip.read_data('D_rifting', path, 3)
rx = []
rz = []
rt = []
for kk in range(len(nrx)):
    rx.append(nrx[len(nrx) - kk - 1])
    rz.append(nrz[len(nrz) - kk - 1])
    rt.append(nrt[len(nrt) - kk - 1])

for kk in range(len(mx)):
    import flac
    #import flacmarker2vtk
    fl = flac.Flac()

    #-------------------------------------------
    print('>>>>> read data in <<<<<')
    #-------------------------------------------

    meanMORloca = []
    MORtime = []
    MORl = []

    if os.path.isfile(path + '/D_time.txt'):
        time = ip.read_data1('D_time', path)
        Ltime = ip.read_data1('D_Ltime', path)
        rx = ip.read_data('D_rifting', path, 1)
        rz = ip.read_data('D_rifting', path, 2)
        rt = ip.read_data('D_rifting', path, 3)

        for kkt in range(len(time) - 1):
            MORloca = []
            for kkr in range(len(rt)):
                if time[kkt] < rt[kkr] and time[kkt + 1] >= rt[kkr]:
                    MORloca.append(rx[kkr])
            if len(MORloca) != 0:
                meanMORloca.append(sum(MORloca) / len(MORloca))
                MORtime.append(time[kkt])
                MORl.append(Ltime[kkt])

        MORrate = cd.rate_calculating(meanMORloca, MORtime)
示例#7
0
    y1 = zmesh[x_index, z_index]
    x2 = xmesh[x_index, z_index + 1]
    y2 = zmesh[x_index, z_index + 1]
    x3 = xmesh[x_index + 1, z_index + 1]
    y3 = zmesh[x_index + 1, z_index + 1]
    x4 = xmesh[x_index + 1, z_index]
    y4 = zmesh[x_index + 1, z_index]
    area1 = ((x1 - x2) * (y3 - y2)) - ((x3 - x2) * (y1 - y2))
    area2 = ((x1 - x4) * (y3 - y4)) - ((x3 - x4) * (y1 - y4))
    area = (abs(area1) + abs(area2)) * 0.5

    return area


#get data
mt = ip.read_data('D_melt', path, 4)
mi_index = ip.read_data('D_melt', path, 5)
mj_index = ip.read_data('D_melt', path, 6)

magmaP = []
Time = []
column = 1
for frame in range(1, vts):
    magmastep = 0
    time = fl.time[frame]
    countmarker = fl.read_countmarker(frame)
    x, z = fl.read_mesh(frame)
    for column_now in range(column, len(mt)):
        if mt[column_now] <= time:
            #=======every melted markers=====================