#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Written by Lucas Sinclair and Paul Rougieux.

JRC Biomass Project.
Unit D1 Bioeconomy.

A script to run the imaginary `ZZ` country to test the pipeline.

Typically you would run this file from a command line like this:

     ipython3 -i -- ~/repos/eu_cbm/eu_cbm_hat/scripts/running/run_zz.py
"""

# Internal modules #
from eu_cbm_hat.core.continent import continent
runner = continent.combos['reference'].runners['ZZ'][-1]
# runner.country.base_year = 2020
runner.num_timesteps = 30
runner.run(keep_in_ram=True, verbose=True, interrupt_on_error=True)

# Load output files
# Input events sent to libcbm before hat
events_input = runner.input_data["events"]
# Output events generated by hat and sent to libcbm
events_hat = runner.output.load("events", with_clfrs=False)
# Annual overview of availability
extras = runner.output.load("extras", with_clfrs=False)
# Pools and fluxes
pool_flux = runner.output.pool_flux

# events_input.dist_type_name.unique()
# array([ 8,  7,  5, 12, 14, 16, 22, 11, 21, 42,  4])

# events_hat.dist_type_name.unique()
# array([14, 16, 22, 21, 12, 18, 11, 29])

# pool_flux.disturbance_type.unique()
# array([ 0,  7,  9, 13, 10, 12,  4,  8,  6, 11,  5, 16,  3], dtype=int32)

# Expected provided
runner.qaqc.expected_provided.by(index=["forest_type", "disturbance_type"])



