当前位置: 首页>>代码示例>>Python>>正文


Python GenericMetadata.readAssetProvenanceObjects方法代码示例

本文整理汇总了Python中ecohydrolib.metadata.GenericMetadata.readAssetProvenanceObjects方法的典型用法代码示例。如果您正苦于以下问题:Python GenericMetadata.readAssetProvenanceObjects方法的具体用法?Python GenericMetadata.readAssetProvenanceObjects怎么用?Python GenericMetadata.readAssetProvenanceObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ecohydrolib.metadata.GenericMetadata的用法示例。


在下文中一共展示了GenericMetadata.readAssetProvenanceObjects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_provenance_overwrite

# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import readAssetProvenanceObjects [as 别名]
 def test_provenance_overwrite(self):
     """ Test case writing provenance metadata, with overwrite """
     asset = AssetProvenance()
     asset.section = GenericMetadata.MANIFEST_SECTION
     asset.name = "dem"
     asset.dcIdentifier = "dem.tif"
     asset.dcSource = "http://www.demexplorer.com/..."
     asset.dcTitle = "Study area DEM"
     asset.dcDate = datetime.strptime("201303", "%Y%m")
     asset.dcPublisher = "USGS"
     asset.dcDescription = "RegisterDEM.py ..."
     asset.writeToMetadata(self.context)
     
     assetProvenance = GenericMetadata.readAssetProvenanceObjects(self.context)[0]
     self.assertTrue(asset.section == assetProvenance.section)
     self.assertTrue(asset.name == assetProvenance.name)
     self.assertTrue(asset.dcIdentifier == assetProvenance.dcIdentifier)
     self.assertTrue(asset.dcSource == assetProvenance.dcSource)
     self.assertTrue(asset.dcTitle == assetProvenance.dcTitle)
     self.assertTrue(asset.dcDate == assetProvenance.dcDate)
     self.assertTrue(asset.dcPublisher == assetProvenance.dcPublisher)
     self.assertTrue(asset.dcDescription == assetProvenance.dcDescription)
     
     asset.dcIdentifier = 'foo.img'
     asset.dcSource = "http://a.different.url/..."
     asset.dcTitle = "A different study area DEM"
     asset.dcDate = datetime.strptime("201304", "%Y%m")
     asset.dcPublisher = "NASA"
     asset.dcDescription = "GetDEMExplorerDEM.py ..."
     asset.writeToMetadata(self.context)
     
     assetProvenance = GenericMetadata.readAssetProvenanceObjects(self.context)[0]
     self.assertTrue(asset.section == assetProvenance.section)
     self.assertTrue(asset.name == assetProvenance.name)
     self.assertTrue(asset.dcIdentifier == assetProvenance.dcIdentifier)
     self.assertTrue(asset.dcSource == assetProvenance.dcSource)
     self.assertTrue(asset.dcTitle == assetProvenance.dcTitle)
     self.assertTrue(asset.dcDate == assetProvenance.dcDate)
     self.assertTrue(asset.dcPublisher == assetProvenance.dcPublisher)
     self.assertTrue(asset.dcDescription == assetProvenance.dcDescription)
开发者ID:dblodgett-usgs,项目名称:EcohydroLib,代码行数:42,代码来源:test_metadata.py

示例2: deleteShapefile

# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import readAssetProvenanceObjects [as 别名]
else:
    outfile = "catchment" 

tmpFilename = "%s%s%s" % (outfile, os.extsep, OGR_DRIVERS[OGR_SHAPEFILE_DRIVER_NAME])
shapeFilepath = os.path.join(context.projectDir, tmpFilename)

if not args.overwrite:
    if os.path.exists(shapeFilepath):
        sys.exit( textwrap.fill("Catchment shapefile already exists in project directory %s.  Use --overwrite option to overwrite." % \
                 args.projectDir ) )
elif os.path.exists(shapeFilepath):
    # Overwrite was specified
    deleteShapefile(shapeFilepath)

# Get provenance data for gage
gageProvenance = [i for i in GenericMetadata.readAssetProvenanceObjects(context) if i.name == 'gage'][0]
if gageProvenance is None:
    sys.exit("Unable to load gage provenance information from metadata")

# Get study area parameters
studyArea = GenericMetadata.readStudyAreaEntries(context)
reachcode = studyArea['nhd_gage_reachcode']
measure = studyArea['nhd_gage_measure_pct']

