Exemplo n.º 1
0
def test_plot_map(tmpdir):
    gf = asf.load_inventory("tests/data/query.geojson")
    with run_in(tmpdir):
        w, s, e, n = gf.geometry.cascaded_union.bounds
        snwe = [s, n, w, e]
        dplot.plot_map(gf, snwe)
        assert os.path.isfile("map.pdf")
Exemplo n.º 2
0
def main(parser):
    """Run as a script with args coming from argparse."""
    inps = parser.parse_args()
    gf = asf.load_inventory(inps.inventory)

    #print(f'Reading from template file: {inps.template}...')
    inputDict = dice.read_yaml_template(inps.template)

    intdir = 'int-{0}-{1}'.format(inps.master, inps.slave)
    if not os.path.isdir(intdir):
        os.mkdir(intdir)
    os.chdir(intdir)

    master_scenes = asf.get_slc_names(gf, inps.master, inps.path)
    slave_scenes = asf.get_slc_names(gf, inps.slave, inps.path)
    # Append processing Path
    if inps.rawdir:
        master_scenes = [os.path.join(inps.rawdir, x) for x in master_scenes]
        slave_scenes = [os.path.join(inps.rawdir, x) for x in slave_scenes]

    # Update input dictionary with argparse inputs
    inputDict['topsinsar']['master']['safe'] = master_scenes
    inputDict['topsinsar']['slave']['safe'] = slave_scenes

    xml = dice.dict2xml(inputDict)
    dice.write_xml(xml)

    os.chdir('../')
Exemplo n.º 3
0
def test_get_slc_urls():
    acquisition_date = "20180320"
    path = 120
    gf = asf.load_inventory("tests/data/query.geojson")
    urls = asf.get_slc_urls(gf, acquisition_date, path)
    assert type(urls) == list
    assert len(urls) == 1
    assert (urls[0] == "https://datapool.asf.alaska.edu/SLC/SB/\
S1B_IW_SLC__1SDV_20180320T232821_20180320T232848_010121_01260A_0613.zip")
Exemplo n.º 4
0
def test_get_slcs():
    """Retrieve SLCs from geopandas inventory."""
    acquisition_date = '20180320'
    path = 120
    gf = asf.load_inventory('tests/data/query.geojson')
    urls = asf.get_slc_urls(gf, acquisition_date, path)

    assert type(urls) == list
    assert len(urls) == 1
    assert urls[0] == 'https://datapool.asf.alaska.edu/SLC/SB/\
Exemplo n.º 5
0
def test_get_slc_names():
    acquisition_date = "20180320"
    path = 120
    gf = asf.load_inventory("tests/data/query.geojson")
    names = asf.get_slc_names(gf, acquisition_date, path)
    assert type(names) == list
    assert len(names) == 1
    assert (
        names[0] ==
        "S1B_IW_SLC__1SDV_20180320T232821_20180320T232848_010121_01260A_0613.zip"
    )
Exemplo n.º 6
0
def main(parser):
    """Run as a script with args coming from argparse."""
    print('Generating map and timeline plots...')
    args = parser.parse_args()
    gf = load_inventory(args.input)
    w, s, e, n = gf.geometry.cascaded_union.bounds
    snwe = [s, n, w, e]
    plat1, plat2 = gf.platform.unique()
    plot.plot_map(gf, snwe, args.polygon)
    plot.plot_timeline(gf, plat1, plat2)
    print('Saved map.pdf and timeline.pdf figures')
Exemplo n.º 7
0
def test_plot_timeline_sentinel(tmpdir):
    gf = asf.load_inventory("tests/data/query.geojson")
    with run_in(tmpdir):
        plat1, plat2 = gf.platform.unique()
        dplot.plot_timeline_sentinel(gf)
        assert os.path.isfile("timeline.pdf")
Exemplo n.º 8
0
def main(parser):
    """Run as a script with args coming from argparse."""
    inps = parser.parse_args()
    gf = asf.load_inventory(inps.inventory)

    if inps.template:
        print(f'Reading from template file: {inps.template}...')
        inputDict = dice.read_yaml_template(inps.template)
    else:
        inputDict = {
            'topsinsar': {
                'sensorname': 'SENTINEL1',
                'master': {
                    'safe': ''
                },
                'slave': {
                    'safe': ''
                },
            }
        }

    intdir = 'int-{0}-{1}'.format(inps.master, inps.slave)
    if not os.path.isdir(intdir):
        os.mkdir(intdir)
    os.chdir(intdir)

    master_urls = asf.get_slc_urls(gf, inps.master, inps.path)
    slave_urls = asf.get_slc_urls(gf, inps.slave, inps.path)
    downloadList = master_urls + slave_urls
    inps.master_scenes = [os.path.basename(x) for x in master_urls]
    inps.slave_scenes = [os.path.basename(x) for x in slave_urls]

    if inps.poeorb:
        try:
            frame = os.path.basename(inps.master_scenes[0])
            downloadList.append(asf.get_orbit_url(frame))
            frame = os.path.basename(inps.slave_scenes[0])
            downloadList.append(asf.get_orbit_url(frame))
        except Exception as e:
            print('Trouble downloading POEORB... maybe scene is too recent?')
            print('Falling back to using header orbits')
            print(e)
            inps.poeorb = False
            pass

    # Update input dictionary with argparse inputs
    inputDict['topsinsar']['master']['safe'] = inps.master_scenes
    inputDict['topsinsar']['slave']['safe'] = inps.slave_scenes
    # Optional inputs
    # swaths, poeorb, dem, roi, gbox, alooks, rlooks, filtstrength
    if inps.swaths:
        inputDict['topsinsar']['swaths'] = inps.swaths
    if inps.dem:
        inputDict['topsinsar']['demfilename'] = inps.dem
    if inps.roi:
        inputDict['topsinsar']['regionofinterest'] = inps.roi
    if inps.gbox:
        inputDict['topsinsar']['geocodeboundingbox'] = inps.gbox
    if inps.filtstrength:
        inputDict['topsinsar']['filterstrength'] = inps.filtstrength
    if inps.alooks:
        inputDict['topsinsar']['azimuthlooks'] = inps.alooks
    if inps.rlooks:
        inputDict['topsinsar']['rangelooks'] = inps.rlooks
    print(inputDict)
    dice.dict2topsAppXML(inputDict)

    # NOTE: hopefully this changes to S3 storage soon
    asf.write_wget_download_file(downloadList)

    # TODO: change these to use boto3 (or at least subprocess)
    os.chdir('../')
    cmd = f'aws s3 mb s3://{intdir}'
    dout.run_bash_command(cmd)
    cmd = f'aws s3 sync {intdir} s3://{intdir}'
    dout.run_bash_command(cmd)
    print(f'Moved files to s3://{intdir}')
Exemplo n.º 9
0
def main():
    """Run as a script with args coming from argparse."""
    parser = cmdLineParse()
    inps = parser.parse_args()
    gf = asf.load_inventory(inps.inventory)

    if inps.template:
        print(f"Reading from template file: {inps.template}...")
        inputDict = dice.read_yaml_template(inps.template)
    else:
        inputDict = {
            "topsinsar": {
                "sensorname": "SENTINEL1",
                "master": {
                    "safe": ""
                },
                "slave": {
                    "safe": ""
                },
            }
        }

    intdir = "int-{0}-{1}".format(inps.master, inps.slave)
    if not os.path.isdir(intdir):
        os.mkdir(intdir)
    os.chdir(intdir)

    master_urls = asf.get_slc_urls(gf, inps.master, inps.path)
    slave_urls = asf.get_slc_urls(gf, inps.slave, inps.path)
    downloadList = master_urls + slave_urls
    inps.master_scenes = [os.path.basename(x) for x in master_urls]
    inps.slave_scenes = [os.path.basename(x) for x in slave_urls]

    if inps.poeorb:
        try:
            frame = os.path.basename(inps.master_scenes[0])
            downloadList.append(asf.get_orbit_url(frame))
            frame = os.path.basename(inps.slave_scenes[0])
            downloadList.append(asf.get_orbit_url(frame))
        except Exception as e:
            print("Trouble downloading POEORB... maybe scene is too recent?")
            print("Falling back to using header orbits")
            print(e)
            inps.poeorb = False
            pass

    # Update input dictionary with argparse inputs
    inputDict["topsinsar"]["master"]["safe"] = inps.master_scenes
    inputDict["topsinsar"]["master"]["output directory"] = "masterdir"
    inputDict["topsinsar"]["slave"]["safe"] = inps.slave_scenes
    inputDict["topsinsar"]["slave"]["output directory"] = "slavedir"
    # Optional inputs
    # swaths, poeorb, dem, roi, gbox, alooks, rlooks, filtstrength
    if inps.swaths:
        inputDict["topsinsar"]["swaths"] = inps.swaths
    if inps.dem:
        inputDict["topsinsar"]["demfilename"] = inps.dem
    if inps.roi:
        inputDict["topsinsar"]["regionofinterest"] = inps.roi
    if inps.gbox:
        inputDict["topsinsar"]["geocodeboundingbox"] = inps.gbox
    if inps.filtstrength:
        inputDict["topsinsar"]["filterstrength"] = inps.filtstrength
    if inps.alooks:
        inputDict["topsinsar"]["azimuthlooks"] = inps.alooks
    if inps.rlooks:
        inputDict["topsinsar"]["rangelooks"] = inps.rlooks
    print(inputDict)
    xml = dice.dict2xml(inputDict)
    dice.write_xml(xml)
    # Create a download file
    asf.write_download_urls(downloadList)
    print(f"Generated download-links.txt and topsApp.xml in {intdir}")
