Re: Errors reading attributes from variables

Daniel Goodman wrote:

Hi
I am using the most up to date libraries. One of the files is attached.

the code fragment is

 public boolean missingValues(Variable v)
 {
   Attribute missing = v.findAttribute("missing_value");

Thanks for your help

Daniel

im not sure what you are seeing. this test is working for me:

 public void testBug() throws java.io.IOException {
NetcdfFile ncfile = new NetcdfFile("C:/data/unknown/2ly7ca.pg.gmts.x3.nc");

   Variable v = null;
   assert(null != (v = ncfile.findVariable("gm_field2max")));
   Attribute att = v.findAttribute("missing_value");
   assert(null != att);
   double val = att.getNumericValue().doubleValue();
   assert close(-1.07374182E9, val): val;

   ncfile.close();
 }

 boolean close( double d1, double d2) {
   return Math.abs((d1-d2)/d1) < 1.0e-5;
 }

you are probably making some simple mistake; check that you are looking at the Variable you think you want.

heres what i get through the ncdump (C library):

$ ncdump -h 2ly7ca.pg.gmts.x3.nc
netcdf 2ly7ca.pg.gmts.x3 {
dimensions:
       time = UNLIMITED ; // (180 currently)
variables:
       double time(time) ;
               time:units = "calendar_month as %Y%m.%f" ;
               time:axis = "T" ;
       float gm_field2max(time) ;
gm_field2max:comment = "Field from ukmo UM model run 2LY7C" ; gm_field2max:long_name = "GLOBAL MEAN U COMPNT OF WIND AFTER TIMESTEP" ;
               gm_field2max:units = "" ;
               gm_field2max:missing_value = -1.073742e+009f ;
               gm_field2max:axis = "T" ;
       float gm_field3max(time) ;
gm_field3max:comment = "Field from ukmo UM model run 2LY7C" ; gm_field3max:long_name = "GLOBAL MEAN V COMPNT OF WIND AFTER TIMESTEP" ;
               gm_field3max:units = "" ;
               gm_field3max:missing_value = -1.073742e+009f ;
               gm_field3max:axis = "T" ;
       float gm_tasmin(time) ;
               gm_tasmin:comment = "Field from ukmo UM model run 2LY7C" ;
gm_tasmin:long_name = "GLOBAL MEAN Daily minimum surface (1.5m) temperature" ;
               gm_tasmin:units = "K" ;
gm_tasmin:level_description = "1.5 meters above earth surface" ;
               gm_tasmin:missing_value = -1.073742e+009f ;
               gm_tasmin:axis = "T" ;
       float gm_tasmax(time) ;
               gm_tasmax:comment = "Field from ukmo UM model run 2LY7C" ;
gm_tasmax:long_name = "GLOBAL MEAN Daily maximum surface (1.5m) temperature" ;
               gm_tasmax:units = "K" ;
gm_tasmax:level_description = "1.5 meters above earth surface" ;
               gm_tasmax:missing_value = -1.073742e+009f ;
               gm_tasmax:axis = "T" ;
       float gm_prmax(time) ;
               gm_prmax:comment = "Field from ukmo UM model run 2LY7C" ;
gm_prmax:long_name = "GLOBAL MEAN Total precipitation rate" ;
               gm_prmax:units = "kg/(m^2*s)" ;
               gm_prmax:level_description = "Earth surface" ;
               gm_prmax:missing_value = -1.073742e+009f ;
               gm_prmax:axis = "T" ;

// global attributes:
               :Conventions = "GDT 1.3" ;
               :appendices = 1 ;
               :calendar = "360" ;
               :production = "lats" ;
               :alpham = 0.57f ;
               :asym_lambda = 0.15f ;
               :charnock = 0.012f ;
               :ct = 0.0001f ;
               :cw_land = 0.0001f ;
               :cw_sea = 2.e-005f ;
:diff_coeff = 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008 f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 4000000.f ; :diff_coeff_q = 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+0 08f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 5.47e+008f, 1.5e+008f, 1.5e+008f, 1.5e+008f, 1.5e+008f, 1.5e+008f, 4000000.f ;
               :diff_exp = "3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 " ;
               :diff_exp_q = "3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 1 " ;
               :dtheta = 0.02f ;
               :dtice = -5.f ;
:eacf = 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.666f, 0.633f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f,
0.6f ;
               :eddydiff = 0.000375f ;
               :entcoef = 9.f ;
               :exptid = "2ly7 " ;
               :g0 = 10.f ;
               :i_cnv_ice_lw = "1 " ;
               :i_cnv_ice_sw = "3 " ;
               :i_st_ice_lw = "1 " ;
               :i_st_ice_sw = "2 " ;
               :ice_size = 2.5e-005f ;
               :kay_gwave = 20000.f ;
               :kay_lee_gwdrag = 300000.f ;
               :r_layers = "4 4 3 3 " ;
:rhcrit = 0.95f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f,
0.9f ;
               :start_level_gwdrag = "3 " ;
               :vf1 = 2.f ;
               :z0fsea = 0.0013f ;
:EXPTURL = "https://climateapps.oucs.ox.ac.uk//cgi-bin/rel2.2//expt/fromfile.pl?file=climate.cont&expt=142990 https://c limateapps.oucs.ox.ac.uk//cgi-bin/rel2.2//expt/fromfile.pl?file=climate.doub&expt=142990 https://climateapps.oucs.ox.ac.uk//cgi-bin/rel 2.2//expt/ncatts.pl?expt=142990 https://climateapps.oucs.ox.ac.uk//cgi-bin/rel2.2//expt/fromfile.pl?file=climate.spin&expt=142990 " ;
               :comment = "blank" ;
               :institution = "climateprediction.net/ukmo" ;
}


heres what i get through the java library:

netcdf C:/data/unknown/2ly7ca.pg.gmts.x3.nc {
dimensions:
  time = UNLIMITED;   // (180 currently)   // (has coord.var)

variables:
  double time(time);
   :units = "calendar_month as %Y%m.%f";
   :axis = "T";
  float gm_field2max(time);
   :comment = "Field from ukmo UM model run 2LY7C";
   :long_name = "GLOBAL MEAN U COMPNT OF WIND AFTER TIMESTEP";
   :units = "";
   :missing_value = -1.07374182E9; // float
   :axis = "T";
  float gm_field3max(time);
   :comment = "Field from ukmo UM model run 2LY7C";
   :long_name = "GLOBAL MEAN V COMPNT OF WIND AFTER TIMESTEP";
   :units = "";
   :missing_value = -1.07374182E9; // float
   :axis = "T";
  float gm_tasmin(time);
   :comment = "Field from ukmo UM model run 2LY7C";
   :long_name = "GLOBAL MEAN Daily minimum surface (1.5m) temperature";
   :units = "K";
   :level_description = "1.5 meters above earth surface";
   :missing_value = -1.07374182E9; // float
   :axis = "T";
  float gm_tasmax(time);
   :comment = "Field from ukmo UM model run 2LY7C";
   :long_name = "GLOBAL MEAN Daily maximum surface (1.5m) temperature";
   :units = "K";
   :level_description = "1.5 meters above earth surface";
   :missing_value = -1.07374182E9; // float
   :axis = "T";
  float gm_prmax(time);
   :comment = "Field from ukmo UM model run 2LY7C";
   :long_name = "GLOBAL MEAN Total precipitation rate";
   :units = "kg/(m^2*s)";
   :level_description = "Earth surface";
   :missing_value = -1.07374182E9; // float
   :axis = "T";

// Global Attributes:
   :Conventions = "GDT 1.3";
   :appendices = 1; // int
   :calendar = "360";
   :production = "lats";
   :alpham = 0.57; // float
   :asym_lambda = 0.15; // float
   :charnock = 0.012; // float
   :ct = 1.0E-4; // float
   :cw_land = 1.0E-4; // float
   :cw_sea = 2.0E-5; // float
:diff_coeff = 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 4000000.0; // float :diff_coeff_q = 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 5.47E8, 1.5E8, 1.5E8, 1.5E8, 1.5E8, 1.5E8, 4000000.0; // float
   :diff_exp = "3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 ";
   :diff_exp_q = "3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 1 ";
   :dtheta = 0.02; // float
   :dtice = -5.0; // float
:eacf = 0.7, 0.7, 0.7, 0.7, 0.7, 0.666, 0.633, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6; // float
   :eddydiff = 3.75E-4; // float
   :entcoef = 9.0; // float
   :exptid = "2ly7 ";
   :g0 = 10.0; // float
   :i_cnv_ice_lw = "1 ";
   :i_cnv_ice_sw = "3 ";
   :i_st_ice_lw = "1 ";
   :i_st_ice_sw = "2 ";
   :ice_size = 2.5E-5; // float
   :kay_gwave = 20000.0; // float
   :kay_lee_gwdrag = 300000.0; // float
   :r_layers = "4 4 3 3 ";
:rhcrit = 0.95, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9; // float
   :start_level_gwdrag = "3 ";
   :vf1 = 2.0; // float
   :z0fsea = 0.0013; // float
:EXPTURL = "https://climateapps.oucs.ox.ac.uk//cgi-bin/rel2.2//expt/fromfile.pl?file=climate.cont&expt=142990 https://climateapps.oucs.ox.ac.uk//cgi-bin/rel2.2//expt/fromfile.pl?file=climate.doub&expt=142990 https://climateapps.oucs.ox.ac.uk//cgi-bin/rel2.2//expt/ncatts.pl?expt=142990 https://climateapps.oucs.ox.ac.uk//cgi-bin/rel2.2//expt/fromfile.pl?file=climate.spin&expt=142990 ";
   :comment = "blank";
   :institution = "climateprediction.net/ukmo";

}



  • 2004 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: