a #eW"@sddlZddlmZddlmZdedddded ddd ed ddd ed dddeddddedddedddeddddeddddedddedddeddddedddd ed!dd"ed#dd$ed%dd&ed'dd(ed)dd*ed+dd,ed-dd.ed/ddd0ed1ddd2ed3ddd4ed5dd6ed7dd8d9d:d;dZed?d@dPdBdCZedDd@dQdFdGZ edHd@dRdIdJZ edKd@dLdMZ dNdOZ dS)SN) lru_cache) gettext_lazyz(N - R) / (N + R)zLNormalized Difference Vegetation Index shows the amount of green vegetation.))exprhelprangez(G - B) / (G + B)zlNormalized difference yellowness index (NDYI), best model variability in relative yield potential in Canola.z(N - Re) / (N + Re)zlNormalized Difference Red Edge Index shows the amount of green vegetation of permanent or later stage crops.z(G - N) / (G + N)zTNormalized Difference Water Index shows the amount of water content in water bodies.z(N - B) / (N + B)z)((N + G) - (2 * B)) / ((N + G) + (2 * B))zEnhanced Normalized Difference Vegetation Index is like NDVI, but uses Blue and Green bands instead of only Red to isolate plant health.)rrz80.5268*((R ** -0.1294) * (G ** 0.3389) * (B ** -0.3118))z{Visible NDVI is an un-normalized index for RGB sensors using constants derived from citrus, grape, and sugarcane crop data.z(G - R) / (G + R - B)zBVisual Atmospheric Resistance Index shows the areas of vegetation.z(G - R) / (G + R)z(Modified Photochemical Reflectance Indexz(2 * G) - (R + B)znExcess Green Index (derived from only the RGB bands) emphasizes the greenness of leafy crops such as potatoes.z,1.0 / (((0.1 - R) ** 2) + ((0.06 - N) ** 2))zMBurn Area Index hightlights burned land in the red to near-infrared spectrum.z%((G * 2) - R - B) / ((G * 2) + R + B)z/Green Leaf Index shows greens leaves and stems.z(N - G) / (N + G)zpGreen Normalized Difference Vegetation Index is similar to NDVI, but measures the green spectrum instead of red.zN / GzMGreen Ratio Vegetation Index is sensitive to photosynthetic rates in forests.z(1.5 * (N - R)) / (N + R + 0.5)zSoil Adjusted Vegetation Index is similar to NDVI but attempts to remove the effects of soil areas using an adjustment factor (0.5).z)((N ** 2 - R) * 1.5) / (N ** 2 + R + 0.5)z\Modified Non-Linear Index improves the Non-Linear Index algorithm to account for soil areas.z!((N / R) - 1) / (sqrt(N / R) + 1)zjModified Simple Ratio is an improvement of the Simple Ratio (SR) index to be more sensitive to vegetation.z(N - R) / sqrt(N + R)zRenormalized Difference Vegetation Index uses the difference between near-IR and red, plus NDVI to show areas of healthy vegetation.z(1.5 * ((N - R) / sqrt(N ** 2 + R + 0.5))zZTransformed Difference Vegetation Index highlights vegetation cover in urban environments.z(N - R) / (N + R + 0.16)zOptimized Soil Adjusted Vegetation Index is based on SAVI, but tends to work better in areas with little vegetation where soil is visible.z73.618 * (2.5 * (N - R) / (N + 6*R - 7.5*B + 1)) * 0.118zALeaf Area Index estimates foliage areas and predicts crop yields.z%2.5 * (N - R) / (N + 6*R - 7.5*B + 1)zzEnhanced Vegetation Index is useful in areas where NDVI might saturate, by using blue wavelengths to correct soil signals.z%(N - (2 * R) + B) / (N + (2 * R) + B)zAtmospherically Resistant Vegetation Index. Useful when working with imagery for regions with high atmospheric aerosol content.LzTemperature in Celsius degrees.zL * 100 + 27315z#Temperature in Centikelvin degrees.zR + B)rr)rrrzR + (sqrt(B) ))ZNDVIZNDYIZNDREZNDWIz NDVI (Blue)ZENDVIZvNDVIZVARIZMPRIZEXGZBAIZGLIZGNDVIZGRVIZSAVIZMNLIZMSRZRDVIZTDVIZOSAVIZLAIZEVIZARVIZCelsiusZKelvinZ_TESTRBZ _TESTFUNC)RGBZRGNZNGBZNRGZNRBZRGBNZRGNReZGRReNZRGBNReZBGRNReZBGRReNZRGBReNZRGBNReLZBGRNReLZBGRReNLZRGBNRePLr )maxsizer c s|dur dSdurd|tvr,td|tddtdDfdd}td |td d t|d }t|d d}||fS)N)NNr zCannot find algorithm css|]}|dkr|VqdS)N).0brr/webodm/app/api/formulas.py z!lookup_formula..z ([A-Z][a-z]*)csR|d}zdt|dWStyLtd|ddYn0dS)NrrzCannot find band "z" from "z". Choose a proper band order.)groupstrindex ValueError)matchesr band_orderZ input_bandsrrrepls   zlookup_formula..repl([A-Z]+?[a-z]*)z\s+r rr)algosrtupleresplitsubget)algorrrhrangerrrlookup_formulas  r%cCsVg}tD]H}|drqtt|d|}t|dkr8q|||dt|q|S)N_rr)idfilters)r startswithget_camera_filters_forlenappend) max_bandsreskZ cam_filtersrrrget_algorithm_lists  r2dc Csg}td}ttt||}tD]X}d}ttt||}|D]}||vrF|d7}qF|t|kr&t||kr&||q&|S)Nrrr)rcompilelistsetfindallcamera_filtersr-r.) rr/resultpatternbandsfcountZfbandsrrrrr,s   r,rcCsXddgddgddgddgd d gd d gd dgd}i}|D]}||D] }|||<qDq8|S)NredrgreengbluernirnrededgerZpanchroplwirl)RGBNZRePr r)Z bands_aliases bands_lookupbandarrrget_bands_lookups   rQc Cst|}|std|t|d}t|d|}|sLtd|d|t}d}|D]<}|ddksZ|d stqZ||d }|durZ||7}qZ||vr|d fS|d d fSdS) NzCannot find formula: rrzCannot find filters for z with max bands r namealpha descriptionTrF)rr"rr-r,Z valueErrorrQlower) orthophoto_bandsformular#r/r*rNrrOZf_bandrrrget_auto_bandss$    rX)r )r')r') r functoolsrdjango.utils.translationrr(rr8r%r2r,rQrXrrrrs  ~