Esempio n. 1
0
		ekxms0 = -( e1[:,:6]-e1[:,4:5] ) # NGA and Ref 
		ekxms0[:,4:5] = e1[:,4:5]   # CS 
	    else: 
		ekxms0 = e1 

	    tmp1.append( ekxms0 ) 
	tmp_ekxms.append( tmp1 ) 
    tmp_ekxms = np.array( tmp_ekxms )   # [Nhypo, NMw, Nsta, Nmodels]
    
    # standard deviation and average over hypocenters 
    tmp_sd_xs = np.sqrt( np.average( tmp_ekxms**2, axis=1,weights=pdf_m) )
    tmp_sd0 = np.average( tmp_sd_xs, axis=0, weights = pdf_x ) 
    tmp_vd0 = np.average( tmp_sd_xs**2, axis=0, weights = pdf_x ) 
    tmp_sd = []; tmp_vd = []
    for imodel in xrange( tmp_sd0.shape[1] ):
	NewValue = interp( lons0, lats0, tmp_sd0[:,imodel], SiteLon1D, SiteLat1D, eps=eps, method=method )
        tmp_sd.append( NewValue ) 
	NewValue = interp( lons0, lats0, tmp_vd0[:,imodel], SiteLon1D, SiteLat1D, eps=eps, method=method )
        tmp_vd.append( NewValue ) 
    
    sigma_M_ks.append( tmp_vd )    # variance unit

    pafile = mapout + '/CyberShake.NGAs.%s.Source%s.Seks'%(T,sid)
    fid = open( pafile, 'w' ) 
    Nrow = len(SiteLon1D)
    for irow in xrange( Nrow ): 
	fid.write( '%s %s %s %s %s %s %s %s\n'%(SiteLon1D[irow],SiteLat1D[irow], \
		   tmp_sd[0][irow], 
		   tmp_sd[1][irow], 
		   tmp_sd[2][irow], 
		   tmp_sd[3][irow], 
Esempio n. 2
0
Input uninterpolated maps and do the interpolation based on the SiteInterpMesh 
""" 
import os, sys 
import numpy as np 
from my_util.numer import interp 

# interpolation (used in GMT)
infile = sys.argv[1]    # file full path with name 
outfile = sys.argv[2] 

inputs = np.loadtxt( infile ) 
SiteLon = inputs[:,0] 
SiteLat = inputs[:,1] 
Value = inputs[:,2] 

site_locs1 = './SiteInterpMesh.txt' 
sites = np.loadtxt( site_locs1 ) 
SiteLon1D = sites[:,0] 
SiteLat1D = sites[:,1] 

eps = 0.001 
smooth = 0.01
method = {'name':'exp','smooth':smooth}
newValue = interp( SiteLon, SiteLat, Value, SiteLon1D, SiteLat1D, eps=eps, method=method ) 

fid = open( outfile, 'w' ) 
for i in xrange( len(SiteLon1D) ): 
    fid.write( '%s %s %s\n'%(SiteLon1D[i], SiteLat1D[i], newValue[i]) )
fid.close()