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)
import pates from pates.generators.ars import _ars if __name__ == '__main__': # ------------------------------------------------------------------- # Generate ARS patterns # Dictionary with patterns parameters dPattsPar = {} # Invoke dictionary dPattsPar['tS'] = 1e-3 # Duration of a sampling pattern [1 ms] dPattsPar['Tg'] = 1e-6 # Sampling grid period [1 us] dPattsPar['fR'] = 100e3 # Average sampling ratio [100 kHz] dPattsPar['iVar'] = 1 # The variance parameter dPattsPar['nPatts'] = 1e3 # The number of patterns to be generated # Run the ARS generator dPatt = _ars.generate_patterns(dPattsPar, {}) # ------------------------------------------------------------------- # Store ARS patterns in a file res_file = open('ARS_patterns.dat', 'wb') cPickle.dump(dPatt, res_file) res_file.close()