コード例 #1
0
ファイル: twc_kbdi_test.py プロジェクト: yosukefk/ulmo
def test_get_data_as_dataframe():
    with test_util.temp_dir() as data_dir:
        with test_util.mocked_urls(MOCKED_URLS):
            data = ulmo.twc.kbdi.get_data(
                start='2013-04-09',
                end='2013-04-09',
                as_dataframe=True,
                data_dir=data_dir,
            )

            assert isinstance(data, pandas.DataFrame)
コード例 #2
0
ファイル: twc_kbdi_test.py プロジェクト: yosukefk/ulmo
def test_data_dir_used():
    with test_util.temp_dir() as data_dir:
        with test_util.mocked_urls(MOCKED_URLS):
            ulmo.twc.kbdi.get_data(
                start='2013-04-09',
                end='2013-04-11',
                as_dataframe=True,
                data_dir=data_dir,
            )
        files_glob = glob.glob(os.path.join(data_dir, '*'))
        assert len(files_glob) == 3
コード例 #3
0
ファイル: twc_kbdi_test.py プロジェクト: yosukefk/ulmo
def test_get_data_by_county():
    with test_util.temp_dir() as data_dir:
        for test_set in test_sets:
            with test_util.mocked_urls(MOCKED_URLS):
                data = ulmo.twc.kbdi.get_data(
                    county=test_set['fips'],
                    start=test_set['start'],
                    end=test_set['end'],
                    data_dir=data_dir,
                )
            assert len(data) == 1
            assert test_set['fips'] in data
コード例 #4
0
ファイル: twc_kbdi_test.py プロジェクト: yosukefk/ulmo
def test_get_data():
    with test_util.temp_dir() as data_dir:
        for test_set in test_sets:
            with test_util.mocked_urls(MOCKED_URLS):
                data = ulmo.twc.kbdi.get_data(
                    start=test_set['start'],
                    end=test_set['end'],
                    data_dir=data_dir,
                )

            values = data.get(test_set['fips'], {})
            test_values = test_set['values']

            for test_value in test_values:
                assert test_value in values
コード例 #5
0
def test_get_raster():
	layer = 'Alaska 2 arc-second'
	bbox = (-149.5, 60.5, -149.3, 60.7)
	#availability_url = 'https://www.sciencebase.gov/catalog/items?fields=webLinks,spatial,title&q=&filter=tags=National Elevation Dataset (NED) Alaska 2 arc-second&filter=tags=IMG&filter=spatialQuery=Polygon ((-149.5 60.7,-149.5 60.5,-149.3 60.5,-149.3 60.7,-149.5 60.7))&format=json&max=1000'
	#zip_url = 'ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/Staged/NED/2/IMG/n61w150.zip'
	availability_url = 'https://www.sciencebase.gov/catalog/*'
	zip_url = 'ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/*'

	url_files = {
		availability_url: 'usgs/ned/get_raster_test_availability.json',
		zip_url: 'n61w150.zip',
	}

	test_file = test_util.get_test_file_path('usgs/ned/n61w150.img')
	with test_util.temp_dir() as data_dir:
		#with test_util.mocked_urls(url_files):
		locs = ulmo.usgs.ned.get_raster(layer, bbox, path=data_dir)
		raster_tile = locs['features'][0]['properties']['file']
		assert filecmp.cmp(raster_tile, test_file)
コード例 #6
0
ファイル: usgs_ned_test.py プロジェクト: muguangyuze/ulmo
def test_get_raster():
    layer = 'Alaska 2 arc-second'
    bbox = (-149.5, 60.5, -149.3, 60.7)
    #availability_url = 'https://www.sciencebase.gov/catalog/items?fields=webLinks,spatial,title&q=&filter=tags=National Elevation Dataset (NED) Alaska 2 arc-second&filter=tags=IMG&filter=spatialQuery=Polygon ((-149.5 60.7,-149.5 60.5,-149.3 60.5,-149.3 60.7,-149.5 60.7))&format=json&max=1000'
    #zip_url = 'ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/Staged/NED/2/IMG/n61w150.zip'
    availability_url = 'https://www.sciencebase.gov/catalog/*'
    zip_url = 'ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/*'

    url_files = {
        availability_url: 'usgs/ned/get_raster_test_availability.json',
        zip_url: 'n61w150.zip',
    }

    test_file = test_util.get_test_file_path('usgs/ned/n61w150.img')
    with test_util.temp_dir() as data_dir:
        #with test_util.mocked_urls(url_files):
        locs = ulmo.usgs.ned.get_raster(layer, bbox, path=data_dir)
        raster_tile = locs['features'][0]['properties']['file']
        assert filecmp.cmp(raster_tile, test_file)
コード例 #7
0
ファイル: usgs_eros_test.py プロジェクト: yosukefk/ulmo
def test_get_raster():
    product_key = 'NCP'
    bbox = (-97.992, 31.991, -97.991, 31.992)
    #availability_url = 'http://extract.cr.usgs.gov/requestValidationServiceClient/sampleRequestValidationServiceProxy/getTiledDataDirectURLs2.jsp?TOP=31.992&BOTTOM=31.991&LEFT=-97.992&RIGHT=-97.991&LAYER_IDS=NCP&JSON=true'
    #jp2_url = 'http://tdds2.cr.usgs.gov/lta5/ortho/naip/compressed/TX/2012/201204_texas_naip_1x0000m_cnir/31097/m_3109701_nw_14_1_20120725_20121015.jp2'
    format_url = 'http://nimbus.cr.usgs.gov/index_service/Index_Service_JSON2.asmx'
    availability_url = 'http://extract.cr.usgs.gov/requestValidationServiceClient/sampleRequestValidationServiceProxy/getTiledDataDirectURLs2.jsp'
    jp2_url = 'http://tdds2.cr.usgs.gov/lta5/ortho/naip/compressed/TX/2012/201204_texas_naip_1x0000m_cnir/31097/m_3109701_nw_14_1_20120725_20121015.jp2'
    url_files = {
        format_url: 'usgs/eros/formats_ncp.json',
        availability_url: 'usgs/eros/get_raster_test_availability.json',
        jp2_url: 'usgs/eros/m_3109701_nw_14_1_20120725_20121015.jp2',
    }

    test_file = test_util.get_test_file_path('usgs/eros/m_3109701_nw_14_1_20120725_20121015.jp2')
    with test_util.temp_dir() as data_dir:
        with test_util.mocked_urls(url_files):
            locs = ulmo.usgs.eros.get_raster(product_key, bbox, path=data_dir)
            raster_tile = locs['features'][0]['properties']['file']
            assert filecmp.cmp(raster_tile, test_file)