def __init__(self, obj):
        ''' 
        :param obj: Directory containing an unzipped Landsat 5, 7, or 8 image.  This should include at least
        a tif for each band, and a .mtl file.
        '''
        self.obj = obj
        if os.path.isdir(obj):
            self.isdir = True

        self.date_acquired = None

        self.file_list = os.listdir(obj)
        self.tif_list = [x for x in os.listdir(obj) if x.endswith('.TIF')]
        self.tif_list.sort()

        # parse metadata file into attributes
        # structure: {HEADER: {SUBHEADER: {key(attribute), val(attribute value)}}}
        self.mtl = mtl.parsemeta(obj)
        self.meta_header = list(self.mtl)[0]
        self.super_dict = self.mtl[self.meta_header]
        for key, val in self.super_dict.items():
            for sub_key, sub_val in val.items():
                # print(sub_key.lower(), sub_val)
                setattr(self, sub_key.lower(), sub_val)
        self.satellite = self.landsat_scene_id[:3]

        # create numpy nd_array objects for each band
        self.band_list = []
        self.tif_dict = {}
        for i, tif in enumerate(self.tif_list):
            raster = os.path.join(self.obj, tif)

            # set all lower case attributes
            tif = tif.lower()
            front_ind = tif.index('b')
            end_ind = tif.index('.tif')
            att_string = tif[front_ind: end_ind]

            self.band_list.append(att_string)
            self.tif_dict[att_string] = raster
            self.band_count = i + 1

            if i == 0:
                with rasopen(raster) as src:
                    transform = src.transform
                    profile = src.profile
                meta = src.meta.copy()
                self.rasterio_geometry = meta
                self.profile = profile
                self.transform = transform
                self.shape = (1, profile['height'], profile['width'])

                bounds = RasterBounds(affine_transform=transform,
                                      profile=profile,
                                      latlon=False)
                self.bounds = bounds
                self.north, self.west, self.south, self.east = bounds.get_nwse_tuple()
                self.coords = bounds.as_tuple('nsew')

        self.solar_zenith = 90. - self.sun_elevation
        self.solar_zenith_rad = self.solar_zenith * pi / 180
        self.sun_elevation_rad = self.sun_elevation * pi / 180
        self.earth_sun_dist = self.earth_sun_d(self.date_acquired)

        dtime = datetime.strptime(str(self.date_acquired), '%Y-%m-%d')
        julian_day = dtime.strftime('%j')
        self.doy = int(julian_day)
        self.scene_coords_deg = self._scene_centroid()
        self.scene_coords_rad = deg2rad(self.scene_coords_deg[0]), deg2rad(self.scene_coords_deg[1])
def __init__ ( self , obj ) : self . obj = obj if os . path . isdir ( obj ) : self . isdir = True self . date_acquired = None self . file_list = os . listdir ( obj ) self . tif_list = [ x for x in os . listdir ( obj ) if x . endswith ( '.TIF' ) ] self . tif_list . sort ( ) self . mtl = mtl . parsemeta ( obj ) self . meta_header = list ( self . mtl ) [ 0 ] self . super_dict = self . mtl [ self . meta_header ] for key , val in self . super_dict . items ( ) : for sub_key , sub_val in val . items ( ) : setattr ( self , sub_key . lower ( ) , sub_val ) self . satellite = self . landsat_scene_id [ : 3 ] self . band_list = [ ] self . tif_dict = { } for i , tif in enumerate ( self . tif_list ) : raster = os . path . join ( self . obj , tif ) tif = tif . lower ( ) front_ind = tif . index ( 'b' ) end_ind = tif . index ( '.tif' ) att_string = tif [ front_ind : end_ind ] self . band_list . append ( att_string ) self . tif_dict [ att_string ] = raster self . band_count = i + 1 if i == 0 : with rasopen ( raster ) as src : transform = src . transform profile = src . profile meta = src . meta . copy ( ) self . rasterio_geometry = meta self . profile = profile self . transform = transform self . shape = ( 1 , profile [ 'height' ] , profile [ 'width' ] ) bounds = RasterBounds ( affine_transform = transform , profile = profile , latlon = False ) self . bounds = bounds self . north , self . west , self . south , self . east = bounds . get_nwse_tuple ( ) self . coords = bounds . as_tuple ( 'nsew' ) self . solar_zenith = 90. - self . sun_elevation self . solar_zenith_rad = self . solar_zenith * pi / 180 self . sun_elevation_rad = self . sun_elevation * pi / 180 self . earth_sun_dist = self . earth_sun_d ( self . date_acquired ) dtime = datetime . strptime ( str ( self . date_acquired ) , '%Y-%m-%d' ) julian_day = dtime . strftime ( '%j' ) self . doy = int ( julian_day ) self . scene_coords_deg = self . _scene_centroid ( ) self . scene_coords_rad = deg2rad ( self . scene_coords_deg [ 0 ] ) , deg2rad ( self . scene_coords_deg [ 1 ] )
:param obj: Directory containing an unzipped Landsat 5, 7, or 8 image.  This should include at least
        a tif for each band, and a .mtl file.