<% import os os.environ['MPLCONFIGDIR'] = "/home/timparkin/public_html/static/focus/tmp" from mod_python import apache try: from mod_python.util import parse_qsl except ImportError: from cgi import parse_qsl def get_env(req): # grab GET variables req.add_common_vars() query = req.subprocess_env['QUERY_STRING'] # grab POST variables if req.subprocess_env['REQUEST_METHOD'] == 'POST': query += '&' + req.read() # break down the urlencoded query string query = parse_qsl(query) http_var = dict(query) return http_var import matplotlib matplotlib.use('Cairo') import numpy as np import matplotlib.cm as cm import matplotlib.mlab as mlab import matplotlib.pyplot as plt from math import tan, atan, sin, cos, log, sqrt pi = 3.1415926535897 http_env = get_env(req) focus=http_env.get('a',95.0) focus = float(focus)/1000 f=http_env.get('f',90.0) f = float(f)/1000 lenstilt=http_env.get('lenstilt',5) lenstilt=float(lenstilt) N=http_env.get('N',22) N = int(N) coc=http_env.get('coc',0.1) coc = float(coc)/1000 import sys H = (f*f)/(N*coc) theta = lenstilt*pi/180.0 J = f/sin(theta) ninety = (90.0*pi)/180.0 maxm = { 16: 13, 22: 9, 32: 6.4, 45: 4.6, 64: 3.2, 90: 2.4, } def get_m(X,Y): Y = Y+J if X==0 and Y==0: X = 0.00001 Y = 0.00001 angle = atan(X/Y) phi = ninety + atan( f/(focus*sin(theta)) - 1/tan(theta) ) y = ((H/tan(angle))-(H/tan(phi))) dofy = (f*J)/focus ratio = abs(y)/abs(dofy) val = (72)/((3.6*ratio) + 8*(9/maxm[N]) ) Rcoc = 1/(coc*ratio*1000) Rdiff = 1500/N R = 1.0/( (1.0/Rdiff) + (1.0/Rcoc) ) return R def filename(f, lenstilt, N, coc, focus): name = 'chart-%s-%s-%s-%s-%s.png'%(int(f),lenstilt, N, coc, focus) return name def path(name): return '/home/timparkin/public_html/static/focus/tmp/%s'%name name = filename(f, lenstilt, N, coc, focus) if not os.path.exists(path(name)): matplotlib.rcParams['xtick.direction'] = 'out' matplotlib.rcParams['ytick.direction'] = 'out' delta = 0.025 x = np.arange(-1, 10, delta) y = np.arange(-2.5, 2.5, delta) X, Y = np.meshgrid(x, y) Z = np.zeros([len(y), len(x)],dtype=float) min = max = None for yn,row in enumerate(X): for xn,column in enumerate(row): z = get_m(X[yn][xn],Y[yn][xn]) Z[yn][xn] = z # Create a simple contour plot with labels using default colors. The # inline argument to clabel will control whether the labels are draw # over the line segments of the contour, removing the lines beneath # the label plt.figure() im = plt.imshow(Z,origin='lower',cmap=cm.spectral, interpolation='bilinear',extent=[-1,10,-2.5,2.5],norm=matplotlib.colors.Normalize(vmin=1,vmax=60)) CS = plt.contour(X, Y, Z, [1,3,5,7,10,15, 20, 30]) plt.clabel(CS, inline=1, fontsize=10) plt.title('Simplest default with labels') #plt.jet() # We can still add a colorbar for the image, too. CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8) plt.savefig(path(name)) %>

Experiment With Lens Tilt

The diagram has markings showing distance values in meters

Lens Tilt

Lens tilt is degrees

Focus

Bellows length is mm

Focal Length

Focal length is mm

Aperture

Aperture is 1/x

Circle of Confusion

CoC is mm

use 0.2/m where m is magnification if you want 'noseable' prints. 0.05 is an excellent choice, 0.1 is OK.

Link to your settings

Heat Map (lp/mm)

click me for detailed heat map