@author: tqc268 """ from Yields import meanyields from Get_allyields import get_allYields from split_nameDir import split_unique_name from Yields import meanyields path = r'../RunTest' allresults = get_allYields(path) meanperkey = meanyields(allresults) dictK = { key: value for key, value in meanperkey.items() if split_unique_name(key)['IsConventional'] != 'False' } dictO = { key: value for key, value in meanperkey.items() if split_unique_name(key)['IsConventional'] == 'False' } soil = ['JB1', 'JB4', 'JB6'] cmean = pd.DataFrame() for s in soil: dict2 = { k: value for k, value in dictK.items() if split_unique_name(k)['ManureMass'] == 170 and split_unique_name(k)['Soiltype'][0:3] == s
from split_nameDir import split_unique_name from Yields import meanyields path = r'../RunK2-7' allresults = get_allYields(path) meanperkey = meanyields(allresults) for key, value in meanperkey.items(): for kl, vl in value.items(): if kl == 'Potato; Sava_Figaro': value['Potato SavaFigaro'] = value.pop(kl) dictK = { key: value for key, value in meanperkey.items() if split_unique_name(key)['IsConventional'] != 'False' } dictO = { key: value for key, value in meanperkey.items() if split_unique_name(key)['IsConventional'] == 'False' } soil = ['JB1', 'JB4', 'JB6'] cmean = pd.DataFrame() for s in soil: dict2 = { k: value for k, value in dictK.items() if split_unique_name(k)['Soiltype'][0:3] == s }
""" Created on Fri May 3 13:56:08 2019 @author: tqc268 """ # Analyse results based on manure input import numpy as np import pandas as pd from Get_allSOC import get_allSOM from split_nameDir import split_unique_name import matplotlib.pyplot as plt path = r'../RunPK3_few' dSOMperkey = get_allSOM(path) dictKonv = {key:value for key, value in dSOMperkey.items() if split_unique_name(key)['IsConventional'] == "True"} #dictOrg = {key:value for key, value in dSOMperkey.items() if split_unique_name(key)['IsConventional'] == "False"} rota= [split_unique_name(k)['Rotation'] for k,v in dSOMperkey.items() ] rotaK= [split_unique_name(k)['Rotation'] for k,v in dictKonv.items() ] rk = np.unique(np.array(rotaK)) rotations= rk.tolist() manure = [split_unique_name(k)['ManureMass'] for k,v in dSOMperkey.items() ] manureK = [split_unique_name(k)['ManureMass'] for k,v in dictKonv.items() ] man = np.unique(np.array(manureK)) ManureAmount =man.tolist() d= pd.DataFrame(index=rotations, columns=ManureAmount) for ma in ManureAmount:
@author: tqc268 """ import numpy as np import pandas as pd from Get_allSOC import get_allSOM from split_nameDir import split_unique_name import matplotlib.pyplot as plt path = r'../RunK1-9' dSOMperkey = get_allSOM(path) dictKonv = { key: value for key, value in dSOMperkey.items() if split_unique_name(key)['ManureMass'] == 170 } dictOrg = { key: value for key, value in dSOMperkey.items() if split_unique_name(key)['IsConventional'] == "False" } dict1 = dictKonv rota = [split_unique_name(k)['Rotation'] for k, v in dict1.items()] rk = np.unique(np.array(rota)) rotations = rk.tolist() manure = [split_unique_name(k)['ManureMass'] for k, v in dict1.items()] man = np.unique(np.array(manure)) ManureAmount = man.tolist()
import pandas as pd from Yields import meanyields from Get_allyieldsCN import get_allYieldsCN from split_nameDir import split_unique_name from Yields import meanyields path = r'../RunK2-7' allresults = get_allYields(path) meanperkey = meanyields(allresults) for key, value in meanperkey.items(): for kl, vl in value.items(): if kl == 'Potato; Sava_Figaro': value['Potato SavaFigaro'] = value.pop(kl) dictK = {key:value for key, value in meanperkey.items() if split_unique_name(key)['IsConventional']!= 'False'} dictO = {key:value for key, value in meanperkey.items() if split_unique_name(key)['IsConventional']== 'False'} soil = ['JB1', 'JB4', 'JB6'] cmean = pd.DataFrame() for s in soil: dict2 = {k:value for k, value in dictK.items() if split_unique_name(k)['Soiltype'][0:3]==s} df =pd.DataFrame.from_dict(dict2, orient='index') df['clovergrass']=df['Ryegrass']+df['Wclover'] means = df.mean(axis = 0) cmean[s] = means """ # Calculate the mean yield of Rygrass in rotations KK8 and KK9 (only ones with only grass - no clover) cmeanG_V = pd.DataFrame() for s in soil:
@author: tqc268 """ import numpy as np import pandas as pd from Get_allSOC import get_allSOM from split_nameDir import split_unique_name import matplotlib.pyplot as plt path = r'../Run4' dSOMperkey = get_allSOM(path) #dictKonv = {key:value for key, value in dSOMperkey.items() if split_unique_name(key)['IsConventional'] == "True"} #dictOrg = {key:value for key, value in dSOMperkey.items() if split_unique_name(key)['IsConventional'] == "False"} rota = [split_unique_name(k)['Rotation'] for k, v in dSOMperkey.items()] rk = np.unique(np.array(rota)) rotations = rk.tolist() manure = [split_unique_name(k)['ManureMass'] for k, v in dSOMperkey.items()] man = np.unique(np.array(manure)) ManureAmount = man.tolist() # Effekt of weather within rotations weather = ['East', 'West'] SOMmeanperRotWe = [] for we in weather: dict1 = { k: value for k, value in dSOMperkey.items() if split_unique_name(k)['Weather'][0:4] == we
@author: tqc268 """ import numpy as np import pandas as pd from Get_allSOC import get_allSOM from split_nameDir import split_unique_name import matplotlib.pyplot as plt path = r'../RunK_170' dSOMperkey = get_allSOM(path) #dictKonv = {key:value for key, value in dSOMperkey.items() if split_unique_name(key)['IsConventional'] == "True"} #dictOrg = {key:value for key, value in dSOMperkey.items() if split_unique_name(key)['IsConventional'] == "False"} rota = [split_unique_name(k)['Rotation'] for k, v in dSOMperkey.items()] rk = np.unique(np.array(rota)) rotations = rk.tolist() ## Effekt of initalization level within rotations initlevel = ['High', 'Medium', 'Low'] meanILRO = pd.DataFrame(index=rotations, columns=initlevel) for il in initlevel: dict1 = { k: value for k, value in dSOMperkey.items() if split_unique_name(k)['Initlevel'] == il } for ro in rotations: dict2 = {
@author: tqc268 """ import numpy as np import pandas as pd from Get_allSOC import get_allSOM from split_nameDir import split_unique_name import matplotlib.pyplot as plt path = r'../RunPK3_few' dSOMperkey = get_allSOM(path) #dictKonv = {key:value for key, value in dSOMperkey.items() if split_unique_name(key)['IsConventional'] == "True"} #dictOrg = {key:value for key, value in dSOMperkey.items() if split_unique_name(key)['IsConventional'] == "False"} rota = [split_unique_name(k)['Rotation'] for k, v in dSOMperkey.items()] rk = np.unique(np.array(rota)) rotations = rk.tolist() #dSOMperkey = dict1 ## Effekt of soil texture within rotations soiltype = ['JB1', 'JB4', 'JB6'] meanJBRO = pd.DataFrame(index=rotations, columns=soiltype) for st in soiltype: dict1 = { k: value for k, value in dSOMperkey.items() if split_unique_name(k)['Soiltype'][0:3] == st } for ro in rotations:
import operator from functools import reduce rota = pd.DataFrame(pd.read_excel('../common/masterinput_v4.xlsx',sheet_name= 'Rotations')) rota.index = rota['ID'] crops = pd.read_excel('../common/masterinput_v4.xlsx',sheet_name= 'Crops') crops.index = crops['Crop'] norm = pd.read_excel('../common/Nnorm_2019.xlsx', sheet_name = "Sheet1") norm.index = norm['afgkode'] path = r'../Run' allresults = get_allYields(path) soil = 'JB6' name_entries = split_unique_name(key) for key, value in allresults.items(): sim_yieldmean ={} if name_entries['Soiltype'][0:3]!=soil: allresult = allresults for key, value in allresults.items(): for kl, vl in value.items(): allresults[key][kl] = np.mean(vl) ## mean value includes zero and it should not df =pd.DataFrame.from_dict(d,orient='index') df['clovergrass']=df['Ryegrass']+df['Wclover'] norm170 = [v for k, v in allresults.items() if split_unique_name(k)['ManureMass']==170 and split_unique_name(k)['Soiltype'][0:3]==soil] cropkeys=[]
from Get_allyieldsC import get_allYields path = r'../RunK1-9' allresults = get_allYields(path) meanperkey = meanyields(allresults) #dictK = {key:value for key, value in meanperkey.items() if split_unique_name(key)['IsConventional']!= 'False'} soil = ['JB1', 'JB4', 'JB6'] cmean = pd.DataFrame() for s in soil: dict2 = { k: value for k, value in meanperkey.items() if split_unique_name(k)['Soiltype'][0:3] == s } df = pd.DataFrame.from_dict(dict2, orient='index') df['clovergrass'] = df['Ryegrass'] + df['Wclover'] means = df.mean(axis=0) cmean[s] = means norm = pd.read_excel('../common/Nnorm_2019.xlsx', sheet_name="Sheet1") norm.index = norm['Daisynavn1'] norm['yield_JB1tDM'] = norm['yieldfaktorDM'] * norm['yield_JB1'] norm['yield_JB4tDM'] = norm['yieldfaktorDM'] * norm['yield_JB4'] norm['yield_JB6tDM'] = norm['yieldfaktorDM'] * norm['yield_JB6'] cmean = cmean.join(norm[norm.columns[-3:]]) cmean['JB1_%fejl'] = round( (cmean['JB1'] - cmean['yield_JB1tDM']) / cmean['yield_JB1tDM'] * 100, 1)
@author: tqc268 """ ## Effekt of initalization level within rotations import numpy as np import pandas as pd from Get_allSOC import get_allSOM from split_nameDir import split_unique_name import matplotlib.pyplot as plt #path = r'../RunKonv' #dSOMperkey = get_allSOM(path) rota = [split_unique_name(k)['Rotation'] for k, v in dSOMperkey.items()] rk = np.unique(np.array(rota)) rotations = rk.tolist() manure = [split_unique_name(k)['ManureMass'] for k, v in dSOMperkey.items()] man = np.unique(np.array(manure)) ManureAmount = man.tolist() dict170 = { k: value for k, value in dSOMperkey.items() if split_unique_name(k)['ManureMass'] == 170 } soilC = ['low', 'med', 'high'] SOMmeandf = pd.DataFrame(index=rotations, columns=soilC) for sc in soilC: