2016-09-05 6 views
-1

私はグラフをプロットしています。そして私は、グラフのカラーバー "U_velocity"と "U_shear_velocity"の値の範囲を-0.3から0.3にしたいと考えています。さらに、私はx軸の範囲をUとVのせん断速度プロットで0〜12.5時間にしようとしていますが、何も働かず、その代わりに私は速度の意味を持っています。どうすればいいですか、私を助けてください。Pythonの海洋図解

from netCDF4 import * 
import matplotlib as mp 
import numpy as np 

#import matplotlib.pyplot as plt 
import pylab as plt 


#%% 

file = "/home/vlad/Desktop/task/Untitled Folder/result.nc" 


ncdata = Dataset(file, 'r') 

u = np.squeeze(ncdata.variables['u'][:]) 
v = np.squeeze(ncdata.variables['v'][:]) 
z = np.squeeze(ncdata.variables['z'][:]) 

time = ncdata.variables['time'][:]/3600 

ncdata.close() 

u_mean = np.mean(u[0:100,:],0) 
z_mean = np.mean(z[0:100,:],0) 
v_mean = np.mean(v[0:100,:],0) 

u_mean_10 = u[900:1000,:] 
v_mean_10 = v[900:1000,:] 
z_10 = np.mean(z[900:1000,:],0) 

time_10 = time[900:1000] - time[900] 


T = len(time_10) 
L = len(z_10) 

fig = plt.figure(6) 
plt.pcolormesh(time_10,z_10,u_mean_10.T) 
plt.xlim([0, time_10[-1]]) 
fig.suptitle('U_velocity', fontsize=25) 
plt.xlabel('time', fontsize=20) 
plt.ylabel('depth(m)', fontsize=20) 
plt.colorbar() 
plt.show() 

shear_u_mean_10 = np.zeros([T,L]) 

for t in range(T): 
    for i in range(L-1): 
     tmp=(u_mean_10[t, i+1]-u_mean_10[t, i])/(z_10[i+1]-z_10[i]) 
     tmp_depth = 0.5 * (z_10[i+1]+z_10[i]) 
     shear_u_mean_10[t,i] = tmp 

fig = plt.figure(10) 
plt.pcolormesh(time_10/3600,z_10, shear_u_mean_10.T) 
plt.xlim([0, time_10[-1]/3600]) 
plt.colorbar() 
#plt.ylim([-30, -25]) 
fig.suptitle('U_shear velocity', fontsize=25) 
plt.xlabel('time', fontsize=20) 
plt.ylabel('depth(m)', fontsize=20) 
plt.show() 


shear_v_mean_10 = np.zeros([T,L]) 

for t in range(T): 
    for i in range(L-1): 
     tmp=(v_mean_10[t, i+1]-v_mean_10[t, i])/(z_10[i+1]-z_10[i]) 
     tmp_depth = 0.5 * (z_10[i+1]+z_10[i]) 
     shear_v_mean_10[t,i] = tmp 

fig = plt.figure(11) 
plt.pcolormesh(time_10/3600,z_10, shear_v_mean_10.T) 
plt.xlim([0, time_10[-1]/3600]) 
plt.colorbar() 
#plt.ylim([-30, -25]) 
fig.suptitle('V_shear velocity', fontsize=25) 
plt.xlabel('time', fontsize=20) 
plt.ylabel('depth(m)', fontsize=20) 
plt.show() 



fig = plt.figure(7) 
plt.pcolormesh(time_10,z_10,v_mean_10.T) 
plt.xlim([0, time_10[-1]]) 
fig.suptitle('V_velocity', fontsize=25) 
plt.xlabel('time', fontsize=20) 
plt.ylabel('depth(m)', fontsize=20) 
plt.colorbar() 
plt.show() 
+1

[mcve]を作成してみてください。走ってみることができますか?または、どのようなエラーメッセージが表示されるか教えてください。データファイルがないため、グラフをプロットできません。また、あなたの質問にあなたの現在のプロット出力の画像を含めてください – Praveen

+0

@Praveen私はこのデータファイルをダウンロードしようとしましたが、私はそれを直接行う方法を見つけることができませんでした。それから私はリンクを通してそれをダウンロードしようとしましたが、ウェブサイトは私がスパムである可能性があるためリンクを参照することを許可していません。 – Vlados9951

答えて

0

これは、コード、未知のファイルresult.ncを参照すると、いくつかの無関係とかなり具体的な問題の壁に答えるために簡単な質問ではありません。以下は役に立ちます:

vmin=-0.3vmax=0.3pcolormeshに渡すことで、カラーバーの範囲を設定できます。

時間の範囲を限定するには、配列スライス(例:time[time<12.5], u[time<12.5])を使用できます。あなたのデータのために

は、確かにスピードは、あなたがさらに支援が必要な場合は、最小完全、かつ検証可能な例を提供してくださいちょうどspeed = np.sqrt(np.power(u,2) + np.power(v,2)

です。

+0

本当にありがとうございました。あなたが書いたことをやろうとします。それ以外の場合は、このデータファイルをダウンロードしようとしましたが、直接行う方法が見つかりませんでした。それから私はリンクを通してそれをダウンロードしようとしましたが、ウェブサイトは私がスパムである可能性があるためリンクを参照することを許可していません。 – Vlados9951

関連する問題