Tuesday, December 16, 2014
Wednesday, November 12, 2014
Computation of Enhanced Vegetation Index Using Spectral Python
This example was demonstrated in masters level course GIS and Remote Sensing, See references for details. Most of commands are taken from user guide [SpectralPython] whereas theoretical basis are discussed in [MODIS-VI_UserGuide]. This post assumes software is already installed and data is locally available. Invoke ipython --pylab=wx at command prompt.
In [1]: from spectral import *
In [2]: img = open_image('92av3c.lan')
In [3]: blu, red, nir = img[:,:,9], img[:,:,29], img[:,:,43]
In [4]: evi = 2.5 * (nir - red) / (nir + 6 * red - 7.5 * blu + 1)
In [5]: view = imshow(evi)
References: [SpectralPython] [MODIS-VI_UserGuide]
The output image is pasted below.
In [1]: from spectral import *
In [2]: img = open_image('92av3c.lan')
In [3]: blu, red, nir = img[:,:,9], img[:,:,29], img[:,:,43]
In [4]: evi = 2.5 * (nir - red) / (nir + 6 * red - 7.5 * blu + 1)
In [5]: view = imshow(evi)
References: [SpectralPython] [MODIS-VI_UserGuide]
The output image is pasted below.
Thursday, October 23, 2014
An Implementation of DFT in Python
This paper I wrote recently to challenge myself on use of Python programming language for implementation of Fourier transform -- a basic signal processing tool. The document can be accessed by website link [PAPER].
Friday, August 1, 2014
Python Code for Quadratic Equation
Writing code to find roots of Quadratic equation was a famous assignment when I was learning GW-BASIC and Borland Turbo C. Recently, I have written following Python code. The output of two sample executions are pasted below as well.
# Quadratic equation with real and non-real roots
# Written by Dr. Tariq Javid as of 31 July 2014
a = raw_input('enter a: ')
b = raw_input('enter b: ')
c = raw_input('enter c: ')
a, b, c = int(a), int(b), int(c)
if ((b ** 2) < (4 * a * c)):
a, b, c = complex(a), complex(b), complex(c)
x1 = ((-b) + ((b ** 2) - 4 * a * c) ** (0.5)) / (2 * a)
x2 = ((-b) - ((b ** 2) - 4 * a * c) ** (0.5)) / (2 * a)
print 'imaginary roots:'
print x1
print x2
else:
a, b, c = float(a), float(b), float(c)
x1 = ((-b) + ((b ** 2) - 4 * a * c) ** (0.5)) / (2 * a)
x2 = ((-b) - ((b ** 2) - 4 * a * c) ** (0.5)) / (2 * a)
print 'real roots:'
print x1
print x2
# Quadratic equation with real and non-real roots
# Written by Dr. Tariq Javid as of 31 July 2014
a = raw_input('enter a: ')
b = raw_input('enter b: ')
c = raw_input('enter c: ')
a, b, c = int(a), int(b), int(c)
if ((b ** 2) < (4 * a * c)):
a, b, c = complex(a), complex(b), complex(c)
x1 = ((-b) + ((b ** 2) - 4 * a * c) ** (0.5)) / (2 * a)
x2 = ((-b) - ((b ** 2) - 4 * a * c) ** (0.5)) / (2 * a)
print 'imaginary roots:'
print x1
print x2
else:
a, b, c = float(a), float(b), float(c)
x1 = ((-b) + ((b ** 2) - 4 * a * c) ** (0.5)) / (2 * a)
x2 = ((-b) - ((b ** 2) - 4 * a * c) ** (0.5)) / (2 * a)
print 'real roots:'
print x1
print x2
Sunday, April 13, 2014
A SHORT INTRODUCTION TO E-LEARNING
This is another article for Better Pakistan published by Thinkers' Forum Pakistan. This article aims novice to consider taking an on-line course and provide quick guidance on the process. [Article Link]
Saturday, April 12, 2014
A MIGHTY TRIPLET: PEN, KEY, AND MOBILE PHONE
Today, I am able to complete a one page write up. This article is intended for Better Pakistan published by Thinkers' Forum Pakistan. I am greatly inspired by Secretary General Colonel (R) Bakhtiar Hakeem SI(M). [Article Link]
Wednesday, April 9, 2014
A Presentation on eLearning with Moodle for HITEC University Faculty
This gives me a great feeling at this point in time as finally this presentation is ready. The presentation is for faculty members in Department of Mechanical Engineering of HITEC University. It was initially agreed in senior management meeting a while ago that I will be delivering a presentation as per Dr. Kamran HoD ME request. The objective is to use this wonderful eLearning platform effectively and with ease. [LINK]
Subscribe to:
Posts (Atom)

