//------------------------------------------------------------------------------------------------

        private void CalcVPDLimitedTr()
        {
            // Calculates hourlyVPDCappedTr as the product of hourlyRUE, capped hourlyVPD and transpEffCoef

            double dmVPDThresh = 0;

            if (hourlyVPD.Max() > VPDThresh)
            {
                hourlyPotTr_VPDLimited = new List <double>();
                XYPairs interpol = new XYPairs
                {
                    X = hourlyVPD.ToArray(),
                    Y = hourlyPotDM.ToArray()
                };
                dmVPDThresh = interpol.ValueIndexed(Math.Max(VPDThresh, minVPD));

                for (int i = 0; i < 24; i++)
                {
                    if (hourlyVPD[i] > VPDThresh)
                    {
                        double trVPDThresh = dmVPDThresh * VPDThresh / transpEffCoef;                      // Hourly transpiration at VPDThresh
                        double reduction   = Math.Max(0, hourlyPotTr[i] - trVPDThresh) * HighVPDReduction; // Reduction in the part of hourly transpiration above trVPDThresh
                        hourlyPotTr_VPDLimited.Add(hourlyPotTr[i] - reduction);
                    }
                    else
                    {
                        hourlyPotTr_VPDLimited.Add(hourlyPotTr[i]);
                    }
                }
            }
            else
            {
                hourlyPotTr_VPDLimited = new List <double>(hourlyPotTr);
            }
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphAndTable"/> class.
 /// </summary>
 /// <param name="xyPairs">The xy pairs.</param>
 /// <param name="title">Graph title.</param>
 /// <param name="xName">The x axis title.</param>
 /// <param name="yName">The y axis title.</param>
 /// <param name="indent">The indentation.</param>
 public GraphAndTable(XYPairs xyPairs, string title, string xName, string yName, int indent)
 {
     this.title   = title;
     this.xyPairs = xyPairs;
     this.xName   = xName;
     this.yName   = yName;
     this.indent  = indent;
 }
Example #3
0
        /// <summary>
        /// Attach the view to the model.
        /// </summary>
        /// <param name="model">The initial water model</param>
        /// <param name="view">The initial water view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.xyPairs           = model as XYPairs;
            this.xyPairsView       = view as XYPairsView;
            this.explorerPresenter = explorerPresenter as ExplorerPresenter;

            // Create a list of profile (array) properties. PpoulateView wil create a table from them and
            // hand the table to the variables grid.
            this.FindAllProperties(this.xyPairs);

            this.PopulateView();

            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");
            this.xyPairs.Children.Add(this.graph);
            this.graph.Parent   = this.xyPairs;
            this.graphPresenter = new GraphPresenter();
            this.graphPresenter.Attach(this.graph, this.xyPairsView.Graph, this.explorerPresenter);
        }
Example #4
0
        /// <summary>
        /// Attach the view to the model.
        /// </summary>
        /// <param name="model">The initial water model</param>
        /// <param name="view">The initial water view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public override void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.xYPairs     = model as XYPairs;
            this.xYPairsView = view as XYPairsView;
            this.presenter   = explorerPresenter as ExplorerPresenter;
            base.Attach(model, xYPairsView.VariablesGrid, explorerPresenter);
            // Create a list of profile (array) properties. PpoulateView wil create a table from them and
            // hand the table to the variables grid.
            this.FindAllProperties(this.xYPairs);

            this.PopulateView();

            this.presenter.CommandHistory.ModelChanged += OnModelChanged;

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource("ApsimNG.Resources.XYPairsGraph.xml");
            this.xYPairs.Children.Add(this.graph);
            this.graph.Parent = this.xYPairs;
            (this.graph.Series[0] as Series).XFieldName = graph.Parent.FullPath + ".X";
            (this.graph.Series[0] as Series).YFieldName = graph.Parent.FullPath + ".Y";
            this.graphPresenter = new GraphPresenter();
            this.presenter.ApsimXFile.Links.Resolve(graphPresenter);
            this.graphPresenter.Attach(this.graph, this.xYPairsView.Graph, this.presenter);
            string xAxisTitle = LookForXAxisTitle();

            if (xAxisTitle != null)
            {
                xYPairsView.Graph.FormatAxis(Axis.AxisType.Bottom, xAxisTitle, false, double.NaN, double.NaN, double.NaN, false);
            }

            string yAxisTitle = LookForYAxisTitle();

            if (yAxisTitle != null)
            {
                xYPairsView.Graph.FormatAxis(Axis.AxisType.Left, yAxisTitle, false, double.NaN, double.NaN, double.NaN, false);
            }

            xYPairsView.Graph.FormatTitle(xYPairs.Parent.Name);
        }
Example #5
0
        /// <summary>
        /// Attach the view to the model.
        /// </summary>
        /// <param name="model">The initial water model</param>
        /// <param name="view">The initial water view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.xyPairs           = model as XYPairs;
            this.xyPairsView       = view as XYPairsView;
            this.explorerPresenter = explorerPresenter as ExplorerPresenter;

            // Create a list of profile (array) properties. PpoulateView wil create a table from them and
            // hand the table to the variables grid.
            this.FindAllProperties(this.xyPairs);

            this.PopulateView();

            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");
            this.xyPairs.Children.Add(this.graph);
            this.graph.Parent   = this.xyPairs;
            this.graphPresenter = new GraphPresenter();
            this.graphPresenter.Attach(this.graph, this.xyPairsView.Graph, this.explorerPresenter);
            string xAxisTitle = LookForXAxisTitle();

            if (xAxisTitle != null)
            {
                xyPairsView.Graph.FormatAxis(Axis.AxisType.Bottom, xAxisTitle, false, double.NaN, double.NaN, double.NaN);
            }

            string yAxisTitle = LookForYAxisTitle();

            if (yAxisTitle != null)
            {
                xyPairsView.Graph.FormatAxis(Axis.AxisType.Left, yAxisTitle, false, double.NaN, double.NaN, double.NaN);
            }

            xyPairsView.Graph.FormatTitle(xyPairs.Parent.Name);
        }
Example #6
0
    static public double Linint3hrlyTemp(double tmax, double tmin, XYPairs ttFn)
    {
        // --------------------------------------------------------------------------
        // Eight interpolations of the air temperature are
        // calculated using a three-hour correction factor.
        // For each air three-hour air temperature, a value
        // is calculated.  The eight three-hour estimates
        // are then averaged to obtain the daily value.
        // --------------------------------------------------------------------------

        //Constants
        int num3hr = 24 / 3;           // number of 3 hourly temperatures

        // Local Variables
        double tot = 0.0;            // sum_of of 3 hr interpolations

        for (int period = 1; period <= num3hr; period++)
        {
            // get mean temperature for 3 hr period (oC)
            double tmean_3hour = temp_3hr(tmax, tmin, period);
            tot = tot + ttFn.ValueIndexed(tmean_3hour);
        }
        return(tot / (double)num3hr);
    }