Exemplo n.º 10
0
def test_load_inventory():
    """Load GeoJSON into GeoDataFrame."""
    gf = asf.load_inventory('tests/data/query.geojson')

    assert type(gf) == gpd.geodataframe.GeoDataFrame
Exemplo n.º 11
0
def main(parser):
    """Run as a script with args coming from argparse."""
    inps = parser.parse_args()
    gf = asf.load_inventory(inps.inventory)

    if inps.template:
        print(f'Reading from template file: {inps.template}...')
        inputDict = dice.read_yaml_template(inps.template)
    else:
        inputDict = {
            'topsinsar': {
                'sensorname': 'SENTINEL1',
                'master': {
                    'safe': ''
                },
                'slave': {
                    'safe': ''
                },
            }
        }

    intdir = 'int-{0}-{1}'.format(inps.master, inps.slave)
    if not os.path.isdir(intdir):
        os.mkdir(intdir)
    os.chdir(intdir)

    master_urls = asf.get_slc_urls(gf, inps.master, inps.path)
    slave_urls = asf.get_slc_urls(gf, inps.slave, inps.path)
    downloadList = master_urls + slave_urls
    inps.master_scenes = [os.path.basename(x) for x in master_urls]
    inps.slave_scenes = [os.path.basename(x) for x in slave_urls]

    if inps.poeorb:
        try:
            frame = os.path.basename(inps.master_scenes[0])
            downloadList.append(asf.get_orbit_url(frame))
            frame = os.path.basename(inps.slave_scenes[0])
            downloadList.append(asf.get_orbit_url(frame))
        except Exception as e:
            print('Trouble downloading POEORB... maybe scene is too recent?')
            print('Falling back to using header orbits')
            print(e)
            inps.poeorb = False
            pass

    # Update input dictionary with argparse inputs
    inputDict['topsinsar']['master']['safe'] = inps.master_scenes
    inputDict['topsinsar']['master']['output directory'] = 'masterdir'
    inputDict['topsinsar']['slave']['safe'] = inps.slave_scenes
    inputDict['topsinsar']['slave']['output directory'] = 'slavedir'
    # Optional inputs
    # swaths, poeorb, dem, roi, gbox, alooks, rlooks, filtstrength
    if inps.swaths:
        inputDict['topsinsar']['swaths'] = inps.swaths
    if inps.dem:
        inputDict['topsinsar']['demfilename'] = inps.dem
    if inps.roi:
        inputDict['topsinsar']['regionofinterest'] = inps.roi
    if inps.gbox:
        inputDict['topsinsar']['geocodeboundingbox'] = inps.gbox
    if inps.filtstrength:
        inputDict['topsinsar']['filterstrength'] = inps.filtstrength
    if inps.alooks:
        inputDict['topsinsar']['azimuthlooks'] = inps.alooks
    if inps.rlooks:
        inputDict['topsinsar']['rangelooks'] = inps.rlooks
    print(inputDict)
    xml = dice.dict2xml(inputDict)
    dice.write_xml(xml)
    # Create a download file
    asf.write_download_urls(downloadList)
    print(f'Generated download-links.txt and topsApp.xml in {intdir}')
Exemplo n.º 12
0
def test_load_inventory():
    gf = asf.load_inventory("tests/data/query.geojson")
    assert type(gf) == gpd.geodataframe.GeoDataFrame
Exemplo n.º 13
0
def test_save_inventory(tmpdir):
    gf = asf.load_inventory("tests/data/query.geojson")
    with run_in(tmpdir):
        asf.save_inventory(gf, outname="test.geojson")
        assert os.path.isfile("test.geojson")
Exemplo n.º 14
0
def test_save_geojson_footprints(tmpdir):
    gf = asf.load_inventory("tests/data/query.geojson")
    with run_in(tmpdir):
        asf.save_geojson_footprints(gf)
        assert os.path.isfile("40/2015-10-03.geojson")
Exemplo n.º 15
0
def test_summarize_orbits(tmpdir):
    gf = asf.load_inventory("tests/data/query.geojson")
    with run_in(tmpdir):
        asf.summarize_orbits(gf)
        assert os.path.isfile("acquisitions_40.csv")