Exemplo n.º 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))
Exemplo n.º 2
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'
Exemplo n.º 3
0
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')
Exemplo n.º 4
0
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')
Exemplo n.º 5
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')
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
0
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')
    gmt.psxy(markers, R=True, J=True, S="s0.1c", W="1p,blue")
    lbl1, lbl2 = anot[cnt]
    txtstr1 = """%f %f 10 0 1 RB %s""" % (_slon, _slat, lbl1)
    txtstr2 = """%f %f 10 0 1 LB %s""" % (_elon, _elat, lbl2)
    gmt.pstext(R=True, J=True, W="white", G="blue", N=True, in_string=txtstr1)
    gmt.pstext(R=True, J=True, W="white", G="blue", N=True, in_string=txtstr2)
    cnt += 1
for lon, lat in invres:
    gmt.psxy(R=True, J=True, S="t0.5c", G="red", in_rows=[[lon, lat]])
Exemplo n.º 9
0
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 
na04_moho = loadtxt(xyzfile)
gmt.xyz2grd(G=mohogrd,I='%f/%f'%(1.,1.),R=rng,out_discard=True,in_rows=na04_moho)
gmt.grdimage(mohogrd,R=True,J=scl,C=mohocpt,X='13c')
gmt.pscoast(R=True,J=scl,B=anot,D='i',W='thinnest' )
gmt.psscale(C=mohocpt,V=True,D='0c/-.7c/6c/.2ch',B='10::/:km:')
gmt.save(fout)
os.system('gv %s&'%fout)
Exemplo n.º 10
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')