Пример #1
0
def _test(vs30file=None):
    print('Testing creation of Sites object with Vs30 file of %s...' % vs30file)
    cx = -118.2
    cy = 34.1
    dx = 0.0083
    dy = 0.0083
    xspan = 3.0
    yspan = 3.0
    mysite = Sites.createFromCenter(cx,cy,xspan,yspan,dx,dy,vs30File=vs30file,
                                    padding=True,resample=False)
    sc = mysite.getSitesContext()
    
    cx = -118.2
    cy = 83
    dx = 0.0083
    dy = 0.0083
    xspan = 3.0
    yspan = 3.0
    mysite = Sites.createFromCenter(cx,cy,xspan,yspan,dx,dy,vs30File=vs30file,padding=True,resample=False)

    xmin = 116.234
    xmax = 120.876
    ymin = 20.12345
    ymax = 24.75435
    dx = 0.0083
    dy = 0.0083
    mysite = Sites.createFromBounds(xmin,xmax,ymin,ymax,dx,dy,vs30File=vs30file,padding=False,resample=False)
    print('Passed creation of Sites object with Vs30 file of %s' % vs30file)
Пример #2
0
def _test(vs30file=None):
    print('Testing creation of Sites object with Vs30 file of %s...' %
          vs30file)
    cx = -118.2
    cy = 34.1
    dx = 0.0083
    dy = 0.0083
    xspan = 3.0
    yspan = 3.0
    mysite = Sites.createFromCenter(cx,
                                    cy,
                                    xspan,
                                    yspan,
                                    dx,
                                    dy,
                                    vs30File=vs30file,
                                    padding=True,
                                    resample=False)
    sc = mysite.getSitesContext()

    cx = -118.2
    cy = 83
    dx = 0.0083
    dy = 0.0083
    xspan = 3.0
    yspan = 3.0
    mysite = Sites.createFromCenter(cx,
                                    cy,
                                    xspan,
                                    yspan,
                                    dx,
                                    dy,
                                    vs30File=vs30file,
                                    padding=True,
                                    resample=False)

    xmin = 116.234
    xmax = 120.876
    ymin = 20.12345
    ymax = 24.75435
    dx = 0.0083
    dy = 0.0083
    mysite = Sites.createFromBounds(xmin,
                                    xmax,
                                    ymin,
                                    ymax,
                                    dx,
                                    dy,
                                    vs30File=vs30file,
                                    padding=False,
                                    resample=False)
    print('Passed creation of Sites object with Vs30 file of %s' % vs30file)
Пример #3
0
def test(vs30file=None):
    vs30file = os.path.join(shakedir, 'data/Vs30_test.grd')
    cx = -118.2
    cy = 34.1
    dx = 0.0083
    dy = 0.0083
    xspan = 0.0083 * 5
    yspan = 0.0083 * 5
    mysite = Sites.createFromCenter(cx, cy, xspan, yspan, dx, dy,
                                    vs30File=vs30file, padding=True,
                                    resample=False)
    grd = mysite.getVs30Grid().getData()
    grd_target = np.array(
      [[ 409.14199829,  428.24468994,  395.90026855,  426.31658936,
         427.53845215,  433.40481567,  436.59918213,  440.43664551,
         413.60662842],
       [ 423.60855103,  426.64892578,  398.89712524,  428.88549805,
         428.78335571,  428.58578491,  430.54354858,  433.59750366,
         415.18811035],
       [ 391.67398071,  426.20635986,  425.57946777,  428.21954346,
         426.06726074,  421.86233521,  423.53192139,  426.25296021,
         365.48190308],
       [ 385.00396729,  428.14602661,  430.05944824,  429.3427124 ,
         426.13626099,  409.76391602,  383.07299805,  372.39117432,
         426.48486328],
       [ 356.68756104,  432.64077759,  434.55209351,  432.21600342,
         395.53771973,  419.31866455,  421.67749023,  426.23449707,
         427.32818604],
       [ 337.0546875 ,  345.14605713,  403.78097534,  385.49118042,
         413.04779053,  428.22869873,  427.00268555,  426.8951416 ,
         425.62023926],
       [ 403.78884888,  336.48217773,  347.82220459,  425.96798706,
         432.0640564 ,  429.40097046,  427.74179077,  427.00006104,
         419.5062561 ],
       [ 420.07458496,  330.57504272,  392.33255005,  430.33862305,
         432.01391602,  429.43969727,  427.30435181,  425.96151733,
         426.15856934]])

    np.testing.assert_allclose(grd, grd_target)

    sc = mysite.getSitesContext()
    scsamp = mysite.sampleFromSites(np.array([34.1, 34.111]),
                                    np.array([-118.2, -118.222]))

    xmin = -118.2
    xmax = -118.12
    ymin = 34.05
    ymax = 34.1
    dx = 0.0083
    dy = 0.0083
    mysite = Sites.createFromBounds(xmin, xmax, ymin, ymax, dx, dy,
                                    vs30File=vs30file, padding=False,
                                    resample=False)
    grd = mysite.getVs30Grid().getData()
    grd_target = np.array(
      [[ 426.13626099,  409.76391602,  383.07299805,  372.39117432,
         426.48486328,  422.45065308,  417.21685791,  410.43737793,
         405.33862305,  400.5239563 ,  396.03030396],
       [ 395.53771973,  419.31866455,  421.67749023,  426.23449707,
         427.32818604,  424.84860229,  415.17590332,  407.5760498 ,
         404.54788208,  402.28500366,  398.95913696],
       [ 413.04779053,  428.22869873,  427.00268555,  426.8951416 ,
         425.62023926,  419.60952759,  411.7961731 ,  407.53509521,
         406.22122192,  405.31622314,  402.92575073],
       [ 432.0640564 ,  429.40097046,  427.74179077,  427.00006104,
         419.5062561 ,  411.10830688,  407.48901367,  406.53305054,
         406.59658813,  406.24887085,  406.17044067],
       [ 432.01391602,  429.43969727,  427.30435181,  425.96151733,
         426.15856934,  427.56121826,  397.67102051,  399.21054077,
         404.54968262,  407.18515015,  410.00823975],
       [ 426.76913452,  428.86270142,  425.99606323,  423.5692749 ,
         423.59835815,  425.92758179,  408.44885254,  406.55810547,
         409.06945801,  413.75210571,  417.71130371],
       [ 423.1892395 ,  427.91104126,  424.53796387,  419.47485352,
         418.177948  ,  424.14065552,  428.57913208,  432.95300293,
         427.77731323,  431.46524048,  442.75540161],
       [ 410.56729126,  423.15557861,  424.48355103,  419.27658081,
         418.60211182,  423.86721802,  428.06176758,  432.42089844,
         438.54446411,  448.37237549,  462.25509644],
       [ 405.86877441,  414.27923584,  419.53878784,  396.18017578,
         414.54452515,  419.80047607,  425.19824219,  424.48919678,
         424.72061157,  431.52270508,  432.84347534]])
    np.testing.assert_allclose(grd, grd_target)
Пример #4
0
def test(vs30file=None):
    vs30file = os.path.join(shakedir, 'tests/data/Vs30_test.grd')
    cx = -118.2
    cy = 34.1
    dx = 0.0083
    dy = 0.0083
    xspan = 0.0083 * 5
    yspan = 0.0083 * 5
    mysite = Sites.createFromCenter(cx, cy, xspan, yspan, dx, dy,
                                    vs30File=vs30file, padding=True,
                                    resample=False)
    grd = mysite.getVs30Grid().getData()
    grd_target = np.array(
      [[ 409.14199829,  428.24468994,  395.90026855,  426.31658936,
         427.53845215,  433.40481567,  436.59918213,  440.43664551,
         413.60662842],
       [ 423.60855103,  426.64892578,  398.89712524,  428.88549805,
         428.78335571,  428.58578491,  430.54354858,  433.59750366,
         415.18811035],
       [ 391.67398071,  426.20635986,  425.57946777,  428.21954346,
         426.06726074,  421.86233521,  423.53192139,  426.25296021,
         365.48190308],
       [ 385.00396729,  428.14602661,  430.05944824,  429.3427124 ,
         426.13626099,  409.76391602,  383.07299805,  372.39117432,
         426.48486328],
       [ 356.68756104,  432.64077759,  434.55209351,  432.21600342,
         395.53771973,  419.31866455,  421.67749023,  426.23449707,
         427.32818604],
       [ 337.0546875 ,  345.14605713,  403.78097534,  385.49118042,
         413.04779053,  428.22869873,  427.00268555,  426.8951416 ,
         425.62023926],
       [ 403.78884888,  336.48217773,  347.82220459,  425.96798706,
         432.0640564 ,  429.40097046,  427.74179077,  427.00006104,
         419.5062561 ],
       [ 420.07458496,  330.57504272,  392.33255005,  430.33862305,
         432.01391602,  429.43969727,  427.30435181,  425.96151733,
         426.15856934]])

    np.testing.assert_allclose(grd, grd_target)

    sc = mysite.getSitesContext()
    scsamp = mysite.sampleFromSites(np.array([34.1, 34.111]),
                                    np.array([-118.2, -118.222]))

    xmin = -118.2
    xmax = -118.12
    ymin = 34.05
    ymax = 34.1
    dx = 0.0083
    dy = 0.0083
    mysite = Sites.createFromBounds(xmin, xmax, ymin, ymax, dx, dy,
                                    vs30File=vs30file, padding=False,
                                    resample=False)
    grd = mysite.getVs30Grid().getData()
    grd_target = np.array(
      [[ 426.13626099,  409.76391602,  383.07299805,  372.39117432,
         426.48486328,  422.45065308,  417.21685791,  410.43737793,
         405.33862305,  400.5239563 ,  396.03030396],
       [ 395.53771973,  419.31866455,  421.67749023,  426.23449707,
         427.32818604,  424.84860229,  415.17590332,  407.5760498 ,
         404.54788208,  402.28500366,  398.95913696],
       [ 413.04779053,  428.22869873,  427.00268555,  426.8951416 ,
         425.62023926,  419.60952759,  411.7961731 ,  407.53509521,
         406.22122192,  405.31622314,  402.92575073],
       [ 432.0640564 ,  429.40097046,  427.74179077,  427.00006104,
         419.5062561 ,  411.10830688,  407.48901367,  406.53305054,
         406.59658813,  406.24887085,  406.17044067],
       [ 432.01391602,  429.43969727,  427.30435181,  425.96151733,
         426.15856934,  427.56121826,  397.67102051,  399.21054077,
         404.54968262,  407.18515015,  410.00823975],
       [ 426.76913452,  428.86270142,  425.99606323,  423.5692749 ,
         423.59835815,  425.92758179,  408.44885254,  406.55810547,
         409.06945801,  413.75210571,  417.71130371],
       [ 423.1892395 ,  427.91104126,  424.53796387,  419.47485352,
         418.177948  ,  424.14065552,  428.57913208,  432.95300293,
         427.77731323,  431.46524048,  442.75540161],
       [ 410.56729126,  423.15557861,  424.48355103,  419.27658081,
         418.60211182,  423.86721802,  428.06176758,  432.42089844,
         438.54446411,  448.37237549,  462.25509644],
       [ 405.86877441,  414.27923584,  419.53878784,  396.18017578,
         414.54452515,  419.80047607,  425.19824219,  424.48919678,
         424.72061157,  431.52270508,  432.84347534]])
    np.testing.assert_allclose(grd, grd_target)