import numpy

############################################################
## Level labels, eg. stratumlabel, treelabel
############################################################
SIMULATIONLABEL = 0
STANDLABEL = 1
STRATUMLABEL = 2
TREELABEL = 3
ASSORTMENTLABEL = 'assortment'

EPSILON = 0.00001

thinningind = {'stratum_id': 2,
               'stratum_sp': 4,
               'stratum_vol': 5,
               'stratum_ba': 6,
               'stratum_N': 7,
               'stratum_tag': 8,
               'tree_id': 2,
               'tree_parentid': 3,
               'tree_d': 4,
               'tree_n': 5,
               'tree_h': 6,
               'tree_d_s': 7,
               'tree_density': 8,
               'tree_bm_branches': 9,
               'tree_bm_roots': 10,
               'tree_bm_stump': 11,
               'tree_bm_foliage': 12,
               'tree_log_reduction': 13,
               'tree_tag': 14}
thinningpar = {'target_density': (None, 0),
               'track_width': (None, 1),
               'track_distance': (None, 2),
               'min_N_after_thinning': (None, 3),
               'remove_from_below_percentage': ('proportion', 4),
               'remove_from_above_percentage': ('proportion', 5),
               'preference_percentage': ('proportion', 6),
               'cut_all_below': ('proportion', 7),
               'forced_preferred_sp': (None, 8)}
# level name, object index, variable index
thinningdata = {'divisor': (SIMULATIONLABEL, 0, 3),
                'max_ba_removal': (SIMULATIONLABEL, 0, 4),
                'min_vol_accumulation': (SIMULATIONLABEL, 0, 5),
                'stump_biomass_to_energy': (SIMULATIONLABEL, 0, 6),
                'branch_biomass_to_energy': (SIMULATIONLABEL, 0, 7),
                'log_reduction_type': (SIMULATIONLABEL, 0, 8),
                'c_life_cycle': (SIMULATIONLABEL, 0, 9),
                'mwh_to_kg_c': (SIMULATIONLABEL, 0, 10),
                'c_in_kg': (SIMULATIONLABEL, 0, 11),
                'life_cycle_period': (SIMULATIONLABEL, 0, 12),
                'use_cache': (SIMULATIONLABEL, 0, 13),
                'cache_resolution': (SIMULATIONLABEL, 0, 14),
                'upper_limit': (STANDLABEL, 0, 3),
                'lower_limit': (STANDLABEL, 0, 4),
                'municipal_id': (STANDLABEL, 0, 5),
                'price_region': (STANDLABEL, 0, 6),
                'd_gm': (STANDLABEL, 0, 7),
                'min_stump_diam': (STANDLABEL, 0, 8),
                'biomass_incl_prop': (STANDLABEL, 0, 9),
                'stump_lift_prop': (STANDLABEL, 0, 10),
                'area': (STANDLABEL, 0, 11),}

selectionpar = {'target_density': (None, 0),
                'track_width': (None, 1),
                'track_distance': (None, 2),
                'min_N_after_thinning': (None, 3),
                'slope': (None, 4),
                'cut_all_above': (None, 5),
                'min_class_size': (None, 6)}

thinning_with_removed_volumedata = {
                'divisor': (SIMULATIONLABEL, 0, 3),
                'max_ba_removal': (SIMULATIONLABEL, 0, 4),
                'min_vol_accumulation': (SIMULATIONLABEL, 0, 6),
                'stump_biomass_to_energy': (SIMULATIONLABEL, 0, 7),
                'branch_biomass_to_energy': (SIMULATIONLABEL, 0, 8),
                'log_reduction_type': (SIMULATIONLABEL, 0, 9),
                'c_life_cycle': (SIMULATIONLABEL, 0, 10),
                'mwh_to_kg_c': (SIMULATIONLABEL, 0, 11),
                'c_in_kg': (SIMULATIONLABEL, 0, 12),
                'life_cycle_period': (SIMULATIONLABEL, 0, 13),
                'use_cache': (SIMULATIONLABEL, 0, 14),
                'cache_resolution': (SIMULATIONLABEL, 0, 15),
                'upper_limit': (STANDLABEL, 0, 3),
                'lower_limit': (STANDLABEL, 0, 4),
                'municipal_id': (STANDLABEL, 0, 5),
                'price_region': (STANDLABEL, 0, 6),
                'd_gm': (STANDLABEL, 0, 7),
                'v_harvested': (STANDLABEL, 0, 8),
                'min_stump_diam': (STANDLABEL, 0, 9),
                'biomass_incl_prop': (STANDLABEL, 0, 10),
                'stump_lift_prop': (STANDLABEL, 0, 11),
                'remaining_ba': (STANDLABEL, 0, 12),}


