// VERSION=3// QuickFire V1.0.0 by Pierre Markuse (https://twitter.com/Pierre_Markuse)// Made for use in the Sentinel Hub EO Browser (https://apps.sentinel-hub.com/eo-browser/?)// CC BY 4.0 International (https://creativecommons.org/licenses/by/4.0/)functionsetup(){return{input:["B01","B02","B03","B04","B08","B8A","B11","B12","CLP","dataMask"],output:{bands:4}};}functionstretch(val,min,max){return(val-min)/(max-min);}functionsatEnh(arr,s){varavg=arr.reduce((a,b)=>a+b,0)/arr.length;returnarr.map(a=>avg*(1-s)+a*s);}functionlayerBlend(lay1,lay2,lay3,op1,op2,op3){returnlay1.map(function(num,index){return(num/100*op1+(lay2[index]/100*op2)+(lay3[index]/100*op3));});}functionevaluatePixel(sample){consthsThreshold=[2.0,1.5,1.25,1.0];consthotspot=1;conststyle=1;consthsSensitivity=1.0;constboost=1;constcloudAvoidance=1;constcloudAvoidanceThreshold=245;constavoidanceHelper=0.8;constoffset=-0.000;constsaturation=1.10;constbrightness=1.00;constsMin=0.01;constsMax=0.99;constshowBurnscars=0;constburnscarThreshold=-0.25;constburnscarStrength=0.3;constNDWI=(sample.B03-sample.B08)/(sample.B03+sample.B08);constNDVI=(sample.B08-sample.B04)/(sample.B08+sample.B04);constwaterHighlight=0;constwaterBoost=2.0;constNDVI_threshold=-0.15;constNDWI_threshold=0.15;constwaterHelper=0.2;constBlack=[0,0,0];constNBRindex=(sample.B08-sample.B12)/(sample.B08+sample.B12);constnaturalColorsCC=[Math.sqrt(brightness*sample.B04+offset),Math.sqrt(brightness*sample.B03+offset),Math.sqrt(brightness*sample.B02+offset)];constnaturalColors=[(2.5*brightness*sample.B04+offset),(2.5*brightness*sample.B03+offset),(2.5*brightness*sample.B02+offset)];constURBAN=[Math.sqrt(brightness*sample.B12*1.2+offset),Math.sqrt(brightness*sample.B11*1.4+offset),Math.sqrt(brightness*sample.B04+offset)];constSWIR=[Math.sqrt(brightness*sample.B12+offset),Math.sqrt(brightness*sample.B8A+offset),Math.sqrt(brightness*sample.B04+offset)];constNIRblue=colorBlend(sample.B08,[0,0.25,1],[[0/255,0/255,0/255],[0/255,100/255,175/255],[150/255,230/255,255/255]]);constclassicFalse=[sample.B08*brightness,sample.B04*brightness,sample.B03*brightness];constNIR=[sample.B08*brightness,sample.B08*brightness,sample.B08*brightness];constatmoPen=[sample.B12*brightness,sample.B11*brightness,sample.B08*brightness];varenhNaturalColors=[0,0,0];for(leti=0;i<3;i+=1){enhNaturalColors[i]=(brightness*((naturalColors[i]+naturalColorsCC[i])/2)+(URBAN[i]/10));}constmanualCorrection=[0.00,0.00,0.00];varViz=layerBlend(URBAN,naturalColors,naturalColorsCC,10,40,50);// Choose visualization(s) and opacity hereif(waterHighlight){if((NDVI<NDVI_threshold)&&(NDWI>NDWI_threshold)&&(sample.B04<waterHelper)){Viz[1]=Viz[1]*1.2*waterBoost+0.1;Viz[2]=Viz[2]*1.5*waterBoost+0.2;}}Viz=satEnh(Viz,saturation);for(leti=0;i<3;i+=1){Viz[i]=stretch(Viz[i],sMin,sMax);Viz[i]+=manualCorrection[i];}if(hotspot){if((!cloudAvoidance)||((sample.CLP<cloudAvoidanceThreshold)&&(sample.B02<avoidanceHelper))){switch(style){case1:if((sample.B12+sample.B11)>(hsThreshold[0]/hsSensitivity))return[((boost*0.50*sample.B12)+Viz[0]),((boost*0.50*sample.B11)+Viz[1]),Viz[2],sample.dataMask];if((sample.B12+sample.B11)>(hsThreshold[1]/hsSensitivity))return[((boost*0.50*sample.B12)+Viz[0]),((boost*0.20*sample.B11)+Viz[1]),Viz[2],sample.dataMask];if((sample.B12+sample.B11)>(hsThreshold[2]/hsSensitivity))return[((boost*0.50*sample.B12)+Viz[0]),((boost*0.10*sample.B11)+Viz[1]),Viz[2],sample.dataMask];if((sample.B12+sample.B11)>(hsThreshold[3]/hsSensitivity))return[((boost*0.50*sample.B12)+Viz[0]),((boost*0.00*sample.B11)+Viz[1]),Viz[2],sample.dataMask];break;case2:if((sample.B12+sample.B11)>(hsThreshold[3]/hsSensitivity))return[1,0,0,sample.dataMask];break;case3:if((sample.B12+sample.B11)>(hsThreshold[3]/hsSensitivity))return[1,1,0,sample.dataMask];break;case4:if((sample.B12+sample.B11)>(hsThreshold[3]/hsSensitivity))return[Viz[0]+0.2,Viz[1]-0.2,Viz[2]-0.2,sample.dataMask];break;default:}}}if(showBurnscars){if(NBRindex<burnscarThreshold){Viz[0]=Viz[0]+burnscarStrength;Viz[1]=Viz[1]+burnscarStrength;}}return[Viz[0],Viz[1],Viz[2],sample.dataMask];}