def test_gyz(): "gravmag.tesseroid.gyz with optimal discretize against half a shell" lons = np.zeros_like(heights) lats = lons tess = tesseroid.gyz(lons, lats, heights, shellmodel) diff = np.abs(tess) assert np.all(diff <= 10 ** (-10)), 'diff: %s' % (str(diff))
# Create the computation grid area = (-80, -30, -40, 10) shape = (100, 100) lons, lats, heights = gridder.regular(area, shape, z=250000) start = time.time() fields = [ tesseroid.potential(lons, lats, heights, model), tesseroid.gx(lons, lats, heights, model), tesseroid.gy(lons, lats, heights, model), tesseroid.gz(lons, lats, heights, model), tesseroid.gxx(lons, lats, heights, model), tesseroid.gxy(lons, lats, heights, model), tesseroid.gxz(lons, lats, heights, model), tesseroid.gyy(lons, lats, heights, model), tesseroid.gyz(lons, lats, heights, model), tesseroid.gzz(lons, lats, heights, model)] print "Time it took: %s" % (utils.sec2hms(time.time() - start)) titles = ['potential', 'gx', 'gy', 'gz', 'gxx', 'gxy', 'gxz', 'gyy', 'gyz', 'gzz'] bm = mpl.basemap(area, 'merc') mpl.figure() mpl.title(titles[0]) mpl.contourf(lons, lats, fields[0], shape, 40, basemap=bm) bm.drawcoastlines() mpl.colorbar() mpl.figure() for i, field in enumerate(fields[1:4]): mpl.subplot(1, 3, i + 1) mpl.title(titles[i + 1])
# Create the computation grid area = (-80, -30, -40, 10) shape = (100, 100) lons, lats, heights = gridder.regular(area, shape, z=250000) start = time.time() fields = [ tesseroid.potential(lons, lats, heights, model), tesseroid.gx(lons, lats, heights, model), tesseroid.gy(lons, lats, heights, model), tesseroid.gz(lons, lats, heights, model), tesseroid.gxx(lons, lats, heights, model), tesseroid.gxy(lons, lats, heights, model), tesseroid.gxz(lons, lats, heights, model), tesseroid.gyy(lons, lats, heights, model), tesseroid.gyz(lons, lats, heights, model), tesseroid.gzz(lons, lats, heights, model) ] print "Time it took: %s" % (utils.sec2hms(time.time() - start)) titles = [ 'potential', 'gx', 'gy', 'gz', 'gxx', 'gxy', 'gxz', 'gyy', 'gyz', 'gzz' ] bm = mpl.basemap(area, 'merc') mpl.figure() mpl.title(titles[0]) mpl.contourf(lons, lats, fields[0], shape, 40, basemap=bm) bm.drawcoastlines() mpl.colorbar() mpl.figure() for i, field in enumerate(fields[1:4]):