def run(self, timeserieData, longitude=None, latitude=None, h=None, freq=None, startdate=None, enddate=None): freq = str(freq) if freq else self.frequency if (h is None): if self.time_change is not None and self.units is not None: h = bfast_utils.calculateMinimalSegmentSize( len(timeserieData), self.time_change, self.units, float(freq)) h = str(h) elif (h > 0.5): raise ValueError("minimum segment size error") startdate = str(startdate) if startdate else self.start_date enddate = str(enddate) if enddate else utils.isNow(self.end_date) # Must be in the following order: h, season, start_date, end_date, timeseriesData, freq bfast_result = check_output([ "integration/py/time-series/lib/bfast.r", str(h), self.season, startdate, enddate, str(timeserieData), freq ]) bfast_res_list = bfast_result.encode('utf-8').split(' ') bfast_res_float = map(float, bfast_res_list) return bfast_res_float
def lockup(self, longitude, latitude): result = [] for i in xrange(0, len(self.start_date)): datasourceInstance = loader.getDatasource(self.layers[i]) datasourceInstance.start_date = self.start_date[i] if self.end_date[i] == 'NOW': datasourceInstance.end_date = utils.isNow(self.end_date[i]) else: datasourceInstance.end_date = self.end_date[i] timeserieData = datasourceInstance.lockup(longitude, latitude) for j in timeserieData: result.append(j) return result
def lookup(self, geoJsonGeometry, mode=None): result = {"values":[]}; for i in xrange(0, len(self.start_date)): datasourceInstance = loader.getDatasource(self.layers[i]) datasourceInstance.start_date = self.start_date[i] if self.end_date[i] == 'NOW': datasourceInstance.end_date = utils.isNow(self.end_date[i]) else: datasourceInstance.end_date = self.end_date[i] timeserieData = datasourceInstance.lookup(geoJsonGeometry, mode) if "series" not in result: result["series"] = timeserieData["series"]; result["values"].extend(timeserieData["values"]); return result
def run(self, timeserieData, longitude = None, latitude = None, h = None, freq = None, startdate = None, enddate = None): freq = str(freq) if freq else self.frequency if(h is None): if self.time_change is not None and self.units is not None: h = bfast_utils.calculateMinimalSegmentSize(len(timeserieData), self.time_change, self.units, float(freq)) h = str(h) elif(h>0.5): raise ValueError("minimum segment size error") startdate = str(startdate) if startdate else self.start_date enddate = str(enddate) if enddate else utils.isNow(self.end_date) # Must be in the following order: h, season, start_date, end_date, timeseriesData, freq bfast_result = check_output(["integration/py/time-series/lib/bfast.r", str(h), self.season, startdate, enddate, str(timeserieData), freq]) bfast_res_list = bfast_result.encode('utf-8').split(' ') bfast_res_float = map(float, bfast_res_list) return bfast_res_float
def lookup(self, geoJsonGeometry, mode=None): result = { "values": [] } for i in xrange(0, len(self.start_date)): datasourceInstance = loader.getDatasource(self.layers[i]) datasourceInstance.start_date = self.start_date[i] if self.end_date[i] == 'NOW': datasourceInstance.end_date = utils.isNow(self.end_date[i]) else: datasourceInstance.end_date = self.end_date[i] timeserieData = datasourceInstance.lookup(geoJsonGeometry, mode) if "series" not in result: result["series"] = timeserieData["series"] result["values"].extend(timeserieData["values"]) return result
def __init__(self, layerParams): for key in layerParams: setattr(self, key, layerParams[key]) self.end_date = utils.isNow(self.end_date)