예제 #1
0
파일: index.py 프로젝트: openwebcc/ba
def metadata(req,scene=None,filename=None):
    """ show auxilliary metadata files for scenes """

    # init AWS module
    aws = AWS()
    aws.set_scene(scene)
    attr = aws.get_scene_attributes()

    # make sure that name of scene is valid
    if not aws.is_valid_scene_name(scene):
        return "Error: invalid scene requested."

    # make sure that filename is valid
    if not filename in aws.get_metadata_filenames():
        return "Error: invalid filename requested"

    # strip qi/ subdirectory from cloudmask
    filename = re.sub('qi/','',filename)

    # link original file to temporary directory and redirect
    in_path = "%s/%s/metadata/%s_%s" % (aws.get_basedir(),attr['tile'],scene,filename)
    out_path = "/home/institut/www/html/data/sentinel2/metatmp/%s_%s" % (scene,filename)
    out_url = re.sub('/home/institut/www/html','',out_path)

    if os.path.exists(in_path):
        if not os.path.exists(out_path):
            os.symlink(in_path,out_path)
        redirect(req,out_url)
    else:
        return "Error: File %s for scene %s does not exist." % (filename,scene)
예제 #2
0
            aws.create_tiledir()

            # find all scenes for this tile by year, month, day, scene
            years = aws.parse_bucket()
            if len(years) > 0:
                for year in years:
                    months = aws.parse_bucket(year)
                    if len(months) > 0:
                        for month in months:
                            days = aws.parse_bucket(year,month)
                            if len(days) > 0:
                                for day in days:
                                    scenes = aws.parse_bucket(year,month,day)
                                    if len(scenes) > 0:
                                        for scene in scenes:
                                            for fname in (aws.get_metadata_filenames()):
                                                store_files.append({
                                                    'tile' : tile,
                                                    'year' : year,
                                                    'month' : month,
                                                    'day' : day,
                                                    'scene' : scene,
                                                    'fname' : fname,
                                                })
            else:
                print "no data found for tile %s" % tile

        elif args.days:
            # find new scenes within the last n-days
            for n in range(int(args.days),0,-1):
                curday = date.today() - timedelta(days=n)