hydroanomaly 0.7.2__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hydroanomaly
3
- Version: 0.7.2
3
+ Version: 1.0.0
4
4
  Summary: A Python package for hydro anomaly detection with simple USGS data retrieval
5
5
  Author-email: Ehsan Kahrizi <ehsan.kahrizi@usu.edu>
6
6
  License: MIT License
@@ -9,12 +9,12 @@ A simple Python package with just 3 modules:
9
9
  That's it - nothing else!
10
10
  """
11
11
 
12
- __version__ = "0.7.2"
12
+ __version__ = "1.0.0"
13
13
  __author__ = "Ehsan Kahrizi (Ehsan.kahrizi@usu.edu)"
14
14
 
15
15
  # Import the 3 simple modules
16
16
  from .usgs_turbidity import get_turbidity, get_usgs_turbidity
17
- from .sentinel_bands import get_sentinel_bands, get_satellite_data, get_sentinel, get_sentinel_bands_gee
17
+ from .sentinel_bands import get_sentinel_bands, get_satellite_data, get_sentinel, get_sentinel_bands_gee, show_sentinel_ndwi_map
18
18
  from .visualize import plot_timeseries, plot_turbidity, plot_sentinel, plot_comparison, plot, visualize
19
19
 
20
20
  # Export everything
@@ -28,6 +28,7 @@ __all__ = [
28
28
  'get_sentinel_bands',
29
29
  'get_satellite_data',
30
30
  'get_sentinel',
31
+ 'show_sentinel_ndwi_map',
31
32
 
32
33
 
33
34
  # Visualization functions
@@ -4,13 +4,15 @@ Sentinel-2 Satellite Data Retrieval using Google Earth Engine (GEE)
4
4
  This module provides a function to retrieve Sentinel-2 satellite band data
5
5
  for a specified location and time period, with masking and cloud filtering.
6
6
  """
7
-
7
+ import ee
8
+ import geemap
8
9
  import pandas as pd
9
10
  import numpy as np
10
11
  from datetime import datetime, timedelta
11
12
  import requests
12
13
  import warnings
13
14
 
