def submit_mosaic_with_months_request(xa,ya,start,end,sats,ba,ma): rid = make_rid() x_arr = [int(x) for x in xa.split(',')] y_arr = [int(y) for y in ya.split(',')] s_arr = [Satellite[s] for s in sats.split(',')] endDate=datetime.strptime(end,"%Y-%m-%d") startDate=datetime.strptime(start,"%Y-%m-%d") m_arr = [int(m) for m in ma.split(',')] b_arr = [] be_arr = ba.split(',') for s in s_arr: for b in be_arr: if s ==Satellite.LS5 or s==Satellite.LS7: try: tmp = Ls57Arg25Bands[b] b_arr.append(tmp) except KeyError: pass elif s==Satellite.LS8: try: tmp = Ls8Arg25Bands[b] b_arr.append(tmp) except KeyError: pass processes[rid] = chord(group(obtain_cloudfree_mosaic.s(x,y,startDate,endDate, b_arr, s_arr,0,4000,4000,"GTiff",gdal.GDT_CInt16,m_arr) for x in x_arr for y in y_arr ),assemble_mosaic.s()).apply_async() posQ = get_queue_length() return "{\"request\":\""+rid+"\",\"position\":\""+str(posQ)+"\"}"
def submit_preview_request(xa,ya,start,end,sats,ba): try: rid = make_rid() x_arr = [int(x) for x in xa.split(',')] y_arr = [int(y) for y in ya.split(',')] s_arr = [Satellite[s] for s in sats.split(',')] endDate=datetime.strptime(end,"%Y-%m-%d") startDate=datetime.strptime(start,"%Y-%m-%d") b_arr = [] be_arr = ba.split(',') for s in s_arr: for b in be_arr: if s ==Satellite.LS5 or s==Satellite.LS7: try: tmp = Ls57Arg25Bands[b] b_arr.append(tmp) except KeyError: pass elif s==Satellite.LS8: try: tmp = Ls8Arg25Bands[b] b_arr.append(tmp) except KeyError: pass processes[rid] = chord(group(obtain_cloudfree_mosaic.s(x,y,startDate,endDate, b_arr, s_arr,5,4000,4000,"GTiff",gdal.GDT_CInt16,None) for x in x_arr for y in y_arr ),assemble_mosaic.s()).apply_async() return "{\"request\":\""+rid+"\"}" except: return "{\"request\":\"WAIT\"}"
def mosaic_tci_b_submit(xa,ya,start,end,sats): rid = make_rid() x_arr = [int(x) for x in xa.split(',')] y_arr = [int(y) for y in ya.split(',')] s_arr = [Satellite[s] for s in sats.split(',')] endDate=datetime.strptime(end,"%Y-%m-%d") startDate=datetime.strptime(start,"%Y-%m-%d") bands=[Ls57Arg25Bands.BLUE, Ls57Arg25Bands.GREEN, Ls57Arg25Bands.RED, Ls57Arg25Bands.NEAR_INFRARED, Ls57Arg25Bands.SHORT_WAVE_INFRARED_1, Ls57Arg25Bands.SHORT_WAVE_INFRARED_2] expressions_list=["0.3561*band1 + 0.3972*band2 + 0.3904*band3 + 0.6966*band4 + 0.2286*band5 + 0.1596*band6","-0.3344*band1 - 0.3544*band2 - 0.4556*band3 + 0.6966*band4 - 0.0242*band5 - 0.2630*band6","0.2626*band1 + 0.2141*band2 + 0.0926*band3 + 0.0656*band4 - 0.7629*band5 - 0.5388*band6"] no_scale.append(rid) processes[rid]=chord(chord((obtain_cloudfree_mosaic.s(x,y,startDate,endDate, bands, s_arr,0,4000,4000,"GTiff",gdal.GDT_CInt16,None)|obtain_file_from_math.s(expressions_list=expressions_list,file_format="GTiff",data_type=gdal.GDT_CFloat32,input_ndv=-999,output_ndv=-999) for x in x_arr for y in y_arr),assemble_mosaic.s()),apply_color_table_to_files.s(output_band=1,color_table="/tilestore/colortables/brightness-color.txt")).apply_async() return "{\"request\":\""+rid+"\"}"
def mosaic_ndvi_submit(xa,ya,start,end,sats): rid = make_rid() x_arr = [int(x) for x in xa.split(',')] y_arr = [int(y) for y in ya.split(',')] s_arr = [Satellite[s] for s in sats.split(',')] endDate=datetime.strptime(end,"%Y-%m-%d") startDate=datetime.strptime(start,"%Y-%m-%d") bands=[Ls57Arg25Bands.RED, Ls57Arg25Bands.NEAR_INFRARED] expressions_list=["(band2 - band1) / (band2 + band1)"] no_scale.append(rid) processes[rid]=chord(chord((obtain_cloudfree_mosaic.s(x,y,startDate,endDate, bands, s_arr,0,4000,4000,"GTiff",gdal.GDT_CInt16,None)|obtain_file_from_math.s(expressions_list=expressions_list,file_format="GTiff",data_type=gdal.GDT_CFloat32,input_ndv=-999,output_ndv=-999) for x in x_arr for y in y_arr),assemble_mosaic.s()),apply_color_table_to_files.s(output_band=1,color_table="/tilestore/colortables/vegetation-color.txt")).apply_async() return "{\"request\":\""+rid+"\"}"