Ejemplo n.º 1
0
def station_plot( slat, slon, lat, lon, rnames, station_color, station_size, source,
                 maxdist, filename, conf_overrides, zexpand=1.0, nsets=1, symbols=('klflag','krflag')):
    conf = dict(**config.station_plot_config)
    conf.update( conf_overrides )
    
    width = conf.pop('width')
    height = conf.pop('height')
    margins = conf.pop('margins')
    
    gmt = gmtpy.GMT( config={ 'LABEL_FONT_SIZE': '12p',
                               'PLOT_DEGREE_FORMAT':'dddF',
                               'PAPER_MEDIA':'Custom_%ix%i' % (width,height),
                               'GRID_PEN_PRIMARY': 'thinnest/0/0/0' } )
    
    layout = gmt.default_layout()
    layout.set_fixed_margins(*margins)
    widget = layout.get_widget()
    widget['J'] = '-JE%g/%g/%g' % (slon, slat, min(maxdist,180.)) + '/%(width)gp'
    aspect = gmtpy.aspect_for_projection( R='g', *widget.J() )
    widget.set_aspect(aspect)
    
    if maxdist > 5.:
        draw_topo(gmt, JXY=widget.JXY(), region='g', resolution=2, coastline_resolution='l', rivers=[], conf=conf, no_clipping=True)

    #gmt.pscoast( R='g', B=True, D='c', A=10000, S=(114,159,207), G=(233,185,110), W='thinnest', *widget.JXY())
    
    # shift source location slightly, so that projection does not crash...
    sdelta = maxdist*0.0001
    
    gmt.psbasemap( R='g', B=True, *widget.JXY() )
    if source and 'strike' in source.keys() and 'dip' in source.keys() and 'slip-rake' in source.keys():
        gmt.psmeca( in_rows=[[float(slon+sdelta), float(slat+sdelta), 1., source['strike'], source['dip'], source['slip-rake'], 6., 0.,0., '' ]],
                        R='g', S='a0.3', *widget.JXY())
    else:
        gmt.psxy( in_rows=[(float(slon+sdelta), float(slat+sdelta))], S='c20p', W='2p/0',  R='g', *widget.JXY())
    
    mi = num.nanmin(station_color)
    ma = num.nanmax(station_color)
    
    colorscale = gmtpy.AutoScaler()
    colorscale.mode = 'symmetric'

    fn_cpt = gmt.tempfilename()
    gmt.makecpt( C='polar', T=colorscale.make_scale((mi,ma)), Z=True, out_filename=fn_cpt )
    
    gmt.psxy( in_columns=(lon[::nsets],lat[::nsets], station_color[::nsets], num.sqrt(station_size[::nsets])/1.5 ),
               R='g', C=fn_cpt, S=symbols[0], W='1p/black', G='white', N=True, *widget.JXY())
    if nsets == 2:
        gmt.psxy( in_columns=(lon[1::nsets],lat[1::nsets], station_color[1::nsets], num.sqrt(station_size[1::nsets])/1.5 ), 
                   R='g', C=fn_cpt, S=symbols[1], W='1p/black', G='white', N=True, *widget.JXY())
    
    nr = len(lat)
    size = [7]*nr
    angle = [0]*nr
    fontno = [1]*nr
    justify = ['MC']*nr
    gmt.pstext( in_columns=(lon,lat,size,angle,fontno,justify,rnames), R='g', D=(0.,-0.1), N=True, *widget.JXY())    
    gmt.save( filename )
