zmk
2023-12-26 736a7162bc5e5da76cafacecd821a46efc09f143
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 20 16:15:23 2023
 
@author: ZMK
"""
 
import numpy as np
import shutil
import os
 
 
prefix ='C:\\Users\\ZMK\\Desktop\\xsModel2\\'
 
baseModel = prefix + 'verifyModel\\'
 
predictModel= prefix + 'predictModel\\'
 
predictParamModel= prefix + 'predictParamModel\\'
 
model_dir = prefix + '0612Model\\'
 
obswellpath = prefix + '监测井.ini'
 
obs_well = np.loadtxt(obswellpath, dtype=str,encoding='utf-8')
 
district_path = prefix +"区县.ini"
 
district= np.loadtxt(district_path, dtype=str,encoding='utf-8')
 
pumpwellpath = prefix +'抽水井.ini'
 
pump_well = np.loadtxt(pumpwellpath, dtype=str,encoding='utf-8')
 
period_path = prefix  +"period.json"
 
areapath = prefix + '分区.ini'
area_array = np.loadtxt(areapath, dtype=str,encoding='utf-8')
 
#水均衡路径
water_equ_path = prefix + 'water_equ.ini'
water_equ = np.loadtxt(water_equ_path, dtype=str,encoding='utf-8')
 
water_equ_path2022 = prefix + 'water_equ2022.ini'
water_equ2022 = np.loadtxt(water_equ_path2022, dtype=str,encoding='utf-8')
 
             
model_config ='C:\\Users\\ZMK\\Desktop\\objclipdig\\ModelFlow_xishan\\config.ini'
 
model3d_path='D:/javaCode/xishan/xishan/xishan/output2/'
 
modeldata_csv_path ="C:/Users/ZMK/Desktop/xsModel2/0612Model/"
 
exe_path = 'C:/Users/ZMK/Desktop/objclipdig/ModelFlow_xishan/ModelFlow_xishan.exe'
 
#调动 exe 程序
def callModelexe():
    os.system(exe_path)
 
 
#更新模型的exe配置
def updateModelConfig(model_name):
    conf = np.loadtxt(model_config, dtype=str,encoding='utf-8')
    outpath = "outpath=" + model3d_path + model_name
    csvpath = "csvpath=" + modeldata_csv_path + model_name +"/output"
    conf[1]=outpath
    conf[2]=csvpath
    np.savetxt(model_config,conf, newline='\n', fmt='%s' , encoding='utf-8')
 
 
 
def getPumpWellName(row,column):
  
    for index, r, c,ids, qu ,name in pump_well:
        if r==row and c == column:
            return name
    
    return "NONE"
 
 
#获取矩阵分组的字典结构
def getAreas():
    arr = np.loadtxt(areapath, dtype=int)
    dict ={}
    for i in range(len(arr)):
        for j in range(len(arr[i])):  
            zb = str(arr[i][j])
            if arr[i][j] == -9999:         
                continue        
            if zb not in dict:
                dict[zb] = [(i,j)]         
            else:
                dict[zb].append((i,j))  
    return dict
 
 
def getAreaDictFirstIndex():
    arr = np.loadtxt(areapath, dtype=int)
    dict ={}
    for i in range(len(arr)):
        for j in range(len(arr[i])):           
            if arr[i][j] == -9999:         
                continue        
            if arr[i][j] not in dict:
                dict[arr[i][j]] = [(i,j)]         
             
    return dict
    
 
#获取分组小标字典数据
def getAreaDictIndexArray():
    arr = np.loadtxt(areapath, dtype=int)
    dict_array={}
    for i in range(len(arr)):
        for j in range(len(arr[i])):  
            zb= str(arr[i][j])
            if arr[i][j] == -9999:         
                continue        
            if zb not in dict_array:
                array= []
                index = getCellIdByRC(i+1,j+1)
                array.append(index)    
                dict_array[zb] = array                              
            else:            
                index = getCellIdByRC(i+1,j+1)
                dict_array[zb].append(index)
            
    return dict_array
 
 
def getCellIdByRC(rowVal, columnVal):   
    return (rowVal - 1) * 114 + columnVal - 1;