API references
iwin.HT
Colors class:
Examples:
- Reset all colors with colors.reset
- Two subclasses fg for foreground and bg for background.
Use as colors.subclass.colorname. i.e. colors.fg.red or colors.bg.green
Also, the generic bold, disable, underline, reverse, strikethrough, and invisible work with the main class i.e. colors.bold
iwin.Site(uid, loc, attributes, params)
Bases: object
Object containing attributes and functions related to the nursery site.
Deprecated
Stop using this class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uid |
integer
|
The unique identifier for the site. |
required |
loc |
integer
|
The number of the location. |
required |
attributes |
object
|
The default attributes for each location in IWIN dataset. |
required |
params |
dictionary
|
The parameters to use during calculations. |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
whatever |
int
|
Some integer. |
Attributes:
| Name | Type | Description |
|---|---|---|
attributes |
str
|
Human readable string describing the attributes collected for a particular site. |
Return
A site with all attributes during processing.
Examples:
Todo
- For module TODOs
- You have to also use
sphinx.ext.todoextension
iwin.Site.getRangeDates(s=None, e=None, verbose=False)
Get range dates for growing period
:param s: Start date eg. Sowing date :param e: End date eg. Maturity date
:return: an array or pandas series with the dates in between, or None if error occurs
iwin.Site.getPhenologyDates(m=None, verbose=False)
Get phenology dates from reported or estimated
iwin.Site.getEstimatedEmergence(m=None, verbose=True)
Get Estimated Emergence
iwin.Site.getEstimatedHeading(m=None, verbose=True)
Get Estimated Heading
iwin.Site.getEstimatedMaturity(m=None, threshold=None, scale=None, rate=None, daysGF=None, verbose=True)
Get Estimated Maturity from Observed Heading and Predicted Heading
iwin.Site.getEstimatedPhenologyDates(m=None, verbose=False)
Estimated Phenology (Emergence, Heading, Maturity)
iwin.Site.getWeather(weatherDF=None, s=None, e=None)
Get phenology dates for growing period
:param weatherDF: A pandas dataframe with weather data :param s: Start date eg. Sowing date :param e: End date eg. Maturity date
:return: a pandas dataframe with the filtered weather data, or None if error occurs
iwin.Site.getSowingDOY()
Get the Day of the Year for Sowing date
iwin.Site.getDayLength(d=None, lat=None, p=0.0)
Get Day length
iwin.Site.getDayLengthDAP(m=None, DAP=None)
Get Date after planting and Day length
:params DAP: Days after sowing date
:return: tuple with Date and Daylength
iwin.Site.getTDay(m=None, w=None, tminFactor=None)
Calculate day time temperature
:param w: Table of weather data with Minimum and Maximum Temperatures :param tminFactor: Minimum Temperature factor
:return: a number or array of Day Temperature
iwin.Site.getGDD(m=None, w=None, Tbase=0)
Growing degree days GDD (°F or °C) Calculated from: ((Daily Max Temp + Daily Min Temp)/2) - 32 °F (or ((Daily Max Temp + Daily Min Temp)/2)).
:param Tmin: Number or array of Minimum Temperatures :param Tmax: Number or array of Maximum Temperatures :param Tbase: Temperature base of the crop
:return: a number or array of Growing degree days (GDD)
iwin.Site.getPRFT(m=None, TDay=None, TOpt=None)
Estimate Photosynthesis reduction factor (PRFT) PRFT = 1 – 0.0025 * (TDay – TOpt)^2
:param TDay: Number or array of Day Temperatures :param TOpt: Optimum Temperature
:return: a number or array of PRFT
iwin.Site.getEmergenceDate(m=None, cGDD=None, GDDreq=None, verbose=False)
Estimate emergence date
Day on which cumulative thermal time reaches 180 GDD (Tbase = 0ºC)
:params cGDD: Cumulative Sum of GDD :params GDDreq: GDD or thermal time required to emergence :params ts: convert date to Timestamp
:return: an emergence date
iwin.Site.getDaysToHeading(m=None, dayHR=None)
Estimate days to heading after sowing date
:params dayHR: Daylength
The following Curves are only applied for ESWYT, IDYN and HTWYT data sets If daylength @ 35 DAS < 10.8 hrs DAYS_TO_HEADING = 491.27 - 38.62 * DayLength @ 35DAS (daylength in hours) If daylength @ 35 DAS > 10.8 hrs DAYS_TO_HEADING = 115.36 - 3.87 * DayLength @ 35DAS
SAWYT is earlier If daylength @ 35 DAS < 10.8 hrs DAYS_TO_HEADING = 617.68 - 51.406 * DayLength@35DAS (daylength in hours) If daylength @ 35 DAS > 10.8 hrs DAYS_TO_HEADING = 87.38 – 2.36 * DayLength @ 35DAS
:return: Estimated days to heading after sowing date
iwin.Site.getMaturityDate(m=None, threshold=None, scale=None, rate=None, daysGF=None, verbose=False)
Estimate maturity date from weather using TAdjDays
:params m: model with the global configuration, parameters and data :params threshold: A threshold to adjust the number of temperature days :params scale: A scale to adjust the number of temperature days :params rate: A rate to adjust the number of temperature days :params daysGF: Days to grain filling
:return: Estimated days to maturity, Maturity date and number of days between heading to maturity date.
iwin.Site.getWeatherParameters(m=None, season=False, verbose=False)
Get additional weather parameters per site
- Avg minimum temperature during growing season
- Avg maximum temperature during growing season
- Avg mean temperature during growing season
- Avg solar radiation during growing season
- Total amount of precipitation during growing season
:params weather: the weather dataset for the specific site
:return: An updated attributes of the site
iwin.Site.setupIPAR(m, _mask_EH=None, _mask_pEH=None, _mask_EpH=None, _mask_pEpH=None, _mask_HM=None, _mask_pHM=None, _mask_HpM=None, _mask_pHpM=None, verbose=False)
Setup parameters to calculate iPAR
iwin.Site.getNormalizeThermalTime(m=None, cGDD_EH=None, cGDD_pEH=None, cGDD_EpH=None, cGDD_pEpH=None, cGDD_HM=None, cGDD_pHM=None, cGDD_pHpM=None, cGDD_HpM=None, verbose=False)
Normalize GDD or Thermal time
iwin.Site.updateWeatherparams(_mask_SE=None, _mask_SpE=None, _mask_EH=None, _mask_pEH=None, _mask_EpH=None, _mask_pEpH=None, _mask_EM=None, _mask_pEM=None, _mask_pEpM=None, _mask_SM=None, _mask_SpM=None, _mask_SH=None, _mask_SpH=None, _mask_HM=None, _mask_HpM=None, _mask_pHM=None, _mask_pHpM=None, _mask_dDAS_H=None, _mask_dDAS_pH=None, season=False, verbose=False)
Update weather statistics
:params _mask_SM: Filter used to get weather data from Sowing to Maturity :params _mask_SH: Filter used to get weather data from Sowing to Heading :params _mask_EH: Filter used to get weather data from Emergence to Heading :params _mask_pEH: Filter used to get weather data from predicted Emergence to Heading :params _mask_HM: Filter used to get weather data from Heading to Maturity :params _mask_SpM: Filter used to get weather data from Sowing to estimated Maturity :params _mask_SpH: Filter used to get weather data from Sowing to estimated Heading :params _mask_pEpH: Filter used to get weather data from predicted Emergence to estimated Heading :params _mask_HpM: Filter used to get weather data from Heading to estimated Maturity :params _mask_pHpM: Filter used to get weather data from estimated Heading to estimated Maturity :params _mask_dDAS_H: Filter used to get weather data from 35 days after Sowing to Heading :params _mask_dDAS_pH: Filter used to get weather data from 35 days after Sowing to estimated Heading
:params season: Display weather statistics for different periods
:result: A Site with updated weather statistics
iwin.Site.estimateNDVI(m=None, verbose=False)
Estimate NDVI values for growing cycle.
Use of Normalized Thermal Time and Observed NDVI to calculate IPAR from Emergence to Heading
:params Norm_TT_EH: Normalize GDD or Thermal time from Emergence to Heading
:return: An array with NDVI values from Emergence to Heading
iwin.Site.estimateNDVI_EH(m=None, Norm_TT_EH=None, verbose=False)
Estimate NDVI values from emergence to heading.
Use of Normalized Thermal Time and Observed NDVI to calculate IPAR from Emergence to Heading
:params Norm_TT_EH: Normalize GDD or Thermal time from Emergence to Heading
:return: An array with NDVI values from Emergence to Heading
iwin.Site.estimateNDVI_HM(m=None, Norm_TT_HM=None, NDVI_atHeading=None, verbose=False)
Estimate NDVI values from Heading to Maturity.
Use of Normalized Thermal Time and Observed NDVI to calculate IPAR from Heading to Maturity.
:params norm_TT_HM: Normalize GDD or Thermal time from Heading to Maturity :params NDVI_max: Maximum NDVI value allowed :params NDVI_atHeading: NDVI reached at Heading date :verbose: Display messages during the processing
:return: An array with NDVI values from Heading to Maturity
iwin.Site.getIPAR(m=None, norm_iPAR_EH_bounds=None, NDVI_constantIPAR=None, RUE=None, YIELD_FACTOR=None, verbose=False)
Total light interception - iPAR
** Asrar, G., Fuchs, M., Kanemasu, E.T., Hatfield, J.L., 1984.
Estimating absorbed photosynthetic radiation and leaf area index from spectral reflectance
in wheat. Agron. J. 76, 300–306.
- Campos 2018 Remote sensing-based crop biomass with water or light-driven crop growth models in
wheat commercial fields
iPAR = NDVI * 1.25 - 0.19 # between heading and maturity (Campos et al. 2018) iPAR = NDVI * 1.25 - 0.21 Daughtry et al. (1992)
:params m: Model with configuration and parameters :params norm_iPAR_EH_bounds: Bounds for iPAR multi-linear equations
:return: An array of Total light interception values
iwin.Site.fit(m=None, season=True, verbose=False)
Run a iPAR Yield model to fit yield
:params m: Model to run :params sites_to_run: Array of Site objects :params season: Display weather statistics for different periods
:resutls: An array of Sites with intermediate results
iwin.gxe
iwin.gxe.Nursery(nursery, data, params=None, weather=None)
Bases: object
iwin.gxe.Nursery.getAvgYieldbyNurseryYear(df=None, nursery=None, verbose=False)
For each nursery year, calculate the average yield of each location and Occ.
:params df: :params nursery:
:return:
iwin.gxe.Nursery.genotypeSelection_byLinearRegression(df_GY=None, nursery=None, methods=['OLS', 'RANSAC'], verbose=True)
Select GIDs by linear regression lines
Method 1: OLS Method 2: Robust linear regression (RANSAC)
iwin.gxe.Nursery.getEnvironment(p, avgGrainYield)
Use cross product to determine whether a point lies above or below a line.
iwin.gxe.Nursery.getClass_old(p, avgGrainYield, avgEnv, target, qd=4)
Use cross product to determine whether a point lies above or below a line.
iwin.gxe.Nursery.getClass(p, avgGrainYield, avgEnv, target=None, qd=4)
Use cross product to determine whether a point lies above or below a line.
iwin.gxe.Nursery.getNumOfOcurrences(df=None, nursery=None, top=10, target=None, qd=4)
Get number of occurrences in classification method
iwin.gxe.Nursery.getNumOfOcurrences_old(df=None, nursery=None, top=10, target=['AL', 'BH', 'AH', 'BL'], qd=4)
Get number of occurrences in classification method
iwin.gxe.Nursery.processLRMethods(df=None, nursery=None, dirname='./', fmt='pdf', saveFig=True, showFig=True, verbose=True)
Process and generate a figure using the classification method proposed by Urs
iwin.gxe.Nursery.processClassificationMethod_old(df=None, nursery=None, target=['LA', 'LB', 'HA', 'HB'], qd=9, threshold=10, dirname='./', fmt='pdf', saveFig=True, showFig=True, verbose=False)
Classify nurseries by avg grain yield
iwin.gxe.Nursery.processClassificationMethod(df=None, nursery=None, target=['AL', 'BH', 'AH_A', 'AH_B', 'BL_A', 'BL_B'], qd=4, threshold=10, dirname='./', fmt='pdf', plot_params=None, saveFig=True, showFig=True, verbose=False)
Classify nurseries by avg grain yield
iwin.gxe.Nursery.commonGIDsinMethods(df_raw=None, df=None, selGIDs_m3=None, nursery=None, lw=0.8, hue='G', s=65, alpha=0.85, loc=2, ncol=1, xt_tl=0.01, yt_tl=0.99, ha='left', va='top', dirname='./', fmt='pdf', showFig=True, saveFig=True, verbose=False)
Combine all of the methods applied to the genotypes selection
iwin.gxe.Nursery.commonGIDsinMethods_v2(df_raw=None, df=None, selGIDs_m3=None, nursery=None, bothEnvs=True, lw=0.8, hue='G', s=65, alpha=0.85, loc=2, ncol=1, xt_tl=0.01, yt_tl=0.99, ha='left', va='top', dirname='./', fmt='pdf', showFig=True, saveFig=True, verbose=False)
Combine all of the methods applied to the genotypes selection
iwin.gxe.Nursery.prepareDatasetforGEmodel(df_gen=None, nursery=None, verbose=False)
Prepare data as an input for the GxE models
iwin.gxe.Nursery.GEmeans(df_ge=None, trial=0, title='', byCountry=False, showFig=True, saveFig=False, annot=True, square=True, dirname='./', fmt='pdf', verbose=False)
Display Genotype, Environment and Genotype-environment means
Genotype’s performance across environments shown in line plots and heatmaps Spatial variations (Heat-maps) for all Genotypes all Environemnts
iwin.gxe.Nursery.ge_impute_missing_values(data=None, threshold=0.5, fillna=True, verbose=False)
Select better environments and Genotypes along sites with no empty values. Remove environments or Genotypes with more than 50% or threshold value of empty data. Fill the rest of the null values with the mean by Environment.
:params data: Table of Genotypes, Environments and GE means :params threshold: Upper limit in percentage to remove emtpy Environments and Genotypes records
:results: A cleaner two-way table of means
iwin.gxe.Nursery.geAMMI(data=None, Gen='G', Env='E', trait='GY', trialname=None, twt=False, threshold=0.5, fillna=True, centering=False, scaling=False, n_components=None, verbose=False)
Additive Main Effect and Multiplicative interaction model
:params data: table with Genotypes, Environments and traits observations :params twt: if the data is Two-way table of means, default False or in long format.
:returns: AMMI model
iwin.gxe.Nursery.geGGE(data=None, env='ENV', gen='GEN', trait='GY', trialname=None, params=None, twt=False, impute_missing_threshold=0.5, verbose=False)
Genotype plus Genotype-Environment interaction model
iwin.gxe.Nursery.gge_rankingG(data=None, env='ENV', gen='GEN', trait='GY', impute_missing_threshold=0.5, params=None, twt=False, title=None, plot_params=None, saveFig=True, showFig=True, dirname='./', fmt='pdf', verbose=False)
Ranking Genotypes Relative to the Ideal Genotype
An ideal genotype should have both high mean performance and high stability across environments.
This figure defines an “ideal” genotype (the center of the concentric circles) to be a point on the AEA (“absolutely stable”) in the positive direction and has a vector length equal to the longest vectors of the genotypes on the positive side of AEA (“highest mean performance”). Therefore, genotypes located closer to the ‘ideal genotype’ are more desirable than others.
This Figure illustrates an important concept regarding “stability”. The term “high stability” is meaningful only when associated with mean performance
Note: it should be easy to see how misleading it can be to search and select for “stability” genes. “Stable” genotypes are desirable only when they have high mean performances.
iwin.gxe.Nursery.gge_www(data=None, env='ENV', gen='GEN', trait='GY', impute_missing_threshold=0.5, params=None, twt=False, title=None, plot_params=None, saveFig=True, showFig=True, dirname='./', fmt='pdf', verbose=False)
Which-won-where
One of the most attractive features of a GGE biplot is its ability to show the which-won-where pattern of a genotype by environment dataset. Many researchers find this use of a biplot intriguing, as it graphically addresses important concepts such as crossover GE, mega-environment differentiation, specific adaptation, etc.
Genotypes located on the vertices of the polygon performed either the best or the poorest in one or more environments.
- The perpendicular lines are equality lines between adjacent genotypes on the polygon, which facilitate visual comparison of them.
- The equality lines divide the biplot into sectors, and the winning genotype for each sector is the one located on the respective vertex.
- This pattern suggests that the target environment may consist of XXXX different mega-environments and that different cultivars should be selected and deployed for each.
iwin.gxe.Nursery.extract_Weather(df_raw=None, df_gen=None, df_weather=None, verbose=False)
Extract weather data from AgERA5 dataset for each location
Use 150 days after planting to define the growing season
iwin.gxe.Nursery.extract_Weather_growthStages(df_raw=None, df_gen=None, df_weather=None, verbose=False)
Extract weather data from AgERA5 dataset for each location
Use 150 days after planting to define the growing season
iwin.gxe.ammi
iwin.gxe.ammi.AMMI(data, trait='', trialname='', params=None)
Bases: object
iwin.gxe.ammi.AMMI.cal_env_residuals()
Cálculo de residuales con respecto a la media de los ambientes
iwin.gxe.ammi.AMMI.calc_gen_residuals()
Cálculo de residuales con respecto a la media de los genotipos
iwin.gxe.ammi.AMMI.plot(title=None, bptype=0, plot_params=None, saveFig=True, showFig=True, dirname='./', fmt='pdf')
Display biplot
iwin.gxe.gge
iwin.gxe.gge.GGE(data, env=None, gen=None, trait=None, trialname='', params=None, twt=False, verbose=False)
Bases: object
Genotype plus Genotype-Environment interaction model
iwin.gxe.gge.GGE.best_G(verbose=False)
Select the best or nearest Genotype after GGE ranking Genotypes relative to the Ideal Genotype
iwin.gxe.gge.GGE.calc_env_residuals()
Cálculo de residuales con respecto a la media de los ambientes
iwin.gxe.gge.GGE.calc_gen_residuals()
Cálculo de residuales con respecto a la media de los genotipos
iwin.gxe.gge.GGE.get_twoway_table(impute_missing_threshold=0.5, fillna=True, verbose=False)
Create two-way table of means
iwin.gxe.gge.GGE.impute_missing_values(data=None, impute_missing_threshold=0.5, fillna=True, verbose=False)
Select better environments and Genotypes along sites with no empty values. Remove environments or Genotypes with more than 50% or threshold value of empty data. Fill the rest of the null values with the mean by Environment.
:params data: Table of Genotypes, Environments and GE means :params impute_missing_threshold: Upper limit in percentage to remove empty Environments and Genotypes records
:results: A cleaner two-way table of means
iwin.gxe.gge.GGE.prepare_data(verbose=False)
Prepare data for GGE biplots
iwin.gxe.gge.GGE.getMegaEnvironments(lim_span=0.25, mxlim=10, verbose=False)
Get Mega-Environments using GGE biplot
iwin.gxe.gge.GGE.plot(title=None, bptype=0, selE=None, selG=None, plot_params=None, saveFig=False, showFig=True, dirname='./', fmt='pdf')
Display biplot
iwin.util
iwin.util.is_number(s)
Check if the string is a number
Raises:
| Type | Description |
|---|---|
ValueError
|
Not a number. |
iwin.util.getDOY(d)
Get Day of the Year
iwin.util.find_nearest_value(array, value)
Find nearest value to a user define value from array
:params array: Array of values :params value: value to find into the array
:return: a number with the nearest value found
iwin.util.find_nearest_index(array, values)
Find nearest index to a user define value from array
:params array: Array of values :params values: value to find into the array
:return: a number with the nearest index found
iwin.util.find_nearest(array, value)
Find nearest index and value to a user define value from array
:params array: Array of values :params value: value to find into the array
:return: a number with the nearest value found
iwin.util.getScores(df, fld1=None, fld2=None)
Get stats for model results
iwin.util.getAccuracy(y_true, y_predicted)
Calculate accuracy and precision for each year in a nursery site
iwin.util.missing_values_table(df)
Look for missing values in a dataset
iwin.util.missingData(df_GE=None, title='IWIN GxE\nMissing data', dirname='./', fmt='pdf', showFig=True, saveFig=False, verbose=True)
Looking for missing values Check for all the variables in an arrays or pandas DF and visualize the missing data
iwin.util.findNearest_point(arr=None, pnt=None, verbose=False)
Select the nearest point
iwin.util.getExtrapoledLine(p1, p2, EXTRAPOL_RATIO=5, rtn_coods=False)
Creates a line extrapoled in p1->p2 direction
iwin.util.custom_rolling(d, w=2, op='min')
Duplica el arreglo para completar todos las columnas con el numero de datos seleccionado para la ventana
iwin.util.assignME(df)
Mega-environments
Al momento solo ME4
iwin.util.normalize_Yield(yld, perc)
Use 95th percentile of yield (top 5%) of each site-year as a reference and express the yield of each GID within a site-year in percent of the top yield.
iwin.util.tidy_corr_matrix(corr_mat)
Función para convertir una matriz de correlación de pandas en formato tidy.
iwin.util.idenfifyTargetGIDs_byNurseryYear(df_filtered, nursery='ESWYT', path_to_save_results='./', drawFigures=False, verbose=True)
Extract the targeted GIDs from a pre-processed IWIN dataset
Classify trials in
- Above Avg in Low Yielding Envs - Below Avg in High Yielding Envs
- Below Avg in Low Yielding Envs - Above Avg in High Yielding Envs
- Highest/Lowest norm. Yield GIDs
- Above Avg. Low Temperature GIDs
- Above Avg. High Temperature GIDs
- Support or not warmer temperature
- Warmest Environments
Return 3 tables with linear model parameters
iwin.util.filterTargetGIDs_byThresholdMaxTemperature(df_filtered, GIDs_inTarget_highTemperature, nursery='ESWYT', avgLT_threshold=10.0, avgHT_threshold=30.0, gt32C_ndays_threshold=10, path_to_save_results='./', saveFiles=True, verbose=True)
Filter target GIDs by Temperature using Season_TMAX_mean and S-H_TMAX_gt32C_ndays as references
iwin.util.displayMap_spatialDistSelectedGIDs(df_gids, nursery='ESWYT', path_to_save_results='./', saveFig=True, verbose=False)
Spatial distribution of selected IWIN genotypes
iwin.util.displayGenotypeSensitivitybyWeather(df_final, gid, yFld='Grain Yield', nursery='ESWYT', path_to_save_results='./', saveFig=False)
The Eberhart and Russell regression with the grain yield environmental means along the x-axis replaced with a climate variable.
Genotypes differ in their sensitivity to climate variables
iwin.util.displayTempVsGY_inGrowStagesforAllGIDs(df_filtered, df_HT, nursery='ESWYT', path_to_save_results='./', saveFig=True)
Temperature vs Grain Yield in 3 growth stages (all GIDs)
iwin.util.drawTemperaturebyGrowthStage_acrossYears(df_data=None, nursery='NURSERY', temp='TMAX', s=20, s2=80, alpha=0.75, lw=1.5, bxplot=False, dirname='GrowthStages_Temperature', fname='TemperatureAcrossYrsxGrowthstage', path_to_save_results='./', saveFig=False, showFig=True, fmt='pdf')
Average daily temperature across years vs mean grain yield by GID
iwin.util.drawTemperaturebyGrowthStage_acrossYears_v2(df_data=None, nursery='NURSERY', s=20, s2=80, alpha=0.75, lw=1.5, bxplot=False, dirname='GrowthStages_Temperature', fname='TemperatureAcrossYrsxGrowthstage_v2', path_to_save_results='./', saveFig=False, showFig=True, fmt='pdf')
Average daily temperature across years vs mean grain yield by GID
iwin.util.drawRegCoefficientbyGrowthStage_acrossYears(df_data=None, nursery='NURSERY', splitYear=2000, trendVar='Temperature', s=20, s2=80, alpha=0.75, lw=1.5, bxplot=False, dirname='GrowthStages_Temperature', fname='TemperatureAcrossYrsxGrowthstage_v3', path_to_save_results='./', saveFig=False, showFig=True, fmt='pdf')
Average daily temperature across years vs mean grain yield by GID
iwin.util.drawCompareGYvsTMAXbyGS(df_data=None, GIDs2compare=None, nursery='NURSERY', s=10, s2=30, alpha=0.65, lw=1.25, dirname='GrowthStages_Temperature', fname='CompareGYvsTMAXbyGS', path_to_save_results='./', saveFig=False, showFig=True, fmt='pdf')
Comparison of Genotypes vs Maximum Temperature by growth stage display the average daily temperature across years vs mean grain yield by selected GID
iwin.util.ranking_selectedGenotypes(df_final)
Ranking Selected Genotypes
iwin.util.getVarietyCounts(df, top=5)
Count the number of site-year trials using a cultivar
iwin.util.searchParenLines(df_raw, df_GY_sorted, top=50)
Identifying parents lines
iwin.util.seachWheatLinesInExtremeWeather(df_raw, df, n='ESWYT', AVGHT_THRESHOLD=30.0, GT32C_NDAYS_THRESHOLD=10, splitYear=2005, top=30, path_to_save_results='./', s=10, s2=30, drawFigures=False, showFig=True, verbose=True)
Run all processes in one step to identify best pedigrees in low yielding environments and extreme weather.
iwin.util.figures
iwin.util.figures.chart_compareResults(df_result=None, fld1=None, fld2=None, alpha=0.75, s=15, xy_lim=2, hue=None, loc_leg=2, ncol=2, ha='left', va='top', title='', xlabel='', ylabel='', dirname='RUNS', fname='iPAR_model_', dispScore=True, dispLegend=True, saveFig=False, showFig=True, fmt='pdf')
Display a scatter plot to compare two variables in the results
Parameters
:params df_result: A pandas DataFrame with the results and variables to compare :params fld1: Variable or column name to compare :params fld2: Variable or column name to compare :params alpha: Transparency of the points in chart :params s: Size of the points in chart :params xy_lim: Used to extend the x-axis limit. Default 2 units :params hue: Variable to classify or discriminate the results in colors :params title: Title of the figure :params xlabel: Label of the x-axis :params ylabel: Label of the y-axis :params dirname: Folder name to save results :params fname: File name to save the figure :params dispScore: Display the accurracy and others stats of the model :params dispLegend: Display the legend of the chart :params saveFig: Save file in JPG or PDF format :params fmt: Format of the output
Returns
:results: A figure in JPG or PDF format with the filename specified into the folder name
iwin.util.figures.chart_compareYieldResults(df_result=None, title='iPAR Yield model', alpha=0.95, s=25, xy_lim=2, hue='country', loc_leg=2, ncol=4, xt_tl=0.03, yt_tl=0.99, ha='left', va='top', dirname='Figures', fname='Figure', dispScore=True, saveFig=True, showFig=True, sharex=False, sharey=False, fmt='pdf')
Create a figure to compare several iPAR model simulations results of grain yield
:params df_result: A table or DataFrame with the needed data :params title: Name of the figure :params alpha: Transparency of the points in chart :params s: Size of the points in chart :params xy_lim: Used to extend the x-axis limit. Default 2 units :params hue: Variable to classify or discriminate the results in colors :params ncol: Number of columns to split the legend :params dirname: Folder name to save results :params fname: File name to save the figure :params saveFig: Save file or export the figure :params sharex: Share or align all x-axis, it will use the same x scale for all charts if the value is True :params sharey: Share or align all y-axis, it will use the same y scale for all charts if the value is True :params fmt: Format of the output (PNG, JPG or PDF)
:results: An integrated figure with 4 charts showing result simulations
iwin.util.figures.chart_compareDaysFromStagesResults(df_result=None, title='iPAR Yield model', alpha=0.95, s=25, xy_lim=2, hue='loc_code', ncol=4, xt_tl=0.01, yt_tl=0.99, ha='left', va='top', dirname='Figures', fname='Figure', dispScore=True, saveFig=True, showFig=True, sharex=False, sharey=False, fmt='pdf')
Create a figure to compare several iPAR model simulations results of grain yield
:params df_result: A table or DataFrame with the needed data :params title: Name of the figure :params alpha: Transparency of the points in chart :params s: Size of the points in chart :params xy_lim: Used to extend the x-axis limit. Default 2 units :params hue: Variable to classify or discriminate the results in colors :params ncol: Number of columns to split the legend :params dirname: Folder name to save results :params fname: File name to save the figure :params saveFig: Save file or export the figure :params sharex: Share or align all x-axis, it will use the same x scale for all charts if the value is True :params sharey: Share or align all y-axis, it will use the same y scale for all charts if the value is True :params fmt: Format of the output (PNG, JPG or PDF)
:results: An integrated figure with 4 simulation charts
iwin.util.figures.chartObsYieldTrendsAllNurseries(df_N=None, title='Observed yield trend', s=15, alpha=0.3, addMaxMinTexts=False, saveFig=True, showFig=True, dirname='./', fmt='pdf')
Display a grain yield trends by year
:params saveFig: Save file in JPG or PDF format :params fmt: Format of the output
:results: A figure in JPG or PDF format with the filename specified into the folder name
iwin.util.figures.chartAvgObsYieldTrendsAllNurseries(df_N=None, title='Average observed yield trends', s=50, alpha=0.83, saveFig=True, showFig=True, dirname='./', fmt='pdf')
Display average grain yield trends by year
:params saveFig: Save file in JPG or PDF format :params fmt: Format of the output
:results: A figure in JPG or PDF format with the filename specified into the folder name
iwin.util.figures.figure_AvgYieldbyGID_LR(avgGY_1=None, nursery='', hue='G', hue2=None, hue3=None, hue4=None, lw=0.8, s=10, s4=20, alpha=0.45, alpha2=0.85, alpha4=0.95, loc=2, ncol=3, xt_tl=0.01, yt_tl=0.99, ha='left', va='top', methods=['OLS', 'RANSAC'], fld1='AvGYxLocOcc', fld2='AvGYxGID', saveFig=True, showFig=True, dirname='./', fmt='pdf')
Display a figure with regression lines applied for GIDs
iwin.util.figures.figure_AvgYieldbyGID_classify(avgGY_1=None, avgGY_2=None, df_countOfGIDs=None, topGinBEnv=None, topGinGEnv=None, nursery='', threshold=5, hue='G', hue2=None, hue3=None, hue4=None, lw=0.8, s=10, s4=20, alpha=0.45, alpha2=0.85, alpha4=0.95, loc=2, ncol=3, xt_tl=0.01, yt_tl=0.99, ha='left', va='top', fld1='AvGYxGID', fld2='AvGYxLocOcc', dispTxt=False, saveFig=True, showFig=True, dirname='./', fmt='pdf')
Display a figure with regression lines applied for GIDs
iwin.util.figures.figure_AvgYieldbyGID_classify_v2(avgGY_1=None, avgGY_2=None, df_countOfGIDs=None, topGinBEnv=None, topBinGEnv=None, nursery='', threshold=5, hue='G', hue2=None, hue3=None, hue4=None, lw=0.8, s=10, s4=35, alpha=0.45, alpha2=0.85, alpha4=0.95, loc=4, ncol=3, xt_tl=0.01, yt_tl=0.99, ha='left', va='top', fld1=' AvGYxGID', fld2='AvGYxLocOcc', dispTxt=False, saveFig=True, showFig=True, dirname='./', fmt='pdf')
Display a figure with regression lines applied for GIDs
iwin.util.figures.plot_AvgYieldbyGID_classify(avgGY_1=None, selGIDs_m3=None, numGIDsOfOcurrences=None, nursery=None, threshold=10, title=None, ptype=0, qd=4, target=[], plot_params=None, saveFig=True, showFig=True, dirname='./', fmt='jpg')
Display figures with classification results by linear regression and clustering lines
iwin.util.figures.figure_AvgYieldbyGID_combineMethods(df_GY=None, fld1='AvGYxLocOcc', fld2='AvGYxGID', nursery='', lw=0.8, hue='G', s=15, alpha=0.85, loc=2, ncol=2, xt_tl=0.01, yt_tl=0.99, ha='left', va='top', showFig=True, saveFig=True, dirname='./', fmt='pdf')
Display a figure with all combined methods
iwin.util.figures.clusterYieldEnvironments(df_selGen=None, nurseryGroup=['ESWYT'], fld1='AvGYxLocOcc', fld2='AvGYxGID', dispText=True, loc=2, ncol=1, alpha=0.65, s=5, hue='YieldEnv', xy_lim=2, xt_tl=0.01, yt_tl=0.99, ha='left', va='top', saveFig=True, showFig=True, oneFigure=True, verbose=True, sharex=False, sharey=False, dirname='./', fmt='pdf')
Display clusters of Yield environments
iwin.util.figures.chartObsYieldTrends(df_GY=None, selGIDs=None, ngrp='ESWYT', n=1, title='Observed yield trends', sx_min=2, sy_min=0.05, sx_max=1, sy_max=0.03, addMaxMinTexts=True, saveFig=True, showFig=True, dirname='./', fmt='pdf')
Display Observed Yield Trends
iwin.stats
iwin.stats.prepareDatasetforR(df, folder='GxE')
Prepare the IWIN dataset in a specific format for analysis in R statistical packages
iwin.stats.joinBLUPnBLUE_andNormilizedYield_GrpByGID(df, BLU, stats, nursery='', saveFile=True)
Join BLUP and BLUE values, and Normalize Yield
It uses 95th percentile of yield (top 5%) of each site-year as a reference and express the yield of each GID within a site-year in percent of the top yield.
Return a group by GID table
iwin.iparyield
iwin.iparyield.model
iwin.iparyield.model.iPARModel(config, parameters=None)
Bases: object
iwin.iparyield.model.iPARModel.load_raw_datasets()
Load raw IWIN and AgERA5 datasets
iwin.iparyield.model.iPARModel.load_datasets()
Load IWIN and AgERA5 datasets in parquet format Reading the Parquet format is much more efficient.
:return: Two dataframes for crop phenology and weather dataset respectively.
iwin.iparyield.model.iPARModel.filterPhenologyData(data=None, fld=None, value=None, selcols=None, verbose=False)
Filter dataset by Nursery
:params data: A table or DF with trial for each site
:results: An array or DF of filtered sites
iwin.iparyield.model.iPARModel.prepareData(data=None, params=None, selcols=None, verbose=False)
Preprocessing dataset to the iPAR yield formats
:params data: A table or DF with phenology for each site :params params: Paramaters used to control the phenology simulation :params selcols: Attibutes or columns selected to use in the simulations
:results: An array of sites with info setup for run model
iwin.iparyield.model.iPARModel.prepareData_toExtractWeather(data=None, selcols=None, verbose=False)
Preprocessing dataset to extract weather data in parallel
:params data: A table or DF with phenology for each site :params selcols: Attibutes or columns selected to use in the simulations
:results: An array of sites with info setup for run model
iwin.iparyield.model.iPARModel.process_ClimateStatsforGrowthStage(s, weather=None, verbose=False)
Distill the climate data down into meaningful variables. Extract weather data from AgERA5 dataset for each location in each growth stage
iwin.iparyield.model.iPARModel.process_ClimateStatsforGrowthPeriod_v3(s, weather=None, climatevars=['TMIN', 'TAVG', 'TMAX', 'PCP', 'SolRad', 'RHUMn', 'RHUMx', 'WIND', 'TDay', 'PTQ', 'iPAR_PRFT'], stats=['min', 'mean', 'max', 'sd'], verbose=False)
Distill the climate data down into meaningful variables. Extract weather data from AgERA5 dataset for each location in each growth stage
iwin.iparyield.model.iPARModel.process_GapFillingforPhenology(sites_to_run=None, climate=True, verbose=False)
Filling gaps for phenology dates using algorithms developed by Urs
iwin.iparyield.model.iPARModel.process_GapFillingforPhenology_v3(m, s, climate=False, verbose=False)
Filling gaps for phenology dates using algorithms developed by Urs
iwin.iparyield.model.iPARModel.fit(sites_to_run=None, season=True, verbose=False)
Run an iPAR Yield model to fit yield
:params sites_to_run: Array of Site objects :params season: Display weather statistics for different periods
:resutls: An array of sites with intermediate results
iwin.iparyield.model.iPARModel.runModel(sites_to_run=None, season=True, verbose=False)
Run an iPAR Yield model to fit yield in Parallel
:params sites_to_run: Array of Site objects :params season: Display weather statistics for different periods
:resutls: An array of sites with intermediate results
iwin.iparyield.model.iPARModel.extractClimatexBestPedigreeSelection(m, sites_to_run=None, batch_start=0, batch_end=100, n_jobs=4, climate=False, fmt='parquet', saveFile=True, verbose=False)
Estimate phenology using Urs' iPAR model and extract weather parameters in Parallel
:params sites_to_run: Array of Site objects
:resutls: An array of sites with intermediate results
iwin.iparyield.model.iPARModel.estimateWeatherPhenology_byObs(model, sites_to_run, batch_size=1000, n_jobs=4, climate=True, saveIntermediateFiles=False, saveFile=True, vb=False)
Estimate phenology using Urs' iPAR model and extract weather parameters for each observation, running in Parallel
iwin.iparyield.model.tadjday
iwin.iparyield.model.tadjday.calcTAdjDay(Tavg, threshold=42, scale=140, rate=-0.055)
Calculate daily progress (Adjusted TDays). Depreciated: 20230127
:param Tavg: Number or array of Average Temperatures :param threshold: Number of TDays. eg. IWIN: 42, Dhillon: 35, South Asia: 41
:return: a number or array of adjusted temperature days
iwin.iparyield.model.tadjday.getTAdjDay(Tavg, threshold=45, scale=140, rate=-0.055)
Calculate daily progress (Adjusted TDays)
:param Tavg: Number or array of Average Temperatures :param threshold: Number of TDays. eg. IWIN: 42, Dhillon: 35, South Asia: 41
The algorithm tends to overestimate the short and
underestimate the long grainfilling durations. y=165* exp(-0.07 * TAverage)
Modified Aug-16-2023:
:return: a number or array of adjusted temperature days
iwin.iparyield.model.tadjday.apply_TAdjDay(Tavg, threshold=45, scale=140, rate=-0.055)
Calculate daily progress (Adjusted TDays)
:param Tavg: Number or array of Average Temperatures :param threshold: Number of TDays. eg. IWIN: 42, Dhillon: 35, South Asia: 41
:return: a number or array of adjusted temperature days
iwin.iparyield.model.tadjday.estimate_TAdjDay(Tavg=None, threshold=45, scale=140, rate=-0.055)
Calculate daily progress (Adjusted TDays)
:param Tavg: Number or array of Average Temperatures :param threshold: Number of TDays. eg. IWIN: 45, Dhillon: 35, South Asia: 41
:return: a number or array of adjusted temperature days
iwin.iparyield.model.gdd
iwin.iparyield.model.gdd.calcGDD(Tmin=None, Tmax=None, Tbase=0)
Growing degree days GDD (°F or °C) Calculated from: ((Daily Max Temp + Daily Min Temp)/2) - 32 °F (or ((Daily Max Temp + Daily Min Temp)/2)).
:param Tmin: Number or array of Minimum Temperatures :param Tmax: Number or array of Maximum Temperatures :param Tbase: Temperature base of the crop
:return: a number or array of Growing degree days (GDD)
iwin.iparyield.model.gdd.getGDD(Tmin, Tmax, Tbase=0)
Growing degree days GDD (°F or °C) Calculated from: ((Daily Max Temp + Daily Min Temp)/2) - 32 °F (or ((Daily Max Temp + Daily Min Temp)/2)).
:param Tmin: Number or array of Minimum Temperatures :param Tmax: Number or array of Maximum Temperatures :param Tbase: Temperature base of the crop
:return: a number or array of Growing degree days (GDD)
iwin.iparyield.model.gdd.apply_GDD(Tmin, Tmax, Tbase=0)
Growing degree days GDD (°F or °C) Calculated from: ((Daily Max Temp + Daily Min Temp)/2) - 32 °F (or ((Daily Max Temp + Daily Min Temp)/2)).
:param Tmin: Number or array of Minimum Temperatures :param Tmax: Number or array of Maximum Temperatures :param Tbase: Temperature base of the crop
:return: a number or array of Growing degree days (GDD)
iwin.iparyield.model.gdd.calculateGDD(Tmin=None, Tmax=None, Tbase=0)
Growing degree days GDD (°F or °C) Calculated from: ((Daily Max Temp + Daily Min Temp)/2) - 32 °F (or ((Daily Max Temp + Daily Min Temp)/2)).
:param Tmin: Number or array of Minimum Temperatures :param Tmax: Number or array of Maximum Temperatures :param Tbase: Temperature base of the crop
:return: a number or array of Growing degree days (GDD)
iwin.iparyield.model.prft
iwin.iparyield.model.prft.calcPRFT(TDay, TOpt=18)
Estimate Photosynthesis reduction factor (PRFT) PRFT = 1 – 0.0025 * (TDay – TOpt)^2
:param TDay: Number or array of Day Temperatures :param TOpt: Optimum Temperature
:return: a number or array of PRFT
iwin.iparyield.model.prft.apply_PRFT(Tday, Topt=18)
Estimate Photosynthesis reduction factor (PRFT) PRFT = 1 – 0.0025 * (TDay – TOpt)^2
:param TDay: Number or array of Day Temperatures :param TOpt: Optimum Temperature
:return: a number or array of PRFT
iwin.iparyield.model.prft.calculatePRFT(Tday, Topt=18)
Estimate Photosynthesis reduction factor (PRFT) PRFT = 1 – 0.0025 * (TDay – TOpt)^2
:param TDay: Number or array of Day Temperatures :param TOpt: Optimum Temperature
:return: a number or array of PRFT
iwin.iparyield.model.ipar
iwin.iparyield.model.ipar.calcIPAR(Norm_TT_EH=None, Norm_SimNDVI_EH=None, Norm_SimNDVI_HM=None, norm_iPAR_EH_bounds=0.5, NDVI_constantIPAR=0.19, verbose=False)
Total light interception - iPAR
** Asrar, G., Fuchs, M., Kanemasu, E.T., Hatfield, J.L., 1984.
Estimating absorbed photosynthetic radiation and leaf area index from spectral reflectance
in wheat. Agron. J. 76, 300–306.
- Campos 2018 Remote sensing-based crop biomass with water or light-driven crop growth models in
wheat commercial fields
iPAR = NDVI * 1.25 - 0.19 # between heading and maturity (Campos et al. 2018) iPAR = NDVI * 1.25 - 0.21 Daughtry et al. (1992)
:params Norm_TT_EH: :params Norm_SimNDVI_EH: :params Norm_SimNDVI_HM: :params norm_iPAR_EH_bounds: Bounds for iPAR multi-linear equations
:return: An array of Total light interception values
iwin.iparyield.model.ipar.getIPAR_EH(Norm_TT_EH, norm_iPAR_EH_bounds=0.5)
Calculate daily progress (Adjusted TDays)
:param Tavg: Number or array of Average Temperatures :param threshold: Number of TDays. eg. IWIN: 42, Dhillon: 35, South Asia: 41
:return: a number or array of adjusted temperature days
iwin.iparyield.model.ipar.apply_IPAR_EH(Norm_TT_EH, norm_iPAR_EH_bounds=0.5)
Calculate daily progress (Adjusted TDays)
:param Tavg: Number or array of Average Temperatures :param threshold: Number of TDays. eg. IWIN: 42, Dhillon: 35, South Asia: 41
:return: a number or array of adjusted temperature days
iwin.iparyield.model.ipar.estimate_IPAR(Norm_TT_EH=None, Norm_SimNDVI_EH=None, Norm_SimNDVI_HM=None, norm_iPAR_EH_bounds=0.5, NDVI_constantIPAR=0.19, verbose=False)
Total light interception - iPAR
** Asrar, G., Fuchs, M., Kanemasu, E.T., Hatfield, J.L., 1984.
Estimating absorbed photosynthetic radiation and leaf area index from spectral reflectance
in wheat. Agron. J. 76, 300–306.
- Campos 2018 Remote sensing-based crop biomass with water or light-driven crop growth models in
wheat commercial fields
iPAR = NDVI * 1.25 - 0.19 # between heading and maturity (Campos et al. 2018) iPAR = NDVI * 1.25 - 0.21 Daughtry et al. (1992)
:params Norm_TT_EH: :params Norm_SimNDVI_EH: :params Norm_SimNDVI_HM: :params norm_iPAR_EH_bounds: Bounds for iPAR multi-linear equations
:return: An array of Total light interception values
iwin.iparyield.model.daylength
iwin.iparyield.model.daylength.CBM_daylength(dayOfYear, lat, p=0.0)
A model comparison for daylength as a function of latitude and day of year
William C. Forsythe a,* Edward J. Rykiel Jr. a, Randal S. Stahl a, Hsin-i Wu a, Robert M. Schoolfield b
Ecological Modelling 80 (1995) 87-95
:param dayOfYear: Day of the Year (DOY) :param lat: Latitude of the site in celsius degrees :param p: Sun angle with the horizon. eg. p = 6.0 : civil twilight, p = 0.0 : day starts / ends when sun is even with the horizon. Default value p=0
:return: a daylength for the specific site
iwin.iparyield.model.daylength.getDaylength(dayOfYear, lat, p=0.0)
Length of the day for a specific site
:param dayOfYear: Day of the Year (DOY) :param lat: Latitude of the site in celsius degrees :param p: Sun angle with the horizon. eg. p = 6.0 : civil twilight, p = 0.0 : day starts / ends when sun is even with the horizon. Default value p=0
:return: a daylength for the specific site
iwin.iparyield.model.daylength.apply_Daylength(dayOfYear, lat, p=0.0)
Length of the day for a specific site
:param dayOfYear: Day of the Year (DOY) :param lat: Latitude of the site in celsius degrees :param p: Sun angle with the horizon. eg. p = 6.0 : civil twilight, p = 0.0 : day starts / ends when sun is even with the horizon. Default value p=0
:return: a daylength for the specific site
iwin.iparyield.model.daylength.calculateDayLength(d=None, lat=None, p=0.0)
Get Day length
iwin.iparyield.model.ndvi
iwin.iparyield.model.ndvi.estimateNDVI_EH(norm_TT_EH=None, NDVI_lowerThreshold=None, NDVI_Threshold=None, NDVI_max=None, verbose=False)
Estimate NDVI values from emergence to heading.
Use of Normalized Thermal Time and Observed NDVI to calculate IPAR from Emergence to Heading
:params norm_TT_EH: Normilize GDD or Thermal time from Emergence to Heading :params NDVI_lowerThreshold: Lower threshold to estimate NDVI :params NDVI_Threshold: Threshold to estimate NDVI :params NDVI_max: Maximum NDVI value allowed :verbose: Display messages during the processing
:return: An array with NDVI values from Emergence to Heading
iwin.iparyield.model.ndvi.estimateNDVI_HM(norm_TT_HM=None, NDVImax=None, NDVI_atHeading=0.94, verbose=False)
Estimate NDVI values from Heading to Maturity.
Use of Normalized Thermal Time and Observed NDVI to calculate IPAR from Heading to Maturity.
:params norm_TT_HM: Normilize GDD or Thermal time from Heading to Maturity :params NDVI_max: Maximum NDVI value allowed :params NDVI_atHeading: NDVI reached at Heading date :verbose: Display messages during the processing
:return: An array with NDVI values from Heading to Maturity
iwin.iparyield.model.ndvi.getNDVI_EH(norm_TT_EH, NDVI_lowerThreshold, NDVI_Threshold, NDVI_max)
Estimate NDVI values from emergence to heading.
Use of Normalized Thermal Time and Observed NDVI to calculate IPAR from Emergence to Heading
:params norm_TT_EH: Normilize GDD or Thermal time from Emergence to Heading :params NDVI_lowerThreshold: Lower threshold to estimate NDVI :params NDVI_Threshold: Threshold to estimate NDVI :params NDVI_max: Maximum NDVI value allowed :verbose: Display messages during the processing
:return: An array with NDVI values from Emergence to Heading
iwin.iparyield.model.ndvi.apply_NDVI_EH(norm_TT_EH, NDVI_lowerThreshold, NDVI_Threshold, NDVI_max)
Estimate NDVI values from emergence to heading.
Use of Normalized Thermal Time and Observed NDVI to calculate IPAR from Emergence to Heading
:params norm_TT_EH: Normilize GDD or Thermal time from Emergence to Heading :params NDVI_lowerThreshold: Lower threshold to estimate NDVI :params NDVI_Threshold: Threshold to estimate NDVI :params NDVI_max: Maximum NDVI value allowed :verbose: Display messages during the processing
:return: An array with NDVI values from Emergence to Heading
iwin.iparyield.model.ndvi.calculateNDVI_EH(norm_TT_EH, NDVI_lowerThreshold, NDVI_Threshold, NDVI_max)
Estimate NDVI values from emergence to heading.
Use of Normalized Thermal Time and Observed NDVI to calculate IPAR from Emergence to Heading
:params norm_TT_EH: Normilize GDD or Thermal time from Emergence to Heading :params NDVI_lowerThreshold: Lower threshold to estimate NDVI :params NDVI_Threshold: Threshold to estimate NDVI :params NDVI_max: Maximum NDVI value allowed :verbose: Display messages during the processing
:return: An array with NDVI values from Emergence to Heading
iwin.iparyield.model.ndvi.getNDVI_HM(norm_TT_HM, NDVImax)
Estimate NDVI values from Heading to Maturity.
Use of Normalized Thermal Time and Observed NDVI to calculate IPAR from Emergence to Heading
:params norm_TT_HM: Normilize GDD or Thermal time from Heading to Maturity :params NDVI_max: Maximum NDVI value allowed :verbose: Display messages during the processing
:return: An array with NDVI values from Heading to Maturity
iwin.iparyield.model.ndvi.apply_NDVI_HM(norm_TT_HM, NDVImax)
Estimate NDVI values from Heading to Maturity.
Use of Normalized Thermal Time and Observed NDVI to calculate IPAR from Heading to Maturity.
:params norm_TT_HM: Normilize GDD or Thermal time from Heading to Maturity :params NDVI_max: Maximum NDVI value allowed :verbose: Display messages during the processing
:return: An array with NDVI values from Heading to Maturity
iwin.iparyield.model.ndvi.calculateNDVI_HM(norm_TT_HM=None, NDVImax=None, NDVI_atHeading=0.94, verbose=False)
Estimate NDVI values from Heading to Maturity.
Use of Normalized Thermal Time and Observed NDVI to calculate IPAR from Heading to Maturity.
:params norm_TT_HM: Normilize GDD or Thermal time from Heading to Maturity :params NDVI_max: Maximum NDVI value allowed :params NDVI_atHeading: NDVI reached at Heading date :verbose: Display messages during the processing
:return: An array with NDVI values from Heading to Maturity
iwin.iparyield.model.tday
iwin.iparyield.model.tday.calcTDay(Tmin, Tmax, tminFactor=0.25)
Calculate day time temperature TDay = 0.75Tmax + 0.25TMin
:param Tn: Number or array of Minimum Temperatures :param Tx: Number or array of Maximum Temperatures :param tminFactor: Minimum Temperature factor
:return: a number or array of Day Temperatures
iwin.iparyield.model.tday.getTDay(Tmin, Tmax, tminFactor=0.25)
Calculate day time temperature TDay = 0.75Tmax + 0.25TMin
:param Tmin: Number or array of Minimum Temperatures :param Tmax: Number or array of Maximum Temperatures :param tminFactor: Minimum Temperature factor
:return: a number or array of Day Temperatures
iwin.iparyield.model.tday.apply_TDay(Tmin, Tmax, tminFactor)
Calculate day time temperature
:param Tmin: Numpy array of Minimum Temperatures :param Tmax: Numpy array of Maximum Temperatures :param tminFactor: Minimum Temperature factor
:return: a number or array of Day Temperatures
iwin.iparyield.model.tday.estimate_TDay(Tmin=None, Tmax=None, tminFactor=0.25)
Calculate day time temperature
:param Tmin: Numpy array of Minimum Temperatures :param Tmax: Numpy array of Maximum Temperatures :param tminFactor: Minimum Temperature factor
:return: a number or array of Day Temperature
iwin.data
iwin.data.load_data(config=None)
Load IWIN and AgERA5 datasets in parquet format Reading the Parquet format is much more efficient.
:return: Two dataframes for crop phenology and weather dataset respectively.
iwin.data.load_IWINdataset(config=None, imputingData=True, cleanSD=True, missigHisto=True, saveHistoFig=False, saveRawFile=False, verbose=False)
Load updated IWIN dataset
iwin.data.filterPhenologyData(config=None, data=None, fld=None, value=None, selcols=None, verbose=False)
Filter dataset by Nursery
:params data: A table or DF with trial for each site
:results: An array or DF of filtered sites
iwin.data.imputingMissingValues(df, verbose=True)
Imputation preserves all cases by replacing missing data with an estimated value based on the average of the site-nursery-year. Once all missing values have been imputed, the data set can then be analysed using standard techniques for complete data.
iwin.data.displaySummaryByNursery(df_N=None, nursery='NURSERY', MIN_PERC=5, MAX_PERC=98, KDEHist=True, sel_cols=['GRAIN_YIELD', '1000_GRAIN_WEIGHT', 'DAYS_TO_HEADING', 'DAYS_TO_ANTHESIS', 'DAYS_TO_MATURITY', 'PLANT_HEIGHT', 'TEST_WEIGHT'], verbose=True)
- Cut-off by using percentiles 5% and 98%
iwin.data.joinBLUPnBLUE_andNormilizedYield_GrpByGID(config, df, BLU, stats, nursery='', saveFile=True)
Join BLUP and BLUE values, and Normalize Yield
It uses 95th percentile of yield (top 5%) of each site-year as a reference and express the yield of each GID within a site-year in percent of the top yield.
Return a group by GID table
iwin.data.getStatsByTrial(config, df_final, fmt='parquet', saveFile=True, verbose=False)
Estimate stats (BLUEs, BLUPs, Heritability, CV, LSD, Genotype significance, among others) for each individual trial.
iwin.data.createArrayOfObjects_toRunInParallel(df)
Create an array of sites with the IWIN observations to speed up further analysis This array of objects is useful to run models in parallel.
iwin.data.formatFeaturesforIWIN(df, removeObsPheno=False, arrObj=True)
Features or columns in IWIN table need to rename and reformat according to the original IWIN package or library.
- Nursery is needed to evaluate the Equation to use in grain filling
- Rename columns to match with the IWIN library
- Create array of objects to run models in parallel
...