Changeset 0e2f93e in flex_extract.git


Ignore:
Timestamp:
Nov 27, 2018, 9:41:47 PM (5 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
786cfd6
Parents:
ca48036
Message:

applied some pep8 styles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/python/mods/disaggregation.py

    r708c667 r0e2f93e  
    210210
    211211    # time step
    212     dt=1.0
     212    dt = 1.0
    213213
    214214    ############### Non-negative Geometric Mean Based Algorithm ###############
     
    217217    # the value at t=0 of the interpolation algorithm coincides with the
    218218    # first data value according to the persistence hypothesis
    219     f=[g[0]]
     219    f = [g[0]]
    220220
    221221    # compute two first sub-grid intervals without monotonicity check
     
    223223    # points and interpolate the corresponding data values
    224224    # except for the last interval due to boundary conditions
    225     for i in range(0,2):
     225    for i in range(0, 2):
    226226
    227227        # as a requirement:
     
    229229        # interval in f has to be zero to such that f[i+1]=f[i+2]=f[i+3]=0
    230230        # 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.])
    233233
    234234        # otherwise the sub-grid values are calculated and added to the list
     
    245245            # the function value at the first sub-grid point (fi1) is determined
    246246            # according to the equal area condition with Eq. (19)
    247             fi1=3./2.*g[i]-5./12.*fip1-1./12.*fi
     247            fi1 = 3./2.*g[i]-5./12.*fip1-1./12.*fi
    248248
    249249            # the function value at the second sub-grid point (fi2) is determined
    250250            # according Eq. (18)
    251             fi2=fi1+1./3.*(fip1-fi)
     251            fi2 = fi1+1./3.*(fip1-fi)
    252252
    253253            # add next interval of interpolated (sub-)grid values
     
    260260    # points and interpolate the corresponding data values
    261261    # 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):
    263263
    264264        # as a requirement:
     
    266266        # interval in f has to be zero to such that f[i+1]=f[i+2]=f[i+3]=0
    267267        # according to Eq. (6)
    268         if g[i]==0.:
     268        if g[i] == 0.:
    269269            # apply monotonicity filter for interval before
    270270            # 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:
    274274
    275275                # the monotonicity filter corrects the value at (fim1) by
     
    283283                # interval boundaries (fi) and (fip2) remains unchanged
    284284                # see Eq. (18) and (19)
    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.
     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.
    290290
    291291            f.extend([0.,0.,0.])
     
    300300            # geometric mean, restricted such that non-negativity is guaranteed
    301301            # 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]) )
    303303
    304304            # the function value at the first sub-grid point (fi1) is determined
    305305            # according to the equal area condition with Eq. (19)
    306             fi1=3./2.*g[i]-5./12.*fip1-1./12.*fi
     306            fi1 = 3./2.*g[i]-5./12.*fip1-1./12.*fi
    307307
    308308            # the function value at the second sub-grid point (fi2) is determined
    309309            # according Eq. (18)
    310             fi2=fi1+1./3.*(fip1-fi)
     310            fi2 = fi1+1./3.*(fip1-fi)
    311311
    312312            # apply monotonicity filter for interval before
    313313            # 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:
    317317
    318318                # the monotonicity filter corrects the value at (fim1) by
     
    326326                # interval boundaries (fi) and (fip2) remains unchanged
    327327                # see Eq. (18) and (19)
    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.
     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.
    333333
    334334            # add next interval of interpolated (sub-)grid values
     
    343343    # interval in f has to be zero to such that f[i+1]=f[i+2]=f[i+3]=0
    344344    # according to Eq. (6)
    345     if g[-1]==0.:
     345    if g[-1] == 0.:
    346346        # apply monotonicity filter for interval before
    347347        # 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:
    351351
    352352            # the monotonicity filter corrects the value at (fim1) by
     
    360360            # interval boundaries (fi) and (fip2) remains unchanged
    361361            # see Eq. (18) and (19)
    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.
     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.
    367367
    368368        f.extend([0.,0.,0.])
     
    385385        # apply monotonicity filter for interval before
    386386        # 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:
    390390
    391391            # the monotonicity filter corrects the value at (fim1) by
     
    399399            # interval boundaries (fi) and (fip2) remains unchanged
    400400            # see Eq. (18) and (19)
    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.
     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.
    406406
    407407        # add next interval of interpolated (sub-)grid values
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG