示例#1
0
def ifft2d(F):
    (Nr, Nc) = F.shape
    f = np.zeros((Nr, Nc), dtype=complex)
    for m in range(Nr):
        f[m,:] = mm.ifft(F[m,:])
    for n in range(Nc):
        f[:,n] = mm.ifft(f[:,n])
    return(f)
示例#2
0
def conv2dsep(x,h,v):
    (Nrx,Ncx)=x.shape
    y=np.zeros((Nrx+len(h)-1, Ncx+len(v)-1))
    for m in range(Nrx):
        y[m,:]=mm.conv(x[m,:],h)
    for n in range(Ncx+len(v)-1):
        y[:,n]=mm.conv(y[:Nrx,n],v)
    return(y)
示例#3
0
def fft2d(f):
    (Nr, Nc) = f.shape
    F = np.zeros((Nr, Nc), dtype=complex)
    for m in range(Nr):
        F[m,:] = mm.fft(f[m,:])
    for n in range(Nc):
        F[:,n] = mm.fft(F[:,n])
    return(F)
示例#4
0
def get_Mu_from_Vs_Rho(Vs, Rho):
    """
	Computes shear modulus from shear velocity and density.
	The units must be as described below.
		
		Input Variables:
			Vs	= (Shear Velocity)				(m/s)
			Rho	= (Density)						(g/(cm^3))
			
		Output Variable:
			Mu	= Shear Modulus					(Gpa)
	"""

    if isinstance(Vs, (int, long, float, complex)) and (isinstance(
            Rho, (int, long, float, complex))):

        # Conversion to (mks) system for computation
        Rho = 1E3 * Rho  # Conversion from g/(cm^3) to Kg/(m^3)

        Mu = Rho * (Vs * Vs)

        Mu = Mu / 1E9  # Conversion from Pa to Gpa

    elif type(Vs) == np.ndarray and (type(Rho)
                                     == np.ndarray) and (len(Vs) == len(Rho)):

        # Conversion to (mks) system for computation
        Rho = 1E3 * Rho  # Conversion from g/(cm^3) to Kg/(m^3)

        Mu = Rho * (Vs * Vs)

        Mu = Mu / 1E9  # Conversion from Pa to Gpa

    elif type(Vs) == list and (type(Rho) == list) and (len(Vs) == len(Rho)):

        Rho = [Rho[i] * 1E3 for i in range(len(Rho))
               ]  # Conversion from g/(cm^3) to Kg/(m^3)

        Mu = [Rho[i] * (Vs[i] * Vs[i]) for i in range(len(Vs))]

        Mu = [Mu[i] / 1E9 for i in range(len(Mu))]  # Conversion from Pa to Gpa

    else:

        mm.myStdErrorMessage(
            "Error: get_Vp_from_K_Mu_Rho",
            ("The input variables are not consistent for this function"))
        return

    return Mu
示例#5
0
def get_Vp_from_K_Mu_Rho(K, Mu, Rho):
    """
	Computes the compressional velocity from bulk modulus, shear modulus and density.
	The units must be as described below.
	
		Input Variables:
			K   = Bulk modulus           (Gpa)
			Mu  = Shear Modulus          (Gpa)
			Rho = Density                (g/cc)
			
		Output Variable:
			Vp  = Compressional Velocity (m/s)
			
	Note the inputs variables can be either scalars, python lists or numpy arrays, 
	however all variables must be of the same type and dimenson in the case of lists
	and arrays.
	"""
    if isinstance(K, (int, long, float, complex)) and (isinstance(
            Mu, (int, long, float, complex))) and (isinstance(
                Rho, (int, long, float, complex))):

        # Conversion to (mks) system for computation
        K = 1E9 * K  # Conversion from GPa to Pa
        Mu = 1E9 * Mu  # Conversion from GPa to Pa
        Rho = 1E3 * Rho  # Conversion from g/(cm^3) to Kg/(m^3)

        Vp = sqrt((K + 4 * Mu / 3) / Rho)

    elif type(K) == np.ndarray and (type(Mu) == np.ndarray) and (
            type(Rho) == np.ndarray) and (len(K) == len(Mu)) and (len(Mu)
                                                                  == len(Rho)):

        Vp = np.sqrt((1E9 * K + 4E9 * Mu / 3) / (1E3 * Rho))

    elif type(K) == list and (type(Mu) == list) and (type(Rho) == list) and (
            len(K) == len(Mu)) and (len(Mu) == len(Rho)):

        Vp = [
            sqrt((1E9 * K[i] + 4E9 * Mu[i] / 3) / (1E3 * Rho[i]))
            for i in range(len(K))
        ]

    else:

        mm.myStdErrorMessage(
            "Error: get_Vp_from_K_Mu_Rho",
            "The input variables are not consistent for this function")
        mm.exitNow()

    return Vp
示例#6
0
def main():
    #startApplication("my_aut")
    #mymodule.click_button(":object_name")
    print("In the Main")
    MyModule.Module_click_button(":Test")
    MyModule3.Module_TestModule3(":Test")
    MyModule2.Module_TestModule2(":Test")
示例#7
0
def vrhAverage(values=[], weights=[]):
    """
	Computes the Voigt-Reuss-Hill average (vrhAve = 1/2(voigtAve + reussAve))
	Weights will be normalized so sum will equal 1.
	"""
    reussAve = 0
    sumWeight = 0
    if len(values) != len(weights):
        mm.myStdErrorMessage("Error: vrhAverage", (
            "The number of elements in your values does not equal the number of weights"
        ))
        mm.exitNow()

    voigtAve = voigtAverage(values, weights)
    reussAve = reussAverage(values, weights)
    vrhAve = 0.5 * (voigtAve + reussAve)

    return vrhAve
示例#8
0
def go():
    try:
        path = sys.argv[1]
        #print(path)
        toemail = sys.argv[3]
        #print(toemail)
        logfilepath, start_time, scanned_files, dup_files = mm.directory(path)
        check = mm.sendemail(logfilepath, toemail, start_time, scanned_files,
                             dup_files)
        if (check):
            print("Email Sent to " + toemail + "with attachement file " +
                  logfilepath)
        else:
            print("email sending error")
            exit()

    except Exception:
        print("Exception")
        print(traceback.format_exc())
示例#9
0
def matrix_K_calculator(constituentVolFrac=[], constituentK=[]):
    """
	The function computes the equivalent bulk modulus Kmin from the 
	contituent minerals within the matrix and their respective volume fractions
	using the Voigt-Reuss-Hill average.
	"""

    if len(constituentVolFrac) == len(constituentK):

        Kmin = vrhAverage(constituentVolFrac, constituentK)

    else:
        mm.myStdErrorMessage(
            "Length missmatch",
            "The number of elements in weights do not match the numvber of constituents"
        )
        return

    return Kmin
示例#10
0
def reussAverage(values=[], weights=[]):
    """
	Computes the Voigt average (1/reussAve = w1/v1 + w2/v2 + ...)
	Weights will be normalized to insure the sum of all weights will equal 1.
	It is assumed, both input values are 1 dimensional.
	"""
    reussAve = 0
    sumWeight = 0
    i = 0

    if type(values) == np.ndarray and (type(weights)
                                       == np.ndarray) and (len(values)
                                                           == len(weights)):

        for i in range(len(weights)):
            sumWeight += weights[i]

        for i in range(len(values)):
            reussAve += weights[i] / (values[i] * sumWeight)

        reussAve = 1 / reussAve

    elif type(values) == list and (type(weights)
                                   == list) and (len(values) == len(weights)):

        for i in range(len(weights)):
            sumWeight += weights[i]

        for i in range(len(values)):
            reussAve += weights[i] / (values[i] * sumWeight)

        reussAve = 1 / reussAve

    else:

        mm.myStdErrorMessage(
            "Error: voigtAverage",
            ("The input variables are not consistent for this function"))
        return

    return reussAve
示例#11
0
	def __init__( self, parent = tk.Tk(), aBunchOfLogs = mm.BunchOfLogs() ):
		"""
		
		Creates a 'BunchOfLogs' object that contains the log information 
		chosen by the caller through a GUI dialog.
		
		"""
		self.numberOneSon = tk.Toplevel( parent )				# tk window under the parent from calling routine
		self.aBunchOfLogs = aBunchOfLogs						# BunchOfLogs object from calling function
		self.lasPath = str(mm.findFileGui()).split("'")[1]		# GUI to find las file and return it's path
		
		if self.lasPath == "":									# If no file selected, exit the process
			mm.myStdErrorMessage( "Read LAS error", "No file was select so will exit process.")
			sys.exit()
			
		self.lasFileName = self.ladPath.split("/")				# Retreive the LAS filename
		self.lasFileName = self.lasFileName[len(self.lasFileName)-1]..replace(".LAS", "").replace(".las", "")
		
		self.logsAvailableInFile = mm.CurvesInfoLAS()			# Retreive available log names in LAS file
		self.logsAvailableInFile = mm.ReadLogTypesFromLasFile( self.lasPath )
		
		self.logChoiceNumber = IntVar( master = self.numberOneSon )
		self.logChoiceNumber.set( 0 )							# Initialize radio button choice to first log curve
		
		self.theLog = mm.Log()									# Container for a particular log curve
		
		self.aBunchOfLogs.setnumLogs( self.logsAvailableInFile.numCurves )
		self.aBunchOfLogs.setlogType( self.logsAvailableInFile.logMnemonic )
		
		def readAllLogsFromLasFile( self , filePath ):
			
			"""
		
			Attempts to read all detected logs in a LAS file pointed to
			by 'filePath' into the 'aBunchOfLogs' object
		
			"""
			self.lasFile = open( self.lasPath, "r")
		
			self.flag = 0
			
			for self.i in range( self.logsAvailableInFile.numCurves ):
				self.aBunchOfLogs.theLog[ self.i ].ValueUnit = self.logsAvailableInFile.logUnit[ self.i ]
		
				for self.lasRow in self.lasFile:
			
			if self.lasRow[0] == '~A':
				self.flag = 1
				
			if self.flag == 1:
				for i in range( self.logsAvailableInFile.numCurves ):
					self.aBuchOfLogs.TheLog[i].Value.append( float( self.lasRow.split()[ self.i ] ) )
