import numpy import bpy import math # Create thin lines. Plot flux as a function of baseline, one line per # declination pixel. Each line is from a different channel and position offset # according to the channel value. filebase = 'Pegasus2500-7000_SN' for channel in range(0,847): print(channel) filename = filebase+'_'+str(channel).zfill(3)+'.txt' # Read in the data from the correct file data = numpy.genfromtxt(filename) sizex = int(numpy.max(data[:,0]))+1 sizey = int(numpy.max(data[:,1]))+1 # Create one line mesh at the same declination slice as the current # channel y = channel #print(y) me = bpy.data.meshes.new('Line_'+str(channel)+'_'+str(y)) # Create the vertices verts = [] for x in range(0,sizex): verts.append((x,y,0)) # Now fill in the faces j = 0 faces = [] while j < sizex-1: faces.append([j,j+1]) j = j + 1 # Create the mesh. Syntax is verts list, edge list, face list me.from_pydata(verts, [], faces) # Create the object obj = bpy.data.objects.new('Line_'+str(channel)+'_'+str(y), me) # Now we can move the vertex positions mesh = obj.data # We want the y slice to be a triangle function of the channel number yrad = math.radians(y*90.0/296.0) y = int(abs(math.degrees(math.asin(math.sin(yrad)))*(269.0/90.0))) i = 0 vindex = 0 while i < data.shape[0]: yp = data[i,1] if (yp == y): xp = data[i,0] flux = data[i,3] mesh.vertices[vindex].co.x = xp mesh.vertices[vindex].co.y = yp mesh.vertices[vindex].co.z = (5.0*flux) - (2.0*channel) vindex = vindex + 1 i = i + 1 #print(vindex) # Add the object to the current scene scene = bpy.context.scene scene.objects.link(obj)