Beispiel #1
0
def plot_canada_map():
    d = defaultdict(list)
    gmt = GMT(config={'PAGE_ORIENTATION':'landscape'})
    rng = '-70/-52/40/52.'
    scl = 'M10c'
    gmt.pscoast(R=rng,J=scl,B='a0.5wsne',D='l',W='thinnest',m=True,A='2/1/1')
    a = gmt.output.getvalue().split('\n')
    z = 0.
    cnt = 0
    connections = list()
    for _l in a:
        if _l.startswith('#'):continue
        if _l.startswith('>'):
            cnt += 1
            continue
        try:
            d[cnt].append(map(float,_l.split('\t')))
        except ValueError:
            print _l

    for _k in d.keys():
        ar = array(d[_k])
        x = (6371)*cos(2*pi*ar[:,1]/360.)*cos(2*pi*ar[:,0]/360.)
        y = (6371)*cos(2*pi*ar[:,1]/360.)*sin(2*pi*ar[:,0]/360.)
        z = (6371)*sin(2*pi*ar[:,1]/360.)
        pts = mlab.plot3d(x,y,z,tube_radius=2.0,color=(0,0,0))
Beispiel #2
0
def plot_2d(field,slat,slon,elat,elon,pdepth,new=True):
    """
    Calculate delaunay triangulation and subsequently probe velocity
    field at points of interest.
    """

    ndist = 0.
    nd = 0.
    values = 0.
                    
    ### calculate points between start and end point using a GMT's project program
    fout = 'profile_points.xyp'
    gmt = GMT()
    gmt.project(C='%f/%f'%(slon,slat),E='%f/%f'%(elon,elat),G=50,Q=True,out_filename=fout)
    lon,lat,dist = np.loadtxt(fout,unpack=True)
    os.remove(fout)
    
    cx = []
    cy = []
    cz = []
    cd = []
    cdp = []
    for _lon,_lat,_dist in zip(lon,lat,dist):
        for _d in pdepth:
            x,y,z = convert_pt(_lat,_lon,_d)
            cx.append(x)
            cy.append(y)
            cz.append(z)
            cd.append(_dist)
            cdp.append(_d)
    values = mlab.pipeline.probe_data(field,cx,cy,cz)
    return np.array(cd), np.array(cdp), values
Beispiel #3
0
def grafica_track(satelite, debris):
    gmt = GMT(config={'BASEMAP_TYPE': 'fancy'})

    gmt.pscoast(
        R='0/280/-75/75',  #g
        J='M6i',  #'G70/-51/5i'
        B='30g30',  # grid
        N='1',
        S=(173, 216, 230),  # wet fill color 
        G=(144, 238, 144),  # dry fill color
        W='thinnest')  # shoreline pen

    gmt.psxy(
        satelite,  #'../Encuentro/archivos/15482U',
        R='',
        J='',
        O='-',
        S='t0.05',
        K='K',
        G='red')

    gmt.psxy(
        debris,  #'../Encuentro/archivos/27386U',
        R='',
        J='',
        O='',
        S='t0.05',
        K='K',
        G='blue')

    gmt.save('../visual/archivos/ploteo_track.ps')

    print 'Grafico Terminado'
Beispiel #4
0
def plot_pdf(nabfile,fout,gauss=True):
    gmt = GMT(config={'BASEMAP_TYPE':'plain','ANOT_FONT_SIZE':8,
                      'LABEL_FONT_SIZE':10,'COLOR_BACKGROUND':'255/255/255',
                      'COLOR_FOREGROUND':'0/0/0','COLOR_NAN':'255/255/255',
                      'PAGE_ORIENTATION':'landscape'} )
    data,ok = read_nab(nabfile)
    if not ok: return 0
    xshift = 1
    yshift = 2
 #   for ii in range(0,4):
 #       x = data[ii,0,:]; y = data[ii,1,:]
 #       ### skip layers with zero thickness:
 #       if x[0] == x[-1]:continue
 #       rng = '%f/%f/%f/%f'%(floor(x[0]),ceil(x[-1]),y.min(),y.max()+0.1*y.max())
 #       scl = 'X4c/4c'
 #       ant = (ceil(x[-1])-floor(x[0]))/5.
 #       fnt = ant/2
 #       gmt.psxy(R=rng,J=scl,B='a%ff%f:Layer thickness [km]:weSn'%(ant,fnt),W='3,black',X='a%dc'%xshift,Y='a%dc'%yshift,in_columns=[x,y])
 #       xshift = xshift + 5
 #   yshift = 8.5
    xshift = 1
    for ii in range(10,15):
        x = data[ii,0,:]; y = data[ii,1,:]
        rng = '%f/%f/%f/%f'%(floor(x[0]),ceil(x[-1]),y.min(),y.max()+0.1*y.max())
        scl = 'X4c/4c'
        ant = (ceil(x[-1])-floor(x[0]))/5.
        fnt = ant/2
        gmt.psxy(R=rng,J=scl,B='a%ff%f:S-velocity [km/s]:weSn'%(ant,fnt),W='3,black',X='a%dc'%xshift,Y='a%dc'%yshift,in_columns=[x,y])
        xshift = xshift + 5
    gmt.save(fout)
    os.system('gv '+fout+'&')
    return 1
Beispiel #5
0
def find_scale(slat,slon,elat,elon):
    gmt = GMT()
    maxdist = 0.
    fout = 'profile_points.xyp'
    for _slat,_slon,_elat,_elon in zip(slat,slon,elat,elon):
        gmt.project(C='%f/%f'%(_slon,_slat),E='%f/%f'%(_elon,_elat),G=100,Q=True,out_filename=fout)
        lon,lat,dist = np.loadtxt(fout,unpack=True)
        if dist.max() > maxdist:
            maxdist = dist.max()
        os.remove(fout)
    return maxdist