示例#12
0
def voigtAverage(values=[], weights=[]):
    """
	Computes the Voigt average (voigtAve = w1*v1 + w2*v2 + ...)
	Weights will be normalized so sum will equal 1.
	"""
    voigtAve = 0
    sumWeight = 0
    i = 0

    if type(values) == np.ndarray and (type(weights)
                                       == np.ndarray) and (len(values)
                                                           == len(weights)):

        for w in np.nditer(weights):
            sumWeight += w

        for i in range(len(values)):
            voigtAve += weights[i] * values[i] / sumWeight

    elif type(values) == list and (type(weights)
                                   == list) and (len(values) == len(weights)):

        for i in range(len(weights)):
            sumWeight += weights[i]

        for i in range(len(values)):
            voigtAve += weights[i] * values[i] / sumWeight

    else:

        mm.myStdErrorMessage(
            "Error: voigtAverage",
            ("The input variables are not consistent for this function"))
        return

    return voigtAve
示例#13
0
	def selectingLogForConversion( self ):
		"""
		Selection of a log from a bunch of logs for 
		"""
		
		self.logChoice = mm.getALogFromBunchOfLogs( self.branch2, self.localBunchOfLogs )
		
		
		print "\n Update information for chosen log:\n"
		print "     Log ID   : " + str(self.logChoice.logId)
		print "     Log Type : " + str(self.logChoice.logType)
		print "     Log Unit : " + str(self.logChoice.logUnit) + "\n"
		
		
		self.displayLogId.set( self.logChoice.logId )
		self.displayLogType.set( self.logChoice.logType )
		self.displayLogUnit.set( self.logChoice.logUnit )
示例#14
0
	def unitConvert( self ):
		"""
		Unit conversion function
		"""
		
		self.FirstTimeOnly = 0
		
		self.branch2 = tk.Toplevel( self.branch1 )
		self.branch2.wm_title( "Unit Conversion Funation")
		
		if self.FirstTimeOnly == 0:
			self.logChoice = mm.getALogFromBunchOfLogs( self.branch2 )
			self.FirstTimeOnly = 1
		
		self.fromUnit = tk.StringVar( self.branch2 )
		self.fromUnit.set( "None" )
		self.toUnit = tk.StringVar( self.branch2 )
		self.toUnit.set( "None" )
		self.displayLogId = tk.StringVar( self.branch2 )
		self.displayLogId.set( str( self.logChoice.logId ) )
		self.displayLogType = tk.StringVar( self.branch2 )
		self.displayLogType.set( str( self.logChoice.logType ) )
		self.displayLogUnit = tk.StringVar( self.branch2 )
		self.displayLogUnit.set( str( self.logChoice.logUnit ) )
		
		# Set up allowed units for conversion. Not all members of this list
		# can be converted to the others, as can be seen by its members.
		# Current convention is to keep all the characters in lower case.
		self.unitList = [ 	'm', 
							'ft',
							'km',
							'm/s',
							'ft/s',
							'km/s'  ]
							
		self.conversionScalarDictionary = {}
		for u in self.unitList:						# Initialize conversion matrix to null values
			for v in self.unitList:
				self.conversionScalarDictionary[ (u,v) ] = None
				
		# Setting actual possible conversion scalars within conversion matrix
		
		#  For Lengths
		self.conversionScalarDictionary[ ('m','ft')  ] = 3.280839895
		self.conversionScalarDictionary[ ('m','m')   ] = 1.0
		self.conversionScalarDictionary[ ('m','km')  ] = 0.001
		self.conversionScalarDictionary[ ('ft','ft') ] = 1.0
		self.conversionScalarDictionary[ ('ft','m')  ] = 1.0 / self.conversionScalarDictionary[('m','ft')]
		self.conversionScalarDictionary[ ('ft','km') ] = 0.001 / self.conversionScalarDictionary[('m','ft')]
		self.conversionScalarDictionary[ ('km','ft') ] = 1.0 / self.conversionScalarDictionary[('ft','km')]
		self.conversionScalarDictionary[ ('km','m')  ] = 1000.0
		self.conversionScalarDictionary[ ('km','km') ] = 1.0
		
		# For Velocities
		self.conversionScalarDictionary[ ('m/s','ft/s')  ] = 3.280839895
		self.conversionScalarDictionary[ ('m/s','km/s')  ] = 0.001
		self.conversionScalarDictionary[ ('m/s','m/s')   ] = 1.0
		self.conversionScalarDictionary[ ('ft/s','m/s')  ] = 1.0 / self.conversionScalarDictionary[('m/s','ft/s')]
		self.conversionScalarDictionary[ ('ft/s','ft/s') ] = 1.0
		self.conversionScalarDictionary[ ('ft/s','km/s') ] = 0.001 / self.conversionScalarDictionary[('m/s','ft/s')]
		self.conversionScalarDictionary[ ('km/s','ft/s') ] = 1.0 / self.conversionScalarDictionary[('ft/s','km/s')]
		self.conversionScalarDictionary[ ('km/s','m/s')  ] = 1000.0
		self.conversionScalarDictionary[ ('km/s','km/s') ] = 1.0
		
		for i in range( len( self.unitList ) ):
			if str( self.unitList[i] ) == str( self.logChoice.logUnit ).lower() :
				self.fromUnit.set( str( self.unitList[i] ) )
				
		self.rowCounter = 0
		
		self.unitConvertMainLable = tk.Label( self.branch2,
								text = "Unit conversion function",
								font = ("Comic Sans MS",16), 
								fg = "Blue" )
		self.unitConvertMainLable.grid( row = self.rowCounter, 
								columnspan = 3, 
								sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 10 )
								
		self.rowCounter += 1
		
		self.chooseALogButton = tk.Button( self.branch2,
								text = "Click to select log",
								command = self.selectingLogForConversion,
								font=("Comic Sans MS",16), 
								fg="Black")
		self.chooseALogButton.grid( row = self.rowCounter,
								columnspan = 3, 
								padx = 20, 
								pady = 10)
		
		self.rowCounter += 1
		
		self.logLabel = tk.Label( self.branch2,
								text = "Chosen Log for Conversion",
								font=("Comic Sans MS",16), 
								fg="Green")
		self.logLabel.grid(row = self.rowCounter, 
								columnspan = 3, 
								sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 5 )
		
		self.rowCounter += 1
		
		self.chosenLogIdLabel = tk.Label( self.branch2,
								text = "Log ID",
								font=("Comic Sans MS",14), 
								fg="Green")
		self.chosenLogIdLabel.grid(row = self.rowCounter,
		 						column = 0, 
								sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 5 )
								
		self.chosenLogTypeLabel = tk.Label( self.branch2,
								text = "Log Type",
								font=("Comic Sans MS",14), 
								fg="Green")
		self.chosenLogTypeLabel.grid(row = self.rowCounter,
		 						column = 1, 
								sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 5 )
								
		self.chosenLogUnitLabel = tk.Label( self.branch2,
								text = "Log Unit",
								font=("Comic Sans MS",14), 
								fg="Green" )
		self.chosenLogUnitLabel.grid( row = self.rowCounter,
								column = 2, 
								sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 5)
		
		self.rowCounter += 1
		
		self.chosenLogId = tk.Label( self.branch2, 
								textvariable = self.displayLogId,
								font=("Comic Sans MS",14), 
								fg="Black" )
		self.chosenLogId.grid( row = self.rowCounter,
								column = 0,
								sticky = tk.E+tk.W, 
								padx = 20 )
								
		self.chosenLogType = tk.Label( self.branch2,
								textvariable = self.displayLogType,
								font=("Comic Sans MS",14), 
								fg="Black" )
		self.chosenLogType.grid( row = self.rowCounter,
								column = 1,
								sticky = tk.E+tk.W, 
								padx = 20 )
								
		self.chosenLogUnit = tk.Label( self.branch2,
								textvariable = self.displayLogUnit,
								font=("Comic Sans MS",14), 
								fg="Black" )
		self.chosenLogUnit.grid( row = self.rowCounter,
								column = 2,
								sticky = tk.E+tk.W, 
								padx = 20)
		
		self.rowCounter += 1
		
		self.lineLabel = tk.Label( self.branch2,
								text = "___________________________________________",
								font = ("Comic Sans MS",12), 
								fg = "Blue")
		self.lineLabel.grid( row = self.rowCounter,
								columnspan = 3,
								sticky = tk.E+tk.W, 
								padx = 20 )
		
		self.rowCounter += 1
		
		self.convetChoiceLabel = tk.Label( self.branch2,
								text = "Choose units for conversion",
								font=("Comic Sans MS",16), 
								fg="Green")
		self.convetChoiceLabel.grid(row = self.rowCounter, 
								columnspan = 3, 
								sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 5 )
								
		self.rowCounter += 1
		
		self.fromLabel = tk.Label( self.branch2,
								text = "From unit below",
								font=("Comic Sans MS",16), 
								fg="Green")
		self.fromLabel.grid(row = self.rowCounter, 
								column = 0, 
								sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 5 )
								
		self.toLabel = tk.Label( self.branch2,
								text = "To unit below",
								font = ("Comic Sans MS",16), 
								fg = "Green")
		self.toLabel.grid(row = self.rowCounter, 
								column = 2, 
								sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 5 )
								
		self.rowCounter += 1
		
		for self.unit in self.unitList:
			
			self.fromButton = tk.Radiobutton( self.branch2,
								text = self.unit,
								variable = self.fromUnit,
								value = self.unit,
								font=("Comic Sans MS",14), 
								fg="Black" )
			self.fromButton.grid(row = self.rowCounter, 
								column = 0, 
								sticky = tk.E+tk.W, 
								padx = 20 )
			
			self.pointerLabel = tk.Label( self.branch2,
								text = "--------->",
								font=("Comic Sans MS",14), 
								fg="Blue" )
			self.pointerLabel.grid( row = self.rowCounter,
								column = 1, 
								sticky = tk.E+tk.W, 
								padx = 20)
			
			self.toButton = tk.Radiobutton( self.branch2,
								text = self.unit,
								variable = self.toUnit,
								value = self.unit,
								font=("Comic Sans MS",14), 
								fg="Black" )
			self.toButton.grid(row = self.rowCounter, 
								column = 2, 
								sticky = tk.E+tk.W, 
								padx = 20 )
								
			self.rowCounter += 1
		
		self.fromLabel = tk.Label( self.branch2,
								text = "Chosen unit to convert",
								font=("Comic Sans MS",16), 
								fg="Green")
		self.fromLabel.grid(row = self.rowCounter, 
								column = 0, 
								sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 5 )

		self.toLabel = tk.Label( self.branch2,
								text = "Chosen resultant unit",
								font = ("Comic Sans MS",16), 
								fg = "Green")
		self.toLabel.grid(row = self.rowCounter, 
								column = 2, 
								sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 5 )

		self.rowCounter += 1
		
		self.finalUnitChoosen = tk.Label( self.branch2,
								textvariable = self.fromUnit,
								font=("Comic Sans MS",14), 
								fg="Black")
		self.finalUnitChoosen.grid( row = self.rowCounter, 
								column = 0, 
								sticky = tk.E+tk.W, 
								padx = 20 )
								
		self.finalUnitChoosen = tk.Label( self.branch2,
								textvariable = self.toUnit,
								font=("Comic Sans MS",14), 
								fg="Black")
		self.finalUnitChoosen.grid( row = self.rowCounter, 
								column = 2, 
								sticky = tk.E+tk.W, 
								padx = 20 )
		self.rowCounter += 1
		
		self.lineLabel = tk.Label( self.branch2,
								text = "___________________________________________",
								font = ("Comic Sans MS",12), 
								fg = "Blue")
		self.lineLabel.grid( row = self.rowCounter,
								columnspan = 3,
								sticky = tk.E+tk.W, 
								padx = 20 )
		
		self.rowCounter += 1
		
		self.submitForUnitChange = tk.Button( self.branch2,
								text = "Submit for Conversion",
								command = self.applyUnitChange,
								font=("Comic Sans MS",14), 
								fg="Black")
		self.submitForUnitChange.grid( row = self.rowCounter,
								column = 1, 
								sticky = tk.E+tk.W, 
								padx = 20)
								
		self.rowCounter += 1
		
		self.exitButton = tk.Button( self.branch2,
								text = "Exit", 
								font = ("Comic Sans MS",14), 
								fg = "Red", 
								command = self.branch1.destroy )
		self.exitButton.grid( row = self.rowCounter, 
								column = 1, 
								sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 10 )
								
		self.branch2.mainloop()
