How to use the eemeter.api.EEMeterWarning function in eemeter

To help you get started, we’ve selected a few eemeter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openeemeter / eemeter / eemeter / caltrack_hourly.py View on Github external
def get_calendar_year_coverage_warning(baseline_data_segmented):
    # this will fail if the model ids aren't calendar months
    warnings = []
    unique_models = baseline_data_segmented.model_id.unique()
    captured_months = [element for sublist in unique_models for element in sublist]
    if len(captured_months) < 12:
        warnings.append(
            EEMeterWarning(
                qualified_name=(
                    "eemeter.caltrack_hourly.incomplete_calendar_year_coverage"
                ),
                description=(
                    "Data does not cover full calendar year. "
                    "{} Missing monthly models: {}".format(
                        12 - len(captured_months),
                        [
                            month
                            for month in range(1, 13)
                            if month not in captured_months
                        ],
                    )
                ),
                data={
                    "num_missing_months": 12 - len(captured_months),
github openeemeter / eemeter / eemeter / caltrack_hourly.py View on Github external
def get_missing_hours_of_week_warning(unique_hours):
    warning = []
    missing_hours = [hour for hour in range(1, 169) if hour not in unique_hours]
    if sorted(unique_hours) != [x for x in range(1, 169)]:
        warning.append(
            EEMeterWarning(
                qualified_name=("eemeter.caltrack_hourly.missing_hours_of_week"),
                description=(
                    "Data does not include all hours of week. "
                    "Missing hours of week: {}".format(missing_hours)
                ),
                data={
                    "num_missing_hours": 168 - len(unique_hours),
                    "missing_hours": missing_hours,
                },
            )
        )
    return warning
github openeemeter / eemeter / eemeter / caltrack_hourly.py View on Github external
def get_fit_failed_model_warning(model_id, model_type):
    warning = [
        EEMeterWarning(
            qualified_name="eemeter.caltrack_hourly.failed_" + model_type,
            description=(
                "Error encountered in statsmodels.formula.api.wls method "
                "for model id: {}".format(model_id)
            ),
            data={
                "model_id": model_id,
                "model_type": model_type,
                "traceback": traceback.format_exc(),
            },
        )
    ]
    return warning
github openeemeter / eemeter / eemeter / caltrack_hourly.py View on Github external
def get_hourly_coverage_warning(
    data, baseline_months, model_id, min_fraction_daily_coverage=0.9
):
    warnings = []
    summary = data.assign(total_days=data.index.days_in_month)
    summary = summary.groupby(summary.index.month).agg(
        {"meter_value": len, "model_id": max, "total_days": max}
    )
    summary["hourly_coverage"] = summary.meter_value / (summary.total_days * 24)

    for month in baseline_months:
        row = summary.loc[summary.index == month]
        if len(row.index) == 0:
            warnings.append(
                EEMeterWarning(
                    qualified_name=(
                        "eemeter.caltrack_hourly.no_baseline_data_for_month"
                    ),
                    description=(
                        "No data for one of the baseline months. Month {}".format(month)
                    ),
                    data={"model_id": model_id, "month": month, "hourly_coverage": 0},
                )
            )
            continue

        if row.hourly_coverage.values[0] < min_fraction_daily_coverage:
            warnings.append(
                EEMeterWarning(
                    qualified_name=(
                        "eemeter.caltrack_hourly.insufficient_hourly_coverage"
github openeemeter / eemeter / eemeter / caltrack_hourly.py View on Github external
def get_invalid_function_dict_warning(function_dict):
    schema = Schema({str: {"function": has_call_attribute, "kwargs": dict}})
    try:
        schema.validate(function_dict)
    except SchemaError as e:
        return [
            EEMeterWarning(
                qualified_name=("eemeter.caltrack_hourly.design_matrix_wrong_schema"),
                description=(
                    "Wrong schema for function list. Expecting dict of dicts."
                ),
                data={
                    "preprocessors": function_dict,
                    "traceback": traceback.format_exc(),
                },
            )
        ]
    return []
github openeemeter / eemeter / eemeter / caltrack_hourly.py View on Github external
def get_design_matrix_wrong_kwargs_warning(function):
    warning = [
        EEMeterWarning(
            qualified_name="eemeter.caltrack_hourly.design_matrix_wrong_kwargs",
            description=(
                "Error: Missing or wrong keyword arguments passed in function "
                "dict. Function name: {}".format(function["function"].__name__)
            ),
            data={
                "function": function["function"].__name__,
                "kwargs": function["kwargs"],
                "traceback": traceback.format_exc(),
            },
        )
    ]
    return warning