Tab autocompletetion with python interpreter in bash terminal

I want to tab autocomplete commands in my python interpreter within bash terminal. This is very useful when I import a module and just want to browse through the methods and autocomplete. Found two ways to do it. Thanks to stack overflow posts. Method 1 (as mentioned here): This is easy. Install pyreadline (pip install pyreadline) and use ipython. This is a snapshot of it working. Method 2 ( as mentioned here): This is for standard  python interpreter in bash terminal (such as in Ubuntu). This method requires readline and rlcompeter modules. Install these modules if you do not have Read More …

Coupled Dipole Approximation in Python

Coupled dipole approximation (CDA) method is a numerical method to calculate the optical properties (scattering and absorption) of interacting dipoles. This method is used in discrete dipole approximation method (like in DDSCAT software), where a big particle (also known as target) is broken into lot of interacting dipoles arranged in cubic lattice. CDA can also be used to calculate the optical properties (scattering and absorption) of random particle distributions (like in L. Zhao et al. J. Phys. Chem. B,  107,  30, 7343,2003 ) and assuming each particle to be small enough that it behaves like a dipole. I have implement Read More …

Controlling Rigol Dp832 with python

DC power supplies are very handy for electronic projects. They help to apply bias to a devicve. Controlling it by a computer by a program is helpful in advanced projects where timing and accurate control is an issue. I got my hands on a RIGOL DP832 which is three channel (two 30V and one 5V) power supply and is programmable through SCPI commands. The device can be controlled by USB and rs232 (optionally by LAN). SCPI commands can be sent to the instruments using VISA interface. I used Python and pyvisa module to communicate with it. I wrote a class Read More …

Hacking Weighing Scale to Upload Weight to Plotly using Raspberry Pi

I have been interested in monitoring and keep track of my weight. In the past, I have used phone apps for this purpose, works OK but I was thinking of reading weight information using some microcontroller from my weighing scale and upload the data to an online database. That means that microcontroller should connect to my wi-fi connection at home and upload the data. I have seen some projects online that use an arduino for this purpose. They use arduino to serially send information to computer. The information on the computer can be potentially sent to an online database. One Read More …

Controlling Newport 1918 Power Meter with Python

Optical power meters in-conjunction with a detector are used to measure power from a laser source or monochromatic output. At work, we use Newport 1918 power meter. This power meter comes with its own software. However, I was interested in controlling this instrument with python. I made a class for this instrument . If you are interested you can download it at my  Github repostitory . This python module contains higher level functions to communicate with Newport 1918 power meter on a Windows computer. It uses python ctypes to access methods in the Newport’s usbdll.dll driver. For connecting the hardware to the Read More …

Python

I am playing with Python for the first time. The syntax seems to be so natural. So many modules (numpy, scipy and matplotlib) for researchers/scientists. Cannot see any shortcoming at this point. Perhaps need more testing and implementation. Some questions I am looking answers for: Is it faster than Fortran? If not faster, can it do everything Matlab does, such as availability of host of toolboxes?