Skip to content

Commit

Permalink
Merge pull request #52 from biplovbhandari/docs_update#1_paper
Browse files Browse the repository at this point in the history
update docs | remove unwanted imports | remove blank spaces
  • Loading branch information
KMarkert authored Jun 19, 2024
2 parents 400bc20 + 7d7efbd commit a9ca48a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
10 changes: 5 additions & 5 deletions hydrafloods/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,20 +1032,20 @@ def _dedupe(id):
id_collection
.mosaic()
)

imgbounds = id_collection.map(lambda x: x.geometry(1e3))

start_time = id_collection.aggregate_array('system:time_start').reduce(ee.Reducer.min())
end_time = id_collection.aggregate_array('system:time_start').reduce(ee.Reducer.max())

return image.clipToCollection(imgbounds).set(
{
'system:time_start': start_time,
'system:time_start': start_time,
'system:time_end':end_time,
'system:index':id
}
)

datatakes = (
self.collection
.aggregate_histogram("DATATAKE_IDENTIFIER")
Expand Down
38 changes: 17 additions & 21 deletions hydrafloods/indices.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# module to host index functions for image transformations
import ee
from ee.ee_exception import EEException
import math
import string
import random
import datetime
from hydrafloods import decorators


Expand Down Expand Up @@ -45,7 +40,7 @@ def evi(img):

@decorators.keep_attrs
def mndwi(img):
"""Function to calculate modified Difference Water Index (MNDWI).
"""Function to calculate Modified Difference Water Index (MNDWI).
Expects image has "green" and "swir1" bands.
args:
Expand All @@ -59,7 +54,7 @@ def mndwi(img):

@decorators.keep_attrs
def nwi(img):
"""Function to calculate new water index (NWI).
"""Function to calculate New Water Index (NWI).
Expects image has "blue", "nir", "swir1" and "swir2" bands.
args:
Expand All @@ -81,7 +76,7 @@ def nwi(img):

@decorators.keep_attrs
def gwi(img):
"""Function to calculate general water index (GWI)
"""Function to calculate General Water Index (GWI)
Expects image has "green", "red", "nir", and "swir1" bands.
args:
Expand All @@ -103,7 +98,7 @@ def gwi(img):

@decorators.keep_attrs
def aewinsh(img):
"""Function to calculate automated water extraction index (AEWI) no shadow
"""Function to calculate Automated Water Extraction Index no shadow (AEWInsh)
Expects image has "green", "nir", "swir1" and "swir2" bands.
args:
Expand All @@ -125,7 +120,7 @@ def aewinsh(img):

@decorators.keep_attrs
def aewish(img):
"""Function to calculate automated water extraction index (AEWI) shadow
"""Function to calculate Automated Water Extraction Index shadow (AEWIsh)
Expects image has "blue", "green", "nir", "swir1" and "swir2" bands.
args:
Expand All @@ -148,7 +143,7 @@ def aewish(img):

@decorators.keep_attrs
def lswi(img):
"""Function to calculate land surface water index (LSWI).
"""Function to calculate Land Surface Water Index (LSWI).
Expects image has "nir" and "swir1" bands.
args:
Expand All @@ -164,7 +159,7 @@ def lswi(img):

@decorators.keep_attrs
def wri(img):
"""Function to calculate water ratio index (WRI).
"""Function to calculate Water Ratio Index (WRI).
Expects image has "green", "red", "nir" and "swir1" bands.
args:
Expand All @@ -186,7 +181,7 @@ def wri(img):

@decorators.keep_attrs
def mbwi(img, factor=3):
"""Function to calculate multi band water index (MBWI).
"""Function to calculate Multi Band Water Index (MBWI).
Expects image has "green", "red", "nir", "swir1", and "swir2" bands.
https://doi.org/10.1016/j.jag.2018.01.018
Expand Down Expand Up @@ -226,19 +221,20 @@ def mwi(img):


@decorators.keep_attrs
def rfi(img):
"""Function to calculate SAR RFI index.
def rvi(img):
"""Function to calculate SAR Radar Vegetation Index (RVI) index.
See more here: https://pro.arcgis.com/en/pro-app/latest/help/analysis/raster-functions/sar-indices-function.htm
Expects image has "VV" and "VH" bands.
args:
img (ee.Image): image to calculate RFI
img (ee.Image): image to calculate RVI
returns:
ee.Image: RFI image
ee.Image: RVI image
"""
return img.expression(
"(4*VH)/(VV+VH)", {"VV": img.select("VV"), "VH": img.select("VH")}
).rename("rfi")
).rename("rvi")


@decorators.keep_attrs
Expand Down Expand Up @@ -273,7 +269,7 @@ def vv_vh_abs_sum(img):

@decorators.keep_attrs
def ndpi(img):
"""Function to calculate nomalized difference polarization index (NDPI).
"""Function to calculate Normalized Difference Polarization Index (NDPI).
Expects image has "VV" and "VH" bands.
args:
Expand All @@ -289,7 +285,7 @@ def ndpi(img):

@decorators.keep_attrs
def nvvi(img):
"""Function to calculate nomalized VV index (NVVI).
"""Function to calculate Normalized VV Index (NVVI).
Expects image has "VV" and "VH" bands.
args:
Expand All @@ -305,7 +301,7 @@ def nvvi(img):

@decorators.keep_attrs
def nvhi(img):
"""Function to calculate nomalized VH index (NVHI).
"""Function to calculate Normalized VH Index (NVHI).
Expects image has "VV" and "VH" bands.
args:
Expand Down

0 comments on commit a9ca48a

Please sign in to comment.