Project: s41467-024-54846-2 | Function: Eq__D_Fveg_lcc (python)

system: You are an expert Python programmer implementing algorithms from scientific papers.
Complete the masked function based on the algorithm description.
Follow Python best practices and maintain consistent code style.
Return **only** the complete Python function code.

user: Complete this Python function:

**DESCRIPTION:** Calculates vegetation carbon flux from land cover change (LCC), implementing the bookkeeping model for direct anthropogenic carbon flux (E_LUC). Takes vegetation carbon stocks and land cover change area as input and returns carbon flux.

**KEY TERMS:** {
  "D_Fveg_lcc": "vegetation carbon flux from land cover change",
  "cveg_0": "initial vegetation carbon stock",
  "D_cveg": "change in vegetation carbon",
  "d_Acover": "land cover change area",
  "E_LUC": "direct anthropogenic carbon flux"
}

**CONTEXT CODE:** 
##################################################
##################################################

"""
CONTENT
-------
1. LAND-USE CHANGE
    1.1. Split
    1.2. Full
    1.3. Lite
    1.4. Cut
"""

##################################################
##################################################

import numpy as np
import xarray as xr


##################################################
##   1. LAND-USE CHANGE
##################################################

##===========
## 1.1. Split
##===========

## this version keeps the 'bio_from' x 'bio_to' matrix for all variables
## it also splits land cover change and management, as well as slash and soil carbon
## it is the most detailed (and heavy) version