15
+ # Retrive data from Google Earth Engine ========================================================
14
16
  def get_sentinel_bands_gee(
15
17
  latitude: float,
16
18
  longitude: float,
@@ -98,6 +100,54 @@ def get_sentinel_bands_gee(
98
100
  df = df.set_index('date')
99
101
  return df
100
102
 
103
+
104
+ # Showing map with NDWI (Normalized Difference Water Index) ========================================================
105
+ def show_sentinel_ndwi_map(
106
+ latitude: float,
107
+ longitude: float,
108
+ start_date: str,
109
+ end_date: str,
110
+ buffer_meters: int = 20,
111
+ cloudy_pixel_percentage: int = 20,
112
+ zoom: int = 15
113
+ ):
114
+ """
115
+ Display an interactive map showing the NDWI, point, and buffer.
116
+
117
+ Args:
118
+ latitude (float): Latitude of the center point.
119
+ longitude (float): Longitude of the center point.
120
+ start_date (str): Start date as "YYYY-MM-DD".
121
+ end_date (str): End date as "YYYY-MM-DD".
122
+ buffer_meters (int): Buffer radius in meters.
123
+ cloudy_pixel_percentage (int): Max allowed cloud percentage.
124
+ zoom (int): Zoom level for map.
125
+ """
126
+ point = ee.Geometry.Point([longitude, latitude])
127
+ buffer = point.buffer(buffer_meters)
128
+
129
+ image = (ee.ImageCollection("COPERNICUS/S2_SR_HARMONIZED")
130
+ .filterBounds(buffer)
131
+ .filterDate(start_date, end_date)
132
+ .filter(ee.Filter.lt("CLOUDY_PIXEL_PERCENTAGE", cloudy_pixel_percentage))
133
+ .median())
134
+
135
+ ndwi = image.normalizedDifference(["B3", "B8"]).rename("NDWI")
136
+
137
+ ndwi_vis = {
138
+ 'min': 0,
139
+ 'max': 1,
140
+ 'palette': ['white', 'cyan', 'blue']}
141
+
142
+ Map = geemap.Map()
143
+ Map.centerObject(buffer, zoom=zoom)
144
+ Map.addLayer(ndwi, ndwi_vis, "NDWI (Water)")
145
+ Map.addLayer(point, {'color': 'yellow'}, 'Point')
146
+ Map.addLayer(buffer, {'color': 'red'}, 'Buffer')
147
+ Map.add_colorbar(ndwi_vis, label="NDWI", layer_name="NDWI (Water)")
148
+ return Map
149
+
150
+
101
151
  # Aliases for user convenience
102
152
  get_sentinel_bands = get_sentinel_bands_gee
103
153
  get_satellite_data = get_sentinel_bands_gee
@@ -11,7 +11,7 @@ import pandas as pd
11
11
  import numpy as np
12
12
  from datetime import datetime
13
13
 
14
-
14
+ # ==============================================================================================
15
15
  def plot_timeseries(data: pd.DataFrame, title: str = "Time Series Data", save_file: str = None) -> None:
16
16
  """
17
17
  Create a simple time series plot.
@@ -26,10 +26,10 @@ def plot_timeseries(data: pd.DataFrame, title: str = "Time Series Data", save_fi
26
26
  """
27
27
 
28
28
  if data.empty:
29
- print("No data to plot")
29
+ print("No data to plot")
30
30
  return
31
31
 
32
- print(f"📊 Creating plot: {title}")
32
+ print(f"Creating plot: {title}")
33
33
 
34
34
  # Create figure
35
35
  plt.figure(figsize=(12, 6))
@@ -59,12 +59,12 @@ def plot_timeseries(data: pd.DataFrame, title: str = "Time Series Data", save_fi
59
59
  # Save if requested
60
60
  if save_file:
61
61
  plt.savefig(save_file, dpi=300, bbox_inches='tight')
62
- print(f"💾 Plot saved as {save_file}")
62
+ print(f"Plot saved as {save_file}")
63
63
 
64
64
  plt.show()
65
- print("Plot created successfully!")
66
-
65
+ print("Plot created successfully!")
67
66
 
67
+ # ==============================================================================================
68
68
  def plot_turbidity(turbidity_data: pd.DataFrame, save_file: str = None) -> None:
69
69
  """
70
70
  Create a turbidity-specific plot with appropriate formatting.
@@ -75,10 +75,10 @@ def plot_turbidity(turbidity_data: pd.DataFrame, save_file: str = None) -> None:
75
75
  """
76
76
 
77
77
  if turbidity_data.empty:
78
- print("No turbidity data to plot")
78
+ print("No turbidity data to plot")
79
79
  return
80
80
 
81
- print("🌫️ Creating turbidity plot")
81
+ print("Creating turbidity plot")
82
82
 
83
83
  plt.figure(figsize=(12, 6))
84
84
 
@@ -92,7 +92,7 @@ def plot_turbidity(turbidity_data: pd.DataFrame, save_file: str = None) -> None:
92
92
  plt.axhline(y=25, color='red', linestyle='--', alpha=0.7, label='High (25 NTU)')
93
93
 
94
94
  # Format plot
95
- plt.title('💧 Turbidity Time Series', fontsize=14, fontweight='bold', pad=20)
95
+ plt.title('Turbidity Time Series', fontsize=14, fontweight='bold', pad=20)
96
96
  plt.xlabel('Date', fontsize=12)
97
97
  plt.ylabel('Turbidity (NTU)', fontsize=12)
98
98
  plt.grid(True, alpha=0.3)
@@ -107,12 +107,12 @@ def plot_turbidity(turbidity_data: pd.DataFrame, save_file: str = None) -> None:
107
107
  # Save if requested
108
108
  if save_file:
109
109
  plt.savefig(save_file, dpi=300, bbox_inches='tight')
110
- print(f"💾 Turbidity plot saved as {save_file}")
110
+ print(f"Turbidity plot saved as {save_file}")
111
111
 
112
112
  plt.show()
113
- print("Turbidity plot created!")
114
-
113
+ print("Turbidity plot created!")
115
114
 
115
+ # ==============================================================================================
116
116
  def plot_sentinel(sentinel_data: pd.DataFrame, save_file: str = None) -> None:
117
117
  """
118
118
  Create a Sentinel satellite data plot.
@@ -123,10 +123,10 @@ def plot_sentinel(sentinel_data: pd.DataFrame, save_file: str = None) -> None:
123
123
  """
124
124
 
125
125
  if sentinel_data.empty:
126
- print("No Sentinel data to plot")
126
+ print("No Sentinel data to plot")
127
127
  return
128
128
 
129
- print("🛰️ Creating Sentinel bands plot")
129
+ print("Creating Sentinel bands plot")
130
130
 
131
131
  plt.figure(figsize=(12, 8))
132
132
 
@@ -146,7 +146,7 @@ def plot_sentinel(sentinel_data: pd.DataFrame, save_file: str = None) -> None:
146
146
  label=column, color=color, linewidth=2, marker='o', markersize=4)
147
147
 
148
148
  # Format plot
149
- plt.title('🛰️ Sentinel Satellite Data', fontsize=14, fontweight='bold', pad=20)
149
+ plt.title('Sentinel Satellite Data', fontsize=14, fontweight='bold', pad=20)
150
150
  plt.xlabel('Date', fontsize=12)
151
151
  plt.ylabel('Digital Number / Index Value', fontsize=12)
152
152
  plt.grid(True, alpha=0.3)
@@ -161,12 +161,12 @@ def plot_sentinel(sentinel_data: pd.DataFrame, save_file: str = None) -> None:
161
161
  # Save if requested
162
162
  if save_file:
163
163
  plt.savefig(save_file, dpi=300, bbox_inches='tight')
164
- print(f"💾 Sentinel plot saved as {save_file}")
164
+ print(f"Sentinel plot saved as {save_file}")
165
165
 
166
166
  plt.show()
167
- print("Sentinel plot created!")
168
-
167
+ print("Sentinel plot created!")
169
168
 
169
+ # ==============================================================================================
170
170
  def plot_comparison(data1: pd.DataFrame, data2: pd.DataFrame,
171
171
  label1: str = "Dataset 1", label2: str = "Dataset 2",
172
172
  title: str = "Data Comparison", save_file: str = None) -> None:
@@ -183,10 +183,10 @@ def plot_comparison(data1: pd.DataFrame, data2: pd.DataFrame,
183
183
  """
184
184
 
185
185
  if data1.empty and data2.empty:
186
- print("No data to plot")
186
+ print("No data to plot")
187
187
  return
188
188
 
189
- print(f"📊 Creating comparison plot: {title}")
189
+ print(f"Creating comparison plot: {title}")
190
190
 
191
191
  fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 10), sharex=True)
192
192
 
@@ -215,10 +215,10 @@ def plot_comparison(data1: pd.DataFrame, data2: pd.DataFrame,
215
215
  # Save if requested
216
216
  if save_file:
217
217
  plt.savefig(save_file, dpi=300, bbox_inches='tight')
218
- print(f"💾 Comparison plot saved as {save_file}")
218
+ print(f"Comparison plot saved as {save_file}")
219
219
 
220
220
  plt.show()
221
- print("Comparison plot created!")
221
+ print("Comparison plot created!")
222
222
 
223
223
 
224
224
  # Simple aliases
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hydroanomaly
3
- Version: 0.7.2
3
+ Version: 1.0.0
4
4
  Summary: A Python package for hydro anomaly detection with simple USGS data retrieval
5
5
  Author-email: Ehsan Kahrizi <ehsan.kahrizi@usu.edu>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hydroanomaly"
7
- version = "0.7.2"
7
+ version = "1.0.0"
8
8
  authors = [
9
9
  {name = "Ehsan Kahrizi", email = "ehsan.kahrizi@usu.edu"},
10
10
  ]
File without changes
File without changes
File without changes