def load(self, satscene, filename=None, *args, **kwargs): conf = ConfigParser() conf.read(os.path.join(CONFIG_PATH, satscene.fullname + ".cfg")) options = dict(conf.items(satscene.instrument_name + "-level2", raw=True)) options["resolution"] = 1000 options["geofile"] = os.path.join(options["dir"], options["geofile"]) options.update(kwargs) fparser = Parser(options.get("filename")) gparser = Parser(options.get("geofile")) if filename is not None: datasets = {} if not isinstance(filename, (list, set, tuple)): filename = [filename] for fname in filename: if fnmatch(os.path.basename(fname), fparser.globify()): metadata = fparser.parse(os.path.basename(fname)) datasets.setdefault( metadata["start_time"], []).append(fname) elif fnmatch(os.path.basename(fname), gparser.globify()): metadata = fparser.parse(fname) datasets.setdefault( metadata["start_time"], []).append(fname) scenes = [] for start_time, dataset in datasets.iteritems(): newscn = copy.deepcopy(satscene) newscn.time_slot = start_time self.load_dataset(newscn, filename=dataset, *args, **kwargs) scenes.append(newscn) if not scenes: logger.debug("Looking for files") self.load_dataset(satscene, *args, **kwargs) else: entire_scene = assemble_segments( sorted(scenes, key=lambda x: x.time_slot)) satscene.channels = entire_scene.channels satscene.area = entire_scene.area satscene.orbit = int(entire_scene.orbit) satscene.info["orbit_number"] = int(entire_scene.orbit) else: self.load_dataset(satscene, *args, **kwargs)
exit(1) #These are the bands necessary for a ghetto pan truecolor image bands = set(["M02","M04","I01", "M05", "M03"]) input_path = sys.argv[1] output_path = sys.argv[2] try: scene_id = os.path.basename(input_path) print "Working on pass " + scene_id input_path = input_path + "/viirs" granules = loadGranules(input_path, bands) print "Data loaded" if(len(granules) > 0): print "Data Assembled" unprojected_data = assemble_segments(granules) base_filename = "{path}/{name}".format(path=output_path,name=scene_id) #Save the unprojected dataA print "Saving unprojected data" #img = unprojected_data.image.truecolor() #img = truecolorTest(unprojected_data.image) #img.save("{base}_{band}_{projection}.tif".format(base=base_filename,band="truecolor",projection="satellite")) print "Projecting data" #This must be defined in $PPP_CONFIG_DIR/areas.def area = "alaska" projected_data = unprojected_data.project(area, mode="nearest") print "Finished projecting" #print "Saving low-res truecolor image" #img = truecolorTest(projected_data.image)#projected_data.image.truecolor()
exit(1) #These are the bands necessary for a ghetto pan truecolor image bands = set(["M02", "M04", "M05", "I01"]) input_path = sys.argv[1] output_path = sys.argv[2] try: scene_id = os.path.basename(input_path) print "Working on pass " + scene_id input_path = input_path + "/viirs" granules = loadGranules(input_path, bands) print "Data loaded" if (len(granules) > 0): print "Data Assembled" unprojected_data = assemble_segments(granules) base_filename = "{path}/{name}".format(path=output_path, name=scene_id) #Save the unprojected dataA print "Saving unprojected data" img = unprojected_data.image.truecolor() img.save("{base}_{band}_{projection}.tif".format( base=base_filename, band="truecolor", projection="satellite")) print "Projecting data" #This must be defined in $PPP_CONFIG_DIR/areas.def area = "alaska" projected_data = unprojected_data.project(area, mode="nearest") print "Finished projecting" print "Saving low-res truecolor image" img = projected_data.image.truecolor()
# This allows us to reproject it. This is a temporary fix until # MPOP is patched to do this automatically #bands = granules[0].image.truecolor.prerequisites #print "I have %d granules" % len(granules) #for granule in granules: #if isvalidgranule(granule, bands,path): #granule.load(bands, dir=path) #granule.area = granule[iter(bands).next()].area #else: #granules.remove(granule) #This appends the granules into one big happy scene print "Data loaded" print "Now I have %d granules" % len(granules) if(len(granules) > 0): global_data = assemble_segments(granules) print "Data Assembled" #Generate the trucolor image and save it as a png and tif #img = global_data.image.truecolor() #img.save('../output/' + scene_id + '.png') #img.save('../output/' + scene_id + '.tif') #Project the image. See conf/areas.def for available definitions #area = "alaska_small" #area = "station_mask_ortho_5k" area = "cleveland" global_data.area.nprocs = 1 local_data = global_data.project(area, mode="nearest") tc = local_data.image.truecolor()
# This allows us to reproject it. This is a temporary fix until # MPOP is patched to do this automatically #bands = granules[0].image.truecolor.prerequisites #print "I have %d granules" % len(granules) #for granule in granules: #if isvalidgranule(granule, bands,path): #granule.load(bands, dir=path) #granule.area = granule[iter(bands).next()].area #else: #granules.remove(granule) #This appends the granules into one big happy scene print "Data loaded" print "Now I have %d granules" % len(granules) if (len(granules) > 0): global_data = assemble_segments(granules) print "Data Assembled" #Generate the trucolor image and save it as a png and tif #img = global_data.image.truecolor() #img.save('../output/' + scene_id + '.png') #img.save('../output/' + scene_id + '.tif') #Project the image. See conf/areas.def for available definitions #area = "alaska_small" #area = "station_mask_ortho_5k" area = "cleveland" global_data.area.nprocs = 1 local_data = global_data.project(area, mode="nearest") tc = local_data.image.truecolor()