def landsat(self, operation, report_id, id): r = Report.get(Key(report_id)) z, x, y = Cell.cell_id(id) cell = Cell.get_or_default(r, operation, x, y, z) bounds = cell.bounds(amazon_bounds) bounds = "%f,%f,%f,%f" % (bounds[1][1], bounds[1][0], bounds[0][1], bounds[0][0]) ee = EELandsat(timestamp(r.start), datetime.datetime.now()) d = ee.list(bounds=bounds) data = {} if len(d) >= 1: x = d[-1] img_info = x.split('/')[2][3:] path = img_info[:3] row = img_info[3:6] year = int(img_info[6: 10]) julian_date = img_info[10: 13] date = date_from_julian(int(julian_date), year) data = { 'info': img_info, 'path': path, 'row': row, 'year': year, 'timestamp': timestamp(date), 'date': date.isoformat() } return Response(json.dumps(data), mimetype='application/json')
def default_maps(): maps = [] r = Report.current() logging.info("report " + unicode(r)) landsat = EELandsat(timestamp(r.start), datetime.datetime.now()) ndfi = NDFI(past_month_range(r.start), r.range()) logging.info('Past_month_range: '+str(past_month_range(r.start))+', Range: '+str(r.range)+', Timestamp: '+str(timestamp(r.start))+', Datetime: '+str(datetime.datetime.now()) ) d = landsat.mapid(timestamp(r.start), datetime.datetime.now()) maps.append({'data' :d, 'info': 'LANDSAT/LE7_L1T'}) d = landsat.mapid_landsat8(timestamp(r.start), datetime.datetime.now()) maps.append({'data':d, 'info': 'LANDSAT/LC8_L1T'}) assetid = r.previous().as_dict().get('assetid') logging.info("Assetid :"+str(assetid)) d = ndfi.smaid() if d: maps.append({'data': d, 'info': 'SMA'}) d = ndfi.rgb1id() if d: maps.append({'data': d, 'info': 'RGB'}) d = ndfi.ndfi0id('modis') if d: maps.append({'data': d, 'info': 'NDFI T0 (MODIS)'}) d = ndfi.ndfi1id('modis') if d: maps.append({'data' :d, 'info': 'NDFI T1 (MODIS)'}) d = ndfi.baseline(r.base_map()) if d: maps.append({'data' :d, 'info': 'Baseline'}) d = ndfi.rgb0id() if d: maps.append({'data': d, 'info': 'Previous RGB'}) return maps """
def landsat(self, report_id, id): r = Report.get(Key(report_id)) z, x, y = Cell.cell_id(id) cell = Cell.get_or_default(r, x, y, z) bounds = cell.bounds(amazon_bounds) bounds = "%f,%f,%f,%f" % (bounds[1][1], bounds[1][0], bounds[0][1], bounds[0][0]) ee = EELandsat(LANDSAT7) d = ee.list(bounds=bounds) data = {} if len(d) >= 1: x = d[-1] img_info = x.split('/')[2][3:] path = img_info[:3] row = img_info[3:6] year = int(img_info[6:10]) julian_date = img_info[10:13] date = date_from_julian(int(julian_date), year) data = { 'info': img_info, 'path': path, 'row': row, 'year': year, 'timestamp': timestamp(date), 'date': date.isoformat() } return Response(json.dumps(data), mimetype='application/json')
def landsat(self, report_id, id): r = Report.get(Key(report_id)) z, x, y = Cell.cell_id(id) cell = Cell.get_or_default(r, x, y, z) bounds = cell.bounds(amazon_bounds) bounds = "%f,%f,%f,%f" % (bounds[1][1], bounds[1][0], bounds[0][1], bounds[0][0]) ee = EELandsat(LANDSAT7) d = ee.list(bounds=bounds) data = {} if len(d) >= 1: x = d[-1] img_info = x.split("/")[2][3:] path = img_info[:3] row = img_info[3:6] year = int(img_info[6:10]) julian_date = img_info[10:13] date = date_from_julian(int(julian_date), year) data = { "info": img_info, "path": path, "row": row, "year": year, "timestamp": timestamp(date), "date": date.isoformat(), } return Response(json.dumps(data), mimetype="application/json")
def default_maps(): maps = [] r = Report.current() logging.info("report " + unicode(r)) landsat = EELandsat() ndfi = NDFI(past_month_range(r.start), r.range()) d = landsat.mapid(timestamp(r.start), datetime.datetime.now()) maps.append({'data' :d, 'info': 'LANDSAT/L7_L1T'}) """ d = landsat.mapid(*past_month_range(r.start)) maps.append({'data' :d, 'info': 'LANDSAT/L7_L1T-old'}) """ #d = ndfi.mapid2() #if d: maps.append({'data' :d, 'info': 'ndfi difference'}) d = ndfi.smaid() if d: maps.append({'data': d, 'info': 'SMA'}) d = ndfi.rgb1id() if d: maps.append({'data': d, 'info': 'RGB'}) d = ndfi.ndfi0id() if d: maps.append({'data': d, 'info': 'NDFI T0'}) d = ndfi.ndfi1id() if d: maps.append({'data' :d, 'info': 'NDFI T1'}) d = ndfi.baseline(r.base_map()) if d: maps.append({'data' :d, 'info': 'Baseline'}) d = ndfi.rgb0id() if d: maps.append({'data': d, 'info': 'Previous RGB'}) return maps
def test_note_list(self): rv = self.app.get('/api/v0/report/' + str(self.r.key()) + '/cell/2_0_0/note') self.assertEquals(200, rv.status_code) js = json.loads(rv.data) self.assertEquals(1, len(js)) n = js[0] self.assertEquals('test msg', n['msg']) self.assertEquals('test', n['author']) self.assertEquals(timestamp(self.when), n['date']) self.assertEquals(1, Note.all().count())
def default_maps(): maps = [] r = Report.current() logging.info("report " + unicode(r)) landsat = EELandsat() ndfi = NDFI(past_month_range(r.start), r.range()) d = landsat.mapid(timestamp(r.start), datetime.datetime.now()) maps.append({'data': d, 'info': 'LANDSAT/LE7_L1T'}) #d = ndfi.mapid2() #if d: maps.append({'data' :d, 'info': 'ndfi difference'}) d = ndfi.smaid() if d: maps.append({'data': d, 'info': 'SMA'}) d = ndfi.rgb1id() if d: maps.append({'data': d, 'info': 'RGB'}) d = ndfi.ndfi0id() if d: maps.append({'data': d, 'info': 'NDFI T0'}) d = ndfi.ndfi1id() if d: maps.append({'data': d, 'info': 'NDFI T1'}) d = ndfi.baseline(r.base_map()) if d: maps.append({'data': d, 'info': 'Baseline'}) d = ndfi.rgb0id() if d: maps.append({'data': d, 'info': 'Previous RGB'}) return maps