Ejemplo n.º 2
0
    def test_basic2(self):
        for version in gmtpy.all_installed_gmt_versions():
            if version.startswith('5'):
                gmt = gmtpy.GMT(
                    version=version,
                    config={'MAP_FRAME_TYPE': 'fancy'},
                    eps_mode=True)
            else:
                gmt = gmtpy.GMT(
                    version=version,
                    config={'BASEMAP_TYPE': 'fancy'})

            layout = gmt.default_layout()
            widget = layout.get_widget()

            xax = gmtpy.Ax(label='Lon', mode='min-max')
            yax = gmtpy.Ax(label='Lat', mode='min-max')
            scaler = gmtpy.ScaleGuru([([5, 15], [52, 58])], axes=(xax, yax))

            par = scaler.get_params()
            lon0 = (par['xmin'] + par['xmax'])/2.
            lat0 = (par['ymin'] + par['ymax'])/2.
            sll = '%g/%g' % (lon0, lat0)
            widget['J'] = '-JM' + sll + '/%(width)gp'

            widget['J'] = '-JM' + sll + '/%(width)gp'
            scaler['B'] = \
                '-B%(xinc)gg%(xinc)g:%(xlabel)s:' \
                '/%(yinc)gg%(yinc)g:%(ylabel)s:WSen'

            aspect = gmtpy.aspect_for_projection(
                version, *(widget.J() + scaler.R()))

            aspect = 1.045
            widget.set_aspect(aspect)

            gmt.pscoast(D='h', W='1p,red', *(widget.JXY() + scaler.R()))
            gmt.psbasemap(*(widget.JXY() + scaler.BR()))

            fname = 'gmtpy_test_basic2.png'
            fpath = self.fpath(fname)
            gmt.save(fpath, resolution=75, bbox=layout.bbox())
Ejemplo n.º 3
0
def plot_erroneous_ne_to_latlon():
    import gmtpy
    import random
    import subprocess
    import time

    while True:
        w, h = 20, 15

        gsize = random.uniform(0., 1.) * 4. * 10.**random.uniform(4., 7.)
        north_grid, east_grid = num.meshgrid(
            num.linspace(-gsize / 2., gsize / 2., 11),
            num.linspace(-gsize / 2., gsize / 2., 11))

        north_grid = north_grid.flatten()
        east_grid = east_grid.flatten()

        lat_delta = gsize / earthradius * r2d * 2.
        lon = random.uniform(-180., 180.)
        lat = random.uniform(-90., 90.)

        print(gsize / 1000.)

        lat_grid, lon_grid = orthodrome.ne_to_latlon(lat, lon, north_grid,
                                                     east_grid)
        lat_grid_alt, lon_grid_alt = \
            orthodrome.ne_to_latlon_alternative_method(
                lat, lon, north_grid, east_grid)

        maxerrlat = num.max(num.abs(lat_grid - lat_grid_alt))
        maxerrlon = num.max(num.abs(lon_grid - lon_grid_alt))
        eps = 1.0e-8
        if maxerrlon > eps or maxerrlat > eps:
            print(lat, lon, maxerrlat, maxerrlon)

            gmt = gmtpy.GMT(
                config={
                    'PLOT_DEGREE_FORMAT': 'ddd.xxxF',
                    'PAPER_MEDIA': 'Custom_%ix%i' %
                    (w * gmtpy.cm, h * gmtpy.cm),
                    'GRID_PEN_PRIMARY': 'thinnest/0/50/0'
                })

            south = max(-85., lat - 0.5 * lat_delta)
            north = min(85., lat + 0.5 * lat_delta)

            lon_delta = lat_delta / math.cos(lat * d2r)

            delta = lat_delta / 360. * earthradius * 2. * math.pi
            scale_km = gmtpy.nice_value(delta / 10.) / 1000.

            west = lon - 0.5 * lon_delta
            east = lon + 0.5 * lon_delta

            x, y = (west, east), (south, north)
            xax = gmtpy.Ax(mode='min-max', approx_ticks=4.)
            yax = gmtpy.Ax(mode='min-max', approx_ticks=4.)
            scaler = gmtpy.ScaleGuru(data_tuples=[(x, y)], axes=(xax, yax))
            scaler['R'] = '-Rg'
            layout = gmt.default_layout()
            mw = 2.5 * gmtpy.cm
            layout.set_fixed_margins(mw, mw, mw / gmtpy.golden_ratio,
                                     mw / gmtpy.golden_ratio)
            widget = layout.get_widget()
            # widget['J'] =  ('-JT%g/%g'  % (lon, lat)) + '/%(width)gp'
            widget['J'] = (
                '-JE%g/%g/%g' % (lon, lat, min(lat_delta/2., 180.)))\
                + '/%(width)gp'
            aspect = gmtpy.aspect_for_projection(*(widget.J() + scaler.R()))
            widget.set_aspect(aspect)

            gmt.psbasemap(B='5g5',
                          L=('x%gp/%gp/%g/%g/%gk' %
                             (widget.width() / 2., widget.height() / 7., lon,
                              lat, scale_km)),
                          *(widget.JXY() + scaler.R()))

            gmt.psxy(in_columns=(lon_grid, lat_grid),
                     S='x10p',
                     W='1p/200/0/0',
                     *(widget.JXY() + scaler.R()))
            gmt.psxy(in_columns=(lon_grid_alt, lat_grid_alt),
                     S='c10p',
                     W='1p/0/0/200',
                     *(widget.JXY() + scaler.R()))

            gmt.save('orthodrome.pdf')
            subprocess.call(['xpdf', '-remote', 'ortho', '-reload'])
            time.sleep(2)
        else:
            print('ok', gsize, lat, lon)
