Example #1
0
def main(lPattSettings, dSysSettings, dPattEval, dPatt):

    # =================================================================
    # Get the needed data

    # System settings:
    inxPS = dSysSettings['inxPS']      # Current index of patterns
                                       # settings (patterns type)

    inxPP = dSysSettings['inxPP']      # Current index of patterns pack

    # -----------------------------------------------------------------

    # -----------------------------------------------------------------
    # Get the number of patterns in a pack (size of a pattern pack)

    dMemory = dSysSettings['dMemory']      # Memory configuration dictionary

    nMaxPacks = dMemory['nMaxPacks']        # The maximum number of packs
                                            # with patterns

    # -----------------------------------------------------------------
    # Get the patterns settings:

    dPattsPar = lPattSettings[inxPS-1]    # Current patterns configuration
                                          # dictionary

    strType = dPattsPar['strType']        # Type of patterns generator

    # =================================================================

    # =================================================================
    # Move the current index of patterns pack forward

    # Move the index forward
    inxPP = inxPP + 1

    # Store the index of a patterns pack
    dSysSettings['inxPP'] = inxPP

    # =================================================================

    # =================================================================

    # Get the file storing settings
    (bPattStore, strPattsDIRName) = \
        _patterns_storing.get_settings(dSysSettings)

    # =================================================================

    # =================================================================
    # Choose the correct patterns generator

    # ----------------------------------------------------------
    # ANGIE
    if strType == 'ANGIE':

        # Generate a pack of patterns
        dPatt = _angie.generate_patterns(dPattsPar, dSysSettings)
        #dPatt = _angie_naive.generate_patterns(dPattsPar, dSysSettings)
        #dPatt = _angie_c.generate_patterns(dPattsPar, dSysSettings)

    # ----------------------------------------------------------
    # ----------------------------------------------------------
    # ADDITIVE RANDOM SAMPLING
    elif strType == 'ARS':

        # Generate a pack of patterns
        dPatt = _ars.generate_patterns(dPattsPar, dSysSettings)

    # ----------------------------------------------------------
    # ----------------------------------------------------------
    # JITTERED SAMPLING
    elif strType == 'JS':

        # Generate a pack of patterns
        dPatt = _js.generate_patterns(dPattsPar, dSysSettings)

    # ----------------------------------------------------------

    # Unknown type of pattern generator
    else:
        print('ERROR: >> %s << is unknown type of patterns generator.!') % \
            strType
        sys.exit(1)

    # ----------------------------------------------------------

    # =================================================================

    # =================================================================
    # Store the patterns?
    if bPattStore == 1:

        # Generate a file name to store the current pack of patterns
        strPattFileName = '%s/%spatterns%d_%d.dat' % \
                          (strPattsDIRName, strType, inxPS, inxPP)

        # Store the pack of patterns in a file
        pk1_file = open(strPattFileName, 'wb')
        cPickle.dump(dPatt, pk1_file)
        pk1_file.close()

    # =================================================================

    # =================================================================
    return (lPattSettings, dSysSettings, dPattEval, dPatt)