source: CPL/oasis3-mct/branches/OASIS3-MCT_2.0_branch/util/oasisgui/library/oasis3-mct/scripts/process_summary.py @ 4775

Last change on this file since 4775 was 4775, checked in by aclsce, 5 years ago
  • Imported oasis3-mct from Cerfacs svn server (not suppotred anymore).

The version has been extracted from https://oasis3mct.cerfacs.fr/svn/branches/OASIS3-MCT_2.0_branch/oasis3-mct@1818

  • Property svn:executable set to *
File size: 13.3 KB
Line 
1from XDR import *
2
3
4###########################
5# INITIALIZATION
6
7init()
8
9
10gridline="******************************************************************"
11gridline+="\n"
12gridline+="*** Summary of the coupling fields and their transformations: \n"
13gridline+="******************************************************************"
14gridline+="\n"
15gridline+="******************************************************************"
16gridline+="\n"
17multiple_list= []
18mult_fields_name=[]
19mult_array={}
20grid_array={}
21grid_names_list=[]
22
23# Get the possible type of fields (single, multiple1, multiple2 ...)
24# depending on nb_mult (by default list initialized to (single,multiple1))
25mult_fields_name=getListValue("mult_fields_name")
26grid_names_list=getListValue("grid_names_list")
27#print("nb_mult",nb_mult)
28#print("mult_fields_name",mult_fields_name)
29
30# Construction of the real names of the sent fields and the received
31# fields for each multiple and store them in the array mult_array
32for mult in mult_fields_name:
33    if mult != "single" :
34#        print(mult)
35        sendnames = []
36        recvnames = []
37        for fields in getChildrenName("flddef"):
38            if getValue("fldmult",fields) == mult:
39                send =getValue("fldnamebef",fields)     
40                recv =getValue("fldnameaft",fields)     
41                field_label = getValue(fields)
42                for fields2 in getChildrenName("group"):
43                    field_label2 = getValue(fields2,"group")
44                    for fields3 in getChildrenName("crs"):
45                        field_label3 = getValue(fields3,"crs")
46#                        print(field_label3,field_label2)
47                        if field_label3 == field_label2 :
48                            statusf= getValue("status",fields3).upper()
49# Treat the case where the field is INPUT or OUTPUT :
50# source and target symbolic names must be the same
51                            if ( (statusf == "OUTPUT") or (statusf == "INPUT") ) :
52                                send =getValue("fldnamebef",fields)
53                                recv = getValue("fldnamebef",fields)   
54                sendnames.append(send)
55                recvnames.append(recv)
56                mult_array[mult,"sendnames"] = sendnames
57                mult_array[mult,"recvnames"] = recvnames
58#                print(sendnames)
59#                print(recvnames)
60
61
62# Create a tab with the characteristics of the
63# different grids defined in Grids and used in Fields
64for gridid in getChildrenName("gridsline"):
65    grid_name=getValue(gridid)
66    grid_array[grid_name,"grid_name"] = grid_name
67    grid_array[grid_name,"grdstatus"] = getValue("gridstatus",gridid)
68    grid_array[grid_name,"overlap"] = getValue("grid_overlap",gridid)
69    grid_array[grid_name,"grddims"] = getValue("dimsgrid",gridid)
70    if grid_array[grid_name,"grddims"] == "dims_on":
71        grid_array[grid_name,"ni"] = getValue("ni_grid",gridid)
72        grid_array[grid_name,"nj"] = getValue("nj_grid",gridid)
73
74
75# Loop over all the coupling fields to write the transformations
76# associated to each field.
77# treat the multiple fields only once.
78for fields in getChildrenName("flddef"):
79    mult_cat = getValue("fldmult",fields)
80#    print("mult_cat",mult_cat)
81    if (mult_cat == "single") :
82        field_label = getValue(fields)
83        for fields3 in getChildrenName("crs"):
84             field_label3 = getValue(fields3,"crs")
85#             print(field_label3,field_label)
86             if field_label3 == field_label :
87                 statusf= getValue("status",fields3).upper()
88# Treat the case where the field is INPUT or OUTPUT :
89# source and target symbolic names must be the same
90                 if ( (statusf == "OUTPUT") or (statusf == "INPUT") ) :
91                     gridline+=getValue("fldnamebef",fields)+"-"+getValue("fldnamebef",fields)+":"
92                 else :
93                     gridline+=getValue("fldnamebef",fields)+"-"+getValue("fldnameaft",fields)+":"
94        gridline+="\n" 
95    else: 
96        if mult_cat in multiple_list:
97            print ("Multiple field alreay treated")
98            field_label="nothing"
99        else :
100            multiple_list.append(mult_cat)
101            field_label=mult_cat
102            gridline+=":".join(mult_array[mult_cat,"sendnames"]) + "-"
103            gridline+=":".join(mult_array[mult_cat,"recvnames"]) 
104            gridline+="\n"
105
106# Get the grids informations   
107    if (field_label != "nothing"):
108         src_name=getValue("srcgrid",fields)
109         tgt_name=getValue("tgtgrid",fields)
110         if grid_array[src_name,"grddims"] == "dims_on":
111             gridline+="Source grid :"
112             gridline+=" "
113             gridline+=src_name
114             gridline+="\n"
115             gridline+="Dimensions :"
116             gridline+=" "
117             gridline+=grid_array[src_name,"ni"]+"x"+grid_array[src_name,"nj"]
118             gridline+="\n"
119             gridline+="Target grid :"
120             gridline+=" "
121             gridline+=tgt_name
122             gridline+="\n"
123             gridline+="Dimensions :"
124             gridline+=" "
125             gridline+=grid_array[tgt_name,"ni"]+"x"+grid_array[tgt_name,"nj"]
126             gridline+="\n"
127         else :
128             gridline+="Source grid :"
129             gridline+=" "
130             gridline+=src_name
131             gridline+="\n"
132             gridline+="Target grid :"
133             gridline+=" "
134             gridline+=tgt_name
135             gridline+="\n"
136
137         for fields2 in getChildrenName("crs"):
138             field_label2 = getValue(fields2,"crs")
139             if field_label == field_label2 :
140                 src_status=grid_array[src_name,"grdstatus"]
141                 src_overlap=grid_array[src_name,"overlap"]
142                 tgt_status=grid_array[tgt_name,"grdstatus"]
143                 tgt_overlap=grid_array[tgt_name,"overlap"]
144                 if src_status == "periodical_grid" : 
145                     gridline+="Source grid periodical with "
146                     gridline+=" "
147                     gridline+=src_overlap+" overlapping points"
148                     gridline+="\n"
149                 elif src_status == "regional_grid" :
150                     gridline+="Source grid regional"
151                     gridline+="\n"
152                 if tgt_status == "periodical_grid" : 
153                     gridline+="Target grid periodical with "
154                     gridline+=" "
155                     gridline+=tgt_overlap+" overlapping points"
156                     gridline+=" "
157                 elif tgt_status == "regional_grid" :
158                     gridline+="Target grid regional"
159                     gridline+=" "
160                 gridline+="\n"
161
162# Get the informations concerning the coupling period, the restart file and the
163# status of the field
164    for fields2 in getChildrenName("crs"):
165        field_label2 = getValue(fields2,"crs")
166#        print(field_label, field_label2)
167        if field_label == field_label2 :
168            gridline+="Coupling period="+getValue("cpl",fields2)
169            gridline+="\n" 
170            gridline+="Restart file: "+getValue("restart",fields2)
171            gridline+="\n" 
172            gridline+="Field status: "+getValue("status",fields2).upper()
173            gridline+="\n" 
174
175    for fields3 in getChildrenName("seqlag","defseqlag"):
176        field_label3 = getValue(fields3,"seqlag")
177        if field_label == field_label3 : 
178            if getValue("seq",fields3) == "seq_on" :
179                 gridline+=" " 
180                 gridline+="SEQ="+getValue("seq_fld",fields3)
181            if getValue("lag",fields3) == "lag_on" :
182                 gridline+=" " 
183                 gridline+="LAG="+getValue("lag_fld",fields3)
184            gridline+="\n"
185   
186
187# Transformations done on the coupling fields
188    for fields2 in getChildrenName("time"):
189        field_label2 = getValue(fields2,"time")
190        if field_label == field_label2 :
191            if getValue("loctrans",fields2) == "loctrans_on" :
192                gridline+="Time transformation:"+getValue("loctransdef",fields2).upper()
193                gridline+="\n"
194
195    for fields2 in getChildrenName("checkinoutminmax"):
196        field_label2 = getValue(fields2,"checkinoutminmax")
197        if field_label == field_label2 :
198            if getValue("checkin",fields2) == "checkin_on" :
199                gridline+="Min and max of the field sent calculated"
200                gridline+="\n"
201
202    for fields2 in getChildrenName("checkinoutminmax"):
203        field_label2 = getValue(fields2,"checkinoutminmax")
204        if field_label == field_label2 :
205            if getValue("checkout",fields2) == "checkout_on" :
206                gridline+="Min and max of the received field calculated"
207                gridline+="\n"
208
209    for fields2 in getChildrenName("multaddoldnew"):
210        field_label2 = getValue(fields2,"multaddoldnew")
211        if field_label == field_label2 :
212            if getValue("blasold",fields2) == "blasold_on" :
213                gridline+="Multiply by "+getValue("xmult_blso","blasold_on",fields2)+" the field sent"
214                gridline+="\n"
215                if getValue("xadd_blso","blasold_on",fields2) == "0." :
216                    gridline+=" "
217                else:
218                    gridline+="Add "+getValue("xadd_blso","blasold_on",fields2)+" to the field sent"
219                    gridline+="\n"
220
221    for fields2 in getChildrenName("multaddoldnew"):
222        field_label2 = getValue(fields2,"multaddoldnew")
223        if field_label == field_label2 :
224            if getValue("blasnew",fields2) == "blasnew_on" :
225                gridline+="Multiply by "+getValue("xmult_blsn","blasnew_on",fields2)+" the received field"
226                gridline+="\n"
227                if getValue("xadd_blsn","blasnew_on",fields2) == "0." :
228                    gridline+=" "
229                else:
230                    gridline+="Add "+getValue("xadd_blsn","blasnew_on",fields2)+" to the received field"
231                    gridline+="\n"
232
233
234    for fields2 in getChildrenName("map"):
235        field_label2 = getValue(fields2,"map")
236        if field_label == field_label2 :
237            if getValue("mapremapping",fields2) == "mapping_on" :
238                gridline+="MAPPING is used with options: "+getValue("maploc",fields2)+" and "+getValue("mapstrategy",fields2)
239                gridline+="\n"
240
241    for fields2 in getChildrenName("interp"):
242        field_label2 = getValue(fields2,"interp")
243        if field_label == field_label2 :
244            if getValue("scrip",fields2) == "scrip_on" :
245                gridline+="SCRIPR is used: "
246                gridline+="\n"
247                if getValue("scriprinterp",fields2) == "distwgt" :
248                    gridline+="DISTWGT interpolation with "+getValue("nv_dist",fields2)+" neighbours"
249                    gridline+="\n"
250                if getValue("scriprinterp",fields2) == "gauswgt" :
251                    gridline+="GAUSWGT interpolation with "+getValue("nv_gaus",fields2)+" neighbours"
252                    gridline+="\n"
253                if getValue("scriprinterp",fields2) == "bilinear" :
254                    gridline+="BILINEAR interpolation"
255                    gridline+="\n"
256                if getValue("scriprinterp",fields2) == "bicubic" :
257                    gridline+="BICUBIC interpolation"
258                    gridline+="\n"
259                if getValue("scriprinterp",fields2) == "conserv_interp" :
260                    gridline+="CONSERVATIVE interpolation of: "
261                    gridline+="\n"
262                    if getValue("order_conserv",fields2) == "first_conserv" :
263                        gridline+= "FIRST ORDER"
264                        gridline+= "\n"
265                    elif getValue("order_conserv",fields2) == "second_conserv" :
266                        gridline+= "SECOND ORDER"
267                        gridline+= "\n"
268                    if getValue("norm_conserv",fields2) == "fracnnei_conserv" :
269                        gridline+= "using FRACNNEI option"
270                        gridline+= " "
271                    elif getValue("norm_conserv",fields2) == "fracarea_conserv" :
272                        gridline+= "FRACAREA"
273                        gridline+= " "
274                    elif getValue("norm_conserv",fields2) == "destarea_conserv" :
275                        gridline+= "DESTAREA"
276                        gridline+= " "
277
278
279    for fields2 in getChildrenName("conservation"):
280        field_label2 = getValue(fields2,"conservation")
281        if field_label == field_label2 :
282            if getValue("conservopt",fields2) == "conserv_on" :
283                gridline+="Redistribution after interpolation (CONSERV)"
284                gridline+="\n"
285                gridline+= "with conserv option: "+getValue("conservstrategy",fields2).upper()
286                gridline+="\n"
287                if getValue("conservalgo",fields2) == "bfb_conserv_on" :
288                    gridline+="and bit-for-bit reproductibility option"
289                    gridline+="\n"
290                elif getValue("conservalgo",fields2) == "opt_conserv_on" :
291                    gridline+="and optimize option"
292                    gridline+="\n"
293
294    if (field_label == "nothing" ):
295        gridline+=""
296    else:
297        gridline+="********************************************************"
298        gridline+="\n"
299        gridline+="********************************************************"
300        gridline+="\n"
301
302
303summaryline=gridline
304# Write the informations in a window of the interface
305# not at the namcouple format
306setValue(summaryline,"summaryscript")
307
308#########################
309# FINISHING
310finish()
311
Note: See TracBrowser for help on using the repository browser.