Ejemplo n.º 4
0
def plot_erroneous_ne_to_latlon():
    import sys
    import gmtpy
    import random
    import subprocess
    import time
    
    while True:
        w,h = 20,15
    
        km = 1000.
        gsize = random.uniform(0.,1.)*4.*10.**random.uniform(4.,7.)
        north_grid, east_grid = num.meshgrid(num.linspace(-gsize/2.,gsize/2.,11) ,
                                             num.linspace(-gsize/2.,gsize/2.,11) )
        
        north_grid = north_grid.flatten()
        east_grid = east_grid.flatten()
        
        lat_delta = gsize/config.earthradius*r2d*2.
        lon = random.uniform(-180.,180.)
        lat = random.uniform(-90.,90.)
        
        print gsize/1000.
        
        lat_grid, lon_grid = ne_to_latlon(lat, lon, north_grid, east_grid)
        lat_grid_alt, lon_grid_alt = ne_to_latlon_alternative_method(lat, lon, north_grid, east_grid)
    
    
        maxerrlat = num.max(num.abs(lat_grid-lat_grid_alt))
        maxerrlon = num.max(num.abs(lon_grid-lon_grid_alt))
        eps = 1.0e-8
        if maxerrlon > eps or maxerrlat > eps:
            print lat, lon, maxerrlat, maxerrlon
        
            gmt = gmtpy.GMT( config={ 'PLOT_DEGREE_FORMAT':'ddd.xxxF',
                                    'PAPER_MEDIA':'Custom_%ix%i' % (w*gmtpy.cm,h*gmtpy.cm),
                                    'GRID_PEN_PRIMARY': 'thinnest/0/50/0' } )
        
            south = max(-85., lat - 0.5*lat_delta)
            north = min(85., lat + 0.5*lat_delta)
                
            lon_delta = lat_delta/math.cos(lat*d2r)
            
            delta = lat_delta/360.*config.earthradius*2.*math.pi
            scale_km = gmtpy.nice_value(delta/10.)/1000.
            
            west = lon - 0.5*lon_delta
            east = lon + 0.5*lon_delta
            
            x,y = (west, east), (south,north)
            xax = gmtpy.Ax(mode='min-max', approx_ticks=4.)
            yax = gmtpy.Ax(mode='min-max', approx_ticks=4.)
            scaler = gmtpy.ScaleGuru( data_tuples=[(x,y)], axes=(xax,yax))    
            scaler['R'] = '-Rg'
            layout = gmt.default_layout()
            mw = 2.5*gmtpy.cm
            layout.set_fixed_margins(mw,mw,mw/gmtpy.golden_ratio,mw/gmtpy.golden_ratio)
            widget = layout.get_widget()
            # widget['J'] =  ('-JT%g/%g'  % (lon, lat)) + '/%(width)gp'
            widget['J'] =  ('-JE%g/%g/%g'  % (lon, lat, min(lat_delta/2.,180.))) + '/%(width)gp'
            aspect = gmtpy.aspect_for_projection( *(widget.J() + scaler.R()) )
            widget.set_aspect(aspect)
            
            if lat > 0:
                axes_layout = 'WSen'
            else:
                axes_layout = 'WseN'
        
            gmt.psbasemap( #B=('%(xinc)gg%(xinc)g:%(xlabel)s:/%(yinc)gg%(yinc)g:%(ylabel)s:' % scaler.get_params())+axes_layout,
                           B='5g5',
                        L=('x%gp/%gp/%g/%g/%gk' % (widget.width()/2., widget.height()/7.,lon,lat,scale_km) ),
                        *(widget.JXY()+scaler.R()) )
            
            gmt.psxy( in_columns=(lon_grid,lat_grid), S='x10p', W='1p/200/0/0', *(widget.JXY()+scaler.R()) )
            gmt.psxy( in_columns=(lon_grid_alt,lat_grid_alt), S='c10p', W='1p/0/0/200', *(widget.JXY()+scaler.R()) )
            
            gmt.save('orthodrome.pdf')
            subprocess.call( [ 'xpdf', '-remote', 'ortho', '-reload' ] )
            time.sleep(2)
        else:
            print 'ok', gsize, lat, lon
