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


Python GenericMetadata.readClimatePointStations方法代码示例

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


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

示例1: test_write_climate_point1_overwrite

# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import readClimatePointStations [as 别名]
 def test_write_climate_point1_overwrite(self):
     """ Test case where there is a single data file the station, the entry is overwritten """
     station = ClimatePointStation()
     station.type = "GHCN"
     station.id = "US1MDBL0027"
     station.longitude = -76.716
     station.latitude = 39.317
     station.elevation = 128.0
     station.name = "My station name"
     station.data = "clim.txt"
     station.startDate = datetime.strptime("201007", "%Y%m")
     station.endDate = datetime.strptime("201110", "%Y%m")
     station.variables = [ClimatePointStation.VAR_PRECIP, \
                          ClimatePointStation.VAR_SNOW]
     station.writeToMetadata(self.context)
     
     climatePointStation = GenericMetadata.readClimatePointStations(self.context)[0]  
     self.assertTrue(station.type.lower() == climatePointStation.type)
     self.assertTrue(station.id.lower() == climatePointStation.id)
     self.assertTrue(station.longitude == climatePointStation.longitude)
     self.assertTrue(station.latitude == climatePointStation.latitude)
     self.assertTrue(station.elevation == climatePointStation.elevation)
     self.assertTrue(station.name == climatePointStation.name)
     self.assertTrue(station.data == climatePointStation.data)
     self.assertTrue(station.startDate == climatePointStation.startDate)
     self.assertTrue(station.endDate == climatePointStation.endDate)
     self.assertTrue(station.variables == climatePointStation.variables)
     
     station.longitude = -76.716
     station.latitude = 39.317
     station.elevation = 128.0
     station.name = "My (longer) station name"
     station.data = "clim.dat"
     station.startDate = datetime.strptime("201006", "%Y%m")
     station.endDate = datetime.strptime("201310", "%Y%m")
     station.variables = [ClimatePointStation.VAR_PRECIP, \
                          ClimatePointStation.VAR_SNOW]
     station.writeToMetadata(self.context)
     
     climatePointStation = GenericMetadata.readClimatePointStations(self.context)[0]  
     self.assertTrue(station.type.lower() == climatePointStation.type)
     self.assertTrue(station.id.lower() == climatePointStation.id)
     self.assertTrue(station.longitude == climatePointStation.longitude)
     self.assertTrue(station.latitude == climatePointStation.latitude)
     self.assertTrue(station.elevation == climatePointStation.elevation)
     self.assertTrue(station.name == climatePointStation.name)
     self.assertTrue(station.data == climatePointStation.data)
     self.assertTrue(station.startDate == climatePointStation.startDate)
     self.assertTrue(station.endDate == climatePointStation.endDate)
     self.assertTrue(station.variables == climatePointStation.variables)
开发者ID:dblodgett-usgs,项目名称:EcohydroLib,代码行数:52,代码来源:test_metadata.py

示例2: test_write_climate_point2

# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import readClimatePointStations [as 别名]
 def test_write_climate_point2(self):
     """ Test case where there are separate data files for each variable and there are two climate stations """
     station = ClimatePointStation()
     station.type = "GHCN"
     station.id = "US1MDBL0027"
     station.longitude = -76.716
     station.latitude = 39.317
     station.elevation = 128.0
     station.name = "My station name"
     station.startDate = datetime.strptime("201007", "%Y%m")
     station.endDate = datetime.strptime("201110", "%Y%m")
     station.variables = [ClimatePointStation.VAR_PRECIP, \
                          ClimatePointStation.VAR_SNOW]
     station.variablesData[ClimatePointStation.VAR_PRECIP] = ClimatePointStation.VAR_PRECIP + '.txt'
     station.variablesData[ClimatePointStation.VAR_SNOW] = ClimatePointStation.VAR_SNOW + '.txt'
     station.writeToMetadata(self.context)
     
     station2 = ClimatePointStation()
     station2.type = "GHCN"
     station2.id = "US1MDBL4242"
     station2.longitude = -42.716
     station2.latitude = 42.317
     station2.elevation = 42.0
     station2.name = "My 42 station"
     station2.startDate = datetime.strptime("199907", "%Y%m")
     station2.endDate = datetime.strptime("200110", "%Y%m")
     station2.variables = [ClimatePointStation.VAR_PRECIP, \
                          ClimatePointStation.VAR_SNOW]
     station2.variablesData[ClimatePointStation.VAR_PRECIP] = ClimatePointStation.VAR_PRECIP + '.txt'
     station2.variablesData[ClimatePointStation.VAR_SNOW] = ClimatePointStation.VAR_SNOW + '.txt'
     station2.writeToMetadata(self.context)
     
     climatePointStation = GenericMetadata.readClimatePointStations(self.context)[0]        
     self.assertTrue(station.type.lower() == climatePointStation.type)
     self.assertTrue(station.id.lower() == climatePointStation.id)
     self.assertTrue(station.longitude == climatePointStation.longitude)
     self.assertTrue(station.latitude == climatePointStation.latitude)
     self.assertTrue(station.elevation == climatePointStation.elevation)
     self.assertTrue(station.name == climatePointStation.name)
     self.assertTrue(station.startDate == climatePointStation.startDate)
     self.assertTrue(station.endDate == climatePointStation.endDate)
     self.assertTrue(station.variables == climatePointStation.variables)
     self.assertTrue(station.variablesData[ClimatePointStation.VAR_PRECIP] == climatePointStation.variablesData[ClimatePointStation.VAR_PRECIP])
     self.assertTrue(station.variablesData[ClimatePointStation.VAR_SNOW] == climatePointStation.variablesData[ClimatePointStation.VAR_SNOW])
开发者ID:dblodgett-usgs,项目名称:EcohydroLib,代码行数:46,代码来源:test_metadata.py

示例3: Context

# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import readClimatePointStations [as 别名]
Usage:
@code
DumpClimateStationInfo.py -p /path/to/project_dir > file.csv
@endcode
"""
import sys
import os
import argparse

from ecohydrolib.context import Context
from ecohydrolib.metadata import GenericMetadata

parser = argparse.ArgumentParser(description='Dump point climate station information from EcohydroLib metadata to standard output')
parser.add_argument('-p', '--projectDir', dest='projectDir', required=True,
                    help='The directory from which metadata should be read')
parser.add_argument('-s', '--separator', dest='separator', required=False, default=',', help='Field separator for output')
args = parser.parse_args()

context = Context(args.projectDir, None) 

s = args.separator

sys.stderr.write("Getting stations from metadata... ")
stations = GenericMetadata.readClimatePointStations(context)
sys.stderr.write("done\n")

for station in stations:
    output = station.id.upper() + s + str(station.latitude) + s + str(station.longitude) + s + str(station.elevation) + s + station.name + os.linesep
    sys.stdout.write(output)
开发者ID:dblodgett-usgs,项目名称:EcohydroLib,代码行数:31,代码来源:DumpClimateStationInfo.py


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