def gmt_map(event_lats=None,
            event_lons=None,
            station_lats=None,
            station_lons=None,
            **kwargs):

    with_stations = False
    if kwargs.get('stations', False):
        with_stations = True

    with_events = False
    if kwargs.get('events', False):
        with_events = True

    gmt = GMT(config={'BASEMAP_TYPE': 'fancy'})

    lat_min = min(station_lats + event_lats)
    lat_max = max(station_lats + event_lats)
    lon_min = min(station_lons + event_lons)
    lon_max = max(station_lons + event_lons)

    lat_offset = (lat_max - lat_min) * 0.3
    lon_offset = (lon_max - lon_min) * 0.3

    gmt.pscoast(R='%i/%i/%i/%i' % (lon_min - lon_offset, lon_max + lon_offset,
                                   lat_min - lat_offset, lat_max + lat_offset),
                J='M10c',
                B='4g4',
                D='f',
                S=(114, 159, 207),
                G=(233, 185, 110),
                W='thinnest')

    if station_lats and station_lons and with_stations:
        gmt.psxy('-St0.5c',
                 R=True,
                 J=True,
                 G=(0, 255, 123),
                 in_columns=[station_lons, station_lats])

    if event_lats and event_lons and with_events:
        gmt.psxy('-Sa0.2c',
                 R=True,
                 J=True,
                 G=(255, 0, 0),
                 in_columns=[event_lons, event_lats])

    gmt.save('mapplot.pdf')
Beispiel #7
0
def plot_moho(nabfile,fout,gauss=True):
    data,ok = read_nab(nabfile)
    if not ok: return 0
    x = data[20,0,:]; y = data[20,1,:]
    gmt = GMT(config={'BASEMAP_TYPE':'plain','ANOT_FONT_SIZE':8,
                      'LABEL_FONT_SIZE':10,'COLOR_BACKGROUND':'255/255/255',
                      'COLOR_FOREGROUND':'0/0/0','COLOR_NAN':'255/255/255'} )
    rng = '%f/%f/%f/%f'%(floor(x[0]),ceil(x[-1]),y.min(),y.max()+0.1*y.max())
    scl = 'X6c/4c'
    ant = int((ceil(x[-1])-floor(x[0]))/10.)
    fnt = ant/2
    gmt.psxy(R=rng,J=scl,B='a%ff%fweSn'%(ant,fnt),W='3,red',in_columns=[x,y])
    if gauss:
        ### fit a gauss-curve to the pdf
        fitfunc = lambda p,x: (1/sqrt(2*pi*p[0]**2))*exp(-(x-p[1])**2/(2*p[0]**2))
        errfunc = lambda p,x,y: fitfunc(p,x)-y
        gaussian = lambda m,s,x: (1/sqrt(2*pi*s**2))*exp(-(x-m)**2/(2*s**2))
        p0 = [10.,50.]
        p1, success = optimize.leastsq(errfunc,p0[:],args=(x,y))
        sigm,mean = p1
        z = gaussian(mean,sigm,x)
        gmt.psxy(R=rng,J=scl,B='a%ff%fweSn'%(ant,fnt),W='3,black,- -',in_columns=[x,z])
    gmt.save(fout)
    os.system('gv '+fout+'&')
    return 1
def gmt_map(event_lats=None, event_lons=None, station_lats=None,
        station_lons=None, **kwargs):

    with_stations = False
    if kwargs.get('stations', False):
        with_stations = True

    with_events= False
    if kwargs.get('events', False):
        with_events = True

    gmt = GMT( config={'BASEMAP_TYPE':'fancy'} )

    lat_min = min(station_lats+ event_lats)
    lat_max = max(station_lats+ event_lats)
    lon_min = min(station_lons+ event_lons)
    lon_max = max(station_lons+ event_lons)

    lat_offset = (lat_max-lat_min)*0.3
    lon_offset = (lon_max-lon_min)*0.3

    gmt.pscoast( R='%i/%i/%i/%i'%(lon_min-lon_offset, 
                                   lon_max+lon_offset, 
                                   lat_min-lat_offset, 
                                   lat_max+lat_offset),
                J='M10c',
                B='4g4',
                D='f',
                S=(114,159,207),
                G=(233,185,110),
                W='thinnest')

    if station_lats and station_lons and with_stations:
        gmt.psxy('-St0.5c', R=True, J=True, G=(0,255,123),
                    in_columns=[station_lons, station_lats])

    if event_lats and event_lons and with_events:
        gmt.psxy('-Sa0.2c', R=True, J=True, G=(255,0,0), 
                    in_columns=[event_lons, event_lats])

    gmt.save('mapplot.pdf')
