Package: asf-search
asf_searchPython wrapper for the ASF SearchAPIimportasf_searchasasfresults=asf.granule_search(['ALPSRS279162400','ALPSRS279162200'])print(results)wkt='POLYGON((-135.7 58.2,-136.6 58.1,-135.8 56.9,-134.6 56.1,-134.9 58.0,-135.7 58.2))'results=asf.geo_search(platform=[asf.PLATFORM.SENTINEL1],intersectsWith=wkt,maxResults=10)print(results)InstallIn order to easily manage dependencies, we recommend using dedicated project environments
viaAnaconda/MinicondaorPython virtual environments.asf_search can be installed into a conda environment withcondainstall-cconda-forgeasf_searchor into a virtual environment withpython3-mpipinstallasf_searchTo install pytest/cov packages for testing, along with the minimal packages:python3-mpipinstallasf_search[test]UsageFull documentation is available athttps://docs.asf.alaska.edu/asf_search/basics/Programmatically searching for ASF data is made simple with asf_search. Several search functions are provided:geo_search()Find product info over an area of interest using a WKT stringgranule_search()Find product info using a list of scenesproduct_search()Find product info using a list of productssearch()Find product info using any combination combination of search parametersstack()Find a baseline stack of products using a reference sceneAdditionally, numerous constants are provided to ease the search processAdditionally, asf_search support downloading data, both from search results as provided by the above search functions, and directly on product URLs. An authenticated session is generally required. This is provided by theASFSessionclass, and use of one of its three authentication methods:auth_with_creds('user', 'pass)auth_with_token('EDL token')auth_with_cookiejar(http.cookiejar)That session should be passed to whichever download method is being called, can be re-used, and is thread safe. Examples:results=asf_search.granule_search([...])session=asf_search.ASFSession()session.auth_with_creds('user','pass')results.download(path='/Users/SARGuru/data',session=session)Alternately, downloading a list of URLs contained inurlsand creating the session inline:urls=[...]asf_search.download_urls(urls=urls,path='/Users/SARGuru/data',session=ASFSession().auth_with_token('EDL token'))Also note thatASFSearchResults.download()and the genericdownload_urls()function both accept aprocessesparameter which allows for parallel downloads.Further examples of all of the above can be found inexamples/DevelopmentBranchingInstanceBranchDescription, Instructions, NotesStablestableAccepts merges from Working and HotfixesWorkingmasterAccepts merges from Features/Issues and HotfixesFeatures/Issuestopic-*Always branch off HEAD of WorkingHotfixhotfix-*Always branch off StableFor an extended description of our workflow, seehttps://gist.github.com/digitaljhelms/4287848Enable LoggingWe use standard the standardloggingin our package for output.Heres a basic example for hooking into it with your application:importasf_searchasasfimportloggingASF_LOGGER=logging.getLogger("asf_search")formatter=logging.Formatter('[%(asctime)s(%(name)s)%(filename)s:%(lineno)d]%(levelname)s-%(message)s')# Get output to the console:stream_handle=logging.StreamHandler()stream_handle.setFormatter(formatter)ASF_LOGGER.addHandler(stream_handle)# If you want it write to a file too:file_handle=logging.FileHandler('MyCustomApp.log')file_handle.setFormatter(formatter)ASF_LOGGER.addHandler(file_handle)# Only see messages that might affect youASF_LOGGER.setLevel(logging.WARNING)# Test if the logger throws an error, you see it as expected:ASF_LOGGER.error("This is only a drill. Please do not panic.")# Should output this:# [ 2023-01-17 10:04:53,780 (asf_search) main.py:42 ] ERROR - This is only a drill. Please do not panic.For more configure options onlogging, please visittheir howto page.