Changeset 0e2f93e in flex_extract.git
- Timestamp:
- Nov 27, 2018, 9:41:47 PM (5 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 786cfd6
- Parents:
- ca48036
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/python/mods/disaggregation.py
r708c667 r0e2f93e 210 210 211 211 # time step 212 dt =1.0212 dt = 1.0 213 213 214 214 ############### Non-negative Geometric Mean Based Algorithm ############### … … 217 217 # the value at t=0 of the interpolation algorithm coincides with the 218 218 # first data value according to the persistence hypothesis 219 f =[g[0]]219 f = [g[0]] 220 220 221 221 # compute two first sub-grid intervals without monotonicity check … … 223 223 # points and interpolate the corresponding data values 224 224 # except for the last interval due to boundary conditions 225 for i in range(0, 2):225 for i in range(0, 2): 226 226 227 227 # as a requirement: … … 229 229 # interval in f has to be zero to such that f[i+1]=f[i+2]=f[i+3]=0 230 230 # according to Eq. (6) 231 if g[i] ==0.:232 f.extend([0., 0.,0.])231 if g[i] == 0.: 232 f.extend([0., 0., 0.]) 233 233 234 234 # otherwise the sub-grid values are calculated and added to the list … … 245 245 # the function value at the first sub-grid point (fi1) is determined 246 246 # according to the equal area condition with Eq. (19) 247 fi1 =3./2.*g[i]-5./12.*fip1-1./12.*fi247 fi1 = 3./2.*g[i]-5./12.*fip1-1./12.*fi 248 248 249 249 # the function value at the second sub-grid point (fi2) is determined 250 250 # according Eq. (18) 251 fi2 =fi1+1./3.*(fip1-fi)251 fi2 = fi1+1./3.*(fip1-fi) 252 252 253 253 # add next interval of interpolated (sub-)grid values … … 260 260 # points and interpolate the corresponding data values 261 261 # except for the last interval due to boundary conditions 262 for i in range(2, len(g)-1):262 for i in range(2, len(g)-1): 263 263 264 264 # as a requirement: … … 266 266 # interval in f has to be zero to such that f[i+1]=f[i+2]=f[i+3]=0 267 267 # according to Eq. (6) 268 if g[i] ==0.:268 if g[i] == 0.: 269 269 # apply monotonicity filter for interval before 270 270 # check if there is "M" or "W" shape 271 if np.sign(f[-5]-f[-6]) * np.sign(f[-4]-f[-5]) ==-1 \272 and np.sign(f[-4]-f[-5]) * np.sign(f[-3]-f[-4]) ==-1 \273 and np.sign(f[-3]-f[-4]) * np.sign(f[-2]-f[-3]) ==-1:271 if np.sign(f[-5]-f[-6]) * np.sign(f[-4]-f[-5]) == -1 \ 272 and np.sign(f[-4]-f[-5]) * np.sign(f[-3]-f[-4]) == -1 \ 273 and np.sign(f[-3]-f[-4]) * np.sign(f[-2]-f[-3]) == -1: 274 274 275 275 # the monotonicity filter corrects the value at (fim1) by … … 283 283 # interval boundaries (fi) and (fip2) remains unchanged 284 284 # see Eq. (18) and (19) 285 f[-4] =fmon286 f[-6] =3./2.*g[i-2]-5./12.*fmon-1./12.*f[-7]287 f[-5] =f[-6]+(fmon-f[-7])/3.288 f[-3] =3./2.*g[i-1]-5./12.*f[-1]-1./12.*fmon289 f[-2] =f[-3]+(f[-1]-fmon)/3.285 f[-4] = fmon 286 f[-6] = 3./2.*g[i-2]-5./12.*fmon-1./12.*f[-7] 287 f[-5] = f[-6]+(fmon-f[-7])/3. 288 f[-3] = 3./2.*g[i-1]-5./12.*f[-1]-1./12.*fmon 289 f[-2] = f[-3]+(f[-1]-fmon)/3. 290 290 291 291 f.extend([0.,0.,0.]) … … 300 300 # geometric mean, restricted such that non-negativity is guaranteed 301 301 # according to Eq. (25) 302 fip1 =min( 3.*g[i] , 3.*g[i+1] , np.sqrt(g[i+1]*g[i]) )302 fip1 = min( 3.*g[i] , 3.*g[i+1] , np.sqrt(g[i+1]*g[i]) ) 303 303 304 304 # the function value at the first sub-grid point (fi1) is determined 305 305 # according to the equal area condition with Eq. (19) 306 fi1 =3./2.*g[i]-5./12.*fip1-1./12.*fi306 fi1 = 3./2.*g[i]-5./12.*fip1-1./12.*fi 307 307 308 308 # the function value at the second sub-grid point (fi2) is determined 309 309 # according Eq. (18) 310 fi2 =fi1+1./3.*(fip1-fi)310 fi2 = fi1+1./3.*(fip1-fi) 311 311 312 312 # apply monotonicity filter for interval before 313 313 # check if there is "M" or "W" shape 314 if np.sign(f[-5]-f[-6]) * np.sign(f[-4]-f[-5]) ==-1 \315 and np.sign(f[-4]-f[-5]) * np.sign(f[-3]-f[-4]) ==-1 \316 and np.sign(f[-3]-f[-4]) * np.sign(f[-2]-f[-3]) ==-1:314 if np.sign(f[-5]-f[-6]) * np.sign(f[-4]-f[-5]) == -1 \ 315 and np.sign(f[-4]-f[-5]) * np.sign(f[-3]-f[-4]) == -1 \ 316 and np.sign(f[-3]-f[-4]) * np.sign(f[-2]-f[-3]) == -1: 317 317 318 318 # the monotonicity filter corrects the value at (fim1) by … … 326 326 # interval boundaries (fi) and (fip2) remains unchanged 327 327 # see Eq. (18) and (19) 328 f[-4] =fmon329 f[-6] =3./2.*g[i-2]-5./12.*fmon-1./12.*f[-7]330 f[-5] =f[-6]+(fmon-f[-7])/3.331 f[-3] =3./2.*g[i-1]-5./12.*f[-1]-1./12.*fmon332 f[-2] =f[-3]+(f[-1]-fmon)/3.328 f[-4] = fmon 329 f[-6] = 3./2.*g[i-2]-5./12.*fmon-1./12.*f[-7] 330 f[-5] = f[-6]+(fmon-f[-7])/3. 331 f[-3] = 3./2.*g[i-1]-5./12.*f[-1]-1./12.*fmon 332 f[-2] = f[-3]+(f[-1]-fmon)/3. 333 333 334 334 # add next interval of interpolated (sub-)grid values … … 343 343 # interval in f has to be zero to such that f[i+1]=f[i+2]=f[i+3]=0 344 344 # according to Eq. (6) 345 if g[-1] ==0.:345 if g[-1] == 0.: 346 346 # apply monotonicity filter for interval before 347 347 # check if there is "M" or "W" shape 348 if np.sign(f[-5]-f[-6]) * np.sign(f[-4]-f[-5]) ==-1 \349 and np.sign(f[-4]-f[-5]) * np.sign(f[-3]-f[-4]) ==-1 \350 and np.sign(f[-3]-f[-4]) * np.sign(f[-2]-f[-3]) ==-1:348 if np.sign(f[-5]-f[-6]) * np.sign(f[-4]-f[-5]) == -1 \ 349 and np.sign(f[-4]-f[-5]) * np.sign(f[-3]-f[-4]) == -1 \ 350 and np.sign(f[-3]-f[-4]) * np.sign(f[-2]-f[-3]) == -1: 351 351 352 352 # the monotonicity filter corrects the value at (fim1) by … … 360 360 # interval boundaries (fi) and (fip2) remains unchanged 361 361 # see Eq. (18) and (19) 362 f[-4] =fmon363 f[-6] =3./2.*g[-3]-5./12.*fmon-1./12.*f[-7]364 f[-5] =f[-6]+(fmon-f[-7])/3.365 f[-3] =3./2.*g[-2]-5./12.*f[-1]-1./12.*fmon366 f[-2] =f[-3]+(f[-1]-fmon)/3.362 f[-4] = fmon 363 f[-6] = 3./2.*g[-3]-5./12.*fmon-1./12.*f[-7] 364 f[-5] = f[-6]+(fmon-f[-7])/3. 365 f[-3] = 3./2.*g[-2]-5./12.*f[-1]-1./12.*fmon 366 f[-2] = f[-3]+(f[-1]-fmon)/3. 367 367 368 368 f.extend([0.,0.,0.]) … … 385 385 # apply monotonicity filter for interval before 386 386 # check if there is "M" or "W" shape 387 if np.sign(f[-5]-f[-6]) * np.sign(f[-4]-f[-5]) ==-1 \388 and np.sign(f[-4]-f[-5]) * np.sign(f[-3]-f[-4]) ==-1 \389 and np.sign(f[-3]-f[-4]) * np.sign(f[-2]-f[-3]) ==-1:387 if np.sign(f[-5]-f[-6]) * np.sign(f[-4]-f[-5]) == -1 \ 388 and np.sign(f[-4]-f[-5]) * np.sign(f[-3]-f[-4]) == -1 \ 389 and np.sign(f[-3]-f[-4]) * np.sign(f[-2]-f[-3]) == -1: 390 390 391 391 # the monotonicity filter corrects the value at (fim1) by … … 399 399 # interval boundaries (fi) and (fip2) remains unchanged 400 400 # see Eq. (18) and (19) 401 f[-4] =fmon402 f[-6] =3./2.*g[-3]-5./12.*fmon-1./12.*f[-7]403 f[-5] =f[-6]+(fmon-f[-7])/3.404 f[-3] =3./2.*g[-2]-5./12.*f[-1]-1./12.*fmon405 f[-2] =f[-3]+(f[-1]-fmon)/3.401 f[-4] = fmon 402 f[-6] = 3./2.*g[-3]-5./12.*fmon-1./12.*f[-7] 403 f[-5] = f[-6]+(fmon-f[-7])/3. 404 f[-3] = 3./2.*g[-2]-5./12.*f[-1]-1./12.*fmon 405 f[-2] = f[-3]+(f[-1]-fmon)/3. 406 406 407 407 # add next interval of interpolated (sub-)grid values
Note: See TracChangeset
for help on using the changeset viewer.