def simulate(
    mdl,  #model instance
    endYear,  # last year simulated
    fileoutName,  #name of the file to write the integrated model variables
    outFrequency,
    log,  #boolean to indicate if simulation information is to be printed
    header=True,
    fileOutAppend=False,
):
    ''' simulation for BRAY
    '''
    #Specify the integration
    integrater = Integrater(
        mdl, varsToIntegrate)  #use the default integrable variables
    #open the fileOut and write header
    with open(fileoutName, 'w') as fileOut:
        fileOut.write('%s\n' % integrater.varNames)
        #short reference to locTime object to accelerate conditionnal tests
        locTime = mdl.locTime
        #simulation loop
        while (locTime.Y is None) or (locTime.Y < endYear + 1):
            #update the model state
            mdl.update()
            #made  the integrations of model variables and output the integrated values each day
            integrater.integrate()
            if (True, locTime.isDayEnd, locTime.isYearEnd)[outFrequency]:
                fileOut.write('%s\n' % integrater.putStr())


#Display selected output values on a python console to monitor the simulation
            if log and locTime.DOY == 165 and locTime.H == 12:
                print (str(locTime.Y), 'Age:',  str(mdl.forest.treeStand.Age), ', nb: ',  str(mdl.forest.treeStand.treesCount), ', HEIGHT:',  str(mdl.forest.treeStand.HEIGHTmean), ', DBH:',
                 str(mdl.forest.treeStand.DBHmean),  'LAI:', str(mdl.forest.treeStand.canopy.LAI), 'IStress:', str(mdl.forest.treeStand.IStress), 'LAI-T:', str(mdl.forest.treeStand.canopy.LAI), \
                'LAI_U', str(mdl.forest.underStorey.canopy.LAI))
def simulate(
    mdl,
    endYear,  # last year simulated
    fileoutName,  #name of the output file 
    outFrequency,
    log,  #boolean to indicate if simulation information is to be printed
    header=True,
    fileOutAppend=False,
):
    ''' simulation 
    '''
    #Specify the integration
    integrater = Integrater(mdl, varsToIntegrate)
    #open the fileOut and write header
    with open(fileoutName, 'w') as fileOut:
        fileOut.write('%s\n' % integrater.varNames)
        #short reference to locTime object to speed up conditionnal tests
        locTime = mdl.locTime
        #simulation loop
        while (locTime.Y is None) or (locTime.Y < endYear + 1):
            #update the model state
            mdl.update()
            #made  the integrations of model variables and output the integrated values each day
            integrater.integrate()
            if (True, locTime.isDayEnd, locTime.isYearEnd)[outFrequency]:
                fileOut.write('%s\n' % integrater.putStr())


#Display selected output values on a python console to monitor the simulation
            if log and locTime.DOY == 195 and locTime.H == 23:
                print(str(locTime.Y), 'Age:', str(mdl.forest.treeStand.Age),
                      'nb: ', str(mdl.forest.treeStand.treesCount), 'HEIGHT:',
                      str(mdl.forest.treeStand.HEIGHTmean), 'DBH:',
                      str(mdl.forest.treeStand.DBHmean), 'LAI:',
                      str(mdl.forest.treeStand.canopy.LAI), 'IStress:',
                      str(mdl.forest.treeStand.IStress), 'LAI-T:',
                      str(mdl.forest.treeStand.canopy.LAI), 'Basal Area:',
                      str(mdl.forest.treeStand.BasalArea), 'Thinnings',
                      str(mdl.manager.thinnings))
예제 #3
0
def simulate(
    mdl,              #model instance
    endYear,          # last year simulated
    fileoutName,      #name of the file to write the integrated model variables
    outFrequency,     
    log,              #boolean to indicate if simulation information is to be printed
    header= True, 
    fileOutAppend = False, 
    ):
    ''' simulation Montreich (MTR) RCP85)
    '''
#integration of output variables
    integrater =Integrater(mdl, varsToIntegrate) 
    with open(fileoutName, 'w') as fileOut:
        fileOut.write('%s\n' % integrater.varNames)
 ## short reference to locTime object to accelerate conditionnal tests
        locTime = mdl.locTime     
 ## simulation loop
        while (locTime.Y is None) or (locTime.Y <endYear + 1):      
 ## update the model state
            mdl.update()
 ## daily output of the integrated values 
            integrater.integrate() 
            if (True,  locTime.isDayEnd,  locTime.isYearEnd)[outFrequency]:
                fileOut.write('%s\n' % integrater.putStr())

#Display selected output values on a python console to monitor the simulation                
            if log and locTime.DOY == 195 and locTime.H == 23:
               print (str(locTime.Y),
                      'Age:',  str(mdl.forest.treeStand.Age), 
                      ', nb: ',  str(mdl.forest.treeStand.treesCount), 
                      ', HEIGHT:',  str(mdl.forest.treeStand.Heightmean), 
                      ', DBH:', str(mdl.forest.treeStand.DBHmean),
                      ', IStress:', str(mdl.forest.treeStand.IStress), 
                      ', LAI:', str(mdl.forest.treeStand.canopy.LAI), 
                      ', Basal Area:', str(mdl.forest.treeStand.BasalArea),
                      ', Thinnings:', str(mdl.manager.thinnings)
                      )