Esempio n. 1
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")
Esempio n. 2
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/\
Esempio n. 3
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}')
Esempio n. 4
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}")
Esempio n. 5
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}')