示例#15
0
	def __init__( self, root, aBunchOfLogs = mm.BunchOfLogs ):
		"""
		Main setup for log processing.
		"""
		self.root = root
		self.localBunchOfLogs = aBunchOfLogs
		
		print "+------------------------------------------+"
		print "|                                          |"
		print "|     Start of log processing function     |"
		print "|                                          |"
		print "+------------------------------------------+"
		
		self.branch1 = tk.Toplevel( self.root )
		self.branch1.wm_title( "Basic Log Processing Function" )
		
		self.logChoice = mm.getALogFromBunchOfLogs()
		
		self.rowCounter = 0
		
		self.basicDescriptionLable = tk.Label( self.branch1,
								text = "Basic Log Processing Functions",
								font=("Comic Sans MS",16), 
								fg="Blue" )
		self.basicDescriptionLable.grid( row = self.rowCounter, 
								columnspan = 2,
								sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 30 )
								
		self.rowCounter += 1
		
		self.unitConversionLabel = tk.Label( self.branch1, 
								text = "Log unit conversion",
								font=("Comic Sans MS",16), 
								fg="Blue" )
		self.unitConversionLabel.grid( row = self.rowCounter, 
								column = 0,
								sticky = tk.W, 
								padx = 20, 
								pady = 5 )
		
		self.unitConversionButton = tk.Button( self.branch1,
								text = "Convert Unit",
								command = self.unitConvert,
								font=("Comic Sans MS",14), 
								fg="Black" )
		self.unitConversionButton.grid( row = self.rowCounter, 
								column = 1, 
								sticky = tk.E+tk.W,
								padx = 20, 
								pady = 5 )
								
		self.rowCounter += 1
		
		self.sonicVelocityTransformLabel = tk.Label( self.branch1, 
								text = "Transform sonic travel time to velocity",
								font=("Comic Sans MS",16), 
								fg="Blue" )
		self.sonicVelocityTransformLabel.grid( row = self.rowCounter, 
								column = 0, 
								sticky = tk.W,
								padx = 20, 
								pady = 5 )
		
		self.sonicVelocityTransformButton = tk.Button( self.branch1,
								text = "Time to Vel",
								command = self.sonicVelocityTransform,
								font=("Comic Sans MS",14), 
								fg="Black" )
		self.sonicVelocityTransformButton.grid( row = self.rowCounter, 
								column = 1, 
								sticky = tk.E+tk.W,
								padx = 20, 
								pady = 5 )
								
		self.rowCounter += 1
		
		self.castagnaVpVsTransformLabel = tk.Label( self.branch1, 
								text = "Castagna Vp to Vs transform",
								font=("Comic Sans MS",16), 
								fg="Blue" )
		self.castagnaVpVsTransformLabel.grid( row = self.rowCounter, 
								column = 0, 
								sticky = tk.W,
								padx = 20, 
								pady = 5 )
		
		self.castagnaVpVsTransformButton = tk.Button( self.branch1,
								text = "Vp to Vs",
								command = self.castagnaVpVsTransform,
								font=("Comic Sans MS",14), 
								fg="Black" )
		self.castagnaVpVsTransformButton.grid( row = self.rowCounter, 
								column = 1, 
								sticky = tk.E+tk.W,
								padx = 20, 
								pady = 5 )
								
		self.rowCounter += 1
		
		self.gardnerDensityVpTransformLabel = tk.Label( self.branch1, 
								text = "Gardner's Density to Vp transform",
								font=("Comic Sans MS",16), 
								fg="Blue" )
		self.gardnerDensityVpTransformLabel.grid( row = self.rowCounter, 
								column = 0, 
								sticky = tk.W,
								padx = 20, 
								pady = 5 )
		
		self.gardnerDensityVpTransformButton = tk.Button( self.branch1,
								text = "Density to Vp",
								command = self.gardnerDensityVpTransform,
								font=("Comic Sans MS",14), 
								fg="Black" )
		self.gardnerDensityVpTransformButton.grid( row = self.rowCounter, 
								column = 1, 
								sticky = tk.E+tk.W,
								padx = 20, 
								pady = 5 )
		
		self.rowCounter += 1
		
		self.exitButton = tk.Button( self.branch1,
								text = "Exit", 
								font = ("Comic Sans MS",16), 
								fg = "Red", 
								command = self.branch1.destroy )
		self.exitButton.grid( row = self.rowCounter, 
								columnspan = 2, 
								# sticky = tk.E+tk.W, 
								padx = 20, 
								pady = 20 )
		
		self.rowCounter += 1
    def __init__(self, name, **kwargs):
        pyrogue.Device.__init__(self,
                                name=name,
                                description='SMuRF Data CustomTransmitter',
                                **kwargs)
        self._transmitter = MyModule.MyTransmitter()

        # Add "Disable" variable
        self.add(
            pyrogue.LocalVariable(
                name='Disable',
                description=
                'Disable the processing block. Data will just pass thorough to the next slave.',
                mode='RW',
                value=False,
                localSet=lambda value: self._transmitter.setDisable(value),
                localGet=self._transmitter.getDisable))

        # Add a variable for the debugData flag
        self.add(
            pyrogue.LocalVariable(
                name='DebugData',
                description='Set the debug mode, for the data',
                mode='RW',
                value=False,
                localSet=lambda value: self._transmitter.setDebugData(value),
                localGet=self._transmitter.getDebugData))

        # Add a variable for the debugMeta flag
        self.add(
            pyrogue.LocalVariable(
                name='DebugMeta',
                description='Set the debug mode, for the metadata',
                mode='RW',
                value=False,
                localSet=lambda value: self._transmitter.setDebugMeta(value),
                localGet=self._transmitter.getDebugMeta))

        # Add the data dropped counter variable
        self.add(
            pyrogue.LocalVariable(name='DataDropCnt',
                                  description='Number of data frame dropped',
                                  mode='RO',
                                  value=0,
                                  pollInterval=1,
                                  localGet=self._transmitter.getDataDropCnt))

        # Add the metadata dropped counter variable
        self.add(
            pyrogue.LocalVariable(
                name='MetaDropCnt',
                description='Number of metadata frame dropped',
                mode='RO',
                value=0,
                pollInterval=1,
                localGet=self._transmitter.getMetaDropCnt))

        # Command to clear all the counters
        self.add(
            pyrogue.LocalCommand(name='clearCnt',
                                 description='Clear all counters',
                                 function=self._transmitter.clearCnt))