Beispiel #9
0
def gmt_north_america(**kwargs):
   '''
   Give rf_data as ([values],[time])
   '''
   from gmtpy import GMT
   #get kwargs
   fname = kwargs.get('fname','USA_map.pdf')
   station_data = kwargs.get('station_data','none')
   quake_locs   = kwargs.get('quake_locs','none')
   rf_data      = kwargs.get('rf_data','none')
   header       = kwargs.get('header','none')

   #topo data
   etopo='/geo/home/romaguir/utils/ETOPO5.grd'
   topo_grad='/geo/home/romaguir/utils/topo_grad.grd'

   #colormap
   colombia='/geo/home/romaguir/utils/colors/colombia'

   region = '-128/-66/24/52'
   scale = 'l-100/35/33/45/1:30000000'

   #initialize gmt
   gmt = GMT(config={'BASEMAP_TYPE':'fancy',
                     'HEADER_FONT_SIZE':'14'})
                     #'COLOR_BACKGROUND':'-',  :setting this to '-' plots z are transparent
                     #'COLOR_FOREGROUND':'-'})

   #make colormap
   cptfile = gmt.tempfilename()
   gmt.makecpt(C=colombia,T='-4000/4950/100',Z=True,out_filename=cptfile,D='i')

   #make gradient
   #topo_grad = gmt.tempfilename()
   #gmt.grdgradient(etopo,V=True,A='100',N='e0.8',M=True,G=topo_grad,K=False)

   #plot topography
   gmt.grdimage( etopo,
                 R = region,
                 J = scale,
                 C = cptfile,
                 E = '200')
                 #I = '0.5')#topo_grad)

   #plot coastlines
   gmt.pscoast( R=region,
                J=scale,
                B='a10',
                D='l',
                A='500',
                W='thinnest,black,-',
                N='all')

   #plot stations
   if station_data != 'none':
      gmt.psxy( R=region,
                J=scale,
                B='a10',
                S='t0.1',
                G='red',
                in_rows = station_data )


   if quake_locs != 'none':
      eq_region = 'g'
      eq_scale  = 'E-100/40/2.25i'
      gmt.pscoast( R = eq_region,
                   J = eq_scale,
                   B = 'p',
                   A = '10000',
                   G = 'lightgrey',
                   W = 'thinnest',
                   Y = '3.5i',
                   X = '-0.5i' ) 
      gmt.psxy( R = eq_region,
                J = eq_scale,
                S = 'a0.05',
                G = 'blue',
                in_rows = quake_locs )

   #plot receiver function stack
   if rf_data != 'none':
      rf_region = '-0.20/0.20/0/100'
      rf_scale  = 'X1i/-5i'
      gmt.psxy( R = rf_region,
                J = rf_scale,
                #G = 'grey', #fill
                B = '0.25::/10:time (s):NE',
                W = 'thin',
                X = '9i',
                Y = '-3.5i',
                in_columns = rf_data )

      #plot shaded area for positive values
      vals = rf_data[0]
      time = rf_data[1]
      poly_vals_pos = []
      poly_time_pos = []
      for i in range(0,len(vals)):
         val_here = max(0,np.float(vals[i]))
         poly_time_pos.append(time[i])
         poly_vals_pos.append(val_here)

      poly_vals_pos.append(0.0)
      poly_time_pos.append(time[::-1][0])
      poly_vals_pos.append(0.0)
      poly_time_pos.append(time[0])
      gmt.psxy( R = rf_region,
                J = rf_scale,
                G = 'red',
                B = '0.25::/10:time (s):NE',
                W = 'thin',
                in_columns = (poly_vals_pos,poly_time_pos) )

      #plot shaded area for negative values
      '''
      vals = rf_data[0]
      time = rf_data[1]
      poly_vals_neg = []
      poly_time_neg = []
      for i in range(0,len(vals)):
         val_here = min(0,np.float(vals[i]))
         poly_time_neg.append(time[i])
         poly_vals_neg.append(val_here)
      poly_vals_neg.append(0.0)
      poly_time_neg.append(time[::-1][0])
      poly_vals_neg.append(0.0)
      poly_time_neg.append(time[0])
      gmt.psxy( R = rf_region,
                J = rf_scale,
                G = 'blue',
                B = '0.25::/10:time (s):NE',
                W = 'thin',
                in_columns = (poly_vals_neg,poly_time_neg) )
      '''

   #header_file = open('header_file','w')
   #header_file.write('<< EOF')
   #header_file.close()

   #write header information
   if header != 'none':
      stations_text = header['N_traces'] + ' traces in stack'
      events_text   = header['N_events'] + ' events'
      freq_text     = header['frequency']
      decon_text    = 'deconvolution method : ' + header['decon']

      gmt.pstext( in_rows = [(-96,60,12,0,1,'MC',stations_text)],
                  R = region,
                  J = scale,
                  N = True,
                  X = '-8.5i' )
      gmt.pstext( in_rows = [(-96,59,12,0,1,'MC',events_text)],
                  R = region,
                  J = scale,
                  N = True )
      gmt.pstext( in_rows = [(-96,58,12,0,1,'MC',freq_text)],
                  R = region,
                  J = scale,
                  N = True )
      gmt.pstext( in_rows = [(-96,57,12,0,1,'MC',decon_text)],
                  R = region,
                  J = scale,
                  N = True )

   #save figure
   gmt.save(fname)
Beispiel #10
0
def main(mdlname,dispdic,title):
    os.system('gpdcreport '+mdlname+' >tmp.mdl')
    models, data, nd, ne, nrow = get_models('tmp.mdl')
    gmt = GMT(config={'BASEMAP_TYPE':'plain','ANOT_FONT_SIZE':8,
                      'LABEL_FONT_SIZE':10,'COLOR_BACKGROUND':'255/255/255',
                      'COLOR_FOREGROUND':'0/0/0','COLOR_NAN':'255/255/255',
                      'PAGE_ORIENTATION':'landscape',
                      'HEADER_FONT_SIZE':15} )
    xyz=gmt.tempfilename('testxyz.txt')
    xyz2=gmt.tempfilename('testxyz2.txt')
    grd=gmt.tempfilename('tmp.grd')
    grdcpt=gmt.tempfilename('tmp.cpt')
    fileout='dens_test.ps'
    rng='1/5/0/40'
    scl='X4.2/-6'
    dreso = 0.2
    sreso = 0.05
    misfit = 0.1
    #grid1, grid2, x, y, smean, dmean = dplot.dplot(models,data,nd,ne,dreso=dreso, sreso=sreso,mf=misfit)
    grid1, grid2, x, y, smean, dmean = dplot.dplot(models,data,nd,ne,dreso=dreso, sreso=sreso,mf=misfit)
    #grid1, grid2, x, y = dplot.dplotpy(models,data,nd,ne,dreso=dreso, sreso=sreso,mf=misfit)
#    matshow(grid1)
#    show()
    f = open(xyz,'w')
    for ii in range(len(y)):
        for jj in range(len(x)):
            if grid1[ii,jj]>0.0:
                print >>f, x[jj],y[ii], grid1[ii,jj]
    f.close()
    f = open(xyz2,'w')
    for ii in range(len(y)):
        for jj in range(len(x)):
            if grid2[ii,jj] > 0:
                print >>f, x[jj], y[ii], '0.5'
    f.close()
    anot = int(grid1.max()/1000.)*1000/2.
    tick = anot/2
    gmt.xyz2grd(xyz,G=grd,R=rng,I='%f/%f'%(sreso,dreso),out_discard=True)
    gmt.grd2cpt(grd,C="wysiwyg",Z=True,out_filename=grdcpt)
    gmt.psmask(xyz2,R=rng,T=True,J=scl,I='%f/%f'%(sreso,dreso),G='lightgray')
    gmt.grdimage(grd,J=scl,R=rng,Q=True,C=grdcpt)
    gmt.psbasemap(R=rng,J=scl,B='a1f.5:S-velocity [km/s]:/a10f5:Depth [km]::.%s:WnSe'%title)
    gmt.psxy(R=True,J=True,B=True,W='3,black',in_columns=[smean,dmean])
    f = open('/home/behrya/dev/data/mt_fixed_layers_ray_c_u_mean.txt','w')
    for _p,_v in zip(dmean,smean):
        print >>f,_p,_v
    f.close()
    gmt.psscale(C=grdcpt,D='1.0/1./4c/.4ch',B='a%df%d:No. of models:/::'%(anot,tick))
    ### plot dispersion curves
    gmt.psbasemap(R='5/30/2.0/5.0',J='X4.2/2.5',X='5',B='a1f.5:Period [s]:/a1f.5:Velocity [km/s]:WnSe')
    for _d in dispdic.keys():
        vo = load(dispdic[_d][0])
        p,v = gpdccurve(mdlname,wtype=dispdic[_d][1],ptype=dispdic[_d][2])
        gmt.psxy(R=True,J=True,B=True,W='3,black',in_columns=[p,v])
        gmt.psxy(R=True,J=True,B=True,W='3,red',in_columns=[vo[:,0],vo[:,1]])

    gmt.save(fileout)
    os.system('gv '+fileout+'&')
