def get_modscag_fn_list(dem_dt, tile_list=('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'), pad_days=<NUM_LIT:7>):
<EOL>import re<EOL>import requests<EOL>from bs4 import BeautifulSoup<EOL>auth = iolib.get_auth()<EOL>pad_days = timedelta(days=pad_days)<EOL>dt_list = timelib.dt_range(dem_dt-pad_days, dem_dt+pad_days+timedelta(<NUM_LIT:1>), timedelta(<NUM_LIT:1>))<EOL>outdir = os.path.join(datadir, '<STR_LIT>')<EOL>if not os.path.exists(outdir):<EOL><INDENT>os.makedirs(outdir)<EOL><DEDENT>out_vrt_fn_list = []<EOL>for dt in dt_list:<EOL><INDENT>out_vrt_fn = os.path.join(outdir, dt.strftime('<STR_LIT>'))<EOL>if os.path.exists(out_vrt_fn):<EOL><INDENT>vrt_ds = gdal.Open(out_vrt_fn)<EOL>if np.all([np.any([tile in sub_fn for sub_fn in vrt_ds.GetFileList()]) for tile in tile_list]):<EOL><INDENT>out_vrt_fn_list.append(out_vrt_fn)<EOL>continue<EOL><DEDENT><DEDENT>modscag_fn_list = []<EOL>for tile in tile_list:<EOL><INDENT>modscag_url_str = '<STR_LIT>' <EOL>modscag_url_base = dt.strftime(modscag_url_str)<EOL>print("<STR_LIT>" % modscag_url_base)<EOL>r = requests.get(modscag_url_base, auth=auth)<EOL>modscag_url_fn = []<EOL>if r.ok:<EOL><INDENT>parsed_html = BeautifulSoup(r.content, "<STR_LIT>")<EOL>modscag_url_fn = parsed_html.findAll(text=re.compile('<STR_LIT>' % tile))<EOL><DEDENT>if not modscag_url_fn:<EOL><INDENT>modscag_url_str = '<STR_LIT>' <EOL>modscag_url_base = dt.strftime(modscag_url_str)<EOL>print("<STR_LIT>" % modscag_url_base)<EOL>r = requests.get(modscag_url_base, auth=auth)<EOL><DEDENT>if r.ok: <EOL><INDENT>parsed_html = BeautifulSoup(r.content, "<STR_LIT>")<EOL>modscag_url_fn = parsed_html.findAll(text=re.compile('<STR_LIT>' % tile))<EOL><DEDENT>if not modscag_url_fn:<EOL><INDENT>print("<STR_LIT>" % dt)<EOL><DEDENT>else:<EOL><INDENT>parsed_html = BeautifulSoup(r.content, "<STR_LIT>")<EOL>modscag_url_fn = parsed_html.findAll(text=re.compile('<STR_LIT>' % tile))<EOL>if modscag_url_fn:<EOL><INDENT>modscag_url_fn = modscag_url_fn[<NUM_LIT:0>]<EOL>modscag_url = os.path.join(modscag_url_base, modscag_url_fn)<EOL>print(modscag_url)<EOL>modscag_fn = os.path.join(outdir, os.path.split(modscag_url_fn)[-<NUM_LIT:1>])<EOL>if not os.path.exists(modscag_fn):<EOL><INDENT>iolib.getfile2(modscag_url, auth=auth, outdir=outdir)<EOL><DEDENT>modscag_fn_list.append(modscag_fn)<EOL><DEDENT><DEDENT><DEDENT>if modscag_fn_list:<EOL><INDENT>cmd = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', out_vrt_fn]<EOL>cmd.extend(modscag_fn_list)<EOL>print(cmd)<EOL>subprocess.call(cmd, shell=False)<EOL>out_vrt_fn_list.append(out_vrt_fn)<EOL><DEDENT><DEDENT>return out_vrt_fn_list<EOL>
Function to fetch and process MODSCAG fractional snow cover products for input datetime

    Products are tiled in MODIS sinusoidal projection

    example url: https://snow-data.jpl.nasa.gov/modscag-historic/2015/001/MOD09GA.A2015001.h07v03.005.2015006001833.snow_fraction.tif