@@ -87,8 +87,8 @@ def print_params(cnn, stnlist):
87
87
% (station ['NetworkCode' ], station ['StationCode' ]), as_dict = True )
88
88
89
89
for p in params :
90
- print (' %s.%s %-5s %-5s %2i' \
91
- % ( station [ 'NetworkCode' ], station [ 'StationCode' ], p ['soln' ], p ['object' ], p ['terms' ]))
90
+ print (' %s.%s %-5s %-5s %2i' % ( station [ 'NetworkCode' ], station [ 'StationCode' ],
91
+ p ['soln' ], p ['object' ], p ['terms' ]))
92
92
93
93
94
94
def insert_modify_param (parser , cnn , stnlist , args ):
@@ -103,26 +103,16 @@ def insert_modify_param(parser, cnn, stnlist, args):
103
103
104
104
# create a bunch object to save all the params that will enter the database
105
105
tpar = Bunch ()
106
- tpar .NetworkCode = None
107
- tpar .StationCode = None
108
- tpar .soln = None
109
- tpar .object = None
110
- tpar .terms = None
111
- tpar .frequencies = None
112
- tpar .jump_type = None
113
- tpar .relaxation = None
114
- tpar .Year = None
115
- tpar .DOY = None
116
- tpar .action = None
106
+ tpar .NetworkCode = tpar .StationCode = tpar .soln = tpar .object = tpar .terms = tpar .frequencies = None
107
+ tpar .jump_type = tpar .relaxation = tpar .Year = tpar .DOY = tpar .action = None
117
108
118
109
ftype = args .function_type [0 ]
119
- remove_eq = False
120
- remove_mec = False
110
+ remove_eq = remove_mec = False
121
111
122
112
try :
123
113
if ftype == 'p' :
124
114
tpar .object = 'polynomial'
125
- tpar .terms = int (args .function_type [1 ])
115
+ tpar .terms = int (args .function_type [1 ])
126
116
127
117
if tpar .terms <= 0 :
128
118
parser .error ('polynomial terms should be > 0' )
@@ -145,8 +135,7 @@ def insert_modify_param(parser, cnn, stnlist, args):
145
135
date , _ = Utils .process_date ([args .function_type [3 ]])
146
136
147
137
# recover the year and doy
148
- tpar .Year = date .year
149
- tpar .DOY = date .doy
138
+ tpar .Year , tpar .DOY = date .year , date .doy
150
139
151
140
except Exception as e :
152
141
parser .error ('while parsing jump date: ' + str (e ))
@@ -161,7 +150,7 @@ def insert_modify_param(parser, cnn, stnlist, args):
161
150
parser .error ('jump type == 1 but no relaxation parameter, please specify relaxation' )
162
151
163
152
elif ftype == 'q' :
164
- tpar .object = 'periodic'
153
+ tpar .object = 'periodic'
165
154
tpar .frequencies = [float (1 / float (p )) for p in args .function_type [1 :]]
166
155
167
156
elif ftype == 't' :
@@ -178,7 +167,7 @@ def insert_modify_param(parser, cnn, stnlist, args):
178
167
for soln in args .solution_type :
179
168
tpar .NetworkCode = station ['NetworkCode' ]
180
169
tpar .StationCode = station ['StationCode' ]
181
- tpar .soln = soln
170
+ tpar .soln = soln
182
171
183
172
station_soln = "%s.%s (%s)" % (station ['NetworkCode' ], station ['StationCode' ], soln )
184
173
@@ -197,8 +186,7 @@ def insert_modify_param(parser, cnn, stnlist, args):
197
186
pyETM .CO_SEISMIC_JUMP )]:
198
187
if eq .magnitude <= float (args .function_type [1 ]):
199
188
# this earthquake should be removed, fill in the data
200
- tpar .Year = eq .date .year
201
- tpar .DOY = eq .date .doy
189
+ tpar .Year , tpar .DOY = jump .date .year , jump .date .doy
202
190
tpar .jump_type = 1
203
191
tpar .relaxation = None
204
192
tpar .action = '-'
@@ -222,8 +210,7 @@ def insert_modify_param(parser, cnn, stnlist, args):
222
210
223
211
if sdate [0 ] <= jump .date <= sdate [1 ]:
224
212
# this jump should be removed, fill in the data
225
- tpar .Year = jump .date .year
226
- tpar .DOY = jump .date .doy
213
+ tpar .Year , tpar .DOY = jump .date .year , jump .date .doy
227
214
tpar .jump_type = 0
228
215
tpar .relaxation = None
229
216
tpar .action = '-'
@@ -244,11 +231,8 @@ def apply_change(cnn, station, tpar, soln):
244
231
# check if solution exists for this station
245
232
try :
246
233
epar = cnn .get ('etm_params' , ppar , list (ppar .keys ()))
247
-
248
234
print (' >> Found a set of matching parameters for station ' + station_soln )
249
-
250
235
print (' -- Deleting ' + station_soln )
251
-
252
236
cnn .delete ('etm_params' , ** epar )
253
237
254
238
except Exception :
@@ -257,7 +241,6 @@ def apply_change(cnn, station, tpar, soln):
257
241
cnn .insert ('etm_params' , ** tpar )
258
242
# insert replaces the uid field
259
243
del tpar .uid
260
-
261
244
print (' -- Inserting %s for %s' % (tpar .object , station_soln ))
262
245
263
246
0 commit comments