Ejemplo n.º 5
0
            west = lon - 0.5 * lon_delta
            east = lon + 0.5 * lon_delta

            x, y = (west, east), (south, north)
            xax = gmtpy.Ax(mode="min-max", approx_ticks=4.0)
            yax = gmtpy.Ax(mode="min-max", approx_ticks=4.0)
            scaler = gmtpy.ScaleGuru(data_tuples=[(x, y)], axes=(xax, yax))
            scaler["R"] = "-Rg"
            layout = gmt.default_layout()
            mw = 2.5 * gmtpy.cm
            layout.set_fixed_margins(mw, mw, mw / gmtpy.golden_ratio, mw / gmtpy.golden_ratio)
            widget = layout.get_widget()
            # widget['J'] =  ('-JT%g/%g'  % (lon, lat)) + '/%(width)gp'
            widget["J"] = ("-JE%g/%g/%g" % (lon, lat, min(lat_delta / 2.0, 180.0))) + "/%(width)gp"
            aspect = gmtpy.aspect_for_projection(*(widget.J() + scaler.R()))
            widget.set_aspect(aspect)

            if lat > 0:
                axes_layout = "WSen"
            else:
                axes_layout = "WseN"

            gmt.psbasemap(  # B=('%(xinc)gg%(xinc)g:%(xlabel)s:/%(yinc)gg%(yinc)g:%(ylabel)s:' % scaler.get_params())+axes_layout,
                B="5g5",
                L=("x%gp/%gp/%g/%g/%gk" % (widget.width() / 2.0, widget.height() / 7.0, lon, lat, scale_km)),
                *(widget.JXY() + scaler.R())
            )

            gmt.psxy(in_columns=(lon_grid, lat_grid), S="x10p", W="1p/200/0/0", *(widget.JXY() + scaler.R()))
            gmt.psxy(in_columns=(lon_grid_alt, lat_grid_alt), S="c10p", W="1p/0/0/200", *(widget.JXY() + scaler.R()))
Ejemplo n.º 6
0
def location_map( filename, lat, lon, lat_delta, conf_overrides, source=None, 
                source_model_infos=None, receivers=None, 
                with_palette=False, shakemap_data=None, shakemap_range=None, shakemap_cpt=None, show_topo=True):

    conf = dict(**config.location_map_config)
    conf.update( conf_overrides )
    
    w = conf.pop('width')
    h = conf.pop('height')
    margins = conf.pop('margins')
        
    d2r = math.pi/180.0
    if source:
        slat, slon = lat, lon
        lat, lon = orthodrome.ne_to_latlon(lat,lon, source['north-shift'], source['east-shift'])
    
    south = lat - 0.5*lat_delta
    north = lat + 0.5*lat_delta
    if lat_delta > 20. or south < -80. or north > 80.:
        resolution = 5
        coastline_resolution = 'i'
        rivers=[]
    else:
        resolution = 1
        coastline_resolution = 'f'
        rivers = ['-Ir',]
        
    lon_delta = lat_delta/math.cos(lat*d2r)
    
    delta = lat_delta/360.*config.earthradius*2.*math.pi
    scale_km = gmtpy.nice_value(delta/10.)/1000.
    
    west = lon - 0.5*lon_delta
    east = lon + 0.5*lon_delta
    
    x,y,z = (west, east), (south,north), (-6000.,4500.)
    xax = gmtpy.Ax(mode='min-max', approx_ticks=4.)
    yax = gmtpy.Ax(mode='min-max', approx_ticks=4.)
    zax = gmtpy.Ax(mode='min-max', inc=1000., label='Height', scaled_unit='km', scaled_unit_factor=0.001)
    scaler = gmtpy.ScaleGuru( data_tuples=[(x,y,z)], axes=(xax,yax,zax))
    
    curcfg = {'TICK_PEN': '1.25p',
                                'TICK_LENGTH': '0.2c',
                                'ANNOT_FONT_PRIMARY': '1',
                                'ANNOT_FONT_SIZE_PRIMARY': '14p',
                                'LABEL_FONT': '1',
                                'LABEL_FONT_SIZE': '14p',
                                'CHAR_ENCODING': 'ISOLatin1+',
                                'D_FORMAT': '%.1f',
                                'PLOT_DEGREE_FORMAT':'DF',
                                'PAPER_MEDIA':'Custom_%ix%i' % (w,h),
                                'GRID_PEN_PRIMARY': 'thinnest/0/0/0' }
    
    #degree_format = 'dddF'
    #if scaler.get_params()['xinc'] < 1. or scaler.get_params()['yinc'] < 1.:
    #    degree_format = 'ddd:mmF'
        
    gmt = gmtpy.GMT( config=curcfg )
    
    if with_palette:
        layout = gmt.default_layout(with_palette=True)
        layout.set_fixed_margins(*margins)
        widget = layout.get_widget().get_widget(0,0)
        palette_layout = gmtpy.FrameLayout()
        palette_layout.set_policy( *layout.get_widget().get_widget(2,0).get_policy() )
        layout.get_widget().set_widget(2,0,palette_layout)
        inset = h-margins[2]-margins[3]
        palette_layout.set_fixed_margins(0.,0.,inset/6., inset/6.)
        palette_widget = palette_layout.get_widget()
    else:
        layout = gmt.default_layout()
        layout.set_fixed_margins(*margins)
        widget = layout.get_widget()
        
    widget['J'] =  ('-JT%g/%g'  % (lon, lat)) + '/%(width)gp'
    aspect = gmtpy.aspect_for_projection( *(widget.J() + scaler.R()) )
    widget.set_aspect(aspect)
    
    if show_topo:
        cptfile = draw_topo(gmt, widget.JXY(), (west,east,south,north), resolution, coastline_resolution, rivers, conf)
    
    zscaler = scaler
    if shakemap_data is not None:
        cptfile, zscaler = draw_shakemap( gmt, widget, scaler, (xax,yax,zax), 
                shakemap_range, shakemap_cpt, *shakemap_data)
        draw_coastlines(gmt, widget.JXY(), (west,east,south,north),  coastline_resolution, rivers)
    
    if source_model_infos and source:
        try:
            draw_rupture(gmt, widget, source_model_infos, axes=(xax,yax,zax), view='from-top', source_loc=(slat,slon), outer_scaler=scaler, with_centroids=False)
        except NoOutlineFound:
            gmt.psxy( in_rows=[[lon,lat]], S='c20p', W='2p,0/0/0',  *(widget.JXY()+scaler.R()))
    
    else:
        if source and 'strike' in source.keys() and 'dip' in source.keys() and 'slip-rake' in source.keys():
            gmt.psmeca( in_rows=[[lon, lat, 1., source['strike'], source['dip'], source['slip-rake'], 6., 0.,0., '' ]],
                     S='a0.3', *(widget.JXY()+scaler.R()) )
        else:
            gmt.psxy( in_rows=[[lon,lat]], S='c20p', W='2p,0/0/0',  *(widget.JXY()+scaler.R()))
    
    if receivers:
        rlats, rlons, rnames = receivers
        gmt.psxy( in_columns=(rlons, rlats), S='t12p', W='1p,black', G='red', *(widget.JXY()+scaler.R()))
        
        nr = len(rnames)
        size = [7]*nr
        angle = [0]*nr
        fontno = [1]*nr
        justify = ['MC']*nr
        gmt.pstext( in_columns=(rlons,rlats,size,angle,fontno,justify,rnames), D=(0.,-0.1), *(widget.JXY()+scaler.R()))
        
    if lat > 0:
        axes_layout = 'WSen'
    else:
        axes_layout = 'WseN'
        
    gmt.psbasemap( B=('%(xinc)gg%(xinc)g:%(xlabel)s:/%(yinc)gg%(yinc)g:%(ylabel)s:' % scaler.get_params())+axes_layout,
                   L=('x%gp/%gp/%g/%g/%gk' % (widget.width()/2., widget.height()/7.,lon,lat,scale_km) ),
                   *(widget.JXY()+scaler.R()) )
                   
    if with_palette and (show_topo or shakemap_data is not None):
        gmtpy.nice_palette(gmt, palette_widget, zscaler, cptfile, innerticks=False, zlabeloffset=1.5*gmtpy.cm)
    gmt.save(filename)
