Exemple #1
0
from colorama import init, Fore, Back
init(autoreset=True) #to convert termcolor to wins color

from os.path import basename as bs
mdlname = bs(__file__).split('.')[0] #py filename

import visa
from statistics import median
from numpy import arange, sqrt, arctan2, frombuffer, array, linspace, pi, log10, reshape
import matplotlib.pyplot as plt
from time import sleep, time, ctime
from pyqum.instrument.logger import get_data, set_data

# pna
rm = visa.ResourceManager()
pna = rm.open_resource("TCPIP0::192.168.0.6::hpib7,16::INSTR") #PNA

pna.read_termination = '\n' #omit termination tag from output 
pna.timeout = 80000000 #set timeout (ms)

#Checking Connections & Identities

# print('All connected GPIB Instruments:', rm.list_resources())
print(pna.query('*IDN?'))  #inquiring machine identity: "who r u?"

#Clear ALL
pna.write('*RST;*CLS;SYST:FPReset') # SYST:FPReset
pna.write("CALCulate:PARameter:DELete:ALL")

# 'setrace' in PNA [done]
Mname = []
Exemple #2
0
# communicating with modulars via dll
from colorama import init, Fore, Back
init(autoreset=True)  #to convert termcolor to wins color

from os.path import basename as bs
mdlname = bs(__file__).split('.')[0]  # modular's name e.g. AWG, VSA, ADC
debugger = 'debug' + mdlname

from inspect import stack  #extract method's name
from functools import wraps  #facilitate wrapper's comments
from ctypes import c_int, c_bool, c_char_p, byref, cdll, c_char, c_long, c_double, c_float
from ctypes.util import find_library
from pyqum.instrument.logger import address, get_status, set_status, status_code

# dloc = "C:\\Program Files\\IVI Foundation\\IVI\Bin\\AgM933x_64.dll" #64-bit
try:
    lib_name = find_library('AgM933x_64.dll')
    print(Fore.YELLOW + "%s's driver located: %s" % (mdlname, lib_name))
    dll = cdll.LoadLibrary(lib_name)  #Python is 64-bit
except:
    print(Fore.RED + "%s's driver not found in this server" % mdlname)


def debug(state=False):
    exec('%s %s; %s = %s' % ('global', debugger, debugger, 'state'), globals(),
         locals())  # open global and local both-ways channels!
    if state:
        print(Back.RED + '%s: Debugging Mode' % debugger.replace('debug', ''))
    return

Exemple #3
0
# Communicating with Benchtop YOKOGAWA dc-power supply
# Communicating with Benchtop PSG
from colorama import init, Fore, Back
init(autoreset=True) #to convert termcolor to wins color

from os.path import basename as bs
mdlname = bs(__file__).split('.')[0] # model's name e.g. ESG, PSG, AWG, VSA, ADC
debugger = 'debug' + mdlname

import visa
from functools import wraps
from time import sleep, time
from contextlib import suppress
from numpy import linspace
from pyqum.instrument.logger import address, set_status, status_code

def debug(state=False):
    exec('%s %s; %s = %s' %('global', debugger, debugger, 'state'), globals(), locals()) # open global and local both-ways channels!
    if state:
        print(Back.RED + '%s: Debugging Mode' %debugger.replace('debug', ''))
    return

debug() # declare the debugger mode here

# INITIALIZATION
def Initiate():
    ad = address()
    rs = ad.lookup(mdlname) # Instrument's Address
    rm = visa.ResourceManager()
    try:
        bench = rm.open_resource(rs) #establishing connection using GPIB# with the machine
Exemple #4
0
# Loading Basics
from colorama import init, Back, Fore
init(autoreset=True)  #to convert termcolor to wins color
from os.path import basename as bs
myname = bs(__file__).split('.')[0]  # This py-script's name

import requests
from flask import Flask, request, render_template, Response, redirect, Blueprint, jsonify
from pyqum.instrument.logger import address, get_status, set_status, status_code, output_code
from pyqum.directive.characterize import TESTC

# Scientific Constants
from scipy import constants as cnst

encryp = 'ghhgjad'
bp = Blueprint(myname, __name__, url_prefix='/mssn')


# Main
@bp.route('/')
def show():
    return render_template("blog/msson/mission.html", encryp=encryp)


# ALL
@bp.route('/all', methods=['GET'])
def all():
    # Test Bed # All Task # Great Work
    return render_template("blog/msson/all.html")

Exemple #5
0
'''Communicating with Benchtop E-series Vector Network Analyzer'''

from colorama import init, Fore, Back
init(autoreset=True) #to convert termcolor to wins color

from os.path import basename as bs
mdlname = bs(__file__).split('.')[0] # instrument-module's name e.g. ENA, PSG, YOKO

import matplotlib.pyplot as plt
from numpy import arange, floor, ceil, linspace

import visa
from pyqum.instrument.logger import address, set_status, status_code, debug
from pyqum.instrument.logger import translate_scpi as Attribute

debugger = debug(mdlname)

# INITIALIZATION
def Initiate():
    rs = address(mdlname, reset=debugger) # Instrument's Address
    rm = visa.ResourceManager()
    try:
        bench = rm.open_resource(rs) #establishing connection using GPIB# with the machine
        stat = bench.write('*RST;*CLS') #Clear buffer memory;
        bench.write("SENS:CORR:EXT:AUTO:RESet") #clear port-extension auto-correction
        bench.read_termination = '\n' #omit termination tag from output 
        bench.timeout = 80000000 #set timeout in ms
        set_status(mdlname, dict(state='connected'))
        print(Fore.GREEN + "%s's connection Initialized: %s" % (mdlname, str(stat[1])[-7:]))
    except: 
        set_status(mdlname, dict(state='DISCONNECTED'))
Exemple #6
0
#!/usr/bin/env python
'''Communicating with Benchtop RIGOL Spectrum Analyzer RSA5065-TG
'''

from colorama import init, Fore, Back
init(autoreset=True)  #to convert termcolor to wins color

from os.path import basename as bs
mdlname = bs(__file__).split('.')[0]  # module's name e.g. PSG

from time import sleep

import visa
from pyqum.instrument.logger import address, set_status, status_code, debug
from pyqum.instrument.logger import translate_scpi as Attribute

debugger = debug(mdlname)


# INITIALIZATION
def Initiate():
    ad = address()
    rs = ad.lookup(mdlname)  # Instrument's Address
    rm = visa.ResourceManager()
    try:
        bench = rm.open_resource(
            rs)  #establishing connection using GPIB# with the machine
        stat = bench.write('*CLS')  #Clear buffer memory
        bench.write(':SYSTem:PRESet')  #Mode preset
        bench.read_termination = '\n'  #omit termination tag from output
        bench.timeout = 150000  #set timeout in ms
Exemple #7
0
import pandas as pd
import glob2
from os.path import basename as bs
import os.path

all_data = pd.DataFrame()

for f in glob2.glob("./sephora/*.csv"):
    print f
    if os.path.getsize(f) > 0:
        df = pd.read_csv(f,
                         index_col=None,
                         header=None,
                         names=None,
                         sep='|',
                         skiprows=0)
        df.index = [bs(f)] * len(df)
        df.to_csv("sephora_all.csv",
                  encoding='utf8',
                  mode='a',
                  header=False,
                  sep='\t')
    print df