# level name, object index, variable index
first_thinning_N_data = {'divisor': (SIMULATIONLABEL, 0, 3),
                'min_vol_accumulation': (SIMULATIONLABEL, 0, 4),
                'stump_biomass_to_energy': (SIMULATIONLABEL, 0, 5),
                'branch_biomass_to_energy': (SIMULATIONLABEL, 0, 6),
                'log_reduction_type': (SIMULATIONLABEL, 0, 7),
                'c_life_cycle': (SIMULATIONLABEL, 0, 8),
                'mwh_to_kg_c': (SIMULATIONLABEL, 0, 9),
                'c_in_kg': (SIMULATIONLABEL, 0, 10),
                'life_cycle_period': (SIMULATIONLABEL, 0, 11),
                'use_cache': (SIMULATIONLABEL, 0, 12),
                'cache_resolution': (SIMULATIONLABEL, 0, 13),
                'upper_limit': (STANDLABEL, 0, 3),
                'lower_limit': (STANDLABEL, 0, 4),
                'municipal_id': (STANDLABEL, 0, 5),
                'price_region': (STANDLABEL, 0, 6),
                'd_gm': (STANDLABEL, 0, 7),
                'max_n_removal': (STANDLABEL, 0, 8),
                'min_stump_diam': (STANDLABEL, 0, 9),
                'biomass_incl_prop': (STANDLABEL, 0, 10),
                'stump_lift_prop': (STANDLABEL, 0, 11),}

first_thinning_N_par = {'track_width': (None, 0),
                     'track_distance': (None, 1),
                     'min_N_after_thinning': (None, 2),
                     'remove_from_below_percentage': ('proportion', 3),
                     'remove_from_above_percentage': ('proportion', 4),
                     'preference_percentage': ('proportion', 5),
                     'cut_all_below': ('proportion', 6),
                     'forced_preferred_sp': (None, 7)}

clearcutind = {'stratum_id': 2,
               'stratum_sp': 4,
               'stratum_vol': 5,
               'stratum_N': 6,
               'stratum_tag': 7,
               'tree_id': 2,
               'tree_parentid': 3,
               'tree_d': 4,
               'tree_n': 5,
               'tree_h': 6,
               'tree_d_s': 7,
               'tree_density': 8,
               'tree_bm_branches': 9,
               'tree_bm_roots': 10,
               'tree_bm_stump': 11,
               'tree_bm_foliage': 12,
               'tree_log_reduction': 13,
               'tree_tag': 14}
clearcutdata = {'divisor': (SIMULATIONLABEL, 0, 3),
                'n_reserve': (SIMULATIONLABEL, 0, 4),
                'vol_reserve': (SIMULATIONLABEL, 0, 5),
                'reserve_tree_d_limit': (SIMULATIONLABEL, 0, 6),
                'stump_biomass_to_energy': (SIMULATIONLABEL, 0, 7),
                'branch_biomass_to_energy': (SIMULATIONLABEL, 0, 8),
                'log_reduction_type': (SIMULATIONLABEL, 0, 9),
                'c_life_cycle': (SIMULATIONLABEL, 0, 10),
                'mwh_to_kg_c': (SIMULATIONLABEL, 0, 11),
                'c_in_kg': (SIMULATIONLABEL, 0, 12),
                'life_cycle_period': (SIMULATIONLABEL, 0, 13),
                'use_cache': (SIMULATIONLABEL, 0, 14),
                'cache_resolution': (SIMULATIONLABEL, 0, 15),
                'municipal_id': (STANDLABEL, 0, 3),
                'price_region': (STANDLABEL, 0, 4),
                'stump_excl_num': (STANDLABEL, 0, 5),
                'min_stump_diam': (STANDLABEL, 0, 6),
                'biomass_incl_prop': (STANDLABEL, 0, 7),
                'stump_lift_prop': (STANDLABEL, 0, 8),
                'area': (STANDLABEL, 0, 9),
               }

seedtreeind = {'stratum_id': 2,
               'stratum_sp': 4,
               'stratum_vol': 5,
               'stratum_ba': 6,
               'stratum_N': 7,
               'stratum_tag': 8,
               'tree_id': 2,
               'tree_parentid': 3,
               'tree_d': 4,
               'tree_n': 5,
               'tree_h': 6,
               'tree_d_s': 7,
               'tree_density': 8,
               'tree_bm_branches': 9,
               'tree_bm_roots': 10,
               'tree_bm_stump': 11,
               'tree_bm_foliage': 12,
               'tree_log_reduction': 13,
               'tree_tag': 14}
seedtreedata = {'divisor': (SIMULATIONLABEL, 0, 3),
                'n_reserve': (SIMULATIONLABEL, 0, 4),
                'vol_reserve': (SIMULATIONLABEL, 0, 5),
                'reserve_tree_d_limit': (SIMULATIONLABEL, 0, 6),
                'min_vol_accumulation_seedtree_position': (SIMULATIONLABEL, 0, 7),
                'stump_biomass_to_energy': (SIMULATIONLABEL, 0, 8),
                'branch_biomass_to_energy': (SIMULATIONLABEL, 0, 9),
                'log_reduction_type': (SIMULATIONLABEL, 0, 10),
                'c_life_cycle': (SIMULATIONLABEL, 0, 11),
                'mwh_to_kg_c': (SIMULATIONLABEL, 0, 12),
                'c_in_kg': (SIMULATIONLABEL, 0, 13),
                'life_cycle_period': (SIMULATIONLABEL, 0, 14),
                'use_cache': (SIMULATIONLABEL, 0, 15),
                'cache_resolution': (SIMULATIONLABEL, 0, 16),
                'municipal_id': (STANDLABEL, 0, 3),
                'price_region': (STANDLABEL, 0, 4),
                'regen_sp': (STANDLABEL, 0, 5),
                'stump_excl_num': (STANDLABEL, 0, 6),
                'ddom': (STANDLABEL, 0, 7),
                'min_stump_diam': (STANDLABEL, 0, 8),
                'biomass_incl_prop': (STANDLABEL, 0, 9),
                'stump_lift_prop': (STANDLABEL, 0, 10),
                'area': (STANDLABEL, 0, 11),}

removeseedtreeind = {'stratum_id': 2,
                     'stratum_sp': 4,
                     'stratum_vol': 5,
                     'stratum_seedtree': 6,
                     'stratum_tag': 7,
                     'tree_id': 2,
                     'tree_parentid': 3,
                     'tree_d': 4,
                     'tree_n': 5,
                     'tree_h': 6,
                     'tree_log_reduction': 7,
                     'tree_tag': 8}
removeseedtreedata = {'divisor': (SIMULATIONLABEL, 0, 3),
                      'min_vol_accumulation_remove_seedtrees': \
                                                     (SIMULATIONLABEL, 0, 4),
                      'log_reduction_type': (SIMULATIONLABEL, 0, 5),
                      'c_life_cycle': (SIMULATIONLABEL, 0, 6),
                      'mwh_to_kg_c': (SIMULATIONLABEL, 0, 7),
                      'c_in_kg': (SIMULATIONLABEL, 0, 8),
                      'life_cycle_period': (SIMULATIONLABEL, 0, 9),
                      'use_cache': (SIMULATIONLABEL, 0, 10),
                      'cache_resolution': (SIMULATIONLABEL, 0, 11),
                      'municipal_id': (STANDLABEL, 0, 3),
                      'price_region': (STANDLABEL, 0, 4),
                      'area': (STANDLABEL, 0, 5),}

standvalueind = {'stratum_id': 2,
                 'stratum_sp': 3,
                 'stratum_vol': 4,
                 'stratum_tag': 5,
                 'tree_id': 2,
                 'tree_parentid': 3,
                 'tree_d': 4,
                 'tree_n': 5,
                 'tree_h': 6,
                 'tree_d_s': 7,
                 'tree_density': 8,
                 'tree_bm_branches': 9,
                 'tree_bm_roots': 10,
                 'tree_bm_stump': 11,
                 'tree_bm_foliage': 12,
                 'tree_log_reduction': 13,
                 'tree_tag': 14}
standvaluedata = {'divisor': (SIMULATIONLABEL, 0, 3),
                  'stump_biomass_to_energy': (SIMULATIONLABEL, 0, 4),
                  'branch_biomass_to_energy': (SIMULATIONLABEL, 0, 5),
                  'log_reduction_type': (SIMULATIONLABEL, 0, 6),
                  'use_cache': (SIMULATIONLABEL, 0, 7),
                  'cache_resolution': (SIMULATIONLABEL, 0, 8),
                  'municipal_id': (STANDLABEL, 0, 3),
                  'price_region': (STANDLABEL, 0, 4)}

woodassortind = {'stratum_id': 2,
                 'stratum_sp': 3,
                 'stratum_vol': 4,
                 'stratum_tag': 5,
                 'tree_id': 2,
                 'tree_parentid': 3,
                 'tree_d': 4,
                 'tree_n': 5,
                 'tree_h': 6,
                 'tree_log_reduction': 7,
                 'tree_tag': 8}
woodassortdata = {'divisor': (SIMULATIONLABEL, 0, 3),
                  'log_reduction_type': (SIMULATIONLABEL, 0, 4),
                  'use_cache': (SIMULATIONLABEL, 0, 5),
                  'cache_resolution': (SIMULATIONLABEL, 0, 6),
                  'municipal_id': (STANDLABEL, 0, 3),
                  'price_region': (STANDLABEL, 0, 4)}

tendingind = {'stratum_id': 2,
              'stratum_sp': 4,
              'stratum_N': 5,
              'stratum_artif': 6,
              'stratum_tag': 7,
              'tree_id': 2,
              'tree_parentid': 3,
              'tree_d': 4,
              'tree_n': 5,
              'tree_tag': 6}
tendingdata = {'N': (STANDLABEL, 0, 3)}

plantingdata = {'REGEN_SP': (STANDLABEL, 0, 3)}

supplemental_plantingdata = {'N': (STANDLABEL, 0, 3),
                             'N_Sp': (STANDLABEL, 0, 4),
                             'N_Ns': (STANDLABEL, 0, 5),
                             'N_sb': (STANDLABEL, 0, 6),
                             'REGEN_SP': (STANDLABEL, 0, 7)}