示例#17
0
def get_Kdry_FromGassmannEquation(Ksat, Kfluid, Kmin, Phi):
    """
	Computes the saturated dry frame bulk modulus of a rock using Gassmann's equation.
	
		Input Variables:
			Ksat   = The saturated bulk modulus			(Gpa)
			Kfluid = The fluid bulk modulus				(Gpa)
			Kmin   = The mineral/matrix bulk modulus	(Gpa)
			Phi    = The porosity 						(Fraction, V/V)
			
		Output Variable:
			Kdry   = The dry frame bulk modulus			(Gpa)
			
	"""

    if isinstance(Ksat, (int, long, float, complex)) and (isinstance(
            Kfluid, (int, long, float, complex))) and (isinstance(
                Kmin, (int, long, float, complex))) and (isinstance(
                    Phi, (int, long, float, complex))):

        A1 = B1 = (Phi * Kmin) / Kfluid
        A2 = A1 + 1 - Phi
        A3 = Ksat * A2
        A = A3 - Kmin
        B2 = Ksat / Kmin
        B = B1 + B2 - 1 - Phi

        Kdry = A / B

    elif type(Kdry) == np.ndarray and (type(Kfluid) == np.ndarray) and (
            type(Kmin) == np.ndarray) and (type(Phi) == np.ndarray) and (
                len(Kdry) == len(Kfluid)) and (len(Kfluid)
                                               == len(Kmin)) and (len(Kmin)
                                                                  == len(Phi)):

        A1 = B1 = (Phi * Kmin) / Kfluid
        A2 = A1 + 1 - Phi
        A3 = Ksat * A2
        A = A3 - Kmin
        B2 = Ksat / Kmin
        B = B1 + B2 - 1 - Phi

        Kdry = A / B

    elif type(Vp) == list and (type(Vs) == list) and (type(Rho) == list) and (
            len(Vp) == len(Vs)) and (len(Vs) == len(Rho)):

        numItems = len(Vp)

        A1 = B1 = [(Phi[i] * Kmin[i]) / Kfluid[i] for i in range(numItems)]
        A2 = [A1[i] + 1 - Phi[i] for i in range(numItems)]
        A3 = [Ksat[i] * A2[i] for i in range(numItems)]
        A = [A3[i] - Kmin[i] for i in range(numItems)]
        B2 = [Ksat[i] / Kmin[i] for i in range(numItems)]
        B = [B1[i] + B2[i] - 1 - Phi[i] for i in range(numItems)]

        Kdry = [A[i] / B[i] for i in range(numItems)]

    else:

        mm.myStdErrorMessage(
            "Error: get_Vp_from_K_Mu_Rho",
            ("The input variables are not consistent for this function"))
        return

    Kdry = A / B

    return Kdry
示例#18
0
import math
import cmath
import numpy as np
import imageio
import MyModule as mm
import time

x=[1,2,3,4]
x1=mm.complex_idft(mm.complex_dft(x))
x2=mm.complex_idft(mm.fft(x))
x3=mm.ifft(mm.complex_dft(x))
x4=mm.ifft(mm.fft(x))

y=[5,6,7,8]
output1=mm.conv(x,y)
output2=mm.ifft(mm.fft(x)*mm.fft(y))


img=imageio.imread('lena.png')#[256-128:256+128,256-128:256+128]

t1=time.time()
imageio.imwrite('lenareconstructed.png',mm.ifft2d(mm.fft2d(img)))

t2=time.time()
print('img ifft takes %10.2f sec' %( t2-t1))

示例#19
0
import matplotlib.pyplot as plt
import MyModule as mm

fs,x=sw.read('Libai.wav')

N=512
fcutoff=2000  #freq
Ncutoff=int(fcutoff/fs*N)   #freq=fs*n/N
Hlp=np.zeros((N),dtype=complex)
for n in range(1,Ncutoff):
    Hlp[n]=(1.0+0.0j)
    Hlp[N-n]=(1.0+0.0j)
Hlp[0]=1.0

hlp=mm.ifft(Hlp)
mm.dftplot(hlp,Hlp)

# Nfft=2**15
# xlp=mm.convlong(x,hlp,Nfft)
# sw.write('LibaiLp.wav',fs,xlp)
import MyModule as mm

mm.sayHello()
示例#21
0
# coding=utf8
"""
Created on Tue Jan 19 23:06:42 2021

@author: Neal LONG
"""
import sys
import imp
MyModule = imp.load_source('MyModule', "/Users/mac/Desktop/MDS5724_DataMining/Data_Mining_Codes/Data_Mining/week2/MyModule.py")
import MyModule as mm
person_name = "Jim"

# from MyModule import person_name


mm.greeting(person_name)
print(mm.pi*(10**2))
示例#22
0
def applyScalarFunctionToArrayVariables(function, parms=[]):
    """
	apply a scalar function to an array of variables each of which can be arrays as well
	right now this function can only handle up to 10 variable arrays of equal dimension.
	
	"""
    numvars = len(parms)

    if numvars == 1:
        output = [function(parms[0][i]) for i in range(len(parms[0]))]
    elif numvars == 2:
        output = [
            function(parms[0][i], parms[1][i]) for i in range(len(parms[0]))
        ]
    elif numvars == 3:
        output = [
            function(parms[0][i], parms[1][i], parms[2][i])
            for i in range(len(parms[0]))
        ]
    elif numvars == 4:
        output = [
            function(parms[0][i], parms[1][i], parms[2][i], parms[3][i])
            for i in range(len(parms[0]))
        ]
    elif numvars == 5:
        output = [
            function(parms[0][i], parms[1][i], parms[2][i], parms[3][i],
                     parms[4][i]) for i in range(len(parms[0]))
        ]
    elif numvars == 6:
        output = [
            function(parms[0][i], parms[1][i], parms[2][i], parms[3][i],
                     parms[4][i], parms[5][i]) for i in range(len(parms[0]))
        ]
    elif numvars == 7:
        output = [
            function(parms[0][i], parms[1][i], parms[2][i], parms[3][i],
                     parms[4][i], parms[5][i], parms[6][i])
            for i in range(len(parms[0]))
        ]
    elif numvars == 8:
        output = [
            function(parms[0][i], parms[1][i], parms[2][i], parms[3][i],
                     parms[4][i], parms[5][i], parms[6][i], parms[7][i])
            for i in range(len(parms[0]))
        ]
    elif numvars == 9:
        output = [
            function(parms[0][i], parms[1][i], parms[2][i], parms[3][i],
                     parms[4][i], parms[5][i], parms[6][i], parms[7][i],
                     parms[8][i]) for i in range(len(parms[0]))
        ]
    elif numvars == 10:
        output = [
            function(parms[0][i], parms[1][i], parms[2][i], parms[3][i],
                     parms[4][i], parms[5][i], parms[6][i], parms[7][i],
                     parms[8][i]) for i in range(len(parms[0]))
        ]
    else:
        mm.myStdErrorMessage(
            "Too many variables",
            "Only up to 10 variables can be entered for a funtion")
        mm.exitNow()

    return output
