Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
streamline plot
#1
hi

I am struggeling with a homeworkassignment.
i Am trying to streamlineplot, but i have only found this scetch. how do i go from this scetch to getting my txt file to work wit a simmilar approach? my assignment is at the bottom.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec

w = 3
Y, X = np.mgrid[-w:w:100j, -w:w:100j]
U = -1 - X**2 + Y
V = 1 + X - Y**2
speed = np.sqrt(U**2 + V**2)

fig = plt.figure(figsize=(7, 9))
gs = gridspec.GridSpec(nrows=3, ncols=2, height_ratios=[1, 1, 2])

#  Varying density along a streamline
ax0 = fig.add_subplot(gs[0, 0])
ax0.streamplot(X, Y, U, V, density=[0.5, 1])
ax0.set_title('Varying Density')
In the data.txt file

, you will find data describing a velocity field on a rectangle of size 100x100. For each point in this rectangle, a vector is stored in data.txt. In total, there are 100 * 100 * 2 = 20000 numbers in this file. The data is organized so that the vector belonging to the coordinate (i, j) in the rectangle is in place 100 * j + in the data (this is x coordinate to vector) and space 100 * 100 + 100 * j + i (y coordinate to vector).
With the tool you choose, you must perform the following two tasks:

Task 1:

a) Plot how the currents go in the vector field

b) Plot the speed at each point using a color plot.

c) Plot the divergence at each point using a color plot.

d) Plot the z coordinate of the rotation (ie, curl) at each point using a color plot.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020