Beispiel #11
0
def plot_vtk_slice(vtk_slice,theta_range=[0,360],depth_range=[0,2885],**kwargs): 
#--------------------------------------------------------------------------------

   '''
   This will plot a cross section of a .vtk file.  Open the .vtk file in paraview,
   choose a slice, and select 'File -> export data'.  This will save the data as
   a .csv file, which can be plotted with this function.

   args--------------------------------------------------------------------------
   vtk_slice: the .csv file
   theta_range: the range in degrees you wish to plot. 
                dtype=tuple
                default=[0,360] (whole earth)
   depth_range: the range in depth you wish to plot.
                dtype=tuple
                default=[0,2885] (whole mantle)

   kwargs------------------------------------------------------------------------
   cmap = colormap to use
          dtype=string
          default='BlueWhiiteOrangeRed'

   data_range = max and min values to use in colorbar.
                dtype=tuple
                default=[-1.0,1.0]

   csteps = number of divisions in colorbar
            dtype=int
            default=100

   cmap_direction = forward or reverse colormap
                    dtype=string
                    default='i'

   fname = filename
           dtype=string
           default='slice.pdf'

   rotation = number of degrees to rotate figure
            dtype=float
            default=90.0 (i.e., rotate from lat coor to colat based coor)

   contour = True or False
   '''

   #get kwargs-------------------------------------------------------------------
   cmap_dir = '/geo/home/romaguir/utils/colors/'
   cmap = kwargs.get('cmap','BlueWhiteOrangeRed')
   cmap = cmap_dir+cmap
   data_range = kwargs.get('data_range',[-0.25,0.25])
   csteps = kwargs.get('csteps',100)
   cmap_direction=kwargs.get('cmap_direction','i')
   fname = kwargs.get('fname','slice.pdf')
   rotation=kwargs.get('rotation',90.0)
   contour=kwargs.get('contour',True)

   #read csv slice (output of paraview)------------------------------------------
   f = pandas.read_csv(vtk_slice)
   p1 = f['Points:0']
   p2 = f['Points:1']
   p3 = f['Points:2']
   dvp = f['dVp()']

   #transform to polar, earth coordinates----------------------------------------
   r,t = cart2polar(p1,p3)
   r *= 6371.0
   t=np.degrees(t)
   

   print min(dvp),max(dvp)

   #setup GMT plot---------------------------------------------------------------
   gmt = GMT(config={'BASEMAP_TYPE':'fancy',
                      'HEADER_FONT_SIZE':'14'})
   region = '{}/{}/{}/{}'.format(theta_range[0],theta_range[1],6371.0-depth_range[1],6371.0-depth_range[0])
   surf_region = '{}/{}/{}/{}'.format(theta_range[0]-2,theta_range[1]+2,6371.0-depth_range[1],6500.0-depth_range[0])
   scale = 'P6i' #Polar, 8 inch radius
   cptfile = gmt.tempfilename()
   grdfile = gmt.tempfilename()

   #gmt.makecpt(C=cmap,T='{}/{}/{}'.format(data_range[0],data_range[1],csteps),Z=False,out_filename=cptfile,D=cmap_direction)
   gmt.makecpt(C=cmap,T='-0.25/0.25/0.025',A=100,out_filename=cptfile,D=True)

   gmt.surface(in_columns=[t+rotation,r,dvp],G=grdfile,I='0.5/25',T=0.0,R=surf_region,out_discard=True)

   '''
   #plot the data----------------------------------------------------------------
   gmt.psxy( R=region,
             J=scale,
             #B='a15f15:"":/200f200:""::."":WSne',
             B='a300f300',
             S='s0.20',
             #G='blue',
             C=cptfile,
             in_columns=[t+rotation,r,dvp] )
   '''
   #plot the data----------------------------------------------------------------
   gmt.grdimage( grdfile, 
                 R=region,
                 J=scale,
                 B='a300f300',
                 C=cptfile,
                 E='i5' )
   
   #contour the data-------------------------------------------------------------
   if contour == True:
      gmt.grdcontour( grdfile,
                      R=region,
                      J=scale,
                      C=cptfile,
                      W='1' )

   #plot 660---------------------------------------------------------------------
   d660 = np.loadtxt('/geo/home/romaguir/utils/660_polar.dat')
   print d660
   gmt.psxy( R=region,
             J=scale,
             W='1',
             in_rows=[d660] )
            
   gmt.save(fname)
Beispiel #12
0
from gmtpy import GMT

gmt = GMT( config={'PAGE_COLOR':'247/247/240'} )
gmt.psbasemap( R=(0,5,0,5), 
               J='X%gi/%gi' % (5,3), 
               B='%g:Time:/%g:Amplitude:SWne' % (1,1) ) 


# Make four different datasets
    
# (1) a nested list, with the first dim corresponding to columns
data_as_columns = [ [ 0,1,2,3,4,5 ], [0,1,0.5,1,0.5,1] ]    

# (2) a nested list, with the first dim corresponding to rows
data_as_rows = [ [0,1], [1,2], [2,3], [3,3.5], [4,3], [5,2] ]

# (3) a string containing an ascii table
data_as_string = '''0 5
1 4
2 3.5
3 4
4 4.5
5 5'''


# (4) write ascii table in a temporary file...

# Get a filename in the private tempdir of the GMT instance.
# Files in that directory get deleted automatically.
filename = gmt.tempfilename('table.txt')
    
Beispiel #13
0
from gmtpy import GMT, cm, GridLayout, FrameLayout, golden_ratio
import numpy as np

# some data to plot...
x = np.linspace(0, 5, 101)
ys = (np.sin(x) + 2.5, np.cos(x) + 2.5)

gmt = GMT(config={'PAGE_COLOR': '247/247/240'})

layout = GridLayout(1, 2)

widgets = []
for iwidget in range(2):
    inner_layout = FrameLayout()
    layout.set_widget(0, iwidget, inner_layout)
    widget = inner_layout.get_widget('center')
    widget.set_horizontal(7 * cm)
    widget.set_vertical(7 * cm / golden_ratio)
    widgets.append(widget)

