Beispiel #1
0
	def getCDO(self):
		"""

		@param source:
		@return: @raise:
		"""
		try:
			conn = self.connF(self.source)
		except:
			logging.critical( 'Failed to load %s' % self.source )
			raise
		else:
			cdo = metaData(meta={'dt': conn.cliSetMeta['dt']}, dataConnection=conn)
		return cdo, conn
Beispiel #2
0
	def calcRegionalMean(self, reg, mod, replace=False):
		assert reg in self.regions, "Region have not been added"
		assert mod in self.models, "Model have not been added"
		modObj = self.models[mod]['cdo']
		thisShp = self.homesrc + 'regshp\\%s.shp' % reg
		dots = modObj.setStInShape(thisShp)
		if len(dots)>0:
			regModelObj = metaData(modObj.meta, stList=[modObj[d] for d in dots])
			cdo = regModelObj.setRegAvgData(greedy=True)
			cdo.save(self.getModelDataSrc(reg,mod), replace=replace)
		else:
			cdo=None
			logging.warning('no model data for region %s for model %s'%(str(reg),mod))
		self.regionMeanData[reg][mod] = cdo
		return cdo
Beispiel #3
0
	def calcObsRegMean(self,reg, replace=False):
		shp = self.homesrc + 'regshp\\%s.shp' % reg
		shpobj=shpFile2shpobj(shp)
		if type(shpobj) is list:
			shpobj.sort(key=lambda a:a.area)
			shpobj=shpobj[0]
		vr=voronoi(self.obsDataSet, shpobj)
		vra={i:s.area for i,s in vr.items() if s is not None}
		vraSum=sum(vra.values())
		vra={i:s/vraSum for i,s in vra.items()}
		# dots = self.obsDataSet.setStInShape(shp)
		if len(vra)>0:
			regObsObj = metaData(self.obsDataSet.meta, stList=[self.obsDataSet[d] for d in vra])
			cdo = regObsObj.setRegAvgData(greedy=True, weight=vra)
			cdo.save(self.getObsDataSrc(reg), replace=replace)
		else:
			cdo=None
			logging.warning('no observations for region %s'%str(reg))
		self.obsMeanData[reg]=cdo
		return cdo