"""
HydroAnomaly

A Python package for hydro anomaly detection, USGS data retrieval, 
time series visualization, and Sentinel satellite data analysis.
"""

__version__ = "0.5.0"
__author__ = "Your Name"
__email__ = "your.email@example.com"

# Import main modules for easy access
from .hello import greet
from .math_utils import add, multiply
from .usgs_data import get_usgs_data, get_usgs_simple, USGSDataRetriever
from .plotting import plot_usgs_data, plot_multiple_gages, quick_plot, WaterDataPlotter

# Base exports
__all__ = [
    'greet',
    'add', 'multiply',
    'get_usgs_data', 'get_usgs_simple', 'USGSDataRetriever',
    'plot_usgs_data', 'plot_multiple_gages', 'quick_plot', 'WaterDataPlotter',
    'get_discharge', 'get_temperature', 'get_water_level'
]

# Try to import Sentinel functionality (optional GEE dependency)
try:
    from .sentinel_data import (
        SentinelDataRetriever, 
        SentinelConfig, 
        setup_gee_authentication, 
        initialize_gee, 
        get_water_area_time_series, 
        detect_water_changes
    )
    _SENTINEL_AVAILABLE = True
    
    # Add Sentinel functions to exports
    __all__.extend([
        'SentinelDataRetriever',
        'SentinelConfig', 
        'setup_gee_authentication',
        'initialize_gee',
        'get_water_area_time_series',
        'detect_water_changes'
    ])
    
except ImportError as e:
    print("⚠️  Sentinel data functionality not available.")
    print("💡 To use Google Earth Engine features, install:")
    print("   pip install earthengine-api")
    print("   Then authenticate: earthengine authenticate")
    _SENTINEL_AVAILABLE = False
    
    # Create placeholder functions for better error messages
    def setup_gee_authentication(*args, **kwargs):
        raise ImportError("Google Earth Engine not available. Install with: pip install earthengine-api")
    
    def initialize_gee(*args, **kwargs):
        raise ImportError("Google Earth Engine not available. Install with: pip install earthengine-api")
    
    def get_water_area_time_series(*args, **kwargs):
        raise ImportError("Google Earth Engine not available. Install with: pip install earthengine-api")
    
    def detect_water_changes(*args, **kwargs):
        raise ImportError("Google Earth Engine not available. Install with: pip install earthengine-api")

# Convenience functions for common use cases
def get_discharge(gage_number, start_date, end_date, save_file=None):
    """
    Quick function to get discharge data from any USGS gage.
    
    Args:
        gage_number (str): USGS gage number (e.g., "08158000")
        start_date (str): Start date in YYYY-MM-DD format
        end_date (str): End date in YYYY-MM-DD format
        save_file (str, optional): Filename to save data
    
    Returns:
        pandas.DataFrame: Discharge data
        
    Example:
        >>> import hydroanomaly
        >>> data = hydroanomaly.get_discharge("08158000", "2023-01-01", "2023-01-31")
        >>> print(f"Got {len(data)} discharge measurements")
    """
    return get_usgs_data(
        site_number=gage_number,
        parameter_code="00060",  # Discharge
        start_date=start_date,
        end_date=end_date,
        save_to_file=save_file,
        parameter_name="Discharge_cfs"
    )

def get_water_level(gage_number, start_date, end_date, save_file=None):
    """
    Quick function to get water level data from any USGS gage.
    
    Args:
        gage_number (str): USGS gage number (e.g., "08158000")
        start_date (str): Start date in YYYY-MM-DD format
        end_date (str): End date in YYYY-MM-DD format
        save_file (str, optional): Filename to save data
    
    Returns:
        pandas.DataFrame: Water level data
    """
    return get_usgs_data(
        site_number=gage_number,
        parameter_code="00065",  # Gage height
        start_date=start_date,
        end_date=end_date,
        save_to_file=save_file,
        parameter_name="WaterLevel_ft"
    )

def get_temperature(gage_number, start_date, end_date, save_file=None):
    """
    Quick function to get water temperature data from any USGS gage.
    
    Args:
        gage_number (str): USGS gage number (e.g., "08158000")
        start_date (str): Start date in YYYY-MM-DD format
        end_date (str): End date in YYYY-MM-DD format
        save_file (str, optional): Filename to save data
    
    Returns:
        pandas.DataFrame: Temperature data
    """
    return get_usgs_data(
        site_number=gage_number,
        parameter_code="00010",  # Temperature
        start_date=start_date,
        end_date=end_date,
        save_to_file=save_file,
        parameter_name="Temperature_C"
    )

__all__ = [
    "greet", "add", "multiply", 
    "get_usgs_data", "USGSDataRetriever",
    "get_discharge", "get_water_level", "get_temperature",
    "plot_usgs_data", "plot_multiple_gages", "quick_plot", "WaterDataPlotter"
]
