VIM for Python Development

Posted on Sun 19 January 2020 in Python, Vim

I have been using VIM lately for software development in Python. I gave a lightening talk on my experiences using VIM at San Diego monthly meetup.

You can see my presentation slides here

You can see my reveal-js source here

Improving code using getters and setters in Python

Posted on Wed 04 December 2019 in Electronics

As I was migrating blog posts from my wordpress website to pelican based static website, I noticed an old python code written for communicating and controlling a Princeton Instruments Acton SP2150i Monochromator.

As I looked at the code, I noticed methods in the class such as get_nm() and set_nm(). I …

Continue reading

Calculating molarity, weight concentration from absorbance value for plasmonic nanoparticles in solution

Posted on Wed 20 June 2018 in Plasmonics

It is common to measure the peak absorbance of the plasmonic nanoparticles in solution and then get the following:

  1. Molarity (moles/liter)
  2. Number of particles per ml
  3. Weight concentration (ug/ml)

I wrote a small python function to extract these parameters.  The following inputs are needed for the function

  1. d_nm …

Continue reading

Creating Energy Band Diagrams for Solar cells and LED

Posted on Mon 11 September 2017 in Misc • Tagged with Python

Energy band diagrams are used to visulize the electron and hole transport in Solar cells and LED research. I want to quickly draw them and came up with a python module.

Here's an example on how to use this code.

from Band_diagram import metal, semiconductor, plot

# Define the metals and …

Continue reading

Tab autocompletetion with python interpreter in bash terminal

Posted on Sat 29 October 2016 in Misc • Tagged with Linux, python

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 …

Continue reading

Did I turn off the stove...ESP8266

Posted on Sat 08 October 2016 in Electronics • Tagged with ESP8266, IOT

My wife and I have a good meal and leave the house. After 20 minutes or so, we are in the car and I ask my wife, did we turn off the stove?

My wife answers…you were the last one to cook. What to do now? Go back home …

Continue reading

Fitting Complex Metal Dielectric Functions with Differential Evolution Method

Posted on Wed 13 April 2016 in Plasmonics

The real and imaginary part of dielectric permittivity of the metals is important to simulate the optical properties of metal films and nanoparticles. Permittivity data is obtained experimentally by ellipsometry and is fitted with analytical models. The most common model for fitting experimental data is with Drude-Lorentz …

Continue reading

Dealing with plotting negative, zero and positive values in log scale

Posted on Wed 30 March 2016 in Misc • Tagged with Python

Sometimes you have to show positive, zero and negative number in log scale. However you cannot take log of negative numbers and zero. But one could approximate it with a log transform modulus as stated here.

In Python with numpy:

from numpy import sign, abs, log10  
import matplotlib.pyplot as …

Continue reading

Generating plasmonic metal dielectric functions in Python

Posted on Thu 10 September 2015 in Plasmonics • Tagged with Python

I keep needing a python code to generate the dielectric functions of plasmonic materials such as Au, Ag, Pd, and Pt. So I wrote a python version of LD.m.

LD.m is a matlab file written by Bora Ung …

Continue reading

DDSCAT on amazon EC2

Posted on Thu 03 September 2015 in Plasmonics • Tagged with DDSCAT

Amazon provides high performance computing capabilities through their EC2 service. You can find more information here

They provide a 750 hr free instance with their a free-tier program. If you want more resources, you can pay for it. See the pricing, pricing seem very reasonable.

I wanted to see …

Continue reading