1# -*- coding: utf-8 -*-

2

3 import os

4 import xml.etree.ElementTree as ET

5

6 from grm.lib.Util import indent

7

8

9 class make:

10 def __init__(self):

11 self.ProjectFile = ""

12

13 # New Project 시에 GMP 파일 생성 하기

14 def Make_GMP_File(self, save_gmp_path):

15 GRMProject = ET.Element("GRMProject")

16 GRMProject.set("xmlns", "http://tempuri.org/GRMProject.xsd")

17 ProjectSettings = ET.SubElement(GRMProject, "ProjectSettings")

18 ET.SubElement(ProjectSettings, "ProjectFile").text = save_gmp_path

19 ET.SubElement(ProjectSettings, "GRMSimulationType").text = "SingleEvent"

20 ET.SubElement(ProjectSettings, "DomainFile")

21 ET.SubElement(ProjectSettings, "SlopeFile")

22 ET.SubElement(ProjectSettings, "FlowDirectionFile")

23 ET.SubElement(ProjectSettings, "FlowAccumFile")

24 ET.SubElement(ProjectSettings, "StreamFile")

25 ET.SubElement(ProjectSettings, "ChannelWidthFile")

26 ET.SubElement(ProjectSettings, "InitialSoilSaturationRatioFile")

27 ET.SubElement(ProjectSettings, "LandCoverDataType").text = "File"

28 ET.SubElement(ProjectSettings, "LandCoverFile")

29 ET.SubElement(ProjectSettings, "LandCoverVATFile")

30 ET.SubElement(ProjectSettings, "ConstantRoughnessCoeff")

31 ET.SubElement(ProjectSettings, "ConstantImperviousRatio")

32 ET.SubElement(ProjectSettings, "LAIFile")

33 ET.SubElement(ProjectSettings, "BlaneyCriddleCoefDataFile")

34 ET.SubElement(ProjectSettings, "SoilTextureDataType").text = "File"

35 ET.SubElement(ProjectSettings, "SoilTextureFile")

36 ET.SubElement(ProjectSettings, "SoilTextureVATFile")

37 ET.SubElement(ProjectSettings, "ConstantSoilPorosity")

38 ET.SubElement(ProjectSettings, "ConstantSoilEffPorosity")

39 ET.SubElement(ProjectSettings, "ConstantSoilWettingFrontSuctionHead")

40 ET.SubElement(ProjectSettings, "ConstantSoilHydraulicConductivity")

41 ET.SubElement(ProjectSettings, "SoilDepthDataType").text = "File"

42 ET.SubElement(ProjectSettings, "SoilDepthFile")

43 ET.SubElement(ProjectSettings, "SoilDepthVATFile")

44 ET.SubElement(ProjectSettings, "ConstantSoilDepth")

45 ET.SubElement(ProjectSettings, "InitialChannelFlowFile")

46 ET.SubElement(ProjectSettings, "PrecipitationDataFile").text = "C:\\"

47 ET.SubElement(ProjectSettings, "PrecipitationInterval_min").text = "0"

48 ET.SubElement(ProjectSettings, "TemperatureMaxDataFile")

49 ET.SubElement(ProjectSettings, "TemperatureMaxInterval_min")

50 ET.SubElement(ProjectSettings, "TemperatureMinDataFile")

51 ET.SubElement(ProjectSettings, "TemperatureMinInterval_min")

52 ET.SubElement(ProjectSettings, "DaytimeLengthDataFile")

53 ET.SubElement(ProjectSettings, "DaytimeLengthInterval_min")

54 ET.SubElement(ProjectSettings, "DaytimeHoursRatioDataFile")

55 ET.SubElement(ProjectSettings, "SolarRadiationDataFile")

56 ET.SubElement(ProjectSettings, "SolarRadiationInterval_min")

57 ET.SubElement(ProjectSettings, "SnowPackTemperatureDataFile")

58 ET.SubElement(ProjectSettings, "SnowPackTemperatureInInterval_min")

59 ET.SubElement(ProjectSettings, "FlowDirectionType").text = "StartsFromE_TauDEM"

60 ET.SubElement(ProjectSettings, "MaxDegreeOfParallelism").text = "-1"

61 ET.SubElement(ProjectSettings, "SimulationStartingTime").text = "0"

62 ET.SubElement(ProjectSettings, "ComputationalTimeStep")

63 ET.SubElement(ProjectSettings, "IsFixedTimeStep").text = "false"

64 ET.SubElement(ProjectSettings, "SimulationDuration")

65 ET.SubElement(ProjectSettings, "OutputTimeStep")

66 ET.SubElement(ProjectSettings, "SimulateInfiltration").text = "true"

67 ET.SubElement(ProjectSettings, "SimulateSubsurfaceFlow").text = "true"

68 ET.SubElement(ProjectSettings, "SimulateBaseFlow").text = "true"

69 ET.SubElement(ProjectSettings, "SimulateInterception").text = "true"

70 ET.SubElement(ProjectSettings, "SimulateEvapotranspiration").text = "true"

71 ET.SubElement(ProjectSettings, "SimulateSnowMelt").text = "true"

72 ET.SubElement(ProjectSettings, "SimulateFlowControl").text = "false"

73 ET.SubElement(ProjectSettings, "MakeIMGFile").text = "false"

74 ET.SubElement(ProjectSettings, "MakeASCFile").text = "false"

75 ET.SubElement(ProjectSettings, "MakeSoilSaturationDistFile").text = "true"

76 ET.SubElement(ProjectSettings, "MakeRfDistFile").text = "true"

77 ET.SubElement(ProjectSettings, "MakeRFaccDistFile").text = "true"

78 ET.SubElement(ProjectSettings, "MakeFlowDistFile").text = "true"

79 ET.SubElement(ProjectSettings, "PrintOption").text = "All"

80 ET.SubElement(ProjectSettings, "PrintAveValue").text = "false"

81 ET.SubElement(ProjectSettings, "AveValueTimeInterval_min")

82 ET.SubElement(ProjectSettings, "WriteLog").text = "false"

83 ET.SubElement(ProjectSettings, "AboutThisProject")

84 ET.SubElement(ProjectSettings, "AboutWatershed")

85 ET.SubElement(ProjectSettings, "AboutLandCoverMap")

86 ET.SubElement(ProjectSettings, "AboutSoilMap")

87 ET.SubElement(ProjectSettings, "AboutSoilDepthMap")

88 ET.SubElement(ProjectSettings, "AboutRainfall")

89 ET.SubElement(ProjectSettings, "ProjectSavedTime")

90

91 # PC 이름 가져오기

92 pc_name = os.getenv("COMPUTERNAME")

93

94 # USER (로그인 된 계정) 이름 가져오기

95 user_name = os.getenv("USERNAME")

96

97 ET.SubElement(ProjectSettings, "ComputerName").text = pc_name

98 ET.SubElement(ProjectSettings, "ComputerUserName").text = user_name

99 ET.SubElement(ProjectSettings, "GRMVersion").text = ""

100 indent(GRMProject)

101 ET.ElementTree(GRMProject).write(

102 save_gmp_path, encoding="utf-8", xml_declaration=True

103 )

104

105

106# self.indent(save_gmp_path)

107#

108# def indent(self,Pro_path):

109# arg=GetScriptDirectory_Path()+ "/ReWriteXML/ReadAndWriteXML.exe " + Pro_path

110# callExecute(arg)