저는 두 가지 월간 글로벌 그리드 데이터 세트 (시간, 라트, 론) 형식의 액체 물 상당 두께가 있습니다. 둘 다 공간적, 시간적 해상도가 동일합니다. 상관 관계를 원하지만 numpy.corrcoef()
은 3D가 아닌 2D 배열에서만 작동합니다. 그래서 전체 시계열에 대해 두 변수의 동일한 격자 점 (x, y)을 상관 시키려고합니다. 사실 상관 계수 격자로 새로운 nc 파일을 원합니다.파이썬에서 그리드 된 데이터 세트를 연결합니다.
import numpy as np
from netCDF4 import Dataset
wdir = '.../Data/'
# read GRACE NCs
GRACE_GFZ = Dataset(wdir+'GRACE/GRCTellus.GFZ.200204_201607.nc','r')
GRACE_JPL = Dataset(wdir+'GRACE/GRCTellus.JPL.200204_201607.nc','r')
두 변수 (GFZ 및 JPL)가 동일한 위치에서 누락 값을 동일한 양을 갖는다.
GRACE_GFZ.variables['lwe_thickness']
<type 'netCDF4._netCDF4.Variable'>
float32 lwe_thickness(time, lat, lon)
long_name: Liquid_Water_Equivalent_Thickness
units: cm
_FillValue: 32767.0
missing_value: 32767.0
unlimited dimensions: time
current shape = (155, 72, 144)
filling off
GRACE_JPL.variables['lwe_thickness']
<type 'netCDF4._netCDF4.Variable'>
float32 lwe_thickness(time, lat, lon)
long_name: Liquid_Water_Equivalent_Thickness
units: cm
_FillValue: 32767.0
missing_value: 32767.0
unlimited dimensions: time
current shape = (155, 72, 144)
filling off
들은 하나 모두에 사용될 수로부터 동일한 공간적 해상도, 시간, 위도 및 경도를 가지고있다.
time = GRACE_GFZ.variables['time'][:]
lons = GRACE_GFZ.variables['lon'][:]
lats = GRACE_GFZ.variables['lat'][:]
gfz = GRACE_GFZ.variables['lwe_thickness'][:]
jpl = GRACE_JPL.variables['lwe_thickness'][:]
여기 그리드를 통과하여 corrcoef를 배열에 넣고 싶습니다. 이것은 나에게 2x2 행렬의 무리를 준다.
test = []
for x in range(len(lats)):
for y in range(len(lons)):
print(np.corrcoef(gfz[:,x,y],jpl[:,x,y]))
어떻게 각 지점의 corrcoef를 올바른 위치에 새로운 배열에 넣을 수 있습니까?
질문을 [최소, 완전하며 검증 가능한 예] (http://stackoverflow.com/help/mcve)로 업데이트 할 수 있습니까? – Kasramvd
@ Kasramvd가 필요한 정보입니까? –