本文整理汇总了Python中pthelma.timeseries.Timeseries.read_meta方法的典型用法代码示例。如果您正苦于以下问题:Python Timeseries.read_meta方法的具体用法?Python Timeseries.read_meta怎么用?Python Timeseries.read_meta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pthelma.timeseries.Timeseries
的用法示例。
在下文中一共展示了Timeseries.read_meta方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: time_step
# 需要导入模块: from pthelma.timeseries import Timeseries [as 别名]
# 或者: from pthelma.timeseries.Timeseries import read_meta [as 别名]
def time_step(self):
"""
Return time step of all time series. If time step is not the same
for all time series, raises exception.
"""
time_step = None
for filename in self.files:
with open(filename) as f:
t = Timeseries()
t.read_meta(f)
item_time_step = (t.time_step.length_minutes,
t.time_step.length_months)
if time_step and (item_time_step != time_step):
raise WrongValueError(
'Not all time series have the same step')
time_step = item_time_step
return time_step
示例2: create_ogr_layer_from_timeseries
# 需要导入模块: from pthelma.timeseries import Timeseries [as 别名]
# 或者: from pthelma.timeseries.Timeseries import read_meta [as 别名]
def create_ogr_layer_from_timeseries(filenames, epsg, data_source):
# Prepare the co-ordinate transformation from WGS84 to epsg
source_sr = osr.SpatialReference()
source_sr.ImportFromEPSG(4326)
target_sr = osr.SpatialReference()
target_sr.ImportFromEPSG(epsg)
transform = osr.CoordinateTransformation(source_sr, target_sr)
layer = data_source.CreateLayer('stations', target_sr)
layer.CreateField(ogr.FieldDefn('filename', ogr.OFTString))
for filename in filenames:
with open(filename) as f:
ts = Timeseries()
ts.read_meta(f)
point = ogr.Geometry(ogr.wkbPoint)
point.AddPoint(ts.location['abscissa'], ts.location['ordinate'])
point.Transform(transform)
f = ogr.Feature(layer.GetLayerDefn())
f.SetGeometry(point)
f.SetField('filename', filename)
layer.CreateFeature(f)
return layer