def model( startYear, #initial year meteoFile, #meteo file path : str ): '''return an instance of the Model parameterized and initialized f. ''' #instanciate the model, set a specific manager and define start year mdl = Model() mdl.manager = Solling_Manager( ) # Additional manager scheme can be used:examples at \goModel\ManagerElements mdl.locTime.Y_start = startYear mdl.climate.meteo_file_path = meteoFile mdl.climate.Scenario = 0 # index code in mdlClimate mmodule; # Code 0: historical record; code 1: 500ppm, code 2: SRES A2; code 3: RCP2.6; code 4: RCP4.5; code 5: 500ppm; code 6: RCP 6.5; code 7: 500.0ppm; code 8: RCP8.5; code 9: 500ppm # Set the site specific parameters from csv external file paraSiteFilePath = os.path.join(basePath, 'Parameters_files', 'Site', 'DE-Sol.csv') fileParaSite = open(paraSiteFilePath, 'r') line = next(fileParaSite) for line in fileParaSite: L = line.split(',') nam = 'mdl' + str(L[0]).lstrip(',').split(" ", 1)[0].replace( "'", "").replace('"', '') val = float(L[1]) exec("%s = %s" % (nam, val)) fileParaSite.close() # Set the species parameters from csv external file Fsylvatica paraSpeFilePath = os.path.join(basePath, 'Parameters_files', 'Species', 'Fsylvatica.csv') fileParaSpe = open(paraSpeFilePath, 'r') line = next(fileParaSpe) for line in fileParaSpe: L = line.split(',') nam = 'mdl' + str(L[0]).lstrip("'").split(',')[0].replace( "'", "").replace('"', '') try: val = round(float(L[1]), 6) except ValueError: val = str(L[1]) exec("%s = %s" % (nam, val)) fileParaSpe.close() yearLastIntervention = max( [y for y in INTERVENTIONS.keys() if y < startYear]) _initial_trees_Density = INTERVENTIONS[yearLastIntervention][1] _installation = mdl.forest.treeStand.pcs_TreeStandInstallation mdl.forest.treeStand.RotationYear = _installation.initialTreesAge _installation.initialTreesDimensionsFile = os.path.join( basePath, 'Parameters_files', 'Tree_stand', 'DE-Sol_dbh_1980.csv') return mdl
def model( startYear, meteoFile, ): '''return an instance of the Model parameterized and initialized. ''' #instanciate the model, set a specific manager and define start year mdl = Model() mdl.manager = Vielle_Manager() mdl.locTime.Y_start = startYear #specific parameters linked to the climate file mdl.climate.meteo_file_path = meteoFile mdl.climate.Scenario = 0 # index code in mdlClimate mmodule; # Code 0: historical record; code 1: 500ppm, code 2: SRES A2; code 3: RCP2.6; code 4: RCP4.5; code 5: 500ppm; code 6: RCP 6.5; code 7: 500.0ppm; code 8: RCP8.5; code 9: 500ppm # Set the site specific parameters from csv external file paraSiteFilePath = os.path.join(basePath, 'Parameters_files', 'Site', 'FR-Vielle.csv') fileParaSite = open(paraSiteFilePath, 'r') line = next(fileParaSite) for line in fileParaSite: L = line.split(',') nam = 'mdl' + str(L[0]).lstrip(',').split(" ", 1)[0].replace( "'", "").replace('"', '') val = float(L[1]) exec("%s = %s" % (nam, val)) fileParaSite.close() # Set the species parameters from csv external file: Fsylvatica or Ppinaster or Pmensiezii or Quercus or any user file paraSpeFilePath = os.path.join(basePath, 'Parameters_files', 'Species', 'Ppinaster.csv') fileParaSpe = open(paraSpeFilePath, 'r') line = next(fileParaSpe) for line in fileParaSpe: L = line.split(',') nam = 'mdl' + str(L[0]).lstrip("'").split(',')[0].replace( "'", "").replace('"', '') try: val = round(float(L[1]), 6) except ValueError: val = str(L[1]) exec("%s = %s" % (nam, val)) fileParaSpe.close() yearLastPlantation = 1976 yearLastIntervention = max( [y for y in INTERVENTIONS.keys() if y < startYear]) _initial_trees_Density = INTERVENTIONS[yearLastIntervention][1] _installation = mdl.forest.treeStand.pcs_TreeStandInstallation mdl.forest.treeStand.RotationYear = _installation.initialTreesAge _installation.initialTreesDimensionsFile = basePath + '/Parameters_files/Tree_stand/FR_Vielle_dbh_1990.csv' return mdl
def model( startYear, #initial year meteoFile, #meteo file path : str ): '''return an instance of the Model parameterized and initialized f. ''' #instanciate the model, set a specific manager and define start year mdl = Model() mdl.manager = mdlManager.Manager() mdl.manager.practicesType = 2 #Select the management plan to be applied. 0 = standard; 2 = self thinning rule. mdl.locTime.Y_start = startYear mdl.climate.meteo_file_path = meteoFile mdl.climate.Scenario = 8 # index code in mdlClimate mmodule; # Code 0: historical record; code 1: 500ppm, code 2: SRES A2; code 3: RCP2.6; code 4: RCP4.5; code 5: 500ppm; code 6: RCP 6.5; code 7: 500.0ppm; code 8: RCP8.5; code 9: 500ppm ## Set the site specific parameters from csv external file paraSiteFilePath = os.path.join(basePath, 'Parameters_files', 'Site', 'FR-Mtr_140.csv') fileParaSite = open(paraSiteFilePath, 'r') line = next(fileParaSite) for line in fileParaSite: L = line.split(',') nam = 'mdl' + str(L[0]).lstrip(',').split(" ", 1)[0].replace( "'", "").replace('"', '') val = float(L[1]) exec("%s = %s" % (nam, val)) fileParaSite.close() ## Set the species parameters from csv external file Fsylvatica paraSpeFilePath = os.path.join(basePath, 'Parameters_files', 'Species', 'Fsylvatica.csv') fileParaSpe = open(paraSpeFilePath, 'r') line = next(fileParaSpe) for line in fileParaSpe: L = line.split(',') nam = 'mdl' + str(L[0]).lstrip("'").split(',')[0].replace( "'", "").replace('"', '') try: val = round(float(L[1]), 6) except ValueError: val = str(L[1]) exec("%s = %s" % (nam, val)) fileParaSpe.close() ## intialise the tree stand. _installation = mdl.forest.treeStand.pcs_TreeStandInstallation mdl.forest.treeStand.RotationYear = _installation.initialTreesAge _installation.initialTreesDimensionsFile = os.path.join( basePath, 'Parameters_files', 'Tree_stand', 'FR-Mtr_dbh_140_85.csv') return mdl
def model( startYear, meteoFile, ): '''return an instance of the Model parameterized and initialized for the Bray site. ''' #instanciate the model, set a specific manager and define start year mdl = Model() mdl.manager = DF49_Manager() # see above mdl.locTime.Y_start = startYear #specific parameters linked to the climate file mdl.climate.meteo_file_path = meteoFile mdl.climate.Scenario = 0 # index code in mdlClimate mmodule # Set the site specific parameters from csv external file paraSiteFilePath = os.path.join(basePath, 'Parameters_files', 'Site', 'BC-DF49.csv') fileParaSite = open(paraSiteFilePath, 'r') line = next(fileParaSite) for line in fileParaSite: L = line.split(',') nam = 'mdl' + str(L[0]).lstrip(',').split(" ", 1)[0].replace( "'", "").replace('"', '') val = float(L[1]) exec("%s = %s" % (nam, val)) fileParaSite.close() # Set the species parameters from csv external file paraSpeFilePath = os.path.join(basePath, 'Parameters_files', 'Species', 'DouglasFir.csv') fileParaSpe = open(paraSpeFilePath, 'r') line = next(fileParaSpe) for line in fileParaSpe: L = line.split(',') nam = 'mdl' + str(L[0]).lstrip("'").split(',')[0].replace( "'", "").replace('"', '') try: val = round(float(L[1]), 6) except ValueError: val = str(L[1]) exec("%s = %s" % (nam, val)) fileParaSpe.close() yearLastIntervention = max( [y for y in INTERVENTIONS.keys() if y < startYear]) _initial_trees_Density = INTERVENTIONS[yearLastIntervention][2] _installation = mdl.forest.treeStand.pcs_TreeStandInstallation mdl.forest.treeStand.RotationYear = _installation.initialTreesAge _installation.initialTreesDimensionsFile = '' return mdl