#gmt.draw_layout( layout )
#print layout

for widget, y in zip(widgets, ys):
    gmt.psbasemap(R=(0, 5, 0, 5),
                  B='%g:Time [ s ]:/%g:Amplitude [ m ]:SWne' % (1, 1),
                  *widget.XYJ())

    gmt.psxy(R=True, W='2p,blue,o', in_columns=(x, y), *widget.XYJ())

gmt.save('example4.pdf', bbox=layout.bbox())
Beispiel #14
0
def gmt_north_america(**kwargs):
   '''
   Give rf_data as ([values],[time])
   '''
   from gmtpy import GMT
   #get kwargs
   fname = kwargs.get('fname','USA_map.pdf')
   station_data = kwargs.get('station_data','none')
   quake_locs   = kwargs.get('quake_locs','none')
   rf_data      = kwargs.get('rf_data','none')
   header       = kwargs.get('header','none')

   #topo data
   etopo='/geo/home/romaguir/utils/ETOPO5.grd'
   topo_grad='/geo/home/romaguir/utils/topo_grad.grd'

   #colormap
   colombia='/geo/home/romaguir/utils/colors/colombia'

   region = '-128/-66/24/52'
   scale = 'l-100/35/33/45/1:30000000'

   #initialize gmt
   gmt = GMT(config={'BASEMAP_TYPE':'fancy',
                     'HEADER_FONT_SIZE':'14'})
                     #'COLOR_BACKGROUND':'-',  :setting this to '-' plots z are transparent
                     #'COLOR_FOREGROUND':'-'})

   #make colormap
   cptfile = gmt.tempfilename()
   gmt.makecpt(C=colombia,T='-4000/4950/100',Z=True,out_filename=cptfile,D='i')

   #make gradient
   #topo_grad = gmt.tempfilename()
   #gmt.grdgradient(etopo,V=True,A='100',N='e0.8',M=True,G=topo_grad,K=False)

   #plot topography
   gmt.grdimage( etopo,
                 R = region,
                 J = scale,
                 C = cptfile,
                 E = '200')
                 #I = '0.5')#topo_grad)

   #plot coastlines
   gmt.pscoast( R=region,
                J=scale,
                B='a10',
                D='l',
                A='500',
                W='thinnest,black,-',
                N='all')

   #plot stations
   if station_data != 'none':
      gmt.psxy( R=region,
                J=scale,
                B='a10',
                S='t0.1',
                G='red',
                in_rows = station_data )


   if quake_locs != 'none':
      eq_region = 'g'
      eq_scale  = 'E-100/40/2.25i'
      gmt.pscoast( R = eq_region,
                   J = eq_scale,
                   B = 'p',
                   A = '10000',
                   G = 'lightgrey',
                   W = 'thinnest',
                   Y = '3.5i',
                   X = '-0.5i' ) 
      gmt.psxy( R = eq_region,
                J = eq_scale,
                S = 'a0.05',
                G = 'blue',
                in_rows = quake_locs )

   #plot receiver function stack
   if rf_data != 'none':
      rf_region = '-0.20/0.20/0/100'
      rf_scale  = 'X1i/-5i'
      gmt.psxy( R = rf_region,
                J = rf_scale,
                #G = 'grey', #fill
                B = '0.25::/10:time (s):NE',
                W = 'thin',
                X = '9i',
                Y = '-3.5i',
                in_columns = rf_data )

      #plot shaded area for positive values
      vals = rf_data[0]
      time = rf_data[1]
      poly_vals_pos = []
      poly_time_pos = []
      for i in range(0,len(vals)):
         val_here = max(0,np.float(vals[i]))
         poly_time_pos.append(time[i])
         poly_vals_pos.append(val_here)

      poly_vals_pos.append(0.0)
      poly_time_pos.append(time[::-1][0])
      poly_vals_pos.append(0.0)
      poly_time_pos.append(time[0])
      gmt.psxy( R = rf_region,
                J = rf_scale,
                G = 'red',
                B = '0.25::/10:time (s):NE',
                W = 'thin',
                in_columns = (poly_vals_pos,poly_time_pos) )

      #plot shaded area for negative values
      '''
      vals = rf_data[0]
      time = rf_data[1]
      poly_vals_neg = []
      poly_time_neg = []
      for i in range(0,len(vals)):
         val_here = min(0,np.float(vals[i]))
         poly_time_neg.append(time[i])
         poly_vals_neg.append(val_here)

      poly_vals_neg.append(0.0)
      poly_time_neg.append(time[::-1][0])
      poly_vals_neg.append(0.0)
      poly_time_neg.append(time[0])
      gmt.psxy( R = rf_region,
                J = rf_scale,
                G = 'blue',
                B = '0.25::/10:time (s):NE',
                W = 'thin',
                in_columns = (poly_vals_neg,poly_time_neg) )
      '''

   #header_file = open('header_file','w')
   #header_file.write('<< EOF')
   #header_file.close()

   #write header information
   if header != 'none':
      stations_text = header['N_traces'] + ' traces in stack'
      events_text   = header['N_events'] + ' events'
      freq_text     = header['frequency']
      decon_text    = 'deconvolution method : ' + header['decon']

      gmt.pstext( in_rows = [(-96,60,12,0,1,'MC',stations_text)],
                  R = region,
                  J = scale,
                  N = True,
                  X = '-8.5i' )
      gmt.pstext( in_rows = [(-96,59,12,0,1,'MC',events_text)],
                  R = region,
                  J = scale,
                  N = True )
      gmt.pstext( in_rows = [(-96,58,12,0,1,'MC',freq_text)],
                  R = region,
                  J = scale,
                  N = True )
      gmt.pstext( in_rows = [(-96,57,12,0,1,'MC',decon_text)],
                  R = region,
                  J = scale,
                  N = True )

   #save figure
   gmt.save(fname)
