4 Star 27 Fork 10

Yonghe/GeoFlying

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ClimatePara.cs 8.91 KB
一键复制 编辑 原始数据 按行查看 历史
Yonghe 提交于 2020-10-02 09:33 . first
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace GeoFly
{
//气象数据结构
public class Climate_File_Info
{
public string DataFileName = null; //气象数据文件名
public string StationFileName = null; //气象站点文件名
};
public class ClimatePara
{
public ClimatePara()
{
}
public void FileWrite(string FileName, List<string> slist)
{
StreamWriter sw = new StreamWriter(FileName);
foreach (string s in slist)
{
sw.WriteLine(s);
}
}
public List<string> FileRead(string FileName)
{
//检查文件
if (!File.Exists(FileName))
{
MessageBox.Show("文件" + FileName + "不存在!");
return null;
}
List<string> slist = new List<string>();
StreamReader sr = new StreamReader(FileName);
while (!sr.EndOfStream)
{
slist.Add(sr.ReadLine());
}
return slist;
}
/// <summary>
/// 读入气象参数
/// </summary>
/// <param name="FileName"></param>
public void ReadClimateFile(string FileName)
{
StreamReader sr = new StreamReader(FileName);
sr.ReadLine();
sr.ReadLine();
string[] saOut= sr.ReadLine().Split(new char[] { ' ','\t' }, StringSplitOptions.RemoveEmptyEntries);
if(saOut.Length>1)
this.PcpInfo.DataFileName = saOut[1];
saOut = sr.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if(saOut.Length>1)
this.TempmxInfo.DataFileName = saOut[1];
saOut=sr.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if(saOut.Length>1)
this.TempmnInfo.DataFileName = saOut[1];
saOut = sr.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if(saOut.Length>1)
this.TempmeanInfo.DataFileName = saOut[1];
saOut = sr.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if(saOut.Length>1)
this.SlrInfo.DataFileName = saOut[1];
saOut = sr.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if(saOut.Length>1)
this.HmdInfo.DataFileName = saOut[1];
saOut = sr.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if(saOut.Length>1)
this.WndInfo.DataFileName = saOut[1];
saOut = sr.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if(saOut.Length>1)
this.PetInfo.DataFileName = saOut[1];
saOut = sr.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if(saOut.Length>1)
this.PcpInfo.StationFileName = saOut[1];
saOut = sr.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if (saOut.Length > 1)
{
this.TempmxInfo.StationFileName = saOut[1];
this.TempmnInfo.StationFileName = saOut[1];
this.TempmeanInfo.StationFileName = saOut[1];
}
saOut = sr.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if (saOut.Length > 1)
this.SlrInfo.StationFileName = saOut[1];
saOut = sr.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if (saOut.Length > 1)
this.HmdInfo.StationFileName = saOut[1];
saOut = sr.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if (saOut.Length > 1)
this.WndInfo.StationFileName = saOut[1];
saOut = sr.ReadLine().Split(new char[] { ' ','\t' }, StringSplitOptions.RemoveEmptyEntries);
if (saOut.Length > 1)
this.PetInfo.StationFileName = saOut[1];
sr.Close();
}
/// <summary>
/// 输出气象参数
/// </summary>
/// <param name="FileName"></param>
public void WriteClimateFile(string FileName)
{
StreamWriter sw = new StreamWriter(FileName);
sw.WriteLine(" Basin Meteo and Hydro Parameter File: " + DateTime.Now.Date+"\t"+DateTime.Now.TimeOfDay);
sw.WriteLine();
sw.WriteLine("降雨量数据文件名:\t"+PcpInfo.DataFileName);
sw.WriteLine("最高气温数据文件名:\t"+TempmxInfo.DataFileName);
sw.WriteLine("最低气温数据文件名:\t"+TempmnInfo.DataFileName);
sw.WriteLine("平均气温数据文件名:\t"+TempmeanInfo.DataFileName);
sw.WriteLine("太阳辐射数据文件名:\t"+SlrInfo.DataFileName);
sw.WriteLine("相对湿度数据文件名:\t"+HmdInfo.DataFileName);
sw.WriteLine("平均风速数据文件名:\t"+WndInfo.DataFileName);
sw.WriteLine("潜在蒸散发数据文件名:\t"+PetInfo.DataFileName);
sw.WriteLine("降雨站点文件名:\t"+PcpInfo.StationFileName);
sw.WriteLine("气温站点文件名:\t"+TempmxInfo.StationFileName);
sw.WriteLine("太阳辐射站点文件名:\t"+SlrInfo.StationFileName);
sw.WriteLine("相对湿度站点文件名:\t"+HmdInfo.StationFileName);
sw.WriteLine("平均风速站点文件名:\t"+WndInfo.StationFileName);
sw.WriteLine("潜在蒸散发站点文件名:\t"+PetInfo.StationFileName);
sw.Close();
}
//气象参数文件信息
/// <summary>
/// 降雨数据文件信息
/// </summary>
public Climate_File_Info PcpInfo = new Climate_File_Info();
/// <summary>
/// //最高气温数据文件信息
/// </summary>
public Climate_File_Info TempmxInfo = new Climate_File_Info();
/// <summary>
/// //最低气温数据文件信息
/// </summary>
public Climate_File_Info TempmnInfo = new Climate_File_Info();
/// <summary>
/// //平均气温数据文件信息
/// </summary>
public Climate_File_Info TempmeanInfo = new Climate_File_Info();
/// <summary>
/// //辐射数据文件信息
/// </summary>
public Climate_File_Info SlrInfo = new Climate_File_Info();
/// <summary>
/// //湿度数据文件信息
/// </summary>
public Climate_File_Info HmdInfo = new Climate_File_Info();
/// <summary>
/// //风速数据文件信息
/// </summary>
public Climate_File_Info WndInfo = new Climate_File_Info();
/// <summary>
/// //潜在蒸散发文件信息
/// </summary>
public Climate_File_Info PetInfo = new Climate_File_Info();
/// <summary>
/// 模型运行起始时间
/// </summary>
public DateTime StartDate;
/// <summary>
/// 模型运行结束时间
/// </summary>
public DateTime EndDate;
//public int startyr; //模型运行起始年
//public int startday; //模型运行起始日
//public int endyr; //模型运行结束年
//public int endday; //模型运行结束日
/// <summary>
/// 降雨量数据
/// </summary>
public IDWInter pcpdata=new IDWInter(); //降雨量数据
/// <summary>
/// 太阳辐射数据
/// </summary>
public IDWInter slrdata=new IDWInter();
/// <summary>
/// 相对湿度数据
/// </summary>
public IDWInter hmddata=new IDWInter();
/// <summary>
/// 最高气温数据
/// </summary>
public IDWInter tmpmxdata=new IDWInter();
/// <summary>
/// 最低气温数据
/// </summary>
public IDWInter tmpmndata=new IDWInter();
/// <summary>
/// 平均气温数据
/// </summary>
public IDWInter tmpmeandata=new IDWInter();
/// <summary>
/// 风速数据
/// </summary>
public IDWInter WindData=new IDWInter();
/// <summary>
/// 潜在蒸散发数据
/// </summary>
public IDWInter petdata=new IDWInter();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/sucksis/geo-flying.git
[email protected]:sucksis/geo-flying.git
sucksis
geo-flying
GeoFlying
master

搜索帮助