Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4316904
refactor: extract getScaleParams and getOffsetParams from ee_extra
12rambau Jul 15, 2026
4ba75b1
refactor: extract scaleAndOffset from ee_extra
12rambau Jul 15, 2026
f03260d
refactor: extract preprocess from ee_extra
12rambau Jul 15, 2026
ddec362
refactor: extract tasseledCap from ee_extra
12rambau Jul 15, 2026
623ecde
refactor: extract maskClouds from ee_extra
12rambau Jul 15, 2026
ccc1349
refactor: extract panSharpen from ee_extra
12rambau Jul 15, 2026
6d0afd0
refactor: extract closest from ee_extra
12rambau Jul 15, 2026
65446ea
refactor: update ee_image_collection methods to use local implementat…
12rambau Jul 15, 2026
1252edd
refactor: extract spectralIndices from ee_extra
12rambau Jul 15, 2026
55fe0dd
refactor: fetch scale/offset params from GitHub instead of local JSON
12rambau Jul 15, 2026
f8b4625
fix: review the scale and offset functions
12rambau Jul 15, 2026
8d44b8c
refactor: reimplement closest
12rambau Jul 15, 2026
cf1c3ea
fix: drop the ee_extra utils alltogether
12rambau Jul 15, 2026
dba214f
fix: delete data folder
12rambau Jul 15, 2026
f52899a
fix: sovle the linting issues
12rambau Jul 15, 2026
a406f16
test: solve the featureCollection tests
12rambau Jul 15, 2026
5de1ff9
test: solve imageCollection
12rambau Jul 15, 2026
6801147
test: make them all pass
12rambau Jul 16, 2026
133da21
refactor: place the extras in a dedicated folder
12rambau Jul 16, 2026
92614cb
build: update dependences list
12rambau Jul 16, 2026
19369ca
fix: add missing type hint
12rambau Jul 16, 2026
44649ea
test: reduce strictness of the image tests
12rambau Jul 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 171 additions & 0 deletions analyze_ee_extra_dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#!/usr/bin/env python3
"""Identify all functions in geetools that depend on ee_extra methods."""

import ast
from collections import defaultdict
from pathlib import Path


class EEExtraDependencyAnalyzer(ast.NodeVisitor):
"""Analyzes Python AST to find ee_extra dependencies."""

def __init__(self, filename):
"""Initialize the analyzer."""
self.filename = filename
self.current_function = None
self.functions_with_ee_extra = []
self.ee_extra_calls = []

def visit_FunctionDef(self, node):
"""Visit function definitions."""
prev_function = self.current_function
self.current_function = node.name
self.generic_visit(node)
self.current_function = prev_function

def visit_AsyncFunctionDef(self, node):
"""Visit async function definitions."""
prev_function = self.current_function
self.current_function = node.name
self.generic_visit(node)
self.current_function = prev_function

def visit_Call(self, node):
"""Visit function calls to find ee_extra usage."""
call_str = self._get_call_string(node)

if call_str and "ee_extra" in call_str:
if self.current_function:
self.functions_with_ee_extra.append(self.current_function)
self.ee_extra_calls.append({"function": self.current_function, "call": call_str})

self.generic_visit(node)

def _get_call_string(self, node):
"""Extract the call string from an AST Call node."""
try:
if isinstance(node.func, ast.Attribute):
parts = []
current = node.func

while isinstance(current, ast.Attribute):
parts.insert(0, current.attr)
current = current.value

if isinstance(current, ast.Name):
parts.insert(0, current.id)
return ".".join(parts)
elif isinstance(node.func, ast.Name):
return node.func.id
except Exception:
pass
return None


def analyze_file(filepath):
"""Analyze a single Python file for ee_extra dependencies."""
try:
with open(filepath, "r", encoding="utf-8") as f:
content = f.read()

tree = ast.parse(content)
analyzer = EEExtraDependencyAnalyzer(filepath)
analyzer.visit(tree)

return analyzer
except Exception as e:
print(f"Error analyzing {filepath}: {e}")
return None


def main():
"""Main function to scan geetools directory."""
geetools_dir = Path("/home/rambap/github/geetools/geetools")

# Collect all dependencies
all_dependencies = defaultdict(list)
file_to_functions = defaultdict(set)

# Walk through all Python files
for py_file in sorted(geetools_dir.glob("*.py")):
analyzer = analyze_file(py_file)

if analyzer and analyzer.functions_with_ee_extra:
functions = set(analyzer.functions_with_ee_extra)
file_to_functions[py_file.name] = functions

for call_info in analyzer.ee_extra_calls:
func_name = call_info["function"]
call = call_info["call"]
all_dependencies[py_file.name].append({"function": func_name, "call": call})