Beispiel #15
0
def plotnad(fnad,fout):
    gmt = GMT(config={'BASEMAP_TYPE':'plain','ANOT_FONT_SIZE':8,
                      'LABEL_FONT_SIZE':10,'COLOR_BACKGROUND':'255/255/255',
                      'COLOR_FOREGROUND':'0/0/0','COLOR_NAN':'255/255/255'} )

    grd=gmt.tempfilename('tmp.grd')
    grdcpt=gmt.tempfilename('tmp.cpt')
    xyz=gmt.tempfilename('xyz.txt')
    xyz2=gmt.tempfilename('xyz2.txt')
    rng='1/5/0/40'
    scl='X4.2/-6'
    kosu1,kosu2,x,y,dbest,sbest,dmean,smean = nadplot(fnad,smin=1.5)
    f = open(xyz,'w')
    for ii in range(len(y)):
        for jj in range(len(x)):
            if kosu1[ii,jj] > 0:
                print >>f, x[jj], y[ii], kosu1[ii,jj]
    f.close()
    f = open(xyz2,'w')
    for ii in range(len(y)):
        for jj in range(len(x)):
            if kosu2[ii,jj] > 0:
                print >>f, x[jj], y[ii], '0.5'

    f.close()
    gmt.xyz2grd(xyz,G=grd,R=rng,I='.02/.5',out_discard=True)
    gmt.grd2cpt(grd,C="wysiwyg",Q='o',Z=True,out_filename=grdcpt)
    gmt.psmask(xyz2,R=rng,T=True,J=scl,I='.02/.5',G='lightgray')
    gmt.grdimage(grd,J=scl,R=rng,Q=True,P=True,C=grdcpt)
    gmt.psbasemap(R=rng,J=scl,B='a1f.5:Velocity [km/s]:/a10f5:Depth [km]:WNse')
    gmt.psxy(R=True,J=True,B=True,W='3,red',in_columns=[sbest,dbest])
    gmt.psxy(R=True,J=True,B=True,W='3,white',in_columns=[smean,dmean])
    gmt.psscale(C=grdcpt,D='1.0/1./4c/.4ch',B='a40f10:No. of models:/::')
    gmt.save(fout) 
    os.system('gv '+fout+'&')
    return 1
Beispiel #16
0
from gmtpy import GMT, cm
import numpy as np

# Some data to plot...
x = np.linspace(0,5,101)
y = np.sin(x) + 2.5

gmt = GMT( config={'PAGE_COLOR':'247/247/240'} )

# Get a default layout for plotting.
# This produces a FrameLayout, a layout built of five widgets,
# a 'center' widget, surrounded by four widgets for the margins:
#
#          +---------------------------+
#          |             top           |
#          +---------------------------+
#          |      |            |       |
#          | left |   center   | right |
#          |      |            |       |
#          +---------------------------+
#          |           bottom          |
#          +---------------------------+

layout = gmt.default_layout()

# We will plot in the 'center' widget:
plot_widget = layout.get_widget('center')


# Set width of plot area to 8 cm and height of the 'top' margin 
# to 1 cm. The other values are calculated automatically.
Beispiel #17
0
def plot_vtk_slice(vtk_slice,
                   theta_range=[0, 360],
                   depth_range=[0, 2885],
                   **kwargs):
    #--------------------------------------------------------------------------------
    '''
   This will plot a cross section of a .vtk file.  Open the .vtk file in paraview,
   choose a slice, and select 'File -> export data'.  This will save the data as
   a .csv file, which can be plotted with this function.

   args--------------------------------------------------------------------------
   vtk_slice: the .csv file
   theta_range: the range in degrees you wish to plot. 
                dtype=tuple
                default=[0,360] (whole earth)
   depth_range: the range in depth you wish to plot.
                dtype=tuple
                default=[0,2885] (whole mantle)

   kwargs------------------------------------------------------------------------
   cmap = colormap to use
          dtype=string
          default='BlueWhiiteOrangeRed'

   data_range = max and min values to use in colorbar.
                dtype=tuple
                default=[-1.0,1.0]

   csteps = number of divisions in colorbar
            dtype=int
            default=100

   cmap_direction = forward or reverse colormap
                    dtype=string
                    default='i'

   fname = filename
           dtype=string
           default='slice.pdf'

   rotation = number of degrees to rotate figure
            dtype=float
            default=90.0 (i.e., rotate from lat coor to colat based coor)

   contour = True or False
   '''

    #get kwargs-------------------------------------------------------------------
    cmap_dir = '/geo/home/romaguir/utils/colors/'
    cmap = kwargs.get('cmap', 'BlueWhiteOrangeRed')
    cmap = cmap_dir + cmap
    data_range = kwargs.get('data_range', [-0.25, 0.25])
    csteps = kwargs.get('csteps', 100)
    cmap_direction = kwargs.get('cmap_direction', 'i')
    fname = kwargs.get('fname', 'slice.pdf')
    rotation = kwargs.get('rotation', 90.0)
    contour = kwargs.get('contour', True)

    #read csv slice (output of paraview)------------------------------------------
    f = pandas.read_csv(vtk_slice)
    p1 = f['Points:0']
    p2 = f['Points:1']
    p3 = f['Points:2']
    dvp = f['dVp()']

    #transform to polar, earth coordinates----------------------------------------
    r, t = cart2polar(p1, p3)
    r *= 6371.0
    t = np.degrees(t)

    print min(dvp), max(dvp)

    #setup GMT plot---------------------------------------------------------------
    gmt = GMT(config={'BASEMAP_TYPE': 'fancy', 'HEADER_FONT_SIZE': '14'})
    region = '{}/{}/{}/{}'.format(theta_range[0], theta_range[1],
                                  6371.0 - depth_range[1],
                                  6371.0 - depth_range[0])
    surf_region = '{}/{}/{}/{}'.format(theta_range[0] - 2, theta_range[1] + 2,
                                       6371.0 - depth_range[1],
                                       6500.0 - depth_range[0])
    scale = 'P6i'  #Polar, 8 inch radius
    cptfile = gmt.tempfilename()
    grdfile = gmt.tempfilename()

    #gmt.makecpt(C=cmap,T='{}/{}/{}'.format(data_range[0],data_range[1],csteps),Z=False,out_filename=cptfile,D=cmap_direction)
    gmt.makecpt(C=cmap,
                T='-0.25/0.25/0.025',
                A=100,
                out_filename=cptfile,
                D=True)

    gmt.surface(in_columns=[t + rotation, r, dvp],
                G=grdfile,
                I='0.5/25',
                T=0.0,
                R=surf_region,
                out_discard=True)
    '''
   #plot the data----------------------------------------------------------------
   gmt.psxy( R=region,
             J=scale,
             #B='a15f15:"":/200f200:""::."":WSne',
             B='a300f300',
             S='s0.20',
             #G='blue',
             C=cptfile,
             in_columns=[t+rotation,r,dvp] )
   '''
    #plot the data----------------------------------------------------------------
    gmt.grdimage(grdfile, R=region, J=scale, B='a300f300', C=cptfile, E='i5')

    #contour the data-------------------------------------------------------------
    if contour == True:
        gmt.grdcontour(grdfile, R=region, J=scale, C=cptfile, W='1')

    #plot 660---------------------------------------------------------------------
    d660 = np.loadtxt('/geo/home/romaguir/utils/660_polar.dat')
    print d660
    gmt.psxy(R=region, J=scale, W='1', in_rows=[d660])

    gmt.save(fname)
