Esempio n. 1
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('../')
Esempio n. 2
0
def test_write_topsApp_xml(tmpdir):
    """Make sure directory is created with necessary and valid files."""
    testDict = {
        "topsinsar": {
            "azimuthlooks": 7,
            "filterstrength": 0.5,
            "reference": {"safe": "s1a.zip"},
            "secondary": {"safe": "s1b.zip"},
        }
    }
    xml = dice.dict2xml(testDict)
    outfile = tmpdir.join("topsApp.xml")
    dice.write_xml(xml, outfile)

    assert os.path.exists(outfile)
Esempio n. 3
0
def test_write_topsApp_xml(tmpdir):
    """Make sure directory is created with necessary and valid files."""
    testDict = {
        'topsinsar': {
            'azimuthlooks': 7,
            'filterstrength': 0.5,
            'master': {
                'safe': 's1a.zip'
            },
            'slave': {
                'safe': 's1b.zip'
            }
        }
    }
    xml = dice.dict2xml(testDict)
    outfile = tmpdir.join('topsApp.xml')
    dice.write_xml(xml, outfile)

    assert os.path.exists(outfile)
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}')