2016-06-24 11 views
0

変数名を使用してNetCDF GridDatasetからGeoGridオブジェクトを取得するJavaコードがあります。これは正常に動作しますが、NetCDFファイルの入力に対しては、このコードを実行するとエラーが発生します.ncdumpなどの他のツールを使用してNetCDFデータセットの変数を見ることはできますが、GeoGridは見つかりませんおよび/またはデバッガでコードをステップ実行するとき。NetCDF w/Java:変数名検索を使用してGridDatasetからGeoGridを取得できません

NetCDFファイル自体に、変数名の検索を介して変数のグリッドの取得を妨げるものがなければならないと仮定します。 NetCDFファイルを見ると、変数が表示され、PanoplyでGeo2D型として表示されます。ファイルのncdump -h出力は以下の通りです:

File "prism_nidis_pet.nc" 
Dataset type: NetCDF-3/CDM 

netcdf file:/C:/home/prism/prism_nidis_pet.nc { 
    dimensions: 
    lon = 1405; 
    lat = 621; 
    time = UNLIMITED; // (1457 currently 
    variables: 
    int time(time=1457); 
     :long_name = "time"; 
     :standard_name = "time"; 
     :units = "days since 1800-1-1 00:00:00"; 
     :calendar = "gregorian"; 

    float lon(lon=1405); 
     :long_name = "longitude"; 
     :standard_name = "longitude"; 
     :units = "degrees_north"; 

    float lat(lat=621); 
     :long_name = "latitude"; 
     :standard_name = "latitude"; 
     :units = "degrees_west"; 

    float pet(time=1457, lon=1405, lat=621); 
     :calibration_start_year_month = "full"; 
     :calibration_end_year_month = "full"; 
     :_FillValue = -999.9f; // float 
     :missing_value = -999.9f; // float 
     :valid_min = 0.0f; // float 
     :valid_max = 3.4028235E38f; // float 
     :units = "millimeters"; 
     :cell_methods = "time: potential evapotranspiration estimate, Thornthwaite equation"; 
     :long_name = "Potential evapotranspiration estimate, Thornthwaite equation"; 
     :standard_name = "Potential evapotranspiration estimate, Thornthwaite equation"; 

    // global attributes: 
    :date_created = "2016-06-23 11:52:37"; 
    :date_modified = "2016-06-23 11:52:37"; 
    :standard_name_vocabulary = "CF Standard Name Table (v26, 08 November 2013)"; 
    :Conventions = "1.6"; 
    :geospatial_lon_min = -125.0f; // float 
    :geospatial_lon_max = -66.5f; // float 
    :geospatial_lat_min = 24.083334f; // float 
    :geospatial_lat_max = 49.916668f; // float 
} 

は、前述したファイルについて何が「ペット」という名前の変数に関連付けられたジオグリッドを得ることができること妨げるありますか?

以下は、上記のファイルを入力として使用した場合に失敗するコードです。

private GeoGrid getGrid(final String netcdfFile, 
          final String variableName) 
     throws IOException 
    { 
     // open the NetCDF data set 
     GridDataset gridDataset = GridDataset.open(netcdfFile); 

     // verify that we opened the GridDataset 
     if (gridDataset == null) 
     { 
      String errorMessage = "Error opening the NetCDF data set using the file \'" + netcdfFile + "\'"; 
      logger.error(errorMessage); 
      throw new RuntimeException(errorMessage); 
     } 

     // THIS IS WHERE THE PROBLEM OCCURS 
     // get the grid based on the associated variable name 
     GeoGrid geoGrid = gridDataset.findGridByShortName(variableName); 

     // verify that we found the GeoGrid 
     if (geoGrid == null) 
     { 
      String errorMessage = "Error finding the NetCDF grid from the NetCDF file \'" + netcdfFile + "\' using the variable name \'" + variableName + "\'"; 
      logger.error(errorMessage); 
      throw new RuntimeException(errorMessage); 
     } 

     // more code omitted... 
    } 

場合は上記のコードが実行され、引数はnetCDFファイル名と、我々は対応するグリッドを取得しようとしているいることはNetCDF変数名である「ペット」です失敗しました。

ここで何がうまくいかないのでしょうか?ありがとうございます...

答えて

1

経度と緯度変数の単位が悪く見えますが、これは明らかに呼び出しているnetCDF-Javaライブラリコードを台無しにしている可能性があります。あなたのCDLスニペットでは、lonの単位は "degrees_north"で、緯度は "degrees_west"です。おそらくlon "degrees_east"とlat "degrees_north"でなければなりません。

+0

私はあなたにこの点をご理解いただきありがとうございます。明らかに、データセットは何とか転置されたので、私は新しいユニットに注意を払わなかった。ありがとう! –

関連する問題