아이리스의 가장 가까운 이웃 코드는, 슬프게도, 현재 필요한 인덱스를 식별하는 데이터를로드합니다. 이 크기의 데이터 세트로 작업하기 위해 시도해 볼 수있는 (https://github.com/SciTools/iris/pull/707) 문제를 해결하기 위해 간단한 테스트 요청을 제출했습니다. 내가 샘플 데이터에서 큐브와 함께 작동하도록하겠습니다
:
import iris
cube = iris.load_cube(iris.sample_data_path('air_temp.pp'))
그리고 데이터는 다음과 같은 기능이 장착되어 있는지 여부를 확인할 수 있습니다 : 그래서
def cube_data_is_loaded(cube):
# A None data manger means the data is loaded...
return cube._data_manager is None
:
>>> print cube_data_is_loaded(cube)
False
기본적으로 가장 가까운 이웃에 대한 인터페이스 (http://scitools.org.uk/iris/docs/latest/iris/iris/analysis/interpolate.html#iris.analysis.interpolate.extract_nearest_neighbour)를 사용하면 point ext raction : 추출 실제로 내 요구 된 점에 가까운 위도 값을 발견했습니다 방법
from iris.analysis.interpolate import extract_nearest_neighbour
smaller_cube = extract_nearest_neighbour(cube,
(('longitude', -180), ('latitude', 1.5)))
>>> print smaller_cube
air_temperature/(K) (scalar cube)
Scalar coordinates:
forecast_period: 6477 hours
forecast_reference_time: 1998-03-01 03:00:00
latitude: 2.50002 degrees
longitude: 180.0 degrees
pressure: 1000.0 hPa
time: 1996-12-01 00:00:00
Attributes:
STASH: m01s16i203
source: Data from Met Office Unified Model
Cell methods:
mean: time
알 수 있습니다. 정말 중요한 것은 당신의 경도 좌표 경우이 기능이 정말 포장을 처리하지 않습니다하는 순환되지 않는 것입니다 : 원래 큐브의 경도 범위 (0-360)가 지금 있다는 것을 의미하는 방법
cube.coord('longitude').circular = False
smaller_cube = extract_nearest_neighbour(cube,
(('longitude', -180), ('latitude', 1.5)))
cube.coord('longitude').circular = True
>>> print smaller_cube
air_temperature/(K) (scalar cube)
Scalar coordinates:
forecast_period: 6477 hours
forecast_reference_time: 1998-03-01 03:00:00
latitude: 2.50002 degrees
longitude: 0.0 degrees
pressure: 1000.0 hPa
time: 1996-12-01 00:00:00, bound=(1994-12-01 00:00:00, 1998-12-01 00:00:00)
Attributes:
STASH: m01s16i203
source: Data from Met Office Unified Model
Cell methods:
mean: time
공지 사항
smaller_traj = interpolate(cube,
(('longitude', [-180, -180]), ('latitude', [1.5, 3.5])),
'nearest')
>>> print smaller_traj
air_temperature/(K) (*ANONYMOUS*: 2)
Auxiliary coordinates:
latitude x
longitude x
Scalar coordinates:
forecast_period: 6477 hours
forecast_reference_time: 1998-03-01 03:00:00
pressure: 1000.0 hPa
time: 1996-12-01 00:00:00, bound=(1994-12-01 00:00:00, 1998-12-01 00:00:00)
Attributes:
STASH: m01s16i203
source: Data from Met Office Unified Model
Cell methods:
mean: time
(원본 큐브의 데이터가 전체에로드되어 있지 않은 방법을 발견하여, 마지막 : -180에 가장 가까운 값은 궤도 추출 할 수있는 기능 (http://scitools.org.uk/iris/docs/latest/iris/iris/analysis/trajectory.html?highlight=trajectory#iris.analysis.trajectory.interpolate)도 있습니다 실제로 0
입니다 내 지부), 실제로, smaller_cube로부터의 데이터는 또한 지연되었습니다 궤도 용
>>> print cube_data_is_loaded(cube)
False
>>> print cube_data_is_loaded(smaller_cube)
False
일반적으로, 지연 로딩이 불가능하지만 netCDF의 사용시 지수 오른쪽 근본적인 netCDF의 라이브러리로 전달되고 있다는 것을 주목할 가치가있다 어떤 시점에서도 전체 배열이 메모리에 저장되지 않습니다.
HTH!
P. 비록 아직 거기에 유사한 인터페이스가 선형 보간을 할, 나는 그 관심을해야한다, 나는 아이리스와 함께 작동하는 스플라인 보간 알고리즘을 알고 아니에요.
고맙습니다. @pelson, 자세한 답변입니다. 그러나, 나는 궤도, netCDF 및 색인에 관하여 당신의 코멘트를 이해하지 않는다. 나는 '궤적'을 시도 할 때.interpolate' 메소드를 내 큐브에서 'nearest'를 사용하여 4 포인트를 추출하면 내 데스크탑의 4G RAM이 충분하지 않고 시스템이 스왑을 시작합니다 (또는 궤적 인터페이스에서도이를 활용하려면 최신 PR이 필요합니까?) –
예. 새 PR은 모든 데이터를로드하지 않고 보간을 얻는 데 절대적으로 필요합니다. 당신이 원했던 것처럼 이것이 작동하려면 사소하지만 필요한 변화였습니다. – pelson