示例#23
0
def hashinShtrikmanMu(K1, Mu1, f1, K2, Mu2, f2):
    """
	Computes Hashin Shtrikman bounds on the shear modulus for 2 material mixture.
	Upper bounds is acheived when the subscrpt 1 is populated with the stiff 
	material and visa versa. Definition of variables follows.
		
		Input Variables:
			K1		=	Bulk modulus of first phase of the mixture		(GPa)
			Mu1		=	Shear modulus of first phase of the mixture		(GPa)
			f1		=	Volume fraction of first phase of the mixture	(fraction, V/V)
			K2		=	Bulk modulus of the 2nd phase of the mixture	(GPa)
			Mu2		=	Shear modulus of the 2nd phase of the mixture	(GPa)
			f1		=	Volume fraction of second phase of the mixture	(fraction, V/V)
		
		Output Variable:
			Muhs	=	Hashin Shtrikman bulk modulus					(GPa)
			
	Recall if (K1,Mu1,f1) corresponds to the stiffer material this will be an upper bound,
	otherwise, if (K1,Mu1,f1) corresponds to the softer material this will be the lower bound.
	
	Mavko-Stanford Rock Physics Lab
	"""

    if isinstance(K1, (int, long, float, complex)) and (isinstance(
            Mu1, (int, long, float, complex))) and (isinstance(
                f1, (int, long, float, complex))) and (isinstance(
                    K2, (int, long, float, complex))) and (isinstance(
                        Mu2, (int, long, float, complex))) and (isinstance(
                            f2, (int, long, float, complex))):

        A = 1 / (Mu2 - Mu1)
        B1 = 2 * f1 * (K1 + 2 * Mu1)
        B2 = 5 * Mu1 * (K1 + 4 * Mu1 / 3)
        B = B1 / B2
        C = f2 / (A + B)

        Muhs = Mu1 + C

    elif type(K1) == np.ndarray and (type(Mu1) == np.ndarray) and (
            type(f1) == np.ndarray) and (type(K2) == np.ndarray) and (
                type(Mu2) == np.ndarray) and (type(f2) == np.ndarray) and (
                    len(K1) == len(Mu1)) and (len(Mu1) == len(f1)) and (
                        len(f1) == len(K2)) and (len(K2)
                                                 == len(Mu2)) and (len(Mu2)
                                                                   == len(f2)):

        A = 1 / (Mu2 - Mu1)
        B1 = 2 * f1 * (K1 + 2 * Mu1)
        B2 = 5 * Mu1 * (K1 + 4 * Mu1 / 3)
        B = B1 / B2
        C = f2 / (A + B)

        Muhs = Mu1 + C

    elif type(K1) == list and (type(Mu1) == list) and (type(f1) == list) and (
            type(K2)
            == list) and (type(f2) == list) and (len(K1) == len(Mu1)) and (
                len(Mu1) == len(f1)) and (len(f1) == len(K2)) and (
                    len(K2) == len(Mu2)) and (len(Mu2) == len(f2)):

        numItems = len(K1)

        A = [1 / (Mu2[i] - Mu1[i]) for i in range(numItems)]
        B1 = [2 * f1[i] * (K1[i] + (2 * Mu1[i])) for i in range(numItems)]
        B2 = [5 * Mu1[i] * (K1[i] + (4 * Mu1[i] / 3)) for i in range(numItems)]
        B = [B1[i] / B2[i] for i in range(numItems)]
        C = [f2[i] / (A[i] + B[i]) for i in range(numItems)]

        Muhs = [Mu1[i] + C[i] for i in range(numItems)]

    else:

        mm.myStdErrorMessage(
            "Error: get_Vp_from_K_Mu_Rho",
            ("The input variables are not consistent for this function"))
        return

    return Muhs
示例#24
0
def get_K_from_Vp_Vs_Rho(Vp, Vs, Rho):
    """
	Computes bulk modulus from compressional velocity, shear velocity and density.
	The units must be as described below.
	
		Input Variables:
			Vp	= Compressional Velocity)		(m/s)
			Vs	= (Shear Velocity)				(m/s)
			Rho	= (Density)						(g/(cm^3))
			
		Output Variable:
			K	= Bulk Modulus					(Gpa)
	"""

    if isinstance(Vp, (int, long, float, complex)) and (isinstance(
            Vs, (int, long, float, complex))) and (isinstance(
                Rho, (int, long, float, complex))):

        # Conversion to (mks) system for computation
        Rho = 1E3 * Rho  # Conversion from g/(cm^3) to Kg/(m^3)

        A = 4 * Vs * Vs / 3
        B = Vp * Vp
        C = B - A
        K = Rho * C

        K = K / 1E9  # Conversion from Pa to Gpa

    elif type(Vp) == np.ndarray and (type(Vs) == np.ndarray) and (
            type(Rho)
            == np.ndarray) and (len(Vp) == len(Vs)) and (len(Vs) == len(Rho)):

        # Conversion to (mks) system for computation
        Rho = 1E3 * Rho  # Conversion from g/(cm^3) to Kg/(m^3)

        A = 4 * (Vs * Vs) / 3
        B = Vp * Vp
        C = B - A
        K = Rho * C

        K = K / 1E9  # Conversion from Pa to Gpa

    elif type(Vp) == list and (type(Vs) == list) and (type(Rho) == list) and (
            len(Vp) == len(Vs)) and (len(Vs) == len(Rho)):

        Rho = [Rho[i] * 1E3 for i in range(len(Rho))
               ]  # Conversion from g/(cm^3) to Kg/(m^3)

        A = [4 * Vs[i] * Vs[i] / 3 for i in range(len(Vs))]
        B = [Vp[i] * Vp[i] for i in range(len(Vp))]
        C = [B[i] - A[i] for i in range(len(B))]
        K = [Rho[i] * C[i] for i in range(len(C))]

        K = [K[i] / 1E9 for i in range(len(K))]  # Conversion from Pa to Gpa

    else:

        mm.myStdErrorMessage(
            "Error: get_Vp_from_K_Mu_Rho",
            ("The input variables are not consistent for this function"))
        return

    return K
    def __init__(self, ip_addr, config_file, server_mode, group_name, epics_prefix,\
        polling_en, comm_type, pcie_rssi_link, stream_pv_size, stream_pv_type,\
        pv_dump_file):

        try:
            pyrogue.Root.__init__(self, name='AMCc', description='AMC Carrier')

            # File writer for streaming interfaces
            # DDR interface (TDEST 0x80 - 0x87)
            stm_data_writer = pyrogue.utilities.fileio.StreamWriter(
                name='streamDataWriter')
            self.add(stm_data_writer)
            # Streaming interface (TDEST 0xC0 - 0xC7)
            stm_interface_writer = pyrogue.utilities.fileio.StreamWriter(
                name='streamingInterface')
            self.add(stm_interface_writer)

            # Workaround to FpgaTopLelevel not supporting rssi = None
            if pcie_rssi_link == None:
                pcie_rssi_link = 0

            # Instantiate Fpga top level
            fpga = FpgaTopLevel(ipAddr=ip_addr,
                                commType=comm_type,
                                pcieRssiLink=pcie_rssi_link)

            # Add devices
            self.add(fpga)

            # Add data streams (0-7) to file channels (0-7)
            for i in range(8):
                # DDR streams
                pyrogue.streamConnect(fpga.stream.application(0x80 + i),
                                      stm_data_writer.getChannel(i))
                # Streaming interface streams
                #pyrogue.streamConnect(fpga.stream.application(0xC0 + i),  # new commended out
                # stm_interface_writer.getChannel(i))

            # Our receiver
            data_fifo = rogue.interfaces.stream.Fifo(1000, 0, 1)  # new
            self.my_processor = MyModule.MyProcessor()
            self.my_processor.setDebug(False)
            #pyrogue.streamConnect(base.FpgaTopLevel.stream.application(0xC1), data_fifo) # new
            #pyrogue.streamConnect(base.FpgaTopLevel.stream.Application(0xC1), data_fifo) # new
            pyrogue.streamConnect(fpga.stream.application(0xC1), data_fifo)
            pyrogue.streamConnect(data_fifo, self.my_processor)
            #pyrogue.streamTap(fpga.stream.application(0xC1), rx)

            # Run control for streaming interfaces
            self.add(
                pyrogue.RunControl(name='streamRunControl',
                                   description='Run controller',
                                   cmd=fpga.SwDaqMuxTrig,
                                   rates={
                                       1: '1 Hz',
                                       10: '10 Hz',
                                       30: '30 Hz'
                                   }))

            # PVs for stream data, used on PCAS-based EPICS server
            if epics_prefix and stream_pv_size:
                if use_pcas:

                    print("Enabling stream data on PVs (buffer size = {} points, data type = {})"\
                        .format(stream_pv_size,stream_pv_type))

                    # Add data streams (0-7) to local variables so they are expose as PVs
                    # Also add PVs to select the data format
                    for i in range(8):

                        # Calculate number of bytes needed on the fifo
                        if '16' in stream_pv_type:
                            fifo_size = stream_pv_size * 2
                        else:
                            fifo_size = stream_pv_size * 4

                        # Setup a FIFO tapped to the steram data and a Slave data buffer
                        # Local variables will talk to the data buffer directly.
                        stream_fifo = rogue.interfaces.stream.Fifo(
                            0, fifo_size, 0)
                        data_buffer = DataBuffer(size=stream_pv_size,
                                                 data_type=stream_pv_type)
                        stream_fifo._setSlave(data_buffer)

                        #pyrogue.streamTap(fpga.stream.application(0x80 + i), stream_fifo)

                        # Variable to read the stream data
                        stream_var = pyrogue.LocalVariable(
                            name='Stream{}'.format(i),
                            description='Stream {}'.format(i),
                            mode='RO',
                            value=0,
                            localGet=data_buffer.read,
                            update=False,
                            hidden=True)

                        # Set the buffer callback to update the variable
                        data_buffer.set_callback(stream_var.updated)

                        # Variable to set the data format
                        data_format_var = pyrogue.LocalVariable(
                            name='StreamDataFormat{}'.format(i),
                            description='Type of data being unpacked',
                            mode='RW',
                            value=0,
                            enum={
                                i: j
                                for i, j in enumerate(
                                    data_buffer.get_data_format_list())
                            },
                            localSet=data_buffer.set_data_format,
                            localGet=data_buffer.get_data_format,
                            hidden=True)

                        # Variable to set the data byte order
                        byte_order_var = pyrogue.LocalVariable(
                            name='StreamDataByteOrder{}'.format(i),
                            description='Byte order of data being unpacked',
                            mode='RW',
                            value=0,
                            enum={
                                i: j
                                for i, j in enumerate(
                                    data_buffer.get_data_byte_order_list())
                            },
                            localSet=data_buffer.set_data_byte_order,
                            localGet=data_buffer.get_data_byte_order,
                            hidden=True)

                        # Variable to read the data format string
                        format_string_var = pyrogue.LocalVariable(
                            name='StreamDataFormatString{}'.format(i),
                            description='Format string used to unpack the data',
                            mode='RO',
                            value=0,
                            localGet=data_buffer.get_data_format_string,
                            hidden=True)

                        # Add listener to update the format string readback variable
                        # when the data format or data byte order is changed
                        data_format_var.addListener(format_string_var)
                        byte_order_var.addListener(format_string_var)

                        # Add the local variable to self
                        self.add(stream_var)
                        self.add(data_format_var)
                        self.add(byte_order_var)
                        self.add(format_string_var)

            # lcaPut limits the maximun lenght of a string to 40 chars, as defined
            # in the EPICS R3.14 CA reference manual. This won't allowed to use the
            # command 'ReadConfig' with a long file path, which is usually the case.
            # This function is a workaround to that problem. Fomr matlab one can
            # just call this function without arguments an the function ReadConfig
            # will be called with a predefined file passed during startup
            # However, it can be usefull also win the GUI, so it is always added.
            self.config_file = config_file
            self.add(
                pyrogue.LocalCommand(name='setDefaults',
                                     description='Set default configuration',
                                     function=self.set_defaults_cmd))

            self.add(
                pyrogue.LocalCommand(name='runGarbageCollection',
                                     description='runGarbageCollection',
                                     function=self.run_garbage_collection))

            self.add(
                pyrogue.LocalVariable(
                    name='smurfProcessorDebug',
                    description='Enable smurf processor transmit debug',
                    mode='RW',
                    value=False,
                    localSet=lambda value: self.my_processor.setDebug(value),
                    hidden=False))

            # Start the root
            if group_name:
                # Start with Pyro4 server
                host_name = get_host_name()
                print(
                    "Starting rogue server with Pyro using group name \"{}\"".
                    format(group_name))
                self.start(pollEn=polling_en,
                           pyroGroup=group_name,
                           pyroHost=host_name,
                           pyroNs=None)
            else:
                # Start without Pyro4 server
                print("Starting rogue server")
                self.start(pollEn=polling_en)

            self.ReadAll()

        except KeyboardInterrupt:
            print("Killing server creation...")
            super(LocalServer, self).stop()
            exit()

        # Show image build information
        try:
            print("")
            print("FPGA image build information:")
            print("===================================")
            print("BuildStamp              : {}"\
                .format(self.FpgaTopLevel.AmcCarrierCore.AxiVersion.BuildStamp.get()))
            print("FPGA Version            : 0x{:x}"\
                .format(self.FpgaTopLevel.AmcCarrierCore.AxiVersion.FpgaVersion.get()))
            print("Git hash                : 0x{:x}"\
                .format(self.FpgaTopLevel.AmcCarrierCore.AxiVersion.GitHash.get()))
        except AttributeError as attr_error:
            print("Attibute error: {}".format(attr_error))
        print("")

        # Start the EPICS server
        if epics_prefix:
            print("Starting EPICS server using prefix \"{}\"".format(
                epics_prefix))

            # Choose the appropiate epics module:
            if use_pcas:
                self.epics = pyrogue.epics.EpicsCaServer(base=epics_prefix,
                                                         root=self)
            else:
                self.epics = pyrogue.protocols.epics.EpicsCaServer(
                    base=epics_prefix, root=self)

                # PVs for stream data, used on GDD-based EPICS server
                if stream_pv_size:

                    print("Enabling stream data on PVs (buffer size = {} points, data type = {})"\
                        .format(stream_pv_size,stream_pv_type))

                    for i in range(8):
                        stream_slave = self.epics.createSlave(
                            name="AMCc:Stream{}".format(i),
                            maxSize=stream_pv_size,
                            type=stream_pv_type)

                        # Calculate number of bytes needed on the fifo
                        if '16' in stream_pv_type:
                            fifo_size = stream_pv_size * 2
                        else:
                            fifo_size = stream_pv_size * 4

                        stream_fifo = rogue.interfaces.stream.Fifo(
                            0, fifo_size, 0)  # chnages
                        stream_fifo._setSlave(stream_slave)
                        pyrogue.streamTap(fpga.stream.application(0x80 + i),
                                          stream_fifo)

            self.epics.start()

            # Dump the PV list to the especified file
            if pv_dump_file:
                try:
                    # Try to open the output file
                    f = open(pv_dump_file, "w")
                except IOError:
                    print("Could not open the PV dump file \"{}\"".format(
                        pv_dump_file))
                else:
                    with f:
                        print("Dumping PV list to \"{}\"...".format(
                            pv_dump_file))
                        try:
                            try:
                                # Redirect the stdout to the output file momentarily
                                original_stdout, sys.stdout = sys.stdout, f
                                self.epics.dump()
                            finally:
                                sys.stdout = original_stdout

                            print("Done!")
                        except:
                            # Capture error from epics.dump() if any
                            print("Errors were found during epics.dump()")

        # If no in server Mode, start the GUI
        if not server_mode:
            create_gui(self)
        else:
            # Stop the server when Crtl+C is pressed
            print("")
            print("Running in server mode now. Press Ctrl+C to stop...")
            try:
                # Wait for Ctrl+C
                while True:
                    time.sleep(1)
            except KeyboardInterrupt:
                pass
