public void Constant(float ppt = 0.15f, float tmax = 15, float tmin = 5, float pet = 0.1f) { var grid = this.Grid as MFGrid; DataCube <float> mat = new DataCube <float>(1, this.TimeService.NumTimeStep, grid.ActiveCellCount); mat.Variables = new string[] { "hru_ppt" }; mat.DateTimes = this.TimeService.Timeline.ToArray(); mat.ILArrays[0][":", ":"] = 0.1f; MMSDataFile data = new MMSDataFile(MasterPackage.PrecipitationFile); data.Save(mat); mat.Variables[0] = "hru_tmax"; mat.ILArrays[0][":", ":"] = UnitConversion.Celsius2Fahrenheit(15); data = new MMSDataFile(MasterPackage.TempMaxFile); data.Save(mat); mat.Variables[0] = "hru_tmin"; mat.ILArrays[0][":", ":"] = UnitConversion.Celsius2Fahrenheit(5); data = new MMSDataFile(MasterPackage.TempMinFile); data.Save(mat); mat.Variables[0] = "hru_pet"; mat.ILArrays[0][":", ":"] = 0.15f; data = new MMSDataFile(MasterPackage.PETFile); data.Save(mat); }
public override bool Load(int var_index, ICancelProgressHandler progress) { _ProgressHandler = progress; var full_file = Path.Combine(ModelService.WorkDirectory, _FileNames[var_index]); var grid = Owner.Grid as MFGrid; _SelectedIndex = var_index; DataCube = new DataCube <float>(Variables.Length, StepsToLoad, grid.ActiveCellCount, true); DataCube.Name = "clm_input"; DataCube.Variables = this.Variables; DataCube.Topology = (Owner.Grid as RegularGrid).Topology; DataCube.TimeBrowsable = true; DataCube.AllowTableEdit = false; if (MasterPackage.ClimateInputFormat == FileFormat.Text) { MMSDataFile data = new MMSDataFile(full_file); data.NumTimeStep = this.NumTimeStep; data.MaxTimeStep = this.MaxTimeStep; data.DataCube = this.DataCube; data.Loading += stream_LoadingProgressChanged; data.DataCubeLoaded += data_DataCubeLoaded; data.LoadFailed += data_LoadFailed; if (MasterPackage.UseGridClimate) { data.Load(_GridHruMapping, var_index); } else { data.LoadDataCube(var_index); } } else { DataCubeStreamReader stream = new DataCubeStreamReader(full_file); stream.NumTimeStep = this.NumTimeStep; stream.MaxTimeStep = this.MaxTimeStep; stream.DataCube = this.DataCube; stream.Scale = (float)this.ScaleFactor; stream.Loading += stream_LoadingProgressChanged; stream.DataCubeLoaded += data_DataCubeLoaded; if (MasterPackage.UseGridClimate) { stream.LoadDataCubeSingle(_GridHruMapping, var_index); } else { stream.LoadDataCubeSingle(var_index); } } return(true); }