Exemplo n.º 1
0
def test_etopo1_topo(make_plot=False, save=False):
    
    try:
        import netCDF4
    except:
        raise nose.SkipTest("netCDF4 not installed, skipping test")
        
    topo1 = topotools.read_netcdf('etopo1', extent=extent, verbose=True)

    topo10 = topotools.read_netcdf('etopo1', extent=extent, 
                                   coarsen=10, verbose=True)

    testdata_path = os.path.join(os.path.dirname(__file__), 'data', 'etopo1_10min.asc')
    if save:
        topo10.write(testdata_path, topo_type=3, Z_format='%.0f')
        print('Created %s' % testdata_path)

    topo10input = topotools.Topography()
    topo10input.read(testdata_path, topo_type=3)
    
    assert numpy.allclose(topo10.Z, topo10input.Z), \
           "topo10.Z does not agree with archived data"
    
    if make_plot:
        import matplotlib.pyplot as plt
        plt.figure(figsize=(12,5))
        ax1 = plt.subplot(1,2,1)
        topo1.plot(axes=ax1)
        plt.title('1 minute etopo1 data')
        ax10 = plt.subplot(1,2,2)
        topo10.plot(axes=ax10)
        plt.title('10 minute etopo1 data')
        pname = 'etopo1_test_plot.png'
        plt.savefig(pname)
        print('Created %s' % pname)
Exemplo n.º 2
0
def test_etopo1_xarray():

    try:
        import xarray
    except:
        raise nose.SkipTest("xarray not installed, skipping test")
        
    topo10,topo10_xarray = topotools.read_netcdf('etopo1', extent=extent, 
                                                 return_xarray=True,
                                                 coarsen=10, verbose=True)

    testdata_path = os.path.join(testdir, 'data', 'etopo1_10min.asc')
    topo10input = topotools.Topography()
    topo10input.read(testdata_path, topo_type=3)
    
    assert numpy.allclose(topo10_xarray['z'], topo10input.Z), \
           "topo10_xarray['z'] does not agree with archived data"
Exemplo n.º 3
0
def test_etopo1_xarray():

    try:
        import xarray
    except ImportError:
        raise nose.SkipTest("xarray not installed, skipping test")

    try:
        topo10, topo10_xarray = topotools.read_netcdf('etopo1',
                                                      extent=extent,
                                                      return_xarray=True,
                                                      coarsen=10,
                                                      verbose=True)
    except (OSError, RuntimeError):
        warnings.warn('Could not read etopo1 data, check if thredds server up')
        raise nose.SkipTest("Reading etopo1 failed, skipping test")

    testdata_path = os.path.join(testdir, 'data', 'etopo1_10min.asc')
    topo10input = topotools.Topography()
    topo10input.read(testdata_path, topo_type=3)

    assert numpy.allclose(topo10_xarray['z'], topo10input.Z), \
           "topo10_xarray['z'] does not agree with archived data"
Exemplo n.º 4
0
from __future__ import print_function

from pylab import *
from clawpack.geoclaw import topotools

# read in slice of etopo1 topography data:

etopo1_url = 'https://www.ngdc.noaa.gov/thredds/dodsC/global/ETOPO1_Ice_g_gmt4.nc'
extent = [-128, -124, 44, 44.5]
print('Attempting to read etopo1 data from\n %s' % etopo1_url)
etopo = topotools.read_netcdf(path=etopo1_url, extent=extent)

#topodir = '/Users/rjl/topo/westport_topo/'
#etopo.read(topodir+'etopo1_-132_-122_42_50_1min.asc',3)

# select a single slice at the desired latitude:
yslice = 44.2
je = find(etopo.y < yslice).max()
print('Extracting slice at latitude %.6f' % etopo.y[je])

xe = etopo.x
Be = etopo.Z[je, :]

if 0:
    je_shore = find(Be > 0).min()
    xe_shore = xe[je_shore]

    xe_to_shore = xe[:je_shore]
    Be_to_shore = Be[:je_shore]

    d = vstack((xe_to_shore, Be_to_shore)).T
Exemplo n.º 5
0
from clawpack.geoclaw import dtopotools, topotools
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
from clawpack.visclaw.plottools import plotbox
import os
from clawpack.visclaw import animation_tools
from IPython.display import HTML

# ## Load etopo1 topo and extract coastline for plotting

# In[ ]:

extent = [-130, -122, 39, 52]
topo = topotools.read_netcdf('etopo1', extent=extent)

# generate coast_xy from etopo1 data:
coast_xy = topo.make_shoreline_xy()

# ### Set up CSZ geometry

# In[ ]:

fault_geometry_file = './cascadia30.mshout'
print('Reading fault geometry from %s' % fault_geometry_file)
print('\nHeader:\n')
print(open(fault_geometry_file).readline())

# In[ ]:
Exemplo n.º 6
0
# Fetch earthquake source model (dtopo file):

url_geoclaw = 'http://depts.washington.edu/clawpack/geoclaw/'

url = os.path.join(url_geoclaw, 'dtopo/tohoku/2011Tohoku_deformation.asc')
get_remote_file(url, output_dir='.', verbose=True)

# Read etopo1 topography data from NCEI thredds server:

# Portion east of -180 (date line):

etopo1_url = 'https://www.ngdc.noaa.gov/thredds/dodsC/global/ETOPO1_Ice_g_gmt4.nc'
extent = [-180, -110, 20, 60]
print('Attempting to read etopo1 data from\n %s' % etopo1_url)
etopo = topotools.read_netcdf(path=etopo1_url,
                              extent=extent,
                              coarsen=1,
                              verbose=True)

fname = 'etopo1_-180_-110_20_60_1min.asc'
etopo.write(fname, topo_type=3)
print('Created ', fname)

# Portion west of 180 (date line):
extent = [120, 180, 20, 60]
print('Attempting to read etopo1 data from\n %s' % etopo1_url)
etopo = topotools.read_netcdf(path=etopo1_url,
                              extent=extent,
                              coarsen=1,
                              verbose=True)

# shift longitude to agree with coordinates of first topo file (longitude West):