예제 #1
0
def builddynamicdeffile (okadaparamfile,faultparamfile,outfile,t0=0.0, tend=1.0, nt = 2):

    faultparams=getokadaparams(okadaparamfile)
    faultparams.update(getfaultparams(faultparamfile))

    fid=open(outfile,'w')

    X=linspace(faultparams['xlower'],faultparams['xupper'],faultparams['mx'])
    Y=linspace(faultparams['ylower'],faultparams['yupper'],faultparams['my'])

    T=linspace(t0,tend,nt)

    dZ=okadamap(faultparams,X,Y)
    ind=fixdata.findbadindices(dZ)
    if ind:
        dZ=fixdata.fillbaddata(dZ,ind)

    dZ = filtermask(dZ,faultparams)
    #pdb.set_trace()
    for it in T:
        alpha=(it-t0)/(tend-t0)
        for jj in xrange(faultparams['my']):
            j=-1-jj
            for i in xrange(faultparams['mx']) :
                fid.write('%012.6e %012.6e %012.6e %012.6e \n' % (it,X[i],Y[j],alpha*dZ[j,i]))

    fid.close()
    return
예제 #2
0
def removenodata_value (inputfile,outputfile,topotypein=2,topotypeout=2,nodata_value=None,method='fill'):
    """
    remove the nodata_values in a topo file by interpolating from meaningful values.
    """
    import pylab

    (X,Y,Z)=topofile2griddata(inputfile,topotypein)

    if topotypein>1 and not nodata_value:
        topoheader=topoheaderread(inputfile)
        nodata_value=topoheader['nodata_value']
    elif not nodata_value:
        print 'provide a value for nodata_value when using topotype1'

    if method=='fill':
        ind=fixdata.findbadindices(Z,nodata_value)
        if size(ind)>0:
            print("Changing %s nodata_value points" % size(ind))
        Z=fixdata.fillbaddata(Z,ind)
        griddata2topofile(X,Y,Z,outputfile,topotypeout,nodata_value,nodata_value)
        return
    nrows= shape(Z)[0]
    ncols= shape(Z)[1]
    npts = nrows*ncols

    xi=X[0,:]
    yi=Y[:,0]

    X.np.reshape(npts)
    Y.np.reshape(npts)
    Z.np.reshape(npts)

    ind=np.where(Z!=nodata_value)
    X=X[ind]
    Y=Y[ind]
    Z=Z[ind]

    ptsremove=npts-len(Z)
    if ptsremove>0:
        print("Removing %s nodata_value points" % ptsremove)

    Z = pylab.griddata(X,Y,Z,xi,yi)
    (X,Y)=np.meshgrid(xi,yi)

    griddata2topofile(X,Y,Z,outputfile,topotypeout,nodata_value,nodata_value)

    return
예제 #3
0
def builddeffile (okadaparamfile,faultparamfile,outfile):

    faultparams=getokadaparams(okadaparamfile)
    faultparams.update(getfaultparams(faultparamfile))

    fid=open(outfile,'w')

    X=linspace(faultparams['xlower'],faultparams['xupper'],faultparams['mx'])
    Y=linspace(faultparams['ylower'],faultparams['yupper'],faultparams['my'])

    dZ=okadamap(faultparams,X,Y)
    ind=fixdata.findbadindices(dZ)
    if ind:
        dZ=fixdata.fillbaddata(dZ,ind)

    dZ = filtermask(dZ,faultparams)
    #pdb.set_trace()
    for jj in xrange(faultparams['my']):
        j=-1-jj
        for i in xrange(faultparams['mx']) :
            fid.write('%012.6e %012.6e %012.6e \n' % (X[i],Y[j],dZ[j,i]))

    fid.close()
    return