def test_get_orbit_url(): """Get URL of precise orbit for a given granule.""" granule = 'S1B_IW_SLC__1SDV_20171117T015310_20171117T015337_008315_00EB6C_40CA' url = asf.get_orbit_url(granule) assert type(url) == str assert url.endswith('.EOF') assert 'AUX_POEORB' in url
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}')
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}")
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}')
def test_get_orbit_url(): gid = "S1B_IW_SLC__1SDV_20171117T015310_20171117T015337_008315_00EB6C_40CA" url = asf.get_orbit_url(gid) assert type(url) == str assert url.endswith(".EOF") assert "AUX_POEORB" in url