How to use the eemeter.structures.ModelingPeriod 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 / tests / structures / test_modeling_period.py View on Github external
def test_tz_unaware(interpretation):
    start_date = datetime(2000, 1, 1)
    end_date = datetime(2000, 1, 2)
    with pytest.raises(ValueError):
        ModelingPeriod(interpretation, start_date, end_date)
github openeemeter / eemeter / tests / structures / test_modeling_period_set.py View on Github external
def test_grouping_out_of_order():
    modeling_periods = {
        "modeling_period_1": ModelingPeriod(
            "BASELINE",
            end_date=datetime(2000, 1, 1, tzinfo=pytz.UTC),
        ),
        "modeling_period_2": ModelingPeriod(
            "REPORTING",
            start_date=datetime(2000, 2, 1, tzinfo=pytz.UTC),
        ),
    }

    grouping = [
        ("modeling_period_2", "modeling_period_1"),
    ]

    with pytest.raises(ValueError):
        ModelingPeriodSet(modeling_periods, grouping)
github openeemeter / eemeter / tests / structures / test_modeling_period.py View on Github external
def test_repr(interpretation):
    start_date = datetime(2000, 1, 1, tzinfo=pytz.UTC)
    end_date = datetime(2000, 1, 2, tzinfo=pytz.UTC)
    mp = ModelingPeriod(interpretation, start_date, end_date)
    assert str(mp).startswith("ModelingPeriod")
github openeemeter / eemeter / tests / structures / test_modeling_period.py View on Github external
def test_start_date_blank_reporting_not_ok(interpretation):
    end_date = datetime(2000, 1, 2, tzinfo=pytz.UTC)
    with pytest.raises(ValueError):
        ModelingPeriod("REPORTING", end_date=end_date)
github openeemeter / eemeter / tests / structures / test_modeling_period_set.py View on Github external
def test_create_basic():
    modeling_period_1 = ModelingPeriod(
        "BASELINE",
        end_date=datetime(2000, 1, 1, tzinfo=pytz.UTC),
    )
    modeling_period_2 = ModelingPeriod(
        "REPORTING",
        start_date=datetime(2000, 1, 1, tzinfo=pytz.UTC),
    )
    modeling_periods = {
        "modeling_period_1": modeling_period_1,
        "modeling_period_2": modeling_period_2,
    }

    grouping = [
        ("modeling_period_1", "modeling_period_2"),
    ]
github openeemeter / eemeter / eemeter / processors / interventions.py View on Github external
baseline_period_end = _get_earliest_intervention_start_date(
        interventions)
    reporting_period_start = _get_latest_intervention_end_date(
        interventions)

    if reporting_period_start is None:
        # fall back to baseline_period_end - interventions are still
        # ongoing.
        reporting_period_start = baseline_period_end

    modeling_periods = {
        "baseline": ModelingPeriod(
            "BASELINE",
            end_date=baseline_period_end
        ),
        "reporting": ModelingPeriod(
            "REPORTING",
            start_date=reporting_period_start
        ),
    }

    groupings = [("baseline", "reporting")]

    modeling_period_set = ModelingPeriodSet(modeling_periods, groupings)

    logger.info("Created one modeling period group.")

    return modeling_period_set
github openeemeter / eemeter / eemeter / io / serializers / meter_input.py View on Github external
return {
            'error': (
                'Project serializations must provide key'
                ' "baseline_period".'
            )
        }
    else:
        start_date = baseline_period.get("start", None)
        if start_date is not None:
            start_date = dateutil.parser.parse(start_date).astimezone(pytz.utc)

        end_date = baseline_period.get("end", None)
        if end_date is not None:
            end_date = dateutil.parser.parse(end_date).astimezone(pytz.utc)

        baseline = ModelingPeriod(
            "BASELINE",
            start_date,
            end_date
        )

    # check for "reporting_period" key
    reporting_period = modeling_period_group.get('reporting_period', None)
    if reporting_period is None:
        return {
            'error': (
                'Project serializations must provide key'
                ' "reporting_period".'
            )
        }
    else:
        start_date = reporting_period.get("start", None)
github openeemeter / eemeter / eemeter / io / serializers / meter_input.py View on Github external
return {
            'error': (
                'Project serializations must provide key'
                ' "reporting_period".'
            )
        }
    else:
        start_date = reporting_period.get("start", None)
        if start_date is not None:
            start_date = dateutil.parser.parse(start_date).astimezone(pytz.utc)

        end_date = reporting_period.get("end", None)
        if end_date is not None:
            end_date = dateutil.parser.parse(end_date).astimezone(pytz.utc)

        reporting = ModelingPeriod(
            "REPORTING",
            start_date,
            end_date
        )

    modeling_periods = {
        "baseline": baseline,
        "reporting": reporting,
    }

    grouping = [
        ("baseline", "reporting"),
    ]

    mps = ModelingPeriodSet(modeling_periods, grouping)
    return {