简体   繁体   中英

How do I convert 1D data into a 2D array?

I have downloaded some aeromagnetic data and am trying to plot it using pcolor or pcolormesh . This data came in a format where each column had a type of data. I read the file and took out the longitude, latitude and background magnetic columns. So I have 3 1D arrays with these values. To plot with pcolor I need the magnetic array to be 2D. I was wondering what the best way to convert the array or if there is some better method of plotting with 1D arrays.

Long = np.genfromtxt('AZ_5041.txt', usecols = 2)
Lat = np.genfromtxt('AZ_5041.txt', usecols = 3)
Mag = np.genfromtxt('AZ_5041.txt', usecols = 9)

You can try something like vstack (or a related method).

https://docs.scipy.org/doc/numpy/reference/generated/numpy.vstack.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM