Skip to content
This repository has been archived by the owner on Jun 14, 2021. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Aug 15, 2017
1 parent 1478c4c commit 79255fc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
19 changes: 5 additions & 14 deletions remotepixel/remotepixel/l8_full.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import json
import concurrent

import boto3
import numpy as np
Expand All @@ -14,10 +13,6 @@
##############################################################
def create(scene, bucket, bands=[4,3,2]):

def worker(window, address):
with rio.open(address) as src:
return src.read(window=window, boundless=True, indexes=1)

scene_params = utils.landsat_parse_scene_id(scene)
meta_data = utils.landsat_get_mtl(scene)
landsat_address = f's3://landsat-pds/{scene_params["key"]}'
Expand All @@ -41,15 +36,11 @@ def worker(window, address):
MR = float(utils.landsat_mtl_extract(meta_data, f'REFLECTANCE_MULT_BAND_{bands[b]}'))
AR = float(utils.landsat_mtl_extract(meta_data, f'REFLECTANCE_ADD_BAND_{bands[b]}'))

with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
future_to_window = {
executor.submit(worker, window, band_address): window
for window in wind}

for future in concurrent.futures.as_completed(future_to_window):
window = future_to_window[future]
result = reflectance.reflectance(future.result(), MR, AR, E, src_nodata=0) * 10000
dataset.write(result.astype(np.uint16), indexes=b+1, window=window)
with rio.open(band_address) as src:
for window in wind:
matrix = src.read(window=window, boundless=True, indexes=1)
result = reflectance.reflectance(matrix, MR, AR, E, src_nodata=0) * 10000
dataset.write(result.astype(np.uint16), window=window, indexes=b+1)

client = boto3.client('s3')
str_band = ''.join(map(str, bands))
Expand Down
2 changes: 1 addition & 1 deletion remotepixel/remotepixel/l8_ndvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def point(scene, coord):
out = {
'ndvi': ratio,
'date': scene_params['date'],
'cloud': float(utils.landsat_mtl_extract(meta_data, 'CLOUD_COVER'))
'cloud': utils.landsat_mtl_extract(meta_data, 'CLOUD_COVER')
}

return out
Expand Down
2 changes: 1 addition & 1 deletion remotepixel/remotepixel/s2_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}


def create(scene, bucket, bands=[4,3,2]):
def create(scene, bucket, bands=['04','03','02']):

scene_params = utils.sentinel_parse_scene_id(scene)
sentinel_address = f's3://sentinel-s2-l1c/{scene_params["key"]}'
Expand Down

0 comments on commit 79255fc

Please sign in to comment.