Skip to content

Allow multiple init dates for functions that use FastHerbie #25

@williamhobbs

Description

@williamhobbs

Preprocess the init_date parameter similar to lat/lon to convert to a list if needed.

hefty/src/hefty/solar.py

Lines 117 to 121 in 6182c8c

# variable formatting
# if lat, lon are single values, convert to lists for pickpoints later
if type(latitude) is float or type(latitude) is int:
latitude = [latitude]
longitude = [longitude]

See herbie.FastHerbie's _validate_Dates:

def _validate_DATES(DATES: Union[Datetime, list[Datetime]]) -> list[Datetime]:
    """Fast Herbie requires DATES as a list-like."""
    if isinstance(DATES, str):
        DATES = [pd.to_datetime(DATES)]
    elif not hasattr(DATES, "__len__"):
        DATES = [pd.to_datetime(DATES)]

    if not isinstance(DATES, (list, pd.DatetimeIndex)):
        raise ValueError(
            f"DATES must be a pandas-parsable datetime string or a list. Gave {DATES}"
        )

    return DATES

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions