0

以下に示すように、水の平均飽和度 (%) のデータを読み取りたいとします。このデータは大きなファイルの一部ですが、平均水飽和度 (%) は指定された形式でのみ繰り返されます。

Average Pressure 
   Total Pore Volume  psia      3884.9                                                                                              
   HC. Pore Volume    psia      3884.9                                                                                              
 Average P/Z 
   Total Pore Volume  psia      4457.8                                                                                              
   HC. Pore Volume    psia      4457.8                                                                                              
 Average Saturation %
   Oil                          84.911                                                                                              
   Gas                          .08873                                                                                              
   Water                        15.000                                                                                              
 Percentage Recovery 
   Stock Tank Oil               .02211                                                                                              
   STO as a % of Mobile Oil     .02891                                                                                              
   Total Gas                    .02034                                                                                              
   Water                        62e-12

readline.m関数を使ってやろうとしたのですが、残念ながら平均含水率(%)データの位置が行番号で固定されていません。異なるモデルの同様の種類の出力ファイルでは、行番号が変わります。

これは私がやろうとしていたことです:

%# Reading Water Saturation (Sw) data from output (.OUT) file of reservoir model
    Sw_LineNo=[554,968,1120,1272,1424,1576,1728,1880,2032,2184,2336,2488,2640,2792,2944,3096,3248,3400,3552,3704,3856]; % This column vector contains the line numbers of the .out file with Sw values for year 1 till 20

    for i=1:size(Sw_LineNo,2)
    read_value=readline('ReservoirModel_ExplorWell_CMGBuilder.out',Sw_LineNo(i)); % read_value stores values in form of string
    Swav_Data_E_W(i,j)=str2num(read_value(33:38)); % converts the required portion of string (Sw value) to number
    end

ここで、モデル ( ReservoirModel_ExplorWell_CMGBuilder.out) が変更されると、テキスト ファイル内の水の平均飽和度 (%) がある行番号も変更されます。したがってSw_LineNo、モデルごとに変化し、多数のモデルがあります。

水データのすべての平均飽和度 (%) を読み取る正しい方法を提案してください。

4

1 に答える 1

0
%# Reading Average Water Saturation (Savw) data from output (.OUT) file of reservoir model
    fid = fopen('ReservoirModel_CMGBuilder.out'); % open the file

    dotOUT_fileContents = textscan(fid,'%s','Delimiter','\n'); % read it into one big array, row by row
    dotOUT_fileContents = dotOUT_fileContents{1};
    fclose(fid); %# don't forget to close the file again

    %# find rows containing 'Average Saturation %'
    Swav_Starts = strmatch('Average Saturation %',dotOUT_fileContents); % Swav_Starts contains the line numbers wherever 'Average Saturation %' is found
    nSwav = length(Swav_Starts); % total no. of Swav values will be equal to the total no. of 'Average Saturation %' read from the .out file

    %# loop through the file and read the numeric data
    for w = 1:nSwav 
        %# read lines containing numbers
        tmp_str = dotOUT_fileContents(Swav_Starts(w)+3); % stores the content of the 3rd row from the row containing 'Average Saturation %' in form of string
        tmp_str = tmp_str{:}; % store the content of the string which contains Swav, as well, in form of a character
        %# assign output
        Swav_yearly(w,j) = str2num(tmp_str(30:35)); % convert the part of the character containing Swav into number
    end

これでtmp_str = dotOUT_fileContents(Swav_Starts(w)+3);、次の文字列が生成されます。

Water                        15.000 

str2num を使用して数値に変換しようとすると、空の行列が得られます。そこで、飽和値 (ここでは15.000) を含むこの文字列の文字を選択し、次のようにこの文字を数字に変更して、平均水飽和度の値を求めます。

str2num(tmp_str(30:35))

私が行ったように、文字を選択せず​​に文字列から数字を抽出する方法がある場合は、アドバイスしてください。

于 2010-08-28T01:45:44.040 に答える