내가 아직 파이썬으로 돌아올하려고하지만,이 문제는 내 지식 초과 :Python : csv에서 배열로 시간 간격 읽기 : numpy를 사용하여 모델 데이터를 사후 처리합니다.
주제 : 유체 역학적 후 처리 : 배열에 유압 소프트웨어의 CSV 출력을 분할 여기
이 데이터와 얼마나 멀리입니다 시간 단계입력 파일 (아래 참조) :
첫 번째 행 : 내가 작업 코드와 함께 결과-노드의 수
두 번째 행 : H eader
세 번째 행 :이 시간 단계의 모든 결과 : 다음 시간 단계의 @ 시간 =
(이 파일 : 13,541 노드 변수) .... 다음 타임 스텝에 다시 같은.
# Number of Nodes: 13541
#X Y Z depth wse
# Output at t = 0
5603.7598 4474.4902 37.470001 0 37.470001
5610.5 4461.6001 36.020001 0 36.020001
5617.25 4448.71 35.130001 0 35.130001
5623.9902 4435.8198 35.07 0 35.07
5630.7402 4422.9199 35.07 0 35.07
5761.5801 4402.79 35.369999 0 35.369999
COMMENT:....................13541 timesteps...........
# Output at t = 120.04446
5603.7598 4474.4902 37.470001 3.6977223 41.167724
5610.5 4461.6001 36.020001 4.1377293 40.15773
5617.25 4448.71 35.130001 3.9119012 39.041902
5623.9902 4435.8198 35.07 3.7923947 38.862394
5630.7402 4422.9199 35.07 3.998436 39.068436
5761.5801 4402.79 35.369999 3.9750571 39.345056
COMMENT:....................13541 timesteps...........
# Output at t = 240.06036
5603.7598 4474.4902 37.470001 11.131587 48.601588
5610.5 4461.6001 36.020001 12.564266 48.584266
5617.25 4448.71 35.130001 13.498463 48.628464
5623.9902 4435.8198 35.07 13.443041 48.513041
5630.7402 4422.9199 35.07 11.625824 46.695824
5761.5801 4402.79 35.369999 19.49551 54.865508
문제 : 나는 배열로 N-시간 단계에서 읽는 루프가 필요합니다.
결과는 다음과 같아야합니다. 각 시간 단계에 대한 배열 :이 경우, 각각 13541 개의 요소가있는 27 개의 시간 단계.
timestep_1 = [이 시간 단계의 모든 요소 : 형상 = 13541,5]
timestep_2 = []
timestep_3 []
........
timestep_n = []
내 코드 지금까지 :
import numpy as np
import csv
from numpy import *
import itertools
#read file to big array
array=np.array([row for row in csv.reader(open("ascii-full.csv", "rb"), delimiter='\t')])
firstRow=array[0]
secondRow=array[1]
# find out how many nodes
strfirstRow=' '.join(map(str,firstRow))
first=strfirstRow.split()
print first[4]
nodes=first[4]
nodes=float(nodes)
#count timesteps
temp=(len(array)-3)/nodes
timesteps=int(temp)+1
#split array into timesteps:
# X Y Z h(t1) h(t2) h(tn)
ts1=array[3:nodes+3]#13541
#print ts1
ts2=array[nodes+4:nodes*2+4]
#print ts2
.......
read ts3 to last timestep to arrays with loop....
어쩌면 누군가 나를 도울 수 있습니다, 감사합니다 !!!
고맙습니다. !!!! – user3740877
그것은 이런 식으로 일했습니다 .... 라인별로 작품을 읽는 것이 더 좋게 작동합니다. – user3740877
당신을 환영합니다! 문제가 해결 된 경우 허용 된 답변으로 내 대답을 선택하십시오. – franzwr