Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARIA Download NISAR GUNWs #394

Closed
wants to merge 9 commits into from
68 changes: 55 additions & 13 deletions tools/bin/ariaDownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import logging
import shapely
import warnings
from dateutil.relativedelta import relativedelta
alexfore marked this conversation as resolved.
Show resolved Hide resolved
from getpass import getpass
import asf_search

import ARIAtools.util.log
Expand All @@ -31,16 +33,18 @@ def createParser():
see: https://github.com/asfadmin/Discovery-asf_search
"""
parser = argparse.ArgumentParser(
description='Command line interface to download GUNW products from '
'the ASF DAAC. GUNW products are hosted at the NASA ASF '
'DAAC.\nDownloading them requires a NASA Earthdata URS '
'user login and requires users to add "GRFN Door (PROD)" '
'and "ASF Datapool Products" to their URS approved '
'applications.',
description='Command line interface to download Sentinel-1/NISAR GUNW '
'products from the ASF DAAC. \nDownloading them requires a '
'NASA Earthdata URS user login and requires users to add '
'"GRFN Door (PROD)" and "ASF Datapool Products" to their '
'URS approved applications. Access to NISAR products '
'requires an Earthdata Bearer token from: '
'https://urs.earthdata.nasa.gov/documentation/for_users/user_token',
epilog='Examples of use:\n'
'\t ariaDownload.py --track 004 --output count\n'
'\t ariaDownload.py --bbox "36.75 37.225 -76.655 -75.928"\n'
'\t ariaDownload.py -t 004,077 --start 20190101 -o count',
'\t ariaDownload.py -t 004,077 --start 20190101 -o count'
'\t ariaDownload.py --mission NISAR -o count',
formatter_class=argparse.RawDescriptionHelpFormatter)

parser.add_argument(
Expand Down Expand Up @@ -76,6 +80,11 @@ def createParser():
help='NASA Earthdata URS user password. Users must add "GRFN Door '
'(PROD)" and "ASF Datapool Products" to their URS approved '
'applications.')

parser.add_argument(
'--mission', default='S1', type=str.upper, choices=('S1', 'NISAR'),
help='Sentinel-1 (S1) or NISAR. Default is S1')

parser.add_argument(
'-l', '--daysless', dest='dayslt', default=math.inf, type=int,
help='Take pairs with a temporal baseline -- days less than this value.')
Expand Down Expand Up @@ -108,6 +117,7 @@ def createParser():
'--log-level', default='warning', help='Logger log level')
return parser


def make_bbox(inp_bbox):
"""Make a WKT from SNWE or a shapefile"""
if inp_bbox is None:
Expand Down Expand Up @@ -197,8 +207,10 @@ def __init__(self, args):
else:
LOGGER.setLevel('INFO')


def __call__(self):
scenes = self.query_asf()

urls, ifgs = get_url_ifg(scenes)

# subset everything by version
Expand Down Expand Up @@ -284,6 +296,7 @@ def __call__(self):

return


def query_asf(self):
"""Get the scenes from ASF"""
bbox = make_bbox(self.args.bbox)
Expand All @@ -302,15 +315,43 @@ def query_asf(self):
else:
tracks = self.args.track

dct_kw = dict(platform=asf_search.constants.SENTINEL1,
processingLevel=asf_search.constants.GUNW_STD,
relativeOrbit=tracks,
flightDirection=flight_direction,
intersectsWith=bbox)
scenes = asf_search.geo_search(**dct_kw)

## buffer a bit for loose subsetting and speedup
st0 = self.args.start + relativedelta(months=-3)
bbuzz31 marked this conversation as resolved.
Show resolved Hide resolved
en0 = self.args.end + relativedelta(months=-3)

if self.args.mission.upper() == 'S1':
dct_kw = dict(dataset='ARIA S1 GUNW',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misalignment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what it's supposed to be

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The llines are not aligned correctly

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    dct_kw = dict(dataset='ARIA S1 GUNW',
                    processingLevel=asf_search.constants.GUNW_STD,

dataset and processingLevel should be aligned on subsequent lines

processingLevel=asf_search.constants.GUNW_STD,
relativeOrbit=tracks,
flightDirection=flight_direction,
intersectsWith=bbox,
start=st0,
end=en0)
scenes = asf_search.geo_search(**dct_kw)

elif self.args.mission.upper() == 'NISAR':
session = asf_search.ASFSession()
session.auth_with_token(getpass('EDL Token:'))
LOGGER.info ('Token accepted.')
bbuzz31 marked this conversation as resolved.
Show resolved Hide resolved
## populate once available on GUNWs are available
search_opts = asf_search.ASFSearchOptions(
shortName='NISAR_L2_GUNW_BETA_V1',
session=session
# processingLevel=asf_search.constants.GUNW_STD,
# relativeOrbit=tracks,
# flightDirection=flight_direction,
# intersectsWith=bbox,
# start=self.args.start,
# end=self.args.end)
)
scenes = asf_search.search(opts=search_opts, maxResults=250)
print (scenes[0])
bbuzz31 marked this conversation as resolved.
Show resolved Hide resolved
raise Exception('NISAR GUNWs not futher supported')

return scenes


def main():
parser = createParser()
args = parser.parse_args()
Expand All @@ -328,5 +369,6 @@ def main():
raise Exception('Must specify either a bbox or track')
Downloader(args)()


if __name__ == '__main__':
main()