示例#26
0
#	It is better to use module's name with its objects
#	in order to avoid confusion with objects of other
#	modules having the same name.
print('Version of this program: {}'.format(__version__))
print('Version of MyModule: {}'.format(mm.__version__))
print('Version of sys module: {}'.format(sys.version))

#	We can get Program's name via sys module as we get
#	from CLI in C. But we cannot get argc.
print('Name of this program: {}'.format(sys.argv[0]))
print('No. of CLI arguments: {}'.format(len(sys.argv)))

#	Module 'os' has interesting usage specially when
#	we need to deal with multiple files with different
#	naming styles.
#	os.walk() returns dirPath, subdirs and filenames.
dirName = '/home/sangeeta/Programming/TensorFlow/ADCIS/exudates'
for dirPath, subDir, imgFileList in os.walk(dirName):
    print(dirPath)
    print(subDir)
    for imgFileName in imgFileList:
        print(imgFileName)

#	Usage of user-defined module
#	(i.e., my module named MyModule)
print('a + b: {}'.format(mm.add()))
print('a - b: {}'.format(mm.sub()))
print('a * b: {}'.format(mm.mul()))
print('a / b: {}'.format(mm.div()))
#from time import *   调用time里的所有功能
#form time import time,localtime  只调用time的time() localtime()函数

import time as t
print(t.time())
print(t.gmtime)

#导入自己的模块

#放在同一目录下或者是在C:\Users\75286\AppData\Local\Programs\Python\Python37\Lib\site-packages

import MyModule
MyModule.Print('world')
def crossplotLogs(aBunchOfLogs=mm.BunchOfLogs()):

    branch = tk.Tk()
    branch.wm_title("Cross plotting logs")
    branch.withdraw

    class simPlotXY:
        def __init__(self, X=[], Y=[]):
            self.Z = zip(self.X, self.Y)
            self.plt = SimPlot()
            plt.plotLine(self.Z)
            plt.mainloop()

    class set_X_VariablesIn:
        def __init__(self, aBunchOfLogs=mm.BunchOfLogs, logNum=-999):
            mainCrossplotFrame.xIdVariable.set(
                str(aBunchOfLogs.MyLogLabel[LogNum]))
            mainCrossplotFrame.xTypeVariable.set(
                str(aBunchOfLogs.LogType[LogNum]))
            mainCrossplotFrame.xLog = aBunchOfLogs.TheLog[LogNum].Value

    class set_Y_VariablesIn:
        def __init__(self, aBunchOfLogs=mm.BunchOfLogs, logNum=-999):
            mainCrossplotFrame.yIdVariable.set(
                str(aBunchOfLogs.MyLogLabel[LogNum]))
            mainCrossplotFrame.yTypeVariable.set(
                str(aBunchOfLogs.LogType[LogNum]))
            mainCrossplotFrame.yLog = aBunchOfLogs.TheLog[LogNum].Value

    class getXLog:
        def __init__(self, myParent, aBunchOfLogs=mm.BunchOfLogs()):

            self.getXLogFrame = tk.Frame(myParent)

            if aBunchOfLogs.NumLogs == 0:

                self.rowCounter = 0

                self.noLogsLabel = tk.Label(
                    self.getXLogFrame,
                    text=" There appears to be no logs for this session ",
                    font=("Comic Sans MS", 16),
                    fg="Blue")
                self.noLogsLabel.grid(row=self.rowCounter, column=0)

                self.rowCounter += 1

                self.exitButton = tk.Button(self.getXLogFrame,
                                            text="Exit",
                                            font=("Comic Sans MS", 14),
                                            fg="Red",
                                            command=myParent.destroy)
                self.exitButton.grid(row=self.rowCounter,
                                     columnspan=3,
                                     stick=E + W)

            else:

                self.rowCounter = 0

                self.pickLogLabel = tk.Label(
                    self.getXLogFrame,
                    text="Pick a log from the list below.",
                    font=("Comic Sans MS", 16),
                    fg="Blue")
                self.pickLogLabel.grid(row=self.rowCounter, columnspan=3)

                self.rowCounter += 1

                self.idLabel = tk.Label(self.getXLogFrame,
                                        text="Log ID",
                                        font=("Comic Sans MS", 14),
                                        fg="Green")
                self.idLabel.grid(row=self.rowCounter, column=0)
                self.typeLabel = tk.Label(self.getXLogFrame,
                                          text="Log Type",
                                          font=("Comic Sans MS", 14),
                                          fg="Green")
                self.typeLabel.grid(row=self.rowCounter, column=1)
                self.unitLabel = tk.Label(self.getXLogFrame,
                                          text="Log Unit",
                                          font=("Comic Sans MS", 14),
                                          fg="Green")
                self.unitLabel.grid(row=self.rowCounter, column=2)

                self.rowCounter += 1

                for self.i in range(aBunchOfLogs.NumLogs):

                    self.LogIdLabel = tk.Label(
                        self.getXLogFrame,
                        text=str(aBunchOfLogs.MyLogLabel[self.i]),
                        font=("Comic Sans MS", 14),
                        fg="Black")
                    self.LogTypeRadioButton = tk.Radiobutton(
                        self.getXLogFrame,
                        text=str(aBunchOfLogs.LogType[self.i]),
                        font=("Comic Sans MS", 14),
                        fg="Black",
                        command=lambda: set_X_VariablesIn(
                            aBunchOfLogs, self.i))
                    self.LogUnitLabel = tk.Label(
                        self.getXLogFrame,
                        text=str(aBunchOfLogs.TheLog[self.i].ValueUnit),
                        font=("Comic Sans MS", 14),
                        fg="Black")

                    self.rowCounter += 1

                self.exitButton = tk.Button(self.getXLogFrame,
                                            text="Exit",
                                            font=("Comic Sans MS", 14),
                                            fg="Red",
                                            command=myParent.destroy)
                self.exitButton.grid(row=self.rowCounter,
                                     columnspan=3,
                                     stick=E + W)

        class getYLog:
            def __init__(self, myParent, aBunchOfLogs=mm.BunchOfLogs()):

                self.getYLogFrame = tk.Frame(myParent)

                if aBunchOfLogs.NumLogs == 0:

                    self.rowCounter = 0

                    self.noLogsLabel = tk.Label(
                        self.getYLogFrame,
                        text=" There appears to be no logs for this session ",
                        font=("Comic Sans MS", 16),
                        fg="Blue")
                    self.noLogsLabel.grid(row=self.rowCounter, column=0)

                    self.rowCounter += 1

                    self.exitButton = tk.Button(self.getYLogFrame,
                                                text="Exit",
                                                font=("Comic Sans MS", 14),
                                                fg="Red",
                                                command=myParent.destroy)
                    self.exitButton.grid(row=self.rowCounter,
                                         columnspan=3,
                                         stick=E + W)

                else:

                    self.rowCounter = 0

                    self.pickLogLabel = tk.Label(
                        self.getYLogFrame,
                        text="Pick a log from the list below.",
                        font=("Comic Sans MS", 16),
                        fg="Blue")
                    self.pickLogLabel.grid(row=self.rowCounter, columnspan=3)

                    self.rowCounter += 1

                    self.idLabel = tk.Label(self.getYLogFrame,
                                            text="Log ID",
                                            font=("Comic Sans MS", 14),
                                            fg="Green")
                    self.idLabel.grid(row=self.rowCounter, column=0)
                    self.typeLabel = tk.Label(self.getYLogFrame,
                                              text="Log Type",
                                              font=("Comic Sans MS", 14),
                                              fg="Green")
                    self.typeLabel.grid(row=self.rowCounter, column=1)
                    self.unitLabel = tk.Label(self.getYLogFrame,
                                              text="Log Unit",
                                              font=("Comic Sans MS", 14),
                                              fg="Green")
                    self.unitLabel.grid(row=self.rowCounter, column=2)

                    self.rowCounter += 1

                    for self.i in range(aBunchOfLogs.NumLogs):

                        self.LogIdLabel = tk.Label(
                            self.getYLogFrame,
                            text=str(aBunchOfLogs.MyLogLabel[self.i]),
                            font=("Comic Sans MS", 14),
                            fg="Black")
                        self.LogTypeRadioButton = tk.Radiobutton(
                            self.getYLogFrame,
                            text=str(aBunchOfLogs.LogType[self.i]),
                            font=("Comic Sans MS", 14),
                            fg="Black",
                            command=lambda: set_Y_VariablesIn(
                                aBunchOfLogs, self.i))
                        self.LogUnitLabel = tk.Label(
                            self.getYLogFrame,
                            text=str(aBunchOfLogs.TheLog[self.i].ValueUnit),
                            font=("Comic Sans MS", 14),
                            fg="Black")

                        self.rowCounter += 1

                    self.exitButton = tk.Button(self.getYLogFrame,
                                                text="Exit",
                                                font=("Comic Sans MS", 14),
                                                fg="Red",
                                                command=myParent.destroy)
                    self.exitButton.grid(row=self.rowCounter,
                                         columnspan=3,
                                         stick=E + W)

    class mainCrossplotFrame:
        def __init__(self, myParent, aBunchOfLogs):
            """
			
			The main definitions of a cross-plotting object
			
			"""
            # setting up the main variables for this class of object
            mainCrossplotFrame.xIdVariable = tk.StrVar()
            mainCrossplotFrame.xIdVariable.set("None")
            mainCrossplotFrame.xTypeVariable = tk.StrVar()
            mainCrossplotFrame.xTypeVariable.set("None")
            mainCrossplotFrame.xLog = []

            mainCrossplotFrame.yIdVariable = tk.StrVar()
            mainCrossplotFrame.yIdVariable.set("None")
            mainCrossplotFrame.yTypeVariable = tk.StrVar()
            mainCrossplotFrame.yTypeVariable.set("None")
            mainCrossplotFrame.yLog = []

            self.xplotFrame = tk.Frame(myParent)
            self.xplotFrame.pack()

            self.rowCounter = 0

            self.mainXplotLabel = tk.Label(self.xplotFrame,
                                           text="Log (x,y) plotting function",
                                           font=("Comic Sans MS", 16),
                                           fg="Blue")
            self.mainXplotLabel.grid(row=self.rowCounter,
                                     columnspan=3,
                                     sticky=E + W)

            self.rowCounter += 1

            self.clickLable = tk.Label(self.xplotFrame,
                                       text="Click button below",
                                       font=("Comic Sans MS", 14),
                                       fg="Green")
            self.clickLable.grid(row=self.rowCounter, column=0)
            self.idLable = tk.Label(row=self.rowCounter,
                                    text="Log ID",
                                    font=("Comic Sans MS", 14),
                                    fg="Green")
            self.idLable.grid(row=self.rowCounter, column=1)
            self.typeLable = tk.Label(row=self.rowCounter,
                                      text="Log ID",
                                      font=("Comic Sans MS", 14),
                                      fg="Green")
            self.typeLable.grid(row=self.rowCounter, column=2)

            self.rowCounter += 1

            self.xLogChooseButton = tk.Button(
                self.xplotFrame,
                text="Choose X Log",
                font=("Comic Sans MS", 14),
                fg="Black",
                command=lambda: getXLog(myParent, aBunchOfLogs))
            self.xLogChooseButton.grid(row=self.rowCounter, column=0)
            self.xLogIdLable = tk.Label(self.xplotFrame,
                                        textvariable=self.xIdVariable,
                                        font=("Comic Sans MS", 14),
                                        fg="Black")
            self.xLogIdLable.grid(row=self.rowCounter, column=1)
            self.xLogTypeLable = tk.Label(self.xplotFrame,
                                          textvariable=self.xIdVariable,
                                          font=("Comic Sans MS", 14),
                                          fg="Black")
            self.xLogTypeLable.grid(row=self.rowCounter, column=2)

            self.rowCounter += 1

            self.yLogChooseButton = tk.Button(
                self.xplotFrame,
                text="Choose Y Log",
                font=("Comic Sans MS", 14),
                fg="Black",
                command=lambda: getYLog(myParent, aBunchOfLogs))
            self.yLogChooseButton.grid(row=self.rowCounter, column=0)
            self.yLogIdLable = tk.Label(self.xplotFrame,
                                        textvariable=self.yIdVariable,
                                        font=("Comic Sans MS", 14),
                                        fg="Black")
            self.yLogIdLable.grid(row=self.rowCounter, column=1)
            self.yLogTypeLable = tk.Label(self.xplotFrame,
                                          textvariable=self.yIdVariable,
                                          font=("Comic Sans MS", 14),
                                          fg="Black")
            self.yLogTypeLable.grid(row=self.rowCounter, column=2)

            self.rowCounter += 1

            self.submitPlotButton = tk.Button(
                self.xplotFrame,
                text="Submit",
                font=("Comic Sans MS", 14),
                fg="Black",
                command=lambda: simPlotXY(self.xLog, self.yLog))
            self.submitPlotButton.grid(row=self.rowCounter,
                                       columnspan=3,
                                       sticky=E + W)

            self.rowCounter += 1

            self.exitButton = tk.Button(self.xplotFrame,
                                        text="Exit",
                                        font=("Comic Sans MS", 14),
                                        fg="Red",
                                        command=myParent.destroy)
            self.exitButton.grid(row=self.rowCounter,
                                 columnspan=3,
                                 stick=E + W)

            self.rowCounter += 1
示例#29
0
# h[4]=0.1
# 
# plt.plot(h)
# plt.plot(np.abs(mm.fft(h)))


'''lp filter'''
LP=np.zeros((N),dtype=complex)
fc=0.08
Nc=int(fc*N)
for n in range(Nc):
    LP[n]=1.0
    LP[(N-n+N) % N]=1.0
    
