Commit fed3aace authored by luroth's avatar luroth
Browse files

holiday

parent 599a3b41
......@@ -28,9 +28,10 @@ def tiller_prediction(LA, GDD_BBCH30):
:return: Estimation of tiller count
"""
# LA is m^2/m^2 (= mm^2/mm^2)
# LA is m^2/m^2 (= mm^2/m^2)
LA = LA * 10**6
# scale to plot size of 125 * 50 * 3 (mm)
LA = LA * (125 * 50 * 3)
LA = (LA / 1.0) * (0.125 * 0.150)
#Asym: Model was fit to plot size of 125 * 50 * 3 (mm)
Asym = 125 * 50 * 3
......@@ -231,8 +232,10 @@ def process_plant_count(path_campaign, delta_to_BBCH30,
def process_tiller_count(path_campaign, path_BBCH30_estimation = None,
def process_tiller_count(path_campaign, path_BBCH30_estimation = None,
path_BBCH30_measured = None, design=None):
GDD_from = - 200
GDD_to = 0
#print("Process campaigns ", path_campaign)
......@@ -259,6 +262,8 @@ def process_tiller_count(path_campaign, path_BBCH30_estimation = None,
df_BBCH30['GDD_date'] = pd.to_datetime(df_BBCH30['trait_value.timestamp']).dt.strftime("%Y-%m-%d")
df_GGD_at_BBCH30 = pd.merge(df_BBCH30, df_GDDs, left_on="GDD_date", right_on="campaign_date")
df_GGD_at_BBCH30['GDD_BBCH30_estimation'] = GDD - df_GGD_at_BBCH30.GDD
df_GGD_at_BBCH30['GDD_BBCH30_estimation'] = df_GGD_at_BBCH30['GDD_BBCH30_estimation'].median()
df_BBCH30_estimations = df_GGD_at_BBCH30
......@@ -270,6 +275,8 @@ def process_tiller_count(path_campaign, path_BBCH30_estimation = None,
df_BBCH30['GDD_date'] = pd.to_datetime(df_BBCH30['trait_value.timestamp']).dt.strftime("%Y-%m-%d")
df_GGD_at_BBCH30 = pd.merge(df_BBCH30, df_GDDs, left_on="GDD_date", right_on="campaign_date")
df_GGD_at_BBCH30['GDD_BBCH30_measurement'] = GDD - df_GGD_at_BBCH30.GDD
df_GGD_at_BBCH30['GDD_BBCH30_measurement'] = df_GGD_at_BBCH30['GDD_BBCH30_measurement'].median()
df_BBCH30_measurements = df_GGD_at_BBCH30
......@@ -277,10 +284,12 @@ def process_tiller_count(path_campaign, path_BBCH30_estimation = None,
LA_data = {}
for LA_file in LA_files:
df_LA = pd.read_csv(LA_file)
if path_BBCH30_estimation is not None:
df_LA = pd.merge(df_LA, df_BBCH30_estimations, left_on="plot_label", right_on='plot.plot_label')
if path_BBCH30_measured is not None:
df_LA = pd.merge(df_LA, df_BBCH30_measurements, left_on="plot_label", right_on='plot.plot_label')
if df_BBCH30_estimations is not None:
df_LA = pd.merge(df_LA, df_BBCH30_estimations[['plot.plot_label', 'GDD_BBCH30_estimation']], left_on="plot_label", right_on='plot.plot_label')
df_LA.drop(columns=['plot.plot_label'], inplace=True)
if df_BBCH30_measurements is not None:
df_LA = pd.merge(df_LA, df_BBCH30_measurements[['plot.plot_label', 'GDD_BBCH30_measurement']], left_on="plot_label", right_on='plot.plot_label')
df_LA.drop(columns=['plot.plot_label'], inplace=True)
parts = LA_file.name.split("_")
......@@ -299,8 +308,10 @@ def process_tiller_count(path_campaign, path_BBCH30_estimation = None,
else:
raise Exception("Do not know how to parse name " + LA_file.name)
LA_data[design_label] = df_LA
df_LA['LA'] = df_LA['value']
LA_data[design_label] = df_LA
# Calc tiller count
for design_label, df_ in LA_data.items():
if design is not None and design_label != design:
......@@ -315,10 +326,10 @@ def process_tiller_count(path_campaign, path_BBCH30_estimation = None,
if path_BBCH30_estimation is not None:
# Filter out too far GDD_BBCH30 values
df__ = df_.loc[(df_['GDD_BBCH30_estimation'] > - 160) & (df_['GDD_BBCH30_estimation'] < -40)].copy()
df__ = df_.loc[(df_['GDD_BBCH30_estimation'] > GDD_from) & (df_['GDD_BBCH30_estimation'] < -GDD_to)].copy()
df__['tiller_estimation_bbch_estimation'] = [
tiller_prediction(row['value'], row['GDD_BBCH30_estimation']) for index, row in df__.iterrows()]
tiller_prediction(row['LA'], row['GDD_BBCH30_estimation']) for index, row in df__.iterrows()]
df__['trait'] = "PltTilDen"
df__['trait_id'] = 34
......@@ -326,7 +337,7 @@ def process_tiller_count(path_campaign, path_BBCH30_estimation = None,
df__['timestamp'] = datetime.strptime(campaign_date, "%Y%m%d")
df__['GDD_BBCH30'] = df__['GDD_BBCH30_estimation']
df__ = df__[['trait', 'trait_id', 'tiller_estimation_bbch_estimation', 'timestamp', 'GDD_BBCH30', 'plot_label']].copy()
df__ = df__[['trait', 'trait_id', 'tiller_estimation_bbch_estimation', 'timestamp', 'GDD_BBCH30', 'plot_label', 'LA']].copy()
df__['value'] = df__['tiller_estimation_bbch_estimation']
df__['value_json'] = df__.apply(lambda row: row.iloc[4:5].to_json(), axis=1)
......@@ -335,6 +346,7 @@ def process_tiller_count(path_campaign, path_BBCH30_estimation = None,
print("Calculated tillers, bbch30 estimation: median",
np.nanmedian(df__['tiller_estimation_bbch_estimation']))
print("Median GDD_BBCH30 estimated:", df__['GDD_BBCH30'].median())
print("Median LA:", df__['LA'].median())
df__.to_csv(path_trait_csvs / (design_label + "_bbch30estimation-tillers.csv"), index=False)
else:
# remove trait file if no measurements found
......@@ -346,10 +358,10 @@ def process_tiller_count(path_campaign, path_BBCH30_estimation = None,
if path_BBCH30_measured is not None:
# Filter out too far GDD_BBCH30 values
df__ = df_.loc[(df_['GDD_BBCH30_measurement'] > - 160) & (df_['GDD_BBCH30_measurement'] < -40)].copy()
df__ = df_.loc[(df_['GDD_BBCH30_measurement'] > GDD_from) & (df_['GDD_BBCH30_measurement'] < GDD_to)].copy()
df__['tiller_estimation_bbch_measurement'] = [
tiller_prediction(row['value'], row['GDD_BBCH30_measurement']) for index, row in df__.iterrows()]
tiller_prediction(row['LA'], row['GDD_BBCH30_measurement']) for index, row in df__.iterrows()]
df__['trait'] = "PltTilDen"
df__['trait_id'] = 34
......@@ -357,7 +369,7 @@ def process_tiller_count(path_campaign, path_BBCH30_estimation = None,
df__['timestamp'] = datetime.strptime(campaign_date, "%Y%m%d")
df__['GDD_BBCH30'] = df__['GDD_BBCH30_measurement']
df__ = df__[['trait', 'trait_id', 'tiller_estimation_bbch_measurement', 'timestamp', 'GDD_BBCH30', 'plot_label']].copy()
df__ = df__[['trait', 'trait_id', 'tiller_estimation_bbch_measurement', 'timestamp', 'GDD_BBCH30', 'plot_label', 'LA']].copy()
df__['value'] = df__['tiller_estimation_bbch_measurement']
df__['value_json'] = df__.apply(lambda row: row.iloc[4:5].to_json(), axis=1)
......@@ -367,6 +379,7 @@ def process_tiller_count(path_campaign, path_BBCH30_estimation = None,
print("Calcualted tillers, bbch30 measurement: median",
np.nanmedian(df__['tiller_estimation_bbch_measurement']))
print("Median GDD_BBCH30 measured:", df__['GDD_BBCH30'].median())
print("Median LA:", df__['LA'].median())
df__.to_csv(path_trait_file, index=False)
else:
print("No measured BBCH30 measurements left after filtering, delete potential trait file")
......
......@@ -2,7 +2,7 @@ from GroundAerialCoverage import CanopyAnalysis
from pathlib import Path
path_p = Path("P:/")
#path_p = Path("/home/luroth/public")
path_p = Path("/home/luroth/public")
if __name__ == "__main__":
......
......@@ -2,7 +2,7 @@ from GroundAerialCoverage import CanopyAnalysis
from pathlib import Path
path_p = Path("P:/")
#path_p = Path("/home/luroth/public")
path_p = Path("/home/luroth/public")
if __name__ == "__main__":
......
......@@ -2,7 +2,7 @@ from GroundAerialCoverage import CanopyAnalysis
from pathlib import Path
path_p = Path("P:")
#path_p = Path("/home/luroth/public")
path_p = Path("/home/luroth/public")
if __name__ == "__main__":
......
......@@ -2,7 +2,7 @@ from GroundAerialCoverage import CanopyAnalysis
from pathlib import Path
path_p = Path("P:/")
#path_p = Path("/home/luroth/public")
path_p = Path("/home/luroth/public")
if __name__ == "__main__":
......@@ -14,6 +14,10 @@ if __name__ == "__main__":
plant_count_date_10 = "20190312"
plant_count_date_5 = "20190319"
plant_count_date_15 = "20190312"
plant_count_date_10 = "20190319"
plant_count_date_5 = "20190402"
# Plant count estimate
path_plant_count_campaign_15 = base_path_campaign / plant_count_date_15 / '28m_M600P'
path_plant_count_campaign_10 = base_path_campaign / plant_count_date_10 / '28m_M600P'
......
......@@ -2,7 +2,7 @@ from GroundAerialCoverage import CanopyAnalysis
from pathlib import Path
path_p = Path("P:/")
#path_p = Path("/home/luroth/public")
path_p = Path("/home/luroth/public")
if __name__ == "__main__":
......
......@@ -2,7 +2,7 @@ from GroundAerialCoverage import CanopyAnalysis
from pathlib import Path
path_p = Path("P:/")
#path_p = Path("/home/luroth/public")
path_p = Path("/home/luroth/public")
if __name__ == "__main__":
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment