私は MITgcm と協力してシミュレーションを行い、特に内部波動モデルを操作しています。結果を含む .nc ファイルを取得しましたが、一部の変数がまったく同じ座標にありません。私は自分自身を説明します:私は速度の成分を計算したいのですが、完全には理解できないいくつかの数値的な理由から、水平速度座標はセルの左側にあり、垂直座標はセルの下部にあります. 速度データを操作するには、すべての座標の参照を統一する必要があります。
私はこのようなことをすることを考えました
u (i,j,k) = u(i,j,k) + u(i+1,j,k)
v (i,j,k) = v(i,j,k) + v(i,j+1,k)
したがって、座標はすべてセルの中心にあり、同じ参照になります。
Pythonを使用してNetCDFファイルを編集する方法がわかりません。すべてのuおよびvデータを抽出し、前述のように編集し、この 2 つの変数だけで新しい NetCDF ファイルを作成するだけで満足できます。
それは可能ですか?どうやってやるの?
編集:ncdump情報を追加
netcdf state.global {
dimensions:
T = UNLIMITED ; // (10001 currently)
Xp1 = 61 ;
Y = 1 ;
Z = 20 ;
X = 60 ;
Yp1 = 2 ;
Zl = 20 ;
variables:
double Xp1(Xp1) ;
Xp1:long_name = "X-Coordinate of cell corner" ;
Xp1:units = "meters" ;
double Y(Y) ;
Y:long_name = "Y-Coordinate of cell center" ;
Y:units = "meters" ;
double Z(Z) ;
Z:long_name = "vertical coordinate of cell center" ;
Z:units = "meters" ;
Z:positive = "up" ;
double X(X) ;
X:long_name = "X-coordinate of cell center" ;
X:units = "meters" ;
double Yp1(Yp1) ;
Yp1:long_name = "Y-Coordinate of cell corner" ;
Yp1:units = "meters" ;
double Zl(Zl) ;
Zl:long_name = "vertical coordinate of upper cell interface" ;
Zl:units = "meters" ;
Zl:positive = "up" ;
double T(T) ;
T:long_name = "model_time" ;
T:units = "s" ;
int iter(T) ;
iter:long_name = "iteration_count" ;
double U(T, Z, Y, Xp1) ;
U:units = "m/s" ;
U:coordinates = "XU YU RC iter" ;
double V(T, Z, Yp1, X) ;
V:units = "m/s" ;
V:coordinates = "XV YV RC iter" ;
double Temp(T, Z, Y, X) ;
Temp:units = "degC" ;
Temp:long_name = "potential_temperature" ;
Temp:coordinates = "XC YC RC iter" ;
double S(T, Z, Y, X) ;
S:long_name = "salinity" ;
S:coordinates = "XC YC RC iter" ;
double Eta(T, Y, X) ;
Eta:long_name = "free-surface_r-anomaly" ;
Eta:units = "m" ;
Eta:coordinates = "XC YC iter" ;
double W(T, Zl, Y, X) ;
W:units = "m/s" ;
W:coordinates = "XC YC RC iter" ;
// global attributes:
:MITgcm_version = "****************" ;
:build_user = "************" ;
:build_host = "**************" ;
:build_date = "*******************" ;
:MITgcm_URL = "***************" ;
:MITgcm_tag_id = "*******************" ;
:MITgcm_mnc_ver = 0.9 ;
:sNx = 30 ;
:sNy = 1 ;
:OLx = 2 ;
:OLy = 2 ;
:nSx = 2 ;
:nSy = 1 ;
:nPx = 1 ;
:nPy = 1 ;
:Nx = 60 ;
:Ny = 1 ;
:Nr = 20 ;
}