コード例 #1
0
 def __init__(self, filepath, geofilepath=None, variable=None):
     super(MODSWHDF4, self).__init__(filepath)
     self.datasets = self.dataobj.datasets().keys()
     self.bandnames = None
     self.coremeta = mtl.parsemeta(self.rawmetadata['CoreMetadata.0'])
     self.archivemeta = mtl.parsemeta(self.rawmetadata['ArchiveMetadata.0'])
     self.coremeta = mtl.parsemeta(self.rawmetadata['CoreMetadata.0'])
     if geofilepath:
         self.geofilepath = geofilepath
     else:
         # TODO
         pass
コード例 #2
0
ファイル: hdf4.py プロジェクト: chris4540/pygaarst
 def __init__(self, filepath, geofilepath=None, variable=None):
     super(MODSWHDF4, self).__init__(filepath)
     self.datasets = self.dataobj.datasets().keys()
     self.bandnames = None
     self.coremeta = mtl.parsemeta(self.rawmetadata['CoreMetadata.0'])
     self.archivemeta = mtl.parsemeta(self.rawmetadata['ArchiveMetadata.0'])
     self.coremeta = mtl.parsemeta(self.rawmetadata['CoreMetadata.0'])
     if geofilepath:
         self.geofilepath = geofilepath
     else:
         # TODO
         pass
コード例 #3
0
ファイル: hdf4.py プロジェクト: imagingearth/pygaarst
 def __init__(self, filepath, geofilepath=None, variable=None):
     super(MODSWHDF4, self).__init__(filepath)
     self.datasets = self.dataobj.datasets().keys()
     self.bandnames = None
     self.coremeta = mtl.parsemeta(self.rawmetadata['CoreMetadata.0'])
     self.archivemeta = mtl.parsemeta(self.rawmetadata['ArchiveMetadata.0'])
     self.coremeta = mtl.parsemeta(self.rawmetadata['CoreMetadata.0'])
     if geofilepath:
         self.geofilepath = geofilepath
     else:
         try:
             geofn = self.dataobj.attrs['N_GEO_Ref'][0][0]
             self.geofilepath = os.path.join(self.dirname, geofn)
         except:
             self.geofilepath = None
コード例 #4
0
def add_mtl_info(scene_dict, scene_root, scene_dir):
    mtl_filename = '%s/%s_MTL.txt' % (scene_dir, scene_root)
    mtl_dict = mtlutils.parsemeta(mtl_filename)

    # Strip useless level of indirection.
    mtl_dict = mtl_dict['L1_METADATA_FILE']
    
    scene_dict['entityId'] = scene_root

    acq_datetime = datetime.datetime.combine(
        mtl_dict['PRODUCT_METADATA']['DATE_ACQUIRED'],
        mtl_dict['PRODUCT_METADATA']['SCENE_CENTER_TIME'])
    scene_dict['acquisitionDate'] = str(acq_datetime)
        
    scene_dict['cloudCover'] = mtl_dict['IMAGE_ATTRIBUTES']['CLOUD_COVER']
    scene_dict['processingLevel'] = mtl_dict['PRODUCT_METADATA']['DATA_TYPE']
    scene_dict['path'] = mtl_dict['PRODUCT_METADATA']['WRS_PATH']
    scene_dict['row'] = mtl_dict['PRODUCT_METADATA']['WRS_ROW']

    lats = [mtl_dict['PRODUCT_METADATA']['CORNER_LL_LAT_PRODUCT'],
            mtl_dict['PRODUCT_METADATA']['CORNER_LR_LAT_PRODUCT'],
            mtl_dict['PRODUCT_METADATA']['CORNER_UL_LAT_PRODUCT'],
            mtl_dict['PRODUCT_METADATA']['CORNER_UL_LAT_PRODUCT']]
    lons = [mtl_dict['PRODUCT_METADATA']['CORNER_LL_LON_PRODUCT'],
            mtl_dict['PRODUCT_METADATA']['CORNER_LR_LON_PRODUCT'],
            mtl_dict['PRODUCT_METADATA']['CORNER_UL_LON_PRODUCT'],
            mtl_dict['PRODUCT_METADATA']['CORNER_UL_LON_PRODUCT']]
        
    scene_dict['min_lat'] = min(lats)
    scene_dict['max_lat'] = max(lats)
    scene_dict['min_lon'] = min(lons)
    scene_dict['max_lon'] = max(lons)
    
    return scene_dict
コード例 #5
0
ファイル: usgsl1.py プロジェクト: GeospatialDaryl/pygaarst
 def __init__(self, dirname):
     self.dirname = dirname
     self.infix = ''
     metadata = mtl.parsemeta(dirname)
     self.meta = metadata['L1_METADATA_FILE']
     self.spacecraft = _get_spacecraftid(
         self.meta['PRODUCT_METADATA']['SPACECRAFT_ID']
         )
     self.sensor = self.meta['PRODUCT_METADATA']['SENSOR_ID']
     self.bands = {}
