Commit a49b69e5 authored by Loic Manceau's avatar Loic Manceau
Browse files

Initial commit

parents
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
using System;
using System.Collections.Generic;
namespace SiriusQuality_SiriusQuality_WheatLAIConsole
{
public class LeafLayer // Storage class for leaf layers
{
#region fields
public bool IsSmallPhytomer { get; set; }
/// <summary>Phyllochron of this Layer</summary>
public double LayerPhyllochron { get; set; }
///<summary>Period of constant area of leaf i, CDay</summary>
public double TTmat { get; set; }
///<summary>Period of senescence of leaf i, CDay</summary>
public double TTsen { get; set; }
///<summary> Thermal Time at emergence of leaf layer i</summary>
public double TTem { get; set; }
///<summary>Growth thermal time of layer i</summary>
public double TTgroLamina { get; set; }
///<summary>Layer Green Area Index</summary>
public double GAI { get { return laminaAI + sheathAI; } }
///<summary>Exposed sheath Area Index of this Layer</summary>
public double sheathAI;
///<summary>Leaf lamina Area Index of this Layer</summary>
public double laminaAI;
/// <summary>Increment of area index for current day, dimensionless</summary>
public double DeltaAI { get; set; }
/// <summary>Change of DM for current day</summary>
public double DeltaDM { get; set; }
///<summary>True if this leaves is dying prematurely because of Ni uptake from mature leaves</summary>
public bool IsPrematurelyDying { get; protected set; }
///<summary>Largest area actually achived by leaf Layer i, dimensionless</summary>
public double MaxAI { get; /*private*/ set; }
///<summary>Current development state of this leaves Layer</summary>
public LeafState State { get; private set; }
///<summary>Lamina Specific Nitrogen (photosyntetically active)</summary>
public double LaminaSpecificN { get; set; }
#endregion
#region Constructors
/// <summary>Initial constructor</summary>
/// <param name="universe">The universe of this LeafLayer.</param>
/// <param name="i">The index of this leaf Layer (0 based index, starts from the bottom of the plant).</param>
public LeafLayer(double phyllochron,double laminaspecificN, double TTatEmergence)
{
LayerPhyllochron = phyllochron;
LaminaSpecificN = laminaspecificN;
DeltaAI = 0.0;
DeltaDM = 0.0;
IsPrematurelyDying = false;
MaxAI = 0.0;
State = LeafState.Growing;
IsSmallPhytomer=false;
TTmat=0.0;
TTsen=0.0;
TTem = TTatEmergence;
TTgroLamina=0.0;
sheathAI = 0.0;
laminaAI = 0.0;
}
///<summary>Copy constructor</summary>
///<param name="universe">The universe of this leaf Layer.</param>
///<param name="toCopy">The leaf Layer to copy</param>
public LeafLayer(LeafLayer toCopy)
{
LayerPhyllochron = toCopy.LayerPhyllochron;
LaminaSpecificN = toCopy.LaminaSpecificN;
DeltaAI = toCopy.DeltaAI;
DeltaDM = toCopy.DeltaDM;
IsPrematurelyDying = toCopy.IsPrematurelyDying;
MaxAI = toCopy.MaxAI;
State = toCopy.State;
IsSmallPhytomer = toCopy.IsSmallPhytomer;
TTmat = toCopy.TTmat;
TTsen = toCopy.TTsen;
TTem = toCopy.TTem;
TTgroLamina = toCopy.TTgroLamina;
sheathAI = toCopy.sheathAI;
laminaAI = toCopy.laminaAI;
}
#endregion
#region Utilities
public void setState(LeafState newState)
{
State = newState;
}
public void setPrematurelyDying(int NewIsPrematurelyDying)
{
IsPrematurelyDying = NewIsPrematurelyDying == 1;
}
#endregion
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SiriusQuality_SiriusQuality_WheatLAIConsole
{
//Enumeration of possible states for the leaf layers
public enum LeafState
{
///<summary>The leaf is growing</summary>
Growing,
///<summary>The leaf is mature</summary>
Mature,
///<summary>The leaf is senescing</summary>
Senescing,
///<summary>The leaf is dead</summary>
Dead
}
}
This diff is collapsed.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("SiriusQuality-SiriusQuality-WheatLAIConsole")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SiriusQuality-SiriusQuality-WheatLAIConsole")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
[assembly: Guid("404f7021-da1f-48bb-bc8c-43a4530a1915")]
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F083391A-C1E7-4CC0-B68C-7F62D7B58326}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SiriusQuality_SiriusQuality_WheatLAIConsole</RootNamespace>
<AssemblyName>SiriusQuality-SiriusQuality-WheatLAIConsole</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CRA.AgroManagement2014">
<HintPath>..\BioMa-DLL\CRA.AgroManagement2014.dll</HintPath>
</Reference>
<Reference Include="CRA.AgroManagement2014.Impacts">
<HintPath>..\BioMa-DLL\CRA.AgroManagement2014.Impacts.dll</HintPath>
</Reference>
<Reference Include="CRA.AgroManagement2014.Rules">
<HintPath>..\BioMa-DLL\CRA.AgroManagement2014.Rules.dll</HintPath>
</Reference>
<Reference Include="CRA.Core.Preconditions">
<HintPath>..\BioMa-DLL\CRA.Core.Preconditions.dll</HintPath>
</Reference>
<Reference Include="CRA.ModelLayer">
<HintPath>..\BioMa-DLL\CRA.ModelLayer.dll</HintPath>
</Reference>
<Reference Include="SiriusQuality-WheatLAI">
<HintPath>..\SiriusQuality-WheatLAI\bin\Debug\SiriusQuality-WheatLAI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="LeafLayer.cs" />
<Compile Include="LeafState.cs" />
<Compile Include="Program.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WheatLAIWrapper.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SiriusQualityWheatLAI;
namespace SiriusQuality_SiriusQuality_WheatLAIConsole
{
class WheatLAIWrapper
{
#region Ouptuts
public List<LeafState> getLeafStateList(){ return GetStateListWheat(); }
public List<LeafState> getLeafPreviousStateList(){return GetPreviousStateListWheat();}
public List<int> getIsPrematurelyDyingList(){return wheatLeafstate_.isPrematurelyDying; }
public double getIncDeltaAreaLimitSF(){return wheatLaistate_.incDeltaAreaLimitSF; }
public double getPotentialIncDeltaArea(){return wheatLaistate_.potentialIncDeltaArea; }
public double DEF{get{return wheatLaistate_.DEF;}}
public double DSF{get{return wheatLaistate_.DSF;}}
public double getWaterLimitedPotDeltaAI(int i)
{
if (i < wheatLaistate_.WaterLimitedPotDeltaAIList.Count)
{
return wheatLaistate_.WaterLimitedPotDeltaAIList[i];
}
else
{
return -1;
}
}
private int previousIndex = -1;
#endregion
#region Parameters
//See "Documentation\SQ-Phenology: BioMA-SiriusQuality component of Wheat potential LAI" document Table A2 for definitions
//Exemple of parameter set for spring wheat and Yecora Rojo variety.
double AreaPL=27.378;
double AreaSL=9.0;
double AreaSS=1.83;
double LowerFPAWexp=0.1;
double LowerFPAWsen=0.1;
double LowerVPD=15.0;
double MaxDSF=4.5;
double NLL=5.69;
double PexpL=1.1;
double RatioFLPL=1.06;
double SLNmin=0.35;
double UpperFPAWexp=0.5;
double UpperFPAWsen=0.4;
double UpperVPD=45.0;
double PlagLL=8.0;
double PlagSL=4.0;
double PsenLL=5.0;
double PsenSL=3.3;
#endregion
#region constructors
public WheatLAIWrapper()
{
wheatLAI_ = new SiriusQualityWheatLAI.Strategies.WheatLAI();
wheatLaistate_ = new SiriusQualityWheatLAI.WheatLAIState();
wheatLeafstate_ = new SiriusQualityWheatLAI.WheatLeafState();
wheatLeafstate1_ = new SiriusQualityWheatLAI.WheatLeafState();
loadParametersWheat();
}
public WheatLAIWrapper(WheatLAIWrapper toCopy)
{
wheatLaistate_ = (toCopy.wheatLaistate_ != null) ? new SiriusQualityWheatLAI.WheatLAIState(toCopy.wheatLaistate_) : null;
wheatLeafstate_ = (toCopy.wheatLeafstate_ != null) ? new SiriusQualityWheatLAI.WheatLeafState(toCopy.wheatLeafstate_) : null;
wheatLeafstate1_ = (toCopy.wheatLeafstate1_ != null) ? new SiriusQualityWheatLAI.WheatLeafState(toCopy.wheatLeafstate1_) : null;
wheatLAI_ = (toCopy.wheatLAI_ != null) ? new SiriusQualityWheatLAI.Strategies.WheatLAI(toCopy.wheatLAI_) : null;
}
#endregion
#region Estimate function
public void Estimate(bool newLeafHasAppeared, int roundedFinalNumber, double finalLeafNumber, double leafNumber,
int newLeafLastPhytoNum, int newLeafindex,double FPAW, bool isPotentialLAI, double cumulTTShoot, double deltaTTShoot, double deltaTTSenescence, List<LeafLayer> All, double VPDairCanopy,
List<double> tilleringProfile, List<double> leafTillerNumberArray)
{
//Valorize inputs
wheatLaistate_.newLeafHasAppeared = newLeafHasAppeared ? 1 : 0;
wheatLaistate_.roundedFinalLeafNumber = roundedFinalNumber;
wheatLaistate_.finalLeafNumber = finalLeafNumber;
wheatLaistate_.leafNumber = leafNumber;
wheatLaistate_.FPAW = FPAW;
wheatLaistate_.isPotentialLAI = isPotentialLAI ? 1 : 0;
wheatLaistate_.cumulTTShoot = cumulTTShoot;
wheatLaistate_.deltaTTShoot = deltaTTShoot;
wheatLaistate_.deltaTTSenescence = deltaTTSenescence;
wheatLaistate_.VPDairCanopy = VPDairCanopy;
wheatLaistate_.tilleringProfile = tilleringProfile;
wheatLaistate_.leafTillerNumberArray = leafTillerNumberArray;
wheatLaistate_.phytonum = newLeafLastPhytoNum;
wheatLaistate_.index = newLeafindex;
wheatLaistate_.previousIndex = previousIndex;
previousIndex = newLeafindex;
//Valorize the leaf layer states of the component from the leaf Layer class
FillIntputLayersWheat(All);
//Call the estimate function of the composite class
wheatLAI_.Estimate(wheatLaistate_, wheatLeafstate_, wheatLeafstate1_, null);
//Fill the objects of the leafLayer Class with the content of leaf layers of the component
FillOutputLayersWheat(All);
}
#endregion
#region Utilities
#region LoadParameters
private void loadParametersWheat()
{
wheatLAI_.AreaPL = AreaPL;
wheatLAI_.AreaSL = AreaSL;
wheatLAI_.AreaSS = AreaSS;
wheatLAI_.LowerFPAWexp = LowerFPAWexp;
wheatLAI_.LowerFPAWsen = LowerFPAWsen;
wheatLAI_.LowerVPD = LowerVPD;
wheatLAI_.MaxDSF = MaxDSF;
wheatLAI_.NLL = NLL;
wheatLAI_.PexpL = PexpL;
wheatLAI_.RatioFLPL = RatioFLPL;
wheatLAI_.SLNmin = SLNmin;
wheatLAI_.UpperFPAWexp = UpperFPAWexp;
wheatLAI_.UpperFPAWsen = UpperFPAWsen;
wheatLAI_.UpperVPD = UpperVPD;
wheatLAI_.PlagLL = PlagLL;
wheatLAI_.PlagSL = PlagSL;
wheatLAI_.PsenLL = PsenLL;
wheatLAI_.PsenSL = PsenSL;
}
#endregion
#region Output state convertors
private List<LeafState> GetStateListWheat()
{
List<LeafState> list = new List<LeafState>();
for (int ilayer = 0; ilayer < wheatLeafstate1_.State.Count; ilayer++)
{
switch (wheatLeafstate1_.State[ilayer])
{
case 0:
list.Add(LeafState.Growing);
break;
case 1:
list.Add(LeafState.Mature);
break;
case 2:
list.Add(LeafState.Senescing);
break;
case 3:
list.Add(LeafState.Dead);
break;
}
}
return list;
}
private List<LeafState> GetPreviousStateListWheat()
{
List<LeafState> list = new List<LeafState>();
for (int ilayer = 0; ilayer < wheatLeafstate_.PreviousState.Count; ilayer++)
{
switch (wheatLeafstate_.PreviousState[ilayer])
{
case 0:
list.Add(LeafState.Growing);
break;
case 1:
list.Add(LeafState.Mature);
break;
case 2:
list.Add(LeafState.Senescing);
break;
case 3:
list.Add(LeafState.Dead);
break;
}
}
return list;
}
#endregion
#region Connection with Leaf layer object
private void FillIntputLayersWheat(List<LeafLayer> All)
{
for (int ilayer = 0; ilayer < All.Count; ilayer++)
{
switch (All[ilayer].State)
{
case LeafState.Growing:
wheatLeafstate_.State[ilayer] = 0;
break;
case LeafState.Mature:
wheatLeafstate_.State[ilayer] = 1;
break;
case LeafState.Senescing:
wheatLeafstate_.State[ilayer] = 2;
break;
case LeafState.Dead:
wheatLeafstate_.State[ilayer] = 3;
break;
}
wheatLeafstate_.GAI[ilayer] = All[ilayer].GAI;
wheatLeafstate_.MaxAI[ilayer] = All[ilayer].MaxAI;
wheatLeafstate_.Phyllochron[ilayer] = All[ilayer].LayerPhyllochron;
wheatLeafstate_.TTGroLamina[ilayer] = All[ilayer].TTgroLamina;
wheatLeafstate_.laminaSpecificN[ilayer] = All[ilayer].LaminaSpecificN;
wheatLeafstate_.LaminaAI[ilayer] = All[ilayer].laminaAI;
wheatLeafstate_.SheathAI[ilayer] = All[ilayer].sheathAI;
wheatLeafstate_.isPrematurelyDying[ilayer] = All[ilayer].IsPrematurelyDying ? 1 : 0;
wheatLeafstate_.TTem[ilayer] = All[ilayer].TTem;
if (All[ilayer].IsSmallPhytomer == true) wheatLeafstate_.isSmallPhytomer[ilayer] = 1;
else wheatLeafstate_.isSmallPhytomer[ilayer] = 0;
}
}
private void FillOutputLayersWheat(List<LeafLayer> All)
{
for (int ilayer = 0; ilayer < wheatLeafstate_.State.Count; ilayer++)
{
switch (wheatLeafstate_.State[ilayer])
{
case 0:
All[ilayer].setState(LeafState.Growing);
break;
case 1:
All[ilayer].setState(LeafState.Mature);
break;
case 2:
All[ilayer].setState(LeafState.Senescing);
break;
case 3:
All[ilayer].setState(LeafState.Dead);
break;