def split_LUC(model_in):
    model = model_in.copy(add_name='_split_LUC')

    ## list LUC processes to be removed
    proc_LUC = ['D_Fveg_bk', 'D_Fsoil1_bk', 'D_Fsoil2_bk', 'D_Fslash1', 'D_Fslash2', 'D_Fhwp', 
        'D_NPP_bk', 'D_Efire_bk', 'D_Eharv_bk', 'D_Egraz_bk', 'D_Fmort1_bk', 'D_Fmort2_bk', 'D_Rh1_bk', 'D_Fmet_bk', 'D_Rh2_bk', 'D_Ehwp',  
        'D_Cveg_bk', 'D_Csoil1_bk', 'D_Csoil2_bk', 'D_Chwp']

    ## remove listed processes
    for proc in proc_LUC:
        if proc in model: del model[proc]

    ## land-use book-keeping initialization of vegetation carbon (LCC)
    model.process('D_Fveg_lcc', ('cveg_0', 'D_cveg', 'd_Acover'), 
        lambda Var, Par: Eq__D_Fveg_lcc(Var, Par), 
        units='PgC yr-1')

    def Eq__D_Fveg_lcc(Var, Par):
        raise NotImplementedError("Function masked for testing - use golden version for implementation")
        
        
    ## land-use book-keeping initialization of vegetation carbon (LU)
    model.process('D_Fveg_lu', ('cveg_0', 'D_cveg', 'd_Hwood', 'd_Ashift'), 
        lambda Var, Par: Eq__D_Fveg_lu(Var, Par), 
        units='PgC yr-1')

    def Eq__D_Fveg_lu(Var, Par):
        ## ancillary
        p_shift = 1 - np.exp(-Par.npp_0 / Var.cveg_0 * Par.t_shift).where(Var.cveg_0 != 0, 0)
        ## main values
        D_Fveg_bk_harv = -0.5*(Var.d_Hwood.rename({'bio_land':'bio_from'}) + Var.d_Hwood.rename({'bio_land':'bio_to'})).where(Var.d_Ashift.bio_from == Var.d_Ashift.bio_to, 0.)
        D_Fveg_bk_shift = -((Var.cveg_0 + Var.D_cveg) * p_shift).rename({'bio_land':'bio_to'}) * Var.d_Ashift
        return D_Fveg_bk_harv + D_Fveg_bk_shift


    ## land-use book-keeping initialization of litter carbon (LCC)
    model.process('D_Fsoil1_lcc', ('csoil1_0', 'D_csoil1', 'd_Acover'), 
        lambda Var, Par: Eq__D_Fsoil1_lcc(Var, Par), 
        units='PgC yr-1')
    
    def Eq__D_Fsoil1_lcc(Var, Par):
        D_Fsoil1_bk_lcc = ((Var.csoil1_0 + Var.D_csoil1).rename({'bio_land':'bio_from'}) - (Var.csoil1_0 + Var.D_csoil1).rename({'bio_land':'bio_to'})) * Var.d_Acover
        return D_Fsoil1_bk_lcc


    ## land-use book-keeping initialization of litter carbon (LU)
    model.process('D_Fsoil1_lu', (), 
        lambda Var, Par: Eq__D_Fsoil1_lu(Var, Par), 
        units='PgC yr-1')

    def Eq__D_Fsoil1_lu(Var, Par):
        return 0.


    ## land-use book-keeping initialization of soil carbon (LCC)
    model.process('D_Fsoil2_lcc', ('csoil2_0', 'D_csoil2', 'd_Acover'), 
        lambda Var, Par: Eq__D_Fsoil2_lcc(Var, Par), 
        units='PgC yr-1')

    def Eq__D_Fsoil2_lcc(Var, Par):
        D_Fsoil2_lcc = ((Var.csoil2_0 + Var.D_csoil2).rename({'bio_land':'bio_from'}) - (Var.csoil2_0 + Var.D_csoil2).rename({'bio_land':'bio_to'})) * Var.d_Acover
        return D_Fsoil2_lcc


    ## land-use book-keeping initialization of soil carbon (LU)
    model.process('D_Fsoil2_lu', (), 
        lambda Var, Par: Eq__D_Fsoil2_lu(Var, Par), 
        units='PgC yr-1')

    def Eq__D_Fsoil2_lu(Var, Par):
        return 0.


    ## land-use initial slash flux to litter pool (LCC)
    model.process('D_Fslash1_lcc', ('cveg_0', 'D_cveg', 'd_Acover'), 
        lambda Var, Par: Eq__D_Fslash1_lcc(Var, Par), 
        units='PgC yr-1')

    def Eq__D_Fslash1_lcc(Var, Par):
        ## ancillary
        p_mu1 = Par.mu1_0 / (Par.mu1_0 + Par.mu2_0)
        ## main values
        D_Fslash_lcc = (p_mu1 * (Var.cveg_0 + Var.D_cveg) * (Par.p_agb * (1 - Par.p_hwp.sum('box_hwp', min_count=1)) + (1 - Par.p_agb))).rename({'bio_land':'bio_from'}) * Var.d_Acover
        return D_Fslash_lcc


    ## land-use initial slash flux to litter pool (LU)
    model.process('D_Fslash1_lu', ('cveg_0', 'D_cveg', 'd_Hwood', 'd_Ashift'), 
        lambda Var, Par: Eq__D_Fslash1_lu(Var, Par), 
        units='PgC yr-1')

    def Eq__D_Fslash1_lu(Var, Par):
        ## ancillary
        p_mu1 = Par.mu1_0 / (Par.mu1_0 + Par.mu2_0)
        p_shift = 1 - np.exp(-Par.npp_0 / Var.cveg_0 * Par.t_shift).where(Var.cveg_0 != 0, 0)
        ## main values
        D_Fslash_harv = (p_mu1 * (1 - Par.p_hwp.sum('box_hwp', min_count=1))).rename({'bio_land':'bio_from'}) * 0.5*(Var.d_Hwood.rename({'bio_land':'bio_from'}) + Var.d_Hwood.rename({'bio_land':'bio_to'})).where(Var.d_Ashift.bio_from == Var.d_Ashift.bio_to, 0.)
        D_Fslash_shift = (p_mu1 * (Var.cveg_0 + Var.D_cveg) * (Par.p_agb * (1 - Par.p_hwp.sum('box_hwp', min_count=1)) + (1 - Par.p_agb)) * p_shift).rename({'bio_land':'bio_from'}) * Var.d_Ashift
        return D_Fslash_harv + D_Fslash_shift


    ## land-use initial slash flux to soil pool (LCC)
    model.process('D_Fslash2_lcc', ('cveg_0', 'D_cveg', 'd_Acover'), 
        lambda Var, Par: Eq__D_Fslash2_lcc(Var, Par), 
        units='PgC yr-1')

    def Eq__D_Fslash2_lcc(Var, Par):
        ## ancillary
        p_mu2 = Par.mu2_0 / (Par.mu1_0 + Par.mu2_0)
        ## main values
        D_Fslash_lcc = (p_mu2 * (Var.cveg_0 + Var.D_cveg) * (Par.p_agb * (1 - Par.p_hwp.sum('box_hwp', min_count=1)) + (1 - Par.p_agb))).rename({'bio_land':'bio_from'}) * Var.d_Acover
        return D_Fslash_lcc


    ## land-use initial slash flux to soil pool (LU)
    model.process('D_Fslash2_lu', ('cveg_0', 'D_cveg', 'd_Hwood', 'd_Ashift'), 
        lambda Var, Par: Eq__D_Fslash2_lu(Var, Par), 


Complete the function implementation replacing "raise NotImplementedError".