# Generate report
output_file = Path("/home/rambap/github/geetools/ee_extra_dependencies.txt")

with open(output_file, "w") as f:
f.write("=" * 80 + "\n")
f.write("EE_EXTRA DEPENDENCIES IN GEETOOLS\n")
f.write("=" * 80 + "\n")
f.write("Analysis Date: 2026-07-15\n")
f.write(f"Total files with ee_extra dependencies: {len(file_to_functions)}\n")

# Count total unique functions
all_functions = set()
for functions in file_to_functions.values():
all_functions.update(functions)

f.write(f"Total unique functions with ee_extra dependencies: {len(all_functions)}\n\n")

# Detailed report by file
f.write("=" * 80 + "\n")
f.write("DETAILED BREAKDOWN BY FILE\n")
f.write("=" * 80 + "\n\n")

for file_name in sorted(file_to_functions.keys()):
functions = sorted(file_to_functions[file_name])
f.write(f"\nFile: {file_name}\n")
f.write(f" Functions with ee_extra dependencies ({len(functions)}):\n")

for func in functions:
f.write(f" - {func}\n")

# Show ee_extra calls for this file
f.write("\n ee_extra Method Calls:\n")
seen_calls = set()
for dep_info in all_dependencies[file_name]:
call = dep_info["call"]
if call not in seen_calls:
f.write(f" - {call}\n")
seen_calls.add(call)
f.write("\n")

# Summary list of all functions
f.write("\n" + "=" * 80 + "\n")
f.write("SUMMARY: ALL FUNCTIONS WITH EE_EXTRA DEPENDENCIES\n")
f.write("=" * 80 + "\n\n")

for func_name in sorted(all_functions):
# Find which file this function is in
for file_name, functions in file_to_functions.items():
if func_name in functions:
f.write(f"{func_name} (in {file_name})\n")
break

print("\n✓ Analysis complete!")
print(f"✓ Results written to: {output_file}")
print("\nSummary:")
print(f" - Files with ee_extra dependencies: {len(file_to_functions)}")
print(f" - Total unique functions: {len(all_functions)}")
print(f" - Total ee_extra calls: {len([d for deps in all_dependencies.values() for d in deps])}")

# Print to console as well
print("\nFunctions with ee_extra dependencies:")
for file_name in sorted(file_to_functions.keys()):
functions = sorted(file_to_functions[file_name])
print(f"\n{file_name}:")
for func in functions:
print(f" - {func}")


if __name__ == "__main__":
main()
59 changes: 59 additions & 0 deletions ee_extra_dependencies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
================================================================================
EE_EXTRA DEPENDENCIES IN GEETOOLS
================================================================================
Analysis Date: 2026-07-15
Total files with ee_extra dependencies: 2
Total unique functions with ee_extra dependencies: 9

================================================================================
DETAILED BREAKDOWN BY FILE
================================================================================


File: ee_image.py
Functions with ee_extra dependencies (8):
- maskClouds
- panSharpen
- preprocess
- spectralIndices
- tasseledCap

ee_extra Method Calls:
- ee_extra.Spectral.core.spectralIndices
- ee_extra.QA.pipelines.preprocess
- ee_extra.Algorithms.core.panSharpen
- ee_extra.Spectral.core.tasseledCap
- ee_extra.QA.clouds.maskClouds


File: ee_image_collection.py
Functions with ee_extra dependencies (9):
- closest
- maskClouds
- panSharpen
- preprocess
- spectralIndices
- tasseledCap

ee_extra Method Calls:
- ee_extra.QA.clouds.maskClouds
- ee_extra.ImageCollection.core.closest
- ee_extra.Spectral.core.spectralIndices
- ee_extra.QA.pipelines.preprocess
- ee_extra.Algorithms.core.panSharpen
- ee_extra.Spectral.core.tasseledCap


================================================================================
SUMMARY: ALL FUNCTIONS WITH EE_EXTRA DEPENDENCIES
================================================================================

closest (in ee_image_collection.py)
getOffsetParams (in ee_image.py)
getScaleParams (in ee_image.py)
maskClouds (in ee_image.py)
panSharpen (in ee_image.py)
preprocess (in ee_image.py)
scaleAndOffset (in ee_image.py)
spectralIndices (in ee_image.py)
tasseledCap (in ee_image.py)
4 changes: 4 additions & 0 deletions geetools/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Constants for geetools."""

# URL for Earth Engine catalog scale and offset parameters
EE_CATALOG_SCALE_OFFSET_URL = "https://raw.githubusercontent.com/davemlz/ee-catalog-scale-offset-params/main/list/ee-catalog-scale-offset-parameters.json"
Loading
Loading