RFmx and FetchSpectrum using Python
Hello
I'm trying to use RFmx through Python.NET. The code works until I have try to catch the spectrum using FetchSpectrum():
# create the name of the variable before you pass it to the method .NET
spectrum = RFmxSpecAnMXSpectrum
# This does not work!
specAn.Spectrum.Results.FetchSpectrum (", timeout, spectrum)
Here's the complete code:
import clr
import sys
# location of the assemblies
assy_path = r'C:\Program files (x 86) \National Instruments\MeasurementStudioVS2010\DotNET\Assemblies\Current'
sys. Path.Append (assy_path)CLR. AddReference ("NationalInstruments.RFmx.SpecAnMX.Fx40")
CLR. AddReference ("NationalInstruments.RFmx.InstrMX.Fx40")from NationalInstruments import *.
from NationalInstruments.RFmx.InstrMX import *.
from NationalInstruments.RFmx.SpecAnMX import *.# The VSA settings
resourceName = "5606_slave."
centerFrequency = 10.0e9 # Hz
referenceLevel = - 10 # dBm
externalAttenuation = 0.00 # dB
Timeout = 10 seconds #.
span = 1.0e + 6 # Hz
RBW = 100e3
averagingCount = 10instrSession = RFmxInstrMX(resourceName, '')
# configuration VSA
rbwAuto = RFmxSpecAnMXSpectrumRbwAutoBandwidth.True
rbwFilterType = RFmxSpecAnMXSpectrumRbwFilterType.Gaussian
averagingEnabled = RFmxSpecAnMXSpectrumAveragingEnabled.False
averagingType = RFmxSpecAnMXSpectrumAveragingType.Rms
#specAn = instrSession.GetSpecAnSignalConfiguration ();
specAn = RFmxSpecAnMXExtension.GetSpecAnSignalConfiguration (instrSession)
specAn.ConfigureRF('',centerFrequency,referenceLevel,externalAttenuation)
specAn.Spectrum.Configuration.ConfigureSpan('', span)
specAn.Spectrum.Configuration.ConfigureRbwFilter (", rbwAuto, rbw, rbwFilterType)
specAn.Spectrum.Configuration.ConfigureAveraging (", averagingEnabled, averagingCount, averagingType)
specAn.SelectMeasurements (", RFmxSpecAnMXMeasurementTypes.Spectrum, bool ())
specAn.Commit ("")# run acquisition
specAn.Initiate('','')# find the peak power in the spectrum
_, pkAmp, pkFreq, freqRes = specAn.Spectrum.Results.FetchMeasurement (", timeout, float (), float (), float ())
Print "peak power: dBm {:0.2f} to {:0.6f} GHz'.format(pkAmp,pkFreq*1e-9)}}""""
A .NET method may require user pass the variable name that it wishes to
change as an argument. Python is not compatible "pass by reference", but the
the variable name must exist in python, before he can be handed over to the .NET method.
The .NET method will simply point to the new instance.http://nbviewer.IPython.org/GitHub/jonnojohnson/Agilent/BLOB/master/Python_Automation/Python_Automation.ipynb
"""# create the name of the variable before you pass it to the method .NET
spectrum = RFmxSpecAnMXSpectrum# This does not work!
specAn.Spectrum.Results.FetchSpectrum (", timeout, spectrum)instrSession.Close)
Here is the error:
Traceback (most recent call changed):
File "
ArgumentException: Object of type 'System.RuntimeType' cannot be converted to type ' NationalInstruments.Spectrum'1 [System.Single] & ". Any ideas? Ah! That's about all. Here's what worked: Here is the result and the final code for future reference:
# To Program Files Windows environment variable Program_Files = os.environ ['ProgramFiles (x 86) ""]
sys. Path.Append (assy_path) CLR. AddReference ("NationalInstruments.Common") from NationalInstruments.RFmx.InstrMX import *. # The VSA settings instrSession = RFmxInstrMX(resourceName, '') # Get the model number # configuration VSA # run acquisition # get x data # get data close a session #. # calculate the frequency and power results of tracking #. Tags: NI Software My older ipad bouchoirs activation requires Apple ID and password used to configure icloud. I think I know the ID because she tips ***@outlook.com, but not the old password. Help? or Contact Apple for the Apple ID account security support Inject an apple ID and PW using the Configurator 2? Hi all Wondering if a id apple & PW can be added to a profile and deployment using the Configurator 2. Sorry if this has been covered, am new to this and learning and discovery I. see you soon, Kristian. Hello, Kristian,. AC2 negates the need to have a configuration of account iTunes\AppleID on each device, can I ask why you wanted to do this, there may be a better way? ipads how are you trying to install? ipad users can add their own iTunes account to download other additional applications then deployed via the configurator. Kind regards Rick Got a 27 "monitor from Apple, with thunderbolt (error). My MacPro can't love at first sight. Apple won't bring back the monitor. Will using a USB 3 map and then using a hard drive with USB 3 and Thunderbolt works? N ° you need a computer logic board which has built in Thunderbolt. I can record is more than all of the new bookmarks after update to Firefox 40.0.2. Thank you for your help. I tried the maintenance of places without success. I have disabled xMarks, but it made no difference, I couldn't save all new bookmarks. I went on the site help above and deleted the "places.sqlite" file and recreates a new file, but it didn't work. I uninstalled Firefox full using IOBit Uninstaller and reinstalled, but I found this program does not delete the profile folder (used to have a checked during uninstall of Firefox, but it seems to have disappeared in the latest versions). The problem persisted. Finally, I took a screenshot of all my addons. Then, I uninstalled Firefox again, then delete the entire folder profiles (located very usefully described in the second link above https://support.mozilla.org/kb/Bookmarks+not+saved#w_fix-the-bookmarks-file ) Thank you for your help This should be an easy solution, because all the other browsers and Firefox used to do this. Firefox is restarted the pages do not charge they just historical display. I have to hit the button reload current page to get new data. This has been driving me crazy for a few weeks. I thought I had fixed a couple of times but only a few pages loaded and now it's the whole story again. Joe Oh, you use the Session Manager. What happens if you check the box in the Session Manager options, to the title of the backup & restore, "Reload All restored Windows"? Hi team, support I intend to create an Add on Firefox using python. Please let me know how this can be achieved. Kind regards Sandeep Hi Sandeep, support.mozilla.org is for user only support, so we cannot give you advice for the development of extensions in this place. Please see resources at https://developer.mozilla.org/en-US/Add-ons or check out the mozilla forum dedicated to the development of addon at https://forums.mozilla.org/viewforum.php?f=7. Thank you Cannot use the mouse to copy and paste using firefox21 Hello I tried to reset firefox is default - and still have the problem I also did a clean reinstall of firefox and still have the issue of copy and paste I tried another browser chrome and has not had the problem with the mouse Is this a problem with the browser firefox 21 Thanks - Steve This happens on all sites, or only on certain sites? Some sites may have "copy" scripts that change what happens when you right-click. To prevent sites from pre-empting the normal context menu of Firefox, try the third "Advanced JavaScript" setting described in this article: JavaScript and their preferences for interactive web pages settings (uncheck the third). Does make a difference? (Incidentally, I noticed on the threads in Google groups if you select widely, the selection is cleared when you do a right click, but if you select a little less, it is not clear.) I have not studied the model in detail). Why my computer loses its cursor and/or loses its and must use the mouse to go back? I will be typing along and all of a sudden, nothing shows up on the screen and must use the mouse to get back. Also will be done solitare or another game and lose her and the mouse to move the things. Is this a virus? I updated my windows and nothing showed as a problem here. Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes). I a s 6 more and when using the phone, if my face touches the screen it clicks on the logout button and the phone hangs up the call. Is it possible to prevent this without holding the phone away from my face when calling? iPhones have a proximity sensor which is supposed to automatically turn off the screen when you hold it in your face. If this is not the case you can take the phone and have it checked. Can I upgrade OS 10.8.5 and always use Adobe Creative Suite 5? Can I upgrade OS 10.8.5 and always use Adobe Creative Suite 5? Also many design fonts Adobe I used for years. Abobe CS5 works very well for me in El Capitan. All fonts work ok it stable and fast. I hope this helps. See you soon Pete My space Icloud is used because of the backup of the Ipad and I use three devices under ID so my iphone always gives the warning of small footprint. How can I save the back upward on my PC so that I can delete of I have cloud and free space Hello You want to know is explained here: https://www.apple.com/support/iphone/backup/ If you want to delete the backups that are currently clogging up your iCloud-storage space, use this: iCloud: delete a backup device iOS to iCloud Re: Satellite L735 PSK0CE: WLan and BT use the same frequency Hello world I reinstalled my Toshiba Satellite L735 - PSK0CE with Windows 7, until the one and download all the drivers for it, I did not too Wirelles conection, Lan and the wirelless use the same channell radiofrecuency than Bluetooth Can you help me with this problem? Thanks in advance Post edited by: aku - aku Hello WiFi and BT use the same frequency. For the most part this isn't a big problem but in case you notice a few connection problems with WLan or BT, you must disable WLan using BT or must turn off BT if you want to use the WLan. ITunes is downloading all items purchased from my iPhone, including tv shows and movies, using all the memory and batteries, does anyone know how to stop this? Hi anthony248, If you don't want the automatic downloads enabled on your iPhone, follow the steps outlined in the article below, except that you will turn off the switch rather than turn them on. I'll also include a link about the storage capacity of your iPhone and how to delete items that you don't want. Check your storage space on your iPhone, iPad and iPod touch Take care If anyone can help, I just bought a 2011 mac book pro and I use it for school and I work in education and currently I have lightroom, photoshop and adobe DC, are all the other apps I put on it? Chaka - welcome! What you want to do on your "new" MBP? I added an external keyboard and an external monitor to my HP Envy laptop m7-n011dx. Both are recognized by the laptop, if I leave the lid open. When I close the lid, the computer goes into mode 'sleep', and I can't use the laptop with the keyboard How to change Local policy setting programmatically I need to change the local policy setting [user rights assignment and security policy] & Service settings programmatically for Windows XP I need to customize the settings for our client workstations. I was watching in Secedit.exe but looking for ot origin of the error 0xC000021A reboot loop on envy 17 I try to start my pc, but the error 0xc000021a code, then it restarts and says prepare auto repair, then the same BSOD error appears and the cycle continues. I tried just about every "fix" I could find on the internet. I bought this computer with win Startup very slow and usually frozen or crashes yet and have to shut down and restart I have a Toshiba Portege T210 with windows 7 64-bit x. It takes about 15-20 minutes so that it starts properly and often still hangs or the screen is frozen. I have it turn off and restart (considering the time it takes to perform the boot). It s slo OK, I spent some time watching some tutorials on the main Board and how to find my pictures on the left panel. Having in mind that I have about 10 years worth of photos on my hard drive and readers. I use Win 7 and drop my picture by year, month and
specAn.Spectrum.Results.FetchSpectrum ("", timeout, spectrum)
at System.RuntimeType.TryChangeType (Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.Reflection.MethodBase.CheckArguments (Object [] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, sig Signature)
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck (Object obj, BindingFlags invokeAttr, Binder binder, Object [] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke (Object obj, BindingFlags invokeAttr, Binder binder, Object [] parameters, CultureInfo culture)
to Python.Runtime.MethodBinder.Invoke (inst IntPtr, IntPtr args, kw, MethodBase info, methodinfo MethodInfo [] IntPtr)spectrum = NationalInstruments.Spectrum [System.Single] (0)
_, spectrum is specAn.Spectrum.Results.FetchSpectrum('',timeout,spectrum)import clr
import sys
Import os
import matplotlib.pyplot as plt
Import numpy as np
assy_path = os.path.join (program_files,
"National Instruments",.
"MeasurementStudioVS2010,"
"DotNET"
"Assemblies."
'Current')
CLR. AddReference ("NationalInstruments.RFmx.SpecAnMX.Fx40")
CLR. AddReference ("NationalInstruments.RFmx.InstrMX.Fx40")
from NationalInstruments.RFmx.SpecAnMX import *.
import NationalInstruments
Import System
resourceName = "5606_slave."
centerFrequency = 25.0e9 # Hz
referenceLevel = #-10 dBm
externalAttenuation = # 0.00 dB
Timeout = 10 # seconds
span = 1.0e + 6 # Hz
RBW = 100e3 # Hz
averagingCount = 10
_, Model = instrSession.GetInstrumentModel (", Str())
rbwAuto = RFmxSpecAnMXSpectrumRbwAutoBandwidth.True
rbwFilterType = RFmxSpecAnMXSpectrumRbwFilterType.Gaussian
averagingEnabled = RFmxSpecAnMXSpectrumAveragingEnabled.False
averagingType = RFmxSpecAnMXSpectrumAveragingType.Rms
specAn = RFmxSpecAnMXExtension.GetSpecAnSignalConfiguration (instrSession)
specAn.ConfigureRF('',centerFrequency,referenceLevel,externalAttenuation)
specAn.Spectrum.Configuration.ConfigureSpan('', span)
specAn.Spectrum.Configuration.ConfigureRbwFilter (", rbwAuto, rbw, rbwFilterType)
specAn.Spectrum.Configuration.ConfigureAveraging (", averagingEnabled, averagingCount, averagingType)
specAn.SelectMeasurements (", RFmxSpecAnMXMeasurementTypes.Spectrum, bool ())
specAn.Commit ("")
specAn.Initiate('','')
spectrum = NationalInstruments.Spectrum [System.Single] (0)
_, spectrum is specAn.Spectrum.Results.FetchSpectrum('',timeout,spectrum)
analogwaveform = NationalInstruments.AnalogWaveform [System.Single] (0)
_, analogwaveform is specAn.Spectrum.Results.FetchPowerTrace('',timeout,analogwaveform)
instrSession.Close)
startFrequency = spectrum. StartFrequency
frequencyIncrement = spectrum. FrequencyIncrement
sampleCount = spectrum. SampleCount
stopFrequency = startFrequency + frequencyIncrement *(sampleCount+1)
freqArray = np.linspace (startFrequency, stopFrequency, sampleCount)
current = list (analogwaveform. GetRawData())
XScale = 1e-3
PLT. Plot ((freqArray-centerFrequency) * XScale, Power, LineWidth = 2.0)
#plt.ylim(referenceLevel-100.,referenceLevel)
PLT.yticks (NP.linspace(referenceLevel-100.,referenceLevel,11))
PLT.xticks(NP.linspace(-span,span,11)/2*XScale)
PLT. XLIM(-span/2*XScale,span/2*XScale)
PLT. Grid (true)
PLT.xlabel (' from center frequency (kHz) ")
PLT.ylabel ('Power (dBm) ")
PLT.title ("{} {:0.6f} GHz spectrum".format(model,centerFrequency*1e-9), fontsize = 'medium')
PLT. Show()Similar Questions
I have over 1000 bookmarks and also use xMarks.
I tried to remove 5 bookmarks and save a new bookmark, but it does not work.
When I click on the bookmark star, stars in the bookmarks folder jumps, but does not record, it does not offer the possibility of filing in the subfolder right it me and the star is not awarded (there should be one filled with stars when the Web site is updated bookmark)
I reinstalled Firefox, reinstalled xMarks and connected and transferred all my favorites, I reinstalled all my previous addons and ALTO - it now everything works perfectly!
When I use my browser firefox21 and use the mouse to select text
I would like to copy then right click on the mouse and select copy
Then, the highlight on the text disappears and won't let me copy and paste using the mouse
I don't have any addons installed - I did a scan for malware using malwarebytes and erase all the showsMaybe you are looking for