Ejemplo n.º 7
0
            x, y = (west, east), (south, north)
            xax = gmtpy.Ax(mode='min-max', approx_ticks=4.)
            yax = gmtpy.Ax(mode='min-max', approx_ticks=4.)
            scaler = gmtpy.ScaleGuru(data_tuples=[(x, y)], axes=(xax, yax))
            scaler['R'] = '-Rg'
            layout = gmt.default_layout()
            mw = 2.5 * gmtpy.cm
            layout.set_fixed_margins(mw, mw, mw / gmtpy.golden_ratio,
                                     mw / gmtpy.golden_ratio)
            widget = layout.get_widget()
            # widget['J'] =  ('-JT%g/%g'  % (lon, lat)) + '/%(width)gp'
            widget['J'] = (
                '-JE%g/%g/%g' %
                (lon, lat, min(lat_delta / 2., 180.))) + '/%(width)gp'
            aspect = gmtpy.aspect_for_projection(*(widget.J() + scaler.R()))
            widget.set_aspect(aspect)

            if lat > 0:
                axes_layout = 'WSen'
            else:
                axes_layout = 'WseN'

            gmt.psbasemap(  #B=('%(xinc)gg%(xinc)g:%(xlabel)s:/%(yinc)gg%(yinc)g:%(ylabel)s:' % scaler.get_params())+axes_layout,
                B='5g5',
                L=('x%gp/%gp/%g/%g/%gk' %
                   (widget.width() / 2., widget.height() / 7., lon, lat,
                    scale_km)),
                *(widget.JXY() + scaler.R()))

            gmt.psxy(in_columns=(lon_grid, lat_grid),
Ejemplo n.º 8
0
def plot_erroneous_ne_to_latlon():
    import sys
    import gmtpy
    import random
    import subprocess
    import time

    while True:
        w, h = 20, 15

        km = 1000.0
        gsize = random.uniform(0.0, 1.0) * 4.0 * 10.0 ** random.uniform(4.0, 7.0)
        north_grid, east_grid = num.meshgrid(
            num.linspace(-gsize / 2.0, gsize / 2.0, 11), num.linspace(-gsize / 2.0, gsize / 2.0, 11)
        )

        north_grid = north_grid.flatten()
        east_grid = east_grid.flatten()

        lat_delta = gsize / config.earthradius * r2d * 2.0
        lon = random.uniform(-180.0, 180.0)
        lat = random.uniform(-90.0, 90.0)

        print gsize / 1000.0

        lat_grid, lon_grid = ne_to_latlon(lat, lon, north_grid, east_grid)
        lat_grid_alt, lon_grid_alt = ne_to_latlon_alternative_method(lat, lon, north_grid, east_grid)

        maxerrlat = num.max(num.abs(lat_grid - lat_grid_alt))
        maxerrlon = num.max(num.abs(lon_grid - lon_grid_alt))
        eps = 1.0e-8
        if maxerrlon > eps or maxerrlat > eps:
            print lat, lon, maxerrlat, maxerrlon

            gmt = gmtpy.GMT(
                config={
                    "PLOT_DEGREE_FORMAT": "ddd.xxxF",
                    "PAPER_MEDIA": "Custom_%ix%i" % (w * gmtpy.cm, h * gmtpy.cm),
                    "GRID_PEN_PRIMARY": "thinnest/0/50/0",
                }
            )

            south = max(-85.0, lat - 0.5 * lat_delta)
            north = min(85.0, lat + 0.5 * lat_delta)

            lon_delta = lat_delta / math.cos(lat * d2r)

            delta = lat_delta / 360.0 * config.earthradius * 2.0 * math.pi
            scale_km = gmtpy.nice_value(delta / 10.0) / 1000.0

            west = lon - 0.5 * lon_delta
            east = lon + 0.5 * lon_delta

            x, y = (west, east), (south, north)
            xax = gmtpy.Ax(mode="min-max", approx_ticks=4.0)
            yax = gmtpy.Ax(mode="min-max", approx_ticks=4.0)
            scaler = gmtpy.ScaleGuru(data_tuples=[(x, y)], axes=(xax, yax))
            scaler["R"] = "-Rg"
            layout = gmt.default_layout()
            mw = 2.5 * gmtpy.cm
            layout.set_fixed_margins(mw, mw, mw / gmtpy.golden_ratio, mw / gmtpy.golden_ratio)
            widget = layout.get_widget()
            # widget['J'] =  ('-JT%g/%g'  % (lon, lat)) + '/%(width)gp'
            widget["J"] = ("-JE%g/%g/%g" % (lon, lat, min(lat_delta / 2.0, 180.0))) + "/%(width)gp"
            aspect = gmtpy.aspect_for_projection(*(widget.J() + scaler.R()))
            widget.set_aspect(aspect)

            if lat > 0:
                axes_layout = "WSen"
            else:
                axes_layout = "WseN"

            gmt.psbasemap(  # B=('%(xinc)gg%(xinc)g:%(xlabel)s:/%(yinc)gg%(yinc)g:%(ylabel)s:' % scaler.get_params())+axes_layout,
                B="5g5",
                L=("x%gp/%gp/%g/%g/%gk" % (widget.width() / 2.0, widget.height() / 7.0, lon, lat, scale_km)),
                *(widget.JXY() + scaler.R())
            )

            gmt.psxy(in_columns=(lon_grid, lat_grid), S="x10p", W="1p/200/0/0", *(widget.JXY() + scaler.R()))
            gmt.psxy(in_columns=(lon_grid_alt, lat_grid_alt), S="c10p", W="1p/0/0/200", *(widget.JXY() + scaler.R()))

            gmt.save("orthodrome.pdf")
            subprocess.call(["xpdf", "-remote", "ortho", "-reload"])
            time.sleep(2)
        else:
            print "ok", gsize, lat, lon