plt.plot(np.abs(LP))
lp=mm.ifft(LP)
lpr=np.zeros((N),dtype=complex)
lpr[:N//2],lpr[N//2:]=lp[N//2:],lp[:N//2]
plt.plot(lpr.real)
#plt.plot(lp.real)

lp_trimed = np.zeros((N),dtype=complex)          
lp_trimed[N//2-M//2:N//2+M//2]=lpr[N//2-M//2:N//2+M//2]
LP_trimed=mm.fft(lp_trimed)

plt.plot(np.abs(LP_trimed))
plt.plot(lp_trimed.real)

'''lp-windowed  0.54-0.46cos(2pi*n/M)'''
window=np.zeros((N),dtype=complex)
for n in range(M):
#program.py
# Author: Yuichiro SUGA
# Created: 2018-04-17
# Email: [email protected]
# This program is a demonstration of calling module from other code file in the same file.
import MyModule

MyModule.hello()
print('fib(10)=', MyModule.fib(10))
示例#31
0
# mm.dftplot(x,x)
'''h=1.0 at 0, 0.2 at 25000, 0.02 at 50000'''
'''y[n]=1x[n]+0.2x[n-25000]+0.02x[n-50000]'''
echolen=25000
numofecho=3
Nfft=2**18
Nfilter=2**17
'''hlen=echolen*numofecho+1'''

hecho=np.zeros((Nfilter),dtype=float)
hecho[0]=1.0
hecho[1*echolen]=0.2
hecho[2*echolen]=0.04
hecho[3*echolen]=0.008

yiffted=mm.convlong(x,hecho,Nfft)
sw.write('Libaiecho.wav',fs,yiffted)

#h=np.array([1.0]+[0.0]*(25000-1)+[0.2]+[0.0]*(25000-1)+[0.02]+[0]*(len(x)-50000-1))
#y=mm.ifft(mm.fft(x)*mm.fft(h))
#y=mm.convlong(x,h,)



# x=np.array([1,2,3,0,1,-1,0,0])
# h=np.array([3,1,4,2,0,0,0,0])
# y=mm.conv(x,h)
# X=mm.fft(x)
# H=mm.fft(h)
# y1=mm.ifft(X*H)
# 
示例#32
0
def get_Ksat_FromGassmannEquation(Kdry, Kfluid, Kmin, Phi):
    """
	Computes the saturated bulk modulus of a rock usin Gassmann's equation.
	
		Input Variables:
			Kdry	= The dry frame bulk modulus			(Gpa)
			Kfluid	= The fluid bulk modulus				(Gpa)
			Kmin	= The mineral/matrix bulk modulus		(Gpa)
			Phi		= The porosity 							(Fraction, V/V)
			
		Output Variable:
			Ksat	= The saturated bulk modulus			(Gpa)
			
	"""

    if isinstance(Kdry, (int, long, float, complex)) and (isinstance(
            Kfluid, (int, long, float, complex))) and (isinstance(
                Kmin, (int, long, float, complex))) and (isinstance(
                    Phi, (int, long, float, complex))):

        A1 = 1 - (Kdry / Kmin)
        A = A1 * A1
        B1 = Phi / Kfluid
        B2 = (1 - Phi) / Kmin
        B3 = Kdry / (Kmin * Kmin)
        B = B1 + B2 - B3
        C = A / B

        Ksat = Kfluid + C

    elif type(Kdry) == np.ndarray and (type(Kfluid) == np.ndarray) and (
            type(Kmin) == np.ndarray) and (type(Phi) == np.ndarray) and (
                len(Kdry) == len(Kfluid)) and (len(Kfluid)
                                               == len(Kmin)) and (len(Kmin)
                                                                  == len(Phi)):

        A1 = 1 - (Kdry / Kmin)
        A = A1 * A1
        B1 = Phi / Kfluid
        B2 = (1 - Phi) / Kmin
        B3 = Kdry / (Kmin * Kmin)
        B = B1 + B2 - B3
        C = A / B

        Ksat = Kfluid + C

    elif type(Vp) == list and (type(Vs) == list) and (type(Rho) == list) and (
            len(Vp) == len(Vs)) and (len(Vs) == len(Rho)):

        numItems = len(Vp)

        A1 = [1 - (Kdry[i] / Kmin[i]) for i in range(numItems)]
        A = [A1[i] * A1[i] for i in range(numItems)]
        B1 = [Phi[i] / Kfluid[i] for i in range(numItems)]
        B2 = [(1 - Phi[i]) / Kmin[i] for i in range(numItems)]
        B3 = [Kdry[i] / (Kmin[i] * Kmin[i]) for i in range(numItems)]
        B = [B1[i] + B[i] - B3[i] for i in range(numItems)]
        C = [A[i] / B[i] for i in range(numItems)]

        Ksat = [Kfluid[i] + C[i] for i in range(numItems)]

    else:

        mm.myStdErrorMessage(
            "Error: get_Vp_from_K_Mu_Rho",
            ("The input variables are not consistent for this function"))
        return

    return Ksat
示例#33
0
# title : python <-> c test
# author : ysoftman
import MyModule

MyModule.syscmd("ls -ahl")
示例#34
0
#-*- coding: utf-8 -*-

# Step13_main.py

import MyModule, YourModule
print "----"

#print "MyModule.nick : ", MyModule.nick
#MyModule.printNick()

print "Step13_main.py __name__:", __name__

# 만일 main 으로 시작 되었을 때 실행할 코드가 있다면
# 아래와 같이 작성한다.

# java에서 main메소드 느낌
if __name__=="__main__":
    # main 으로 시작 되었을때만 실행순서가 들어온다.
    MyModule.printNick()
    YourModule.printNick()
        def __init__(self, myParent, aBunchOfLogs=mm.BunchOfLogs()):

            self.getXLogFrame = tk.Frame(myParent)

            if aBunchOfLogs.NumLogs == 0:

                self.rowCounter = 0

                self.noLogsLabel = tk.Label(
                    self.getXLogFrame,
                    text=" There appears to be no logs for this session ",
                    font=("Comic Sans MS", 16),
                    fg="Blue")
                self.noLogsLabel.grid(row=self.rowCounter, column=0)

                self.rowCounter += 1

                self.exitButton = tk.Button(self.getXLogFrame,
                                            text="Exit",
                                            font=("Comic Sans MS", 14),
                                            fg="Red",
                                            command=myParent.destroy)
                self.exitButton.grid(row=self.rowCounter,
                                     columnspan=3,
                                     stick=E + W)

            else:

                self.rowCounter = 0

                self.pickLogLabel = tk.Label(
                    self.getXLogFrame,
                    text="Pick a log from the list below.",
                    font=("Comic Sans MS", 16),
                    fg="Blue")
                self.pickLogLabel.grid(row=self.rowCounter, columnspan=3)

                self.rowCounter += 1

                self.idLabel = tk.Label(self.getXLogFrame,
                                        text="Log ID",
                                        font=("Comic Sans MS", 14),
                                        fg="Green")
                self.idLabel.grid(row=self.rowCounter, column=0)
                self.typeLabel = tk.Label(self.getXLogFrame,
                                          text="Log Type",
                                          font=("Comic Sans MS", 14),
                                          fg="Green")
                self.typeLabel.grid(row=self.rowCounter, column=1)
                self.unitLabel = tk.Label(self.getXLogFrame,
                                          text="Log Unit",
                                          font=("Comic Sans MS", 14),
                                          fg="Green")
                self.unitLabel.grid(row=self.rowCounter, column=2)

                self.rowCounter += 1

                for self.i in range(aBunchOfLogs.NumLogs):

                    self.LogIdLabel = tk.Label(
                        self.getXLogFrame,
                        text=str(aBunchOfLogs.MyLogLabel[self.i]),
                        font=("Comic Sans MS", 14),
                        fg="Black")
                    self.LogTypeRadioButton = tk.Radiobutton(
                        self.getXLogFrame,
                        text=str(aBunchOfLogs.LogType[self.i]),
                        font=("Comic Sans MS", 14),
                        fg="Black",
                        command=lambda: set_X_VariablesIn(
                            aBunchOfLogs, self.i))
                    self.LogUnitLabel = tk.Label(
                        self.getXLogFrame,
                        text=str(aBunchOfLogs.TheLog[self.i].ValueUnit),
                        font=("Comic Sans MS", 14),
                        fg="Black")

                    self.rowCounter += 1

                self.exitButton = tk.Button(self.getXLogFrame,
                                            text="Exit",
                                            font=("Comic Sans MS", 14),
                                            fg="Red",
                                            command=myParent.destroy)
                self.exitButton.grid(row=self.rowCounter,
                                     columnspan=3,
                                     stick=E + W)
示例#36
0
from sys import exit
import MyModule

a_map = MyModule.Map('phone_call')
a_game = MyModule.Engine(a_map)
a_game.play()


MyModule.Engine()
import MyModule

MyModule.PrintDetails("Ajeya Nayak", "DS235062", "6363520361")

import datetime
x = datetime.datetime.now()
print(x)
print(x.year)
print(x.strftime("%A"))
示例#38
0
import MyModule

# simple functions
print MyModule.getNumber()
print MyModule.setGetNumber(4)
print MyModule.getString()

# struct
point = MyModule.getPoint()
print point.x

# class
classA = MyModule.ClassA( 55 )
print classA.a
print classA.getA();

# struct in class
vector = classA.getVector();
print vector.x

# enum in class
print classA.setGetColor(MyModule.ClassA_COLOR.RED);