writeMetadata = False
if args.source == 'local':
    sys.stdout.write('Getting catchment area draining through gage using local NHDPlus dataset...')
    sys.stdout.flush()
    if not context.config.has_option('NHDPLUS2', 'PATH_OF_NHDPLUS2_DB'):
        sys.exit("Config file %s does not define option %s in section %s" % \
              (args.configfile, 'NHDPLUS2', 'PATH_OF_NHDPLUS2_DB'))
开发者ID:dblodgett-usgs,项目名称:EcohydroLib,代码行数:33,代码来源:GetCatchmentShapefileForNHDStreamflowGage.py

示例3: Context

# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import readAssetProvenanceObjects [as 别名]
                    help='The directory to which metadata, intermediate, and final files should be saved')
args = parser.parse_args()
cmdline = GenericMetadata.getCommandLine()

configFile = None
if args.configfile:
    configFile = args.configfile

context = Context(args.projectDir, configFile) 

if not context.config.has_option('SOLIM', 'PATH_OF_SOLIM'):
    sys.exit("Config file %s does not define option %s in section %s" & \
          (args.configfile, 'SOLIM', 'PATH_OF_SOLIM'))

# Get provenance data for SSURGO
ssurgoProvenance = [i for i in GenericMetadata.readAssetProvenanceObjects(context) if i.name == 'soil_features'][0]
if ssurgoProvenance is None:
    sys.exit("Unable to load SSURGO provenance information from metadata")

# Get manifest entries
manifest = GenericMetadata.readManifestEntries(context)
shpFilename = manifest['soil_features']
shpFilepath = os.path.join(context.projectDir, shpFilename)
demFilename = manifest['dem']
demFilepath = os.path.join(context.projectDir, demFilename)
layerName = os.path.splitext(shpFilename)[0]

# Get study area parameters
studyArea = GenericMetadata.readStudyAreaEntries(context)
outputrasterresolutionX = studyArea['dem_res_x']
outputrasterresolutionY = studyArea['dem_res_y']
开发者ID:jaa78,项目名称:EcohydroLib,代码行数:33,代码来源:GenerateSoilPropertyRastersFromSOLIM.py

示例4: writeDictToXMLFile

# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import readAssetProvenanceObjects [as 别名]
outfile = codecs.getwriter('utf-8')(open(outfilePath, 'w')) 
outfile.write('<?xml version="1.0" encoding="UTF-8" ?>\n')
outfile.write('<metadata>\n')

# Write study area metadata to collection root
writeDictToXMLFile(outfile,  collection, GenericMetadata.readStudyAreaEntries(context))

# Write processing history to collection root
history = GenericMetadata.getProcessingHistoryList(context)
i = 1
for entry in history:
    attribute = "processing_step_%d" % (i,); i += 1
    writeAVUToXMLFile(outfile, collection, attribute, entry)

# Write provenance to each item in the manifest
provenance = GenericMetadata.readAssetProvenanceObjects(context)
for entry in provenance:
    target = collection + PATH_SEP_IRODS + entry.dcIdentifier
    writeAVUToXMLFile(outfile, target, 'name', entry.name)
    writeAVUToXMLFile(outfile, target, 'dc.source', entry.dcSource)
    writeAVUToXMLFile(outfile, target, 'dc.title', entry.dcTitle)
    writeAVUToXMLFile(outfile, target, 'dc.date', entry.dcDate.strftime(AssetProvenance.FMT_DATE))
    writeAVUToXMLFile(outfile, target, 'dc.publisher', entry.dcPublisher)
    writeAVUToXMLFile(outfile, target, 'dc.description', entry.dcDescription)
    
# Write point climate station metadata to the data file for that station
stations = GenericMetadata.readClimatePointStations(context)
for station in stations:
    target = collection + PATH_SEP_IRODS + station.data
    writeAVUToXMLFile(outfile, target, 'id', station.id)
    writeAVUToXMLFile(outfile, target, 'name', station.name)
开发者ID:dblodgett-usgs,项目名称:EcohydroLib,代码行数:33,代码来源:DumpMetadataToiRODSXML.py


注:本文中的ecohydrolib.metadata.GenericMetadata.readAssetProvenanceObjects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。