コード例 #6
0
ファイル: usgsl1.py プロジェクト: atedstone/pygaarst
 def __init__(self, dirname):
     self.dirname = dirname
     self.infix = ''
     metadata = mtl.parsemeta(dirname)
     self.meta = metadata['L1_METADATA_FILE']
     self.spacecraft = _get_spacecraftid(
         self.meta['PRODUCT_METADATA']['SPACECRAFT_ID']
         )
     self.sensor = self.meta['PRODUCT_METADATA']['SENSOR_ID']
     self.bands = {}
コード例 #7
0
ファイル: usgsl1.py プロジェクト: harshalgalgale/pygaarst
 def __init__(self, dirname):
     self.dirname = dirname
     self.infix = ''
     metadata = mtl.parsemeta(dirname)
     try:
         self.meta = metadata['L1_METADATA_FILE']
     except KeyError:
         raise PygaarstRasterError("Metadata from %s could not be read. " %
                                   dirname + " Please check your dataset.")
     self.spacecraft = _get_spacecraftid(
         self.meta['PRODUCT_METADATA']['SPACECRAFT_ID'])
     self.sensor = self.meta['PRODUCT_METADATA']['SENSOR_ID']
     self.bands = {}
コード例 #8
0
ファイル: usgsl1.py プロジェクト: harshalgalgale/pygaarst
 def __init__(self, filepath, band=None, scene=None):
     self.band = band
     self.scene = scene
     self.meta = None
     if self.scene:
         self.meta = self.scene.meta
     if not self.meta:
         try:
             self.meta = mtl.parsemeta(os.path.basename(self.filepath))
         except AttributeError:
             LOGGER.warning("Could not find metadata for band object. " +
                            "Set it explicitly: [bandobject].meta = " +
                            "pygaarst.mtlutils.parsemeta([metadatafile])")
     super(USGSL1band, self).__init__(filepath)
コード例 #9
0
ファイル: usgsl1.py プロジェクト: chris4540/pygaarst
 def __init__(self, filepath, band=None, scene=None):
     self.band = band
     self.scene = scene
     self.meta = None
     if self.scene:
         self.meta = self.scene.meta
     if not self.meta:
         try:
             self.meta = mtl.parsemeta(os.path.basename(self.filepath))
         except AttributeError:
             LOGGER.warning(
                 "Could not find metadata for band object. "
                 + "Set it explicitly: [bandobject].meta = "
                 +"pygaarst.mtlutils.parsemeta([metadatafile])"
             )
     super(USGSL1band, self).__init__(filepath)
コード例 #10
0
ファイル: usgsl1.py プロジェクト: chris4540/pygaarst
 def __init__(self, dirname):
     self.dirname = dirname
     self.infix = ''
     metadata = mtl.parsemeta(dirname)
     try:
         self.meta = metadata['L1_METADATA_FILE']
     except KeyError:
         raise PygaarstRasterError(
             "Metadata from %s could not be read. " % dirname 
             + " Please check your dataset."
         )
     self.spacecraft = _get_spacecraftid(
         self.meta['PRODUCT_METADATA']['SPACECRAFT_ID']
         )
     self.sensor = self.meta['PRODUCT_METADATA']['SENSOR_ID']
     self.bands = {}
コード例 #11
0
def test_read_MODL2_metadata_from_string():
    meta = mtl.parsemeta(MODL2meta)
    assert meta["INVENTORYMETADATA"]["ANCILLARYINPUTGRANULE"]["ANCILLARYINPUTPOINTER"] == 'MOD03.A2015167.0805.005.2015170114131.hdf'
    assert meta["INVENTORYMETADATA"]["ADDITIONALATTRIBUTES"]["AveragedBlackBodyTemperature"] == 290.01
    assert len(meta["INVENTORYMETADATA"]) == 4
コード例 #12
0
def test_read_metadata_L8():
    meta = mtl.parsemeta(metadatapaths[0])
    assert meta['L1_METADATA_FILE']['PRODUCT_METADATA']['SPACECRAFT_ID']  == 'LANDSAT_8'
    assert meta['L1_METADATA_FILE']['METADATA_FILE_INFO']['PROCESSING_SOFTWARE_VERSION'] == 'LPGS_2.2.2'
コード例 #13
0
ファイル: test_mtlutils.py プロジェクト: chris4540/pygaarst
def test_read_MODL2_metadata_from_string():
    meta = mtl.parsemeta(MODL2meta)
    assert meta["INVENTORYMETADATA"]["ANCILLARYINPUTGRANULE"]["ANCILLARYINPUTPOINTER"] == 'MOD03.A2015167.0805.005.2015170114131.hdf'
    assert meta["INVENTORYMETADATA"]["ADDITIONALATTRIBUTES"]["AveragedBlackBodyTemperature"] == 290.01
    assert len(meta["INVENTORYMETADATA"]) == 4
コード例 #14
0
ファイル: test_mtlutils.py プロジェクト: chris4540/pygaarst
def test_read_metadata_L8():
    meta = mtl.parsemeta(metadatapaths[0])
    assert meta['L1_METADATA_FILE']['PRODUCT_METADATA']['SPACECRAFT_ID']  == 'LANDSAT_8'
    assert meta['L1_METADATA_FILE']['METADATA_FILE_INFO']['PROCESSING_SOFTWARE_VERSION'] == 'LPGS_2.2.2'