Beispiel #18
0
def plot_rep(repfile, paramfile, wtype, pixfile, show=True, misfit=0.1,
             minmax=True):
    """
    Plot 1D velocity profile.
    """
    # ## read in models from dinver-output
    os.system('gpdcreport ' + repfile + ' >tmp.mdl')
    models, data, nd, ne, nrow, nlayer = get_models('tmp.mdl')
    os.remove('tmp.mdl')
    if misfit == 'all':
        misfit = data.max()
    elif misfit <= data.min():
        misfit = median(data)
    # ## calculate density
    sreso = 0.05  # horizontal resolution
    dreso = .5  # vertical resolution
    grid1, grid2, x, y, smean, dmean = dplot(models, data, nd, ne, dreso=dreso,
                                             sreso=sreso, mf=misfit, nlayer=nlayer, dmax=120)
    # ## write output into temporary files that can be plotted by gmt
    xyz = tempfile.mktemp()
    xyz2 = tempfile.mktemp()
    grd = tempfile.mktemp()
    grdcpt = tempfile.mktemp()
    fout = pixfile
    f = open(xyz, 'w')
    for ii in range(len(y)):
        for jj in range(len(x)):
            if grid1[ii, jj] > 0.0:
                print >> f, x[jj], -y[ii], grid1[ii, jj]
    f.close()
    f = open(xyz2, 'w')
    for ii in range(len(y)):
        for jj in range(len(x)):
            if grid2[ii, jj] > 0:
                print >> f, x[jj], -y[ii], '0.5'
    f.close()
    lat, lon = dissect_fname(repfile)
    if wtype == 'love':
        wt = 'L'
    if wtype == 'rayleigh':
        wt = 'R'
    # print repfile, lat, lon
    # ## gmt plot
    rng = '1/5/-120/0'
    step = '%f/%f' % (sreso, dreso)
    anot = int(grid1.max() / 1000.) * 1000 / 2.
    tick = anot / 2
    gmt = GMT(config={'ANOT_FONT_SIZE':8, 'LABEL_FONT_SIZE':10,
                      'ANNOT_OFFSET_SECONDARY':'0.1c',
                      'ANNOT_OFFSET_PRIMARY':'0.1c',
                      'LABEL_OFFSET':'0.1c',
                      'FRAME_PEN':'.5p'})
    widgets, layout = make_widget()
    if 1:
        widget = widgets[2]
        gmt.xyz2grd(xyz, G=grd, R=rng, I='%f/%f' % (sreso, dreso), out_discard=True)
        gmt.grd2cpt(grd, L='0/%d' % 3000, C="wysiwyg", D=True, Z=True, out_filename=grdcpt)
        gmt.psbasemap(R=True, B='a1f.5:S-velocity [km/s]:/a10f5:Depth [km]:WnSe', *widget.XYJ())
        # gmt.psmask(xyz2, R=True, T=True, I='%f/%f' % (sreso, dreso), G='lightgray', *widget.XYJ())
        gmt.grdimage(grd, R=True, Q=True, C=grdcpt, *widget.XYJ())
        gmt.psxy(R=True, B=True, W='3,black', in_columns=[smean, -dmean], *widget.XYJ())
        bmdl = get_best_model(repfile, dreso, dmax=120., dmin=0.)
        gmt.psxy(R=True, B=True, W='3,black,-', in_rows=bmdl, *widget.XYJ())
        gmt.psscale(widget.XYJ()[0], widget.XYJ()[1], C=grdcpt, D='1.7c/1.5c/2.5c/.4ch', B='a%df%d10:No. of models:/::' % (1000, 500))
        txtstr = "1.2 -7. 8 0 1 LT lat = %3.2f" % lat
        gmt.pstext(R=rng, G='0/0/0', N=True, in_string=txtstr, *widget.XYJ())
        txtstr = "1.2 -12. 8 0 1 LT lon = %3.2f" % lon
        gmt.pstext(R=True, G='0/0/0', N=True, in_string=txtstr, *widget.XYJ())
        # plot the minimum and maximum model that is allowed
        # by the parameterisation
        if minmax:
            mdl_min, mdl_max = minmax_mdl(paramfile)
            gmt.psxy(R=True, B=True, W='3,red,-', in_rows=mdl_min, *widget.XYJ())
            gmt.psxy(R=True, B=True, W='3,red,-', in_rows=mdl_max, *widget.XYJ())
    if 1:
        p, v, e = get_disp(repfile, wtype='phase')
        plot_disp(gmt, repfile, widgets[1], p, v, e, 'phase', ptype='p', wtype=wt, mode=0, misfit=misfit)
        p, v, e = get_disp(repfile, wtype='group')
        plot_disp(gmt, repfile, widgets[0], p, v, e, 'group', ptype='g', wtype=wt, mode=0, misfit=misfit)
    if 0:
        p, v, e = get_disp(repfile, wtype='grouponly')
        plot_disp(gmt, repfile, widgets[0], p, v, e, 'group', ptype='g', wtype=wt, mode=0, misfit=misfit)
    if 0:
        plot_hist(gmt, widgets, models, nd, ne)
    gmt.save(fout)
    meanfout = fout.replace('.eps', '_mean.txt')
    savetxt(meanfout, vstack((-dmean, smean)).T)
    if show:
        os.system('gv %(fout)s&' % vars())
"""

from gmtpy import GMT
runlat = arange(24.,89.)
runlon = arange(-156.,-43.)
xyfile = 'surface_wave_coord.txt'
xyzfile = 'lith5.0_moho.txt'
f = open(xyfile,'w')
for lat in runlat:
    for lon in runlon:
        print >>f, lon, lat
f.close()

### Plot original
na04_moho = loadtxt('./LITH5.0/NA04_moho.xyf')
gmt = GMT(config={'PAGE_ORIENTATION':'landscape'})
rng = '-145/-50/35/80'
scl = 'L-100/60/45/65/12c'
anot = 'a20f10/a25f5WSne'
fout = 'na04_moho.eps'
tmpgrd = gmt.tempfilename('moho_temp.grd')
mohogrd = gmt.tempfilename('moho.grd')
mohocpt = gmt.tempfilename('moho.cpt')
gmt.xyz2grd(G=mohogrd,I='%f/%f'%(0.25,0.25),R=rng,out_discard=True,in_rows=na04_moho)
gmt.grd2cpt(mohogrd,E=50,L='10/60',C="seis",out_filename=mohocpt)
gmt.grdtrack(xyfile,G=mohogrd,R=True,out_filename=xyzfile)
gmt.grdimage(mohogrd,R=True,J=scl,C=mohocpt)
gmt.pscoast(R=True,J=scl,B=anot,D='i',W='thinnest' )


### Plot resampled 
Beispiel #20
0
from gmtpy import GMT

gmt = GMT(config={'PAGE_COLOR': '247/247/240'})
gmt.psbasemap(R=(0, 5, 0, 5),
              J='X%gi/%gi' % (5, 3),
              B='%g:Time:/%g:Amplitude:SWne' % (1, 1))

# Make four different datasets

# (1) a nested list, with the first dim corresponding to columns
data_as_columns = [[0, 1, 2, 3, 4, 5], [0, 1, 0.5, 1, 0.5, 1]]

# (2) a nested list, with the first dim corresponding to rows
data_as_rows = [[0, 1], [1, 2], [2, 3], [3, 3.5], [4, 3], [5, 2]]

# (3) a string containing an ascii table
data_as_string = '''0 5
1 4
2 3.5
3 4
4 4.5
5 5'''

# (4) write ascii table in a temporary file...

# Get a filename in the private tempdir of the GMT instance.
# Files in that directory get deleted automatically.
filename = gmt.tempfilename('table.txt')

f = open(filename, 'w')
f.write('0 3\n1 3\n5 1.2\n')
Beispiel #21
0
     elon = eval(conf.get('ns-profiles','elon'))
     anot = eval(conf.get('ns-profiles','anot'))
 elif direction == 'we':
     slat = eval(conf.get('we-profiles','slat'))
     slon = eval(conf.get('we-profiles','slon'))
     elat = eval(conf.get('we-profiles','elat'))
     elon = eval(conf.get('we-profiles','elon'))
     anot = eval(conf.get('we-profiles','anot'))
 else:
     print "'direction' has to be either 'ns' or 'we'"
     sys.exit(1)
     
 #maxdist = find_scale(slat,slon,elat,elon)
 gmt = GMT(config={'ANOT_FONT_SIZE':14,'LABEL_FONT_SIZE':14,
                   'ANNOT_OFFSET_SECONDARY':'0.1c',
                   'ANNOT_OFFSET_PRIMARY':'0.1c',
                   'LABEL_OFFSET':'0.1c',
                   'FRAME_PEN':'.5p'})
 #scly = (28.-3.-3.*len(slat))/len(slat)
 cptws = gmt.tempfilename('ws.cpt')
 gmt.makecpt(C='seis',D=True,T='3.0/4.5/0.05',out_filename=cptws)
 gmt.psscale(C=cptws,D='8c/.5c/10c/.2ch',B='a%ff.1:Vs:'%(.5))
 cnt = 1
 for _slat,_slon,_elat,_elon in zip(slat,slon,elat,elon):
     print "plotting profile %d"%cnt
     ndist, nd, values = plot_2d(field,_slat,_slon,_elat,_elon,pdepth,new=True)
     lbl1,lbl2 = anot[cnt-1]
     fstr = cStringIO.StringIO()
     for dist,depth,vs in zip(ndist,nd,values):
         fstr.write("%f %f %f\n"%(dist,depth,vs))
     sclx = 18.*ndist.max()/xscale
Beispiel #22
0
from gmtpy import GMT

gmt = GMT(config={'BASEMAP_TYPE': 'fancy'})

gmt.pscoast(
    R='5/15/52/58',  # region
    J='B10/55/55/60/10c',  # projection
    B='4g4',  # grid
    D='f',  # resolution
    S=(114, 159, 207),  # wet fill color 
    G=(233, 185, 110),  # dry fill color
    W='thinnest')  # shoreline pen

gmt.save('example1.pdf')
gmt.save('example1.eps')
Beispiel #23
0
from gmtpy import GMT

gmt = GMT( config={'BASEMAP_TYPE':'fancy'})

gmt.pscoast( R='5/15/52/58',       # region
             J='B10/55/55/60/10c', # projection
             B='4g4',              # grid
             D='f',                # resolution
             S=(114,159,207),      # wet fill color 
             G=(233,185,110),      # dry fill color
             W='thinnest' )        # shoreline pen
             
gmt.save('example1.pdf')
gmt.save('example1.eps')
Beispiel #24
0
we_anot = eval(conf.get("we-profiles", "anot"))
foutmap = conf.get("map", "fout")
invres = eval(conf.get("map", "invres"))

slat = ns_slat + we_slat
slon = ns_slon + we_slon
elat = ns_elat + we_elat
elon = ns_elon + we_elon
anot = ns_anot + we_anot
# plot cross-section on map
gmt = GMT(
    config={
        "ANOT_FONT_SIZE": 14,
        "LABEL_FONT_SIZE": 14,
        "ANNOT_OFFSET_SECONDARY": "0.1c",
        "ANNOT_OFFSET_PRIMARY": "0.1c",
        "LABEL_OFFSET": "0.1c",
        "FRAME_PEN": ".5p",
        "PLOT_DEGREE_FORMAT": "-D",
    }
)
rng = "-145/-50/41/85"
scl = "L-97.5/63/41/85/15c"
markers = "markers.xyp"
gmt.psbasemap(R=rng, J=scl, B="a15f5WSne", Y="2c", X="2c")
gmt.pscoast("-N1", R=True, J=True, D="i", W="0.5p,black", N="2")
cnt = 0
for _slon, _slat, _elon, _elat in zip(slon, slat, elon, elat):
    gmt.project(C="%f/%f" % (_slon, _slat), E="%f/%f" % (_elon, _elat), G=100, Q=True, out_filename=markers)
    gmt.psxy(R=True, J=True, W="2p,red,", in_rows=[[_slon, _slat], [_elon, _elat]])
    # gmt.psxy(markers,R=True,J=True,S='y0.1c',W='1p,blue')