[netcdf-java] read a BUFR file and get values

Hi,
I've many bufr files to read, I'm using your java library and I've just
followed your example on:

http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/reference/C
ookbook.html#readSequences

but with version 4.2+ I've this error:

13:34:23,007 INFO  [stdout] (default task-1)  TableLookup cant find Table B
descriptor = 0-30-196 in tables none, wmo.v13.composite mode=wmoOnly
13:34:23,008 INFO  [stdout] (default task-1)  TableLookup cant find Table B
descriptor = 0-29-201 in tables none, wmo.v13.composite mode=wmoOnly
13:34:23,008 INFO  [stdout] (default task-1)  TableLookup cant find Table B
descriptor = 0-29-193 in tables none, wmo.v13.composite mode=wmoOnly
13:34:23,009 INFO  [stdout] (default task-1)  TableLookup cant find Table B
descriptor = 0-29-194 in tables none, wmo.v13.composite mode=wmoOnly
13:34:23,009 INFO  [stdout] (default task-1)  TableLookup cant find Table B
descriptor = 0-29-195 in tables none, wmo.v13.composite mode=wmoOnly
13:34:23,010 INFO  [stdout] (default task-1)  TableLookup cant find Table B
descriptor = 0-29-196 in tables none, wmo.v13.composite mode=wmoOnly
13:34:23,010 INFO  [stdout] (default task-1)  TableLookup cant find Table B
descriptor = 0-29-199 in tables none, wmo.v13.composite mode=wmoOnly
13:34:23,011 INFO  [stdout] (default task-1)  TableLookup cant find Table B
descriptor = 0-29-200 in tables none, wmo.v13.composite mode=wmoOnly
13:34:23,011 INFO  [stdout] (default task-1)  TableLookup cant find Table D
descriptor 3-21-250 in tables
none,resource:/resources/bufrTables/wmo/TableD-121509.csv mode=wmoOnly
13:34:23,011 INFO  [stdout] (default task-1)  TableLookup cant find Table D
descriptor 3-21-193 in tables
none,resource:/resources/bufrTables/wmo/TableD-121509.csv mode=wmoOnly
13:34:23,012 INFO  [stdout] (default task-1) Exception: BUFR file has
incomplete tables
13:34:23,013 ERROR [stderr] (default task-1)
java.lang.IllegalStateException: BUFR file has incomplete tables
13:34:23,013 ERROR [stderr] (default task-1)    at
ucar.nc2.iosp.bufr.BufrIosp.open(BufrIosp.java:99)
13:34:23,013 ERROR [stderr] (default task-1)    at
ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:1439)
13:34:23,014 ERROR [stderr] (default task-1)    at
ucar.nc2.NetcdfFile.open(NetcdfFile.java:846)
13:34:23,014 ERROR [stderr] (default task-1)    at
ucar.nc2.NetcdfFile.open(NetcdfFile.java:479)
13:34:23,014 ERROR [stderr] (default task-1)    at
ucar.nc2.NetcdfFile.open(NetcdfFile.java:449)
13:34:23,014 ERROR [stderr] (default task-1)    at
ucar.nc2.NetcdfFile.open(NetcdfFile.java:436)
13:34:23,015 ERROR [stderr] (default task-1)    at
ucar.nc2.NetcdfFile.open(NetcdfFile.java:424)

So I've taken your sources of 4.2 version (I've not found sources of latest
version...) and I've modified them to try to read these my bufr files, but
even if I'm able to read description of BUFR content I'm not able to read
data section. I've just tried with your 4.3+ version but I've the same
error.

I'm trying to test this code to get values but I've zero returns:


           NetcdfFile ncfile = NetcdfFile.open(filename);

           Variable fvar = ncfile.findVariable("obs."+innerSeq);
            
            Array uhm =null;
            
            if (fvar!=null)
              uhm= fvar.read();
            
            Object uhmstr = null;
            
            if (uhm!=null)
              uhmstr =uhm.copyToNDJavaArray();
            
 
            DataType dtt = tmp_.getDataType();
            
            try
            {
            if (dtt.name().equalsIgnoreCase("int"))
            {
              pw.println(((int[])uhmstr)[0]);
            }
            else if (dtt.name().equalsIgnoreCase("byte"))
            {
              pw.println(((byte[])uhmstr)[0]);
            }
            else if (dtt.name().equalsIgnoreCase("short"))
            {
              pw.println(((short[])uhmstr)[0]);
            }
            else if (dtt.name().equalsIgnoreCase("char"))
            {
              pw.println(((char[])uhmstr)[0]);
            }
            else if (dtt.name().equalsIgnoreCase("double"))
            {
              pw.println(((double[])uhmstr)[0]);
            }
            }
            catch (Exception e)
            {
              ;
            }


The CDL (readed from debug) is: 


netcdf D:\01-03-2014-09-00_R_SRI_@@@@_@@@@.BUFR {
 types:
  enum 0-29-2 { 'Cartesian' = 0, 'Polar' = 1, 'Other' = 2, 'Missing value' =
7};
  enum 0-30-31 { 'PPI' = 0, 'Composite' = 1, 'CAPPl' = 2, 'Vertical section'
= 3, 'Alphanumeric data' = 4, 'Map of subject clutter' = 5, 'Map' = 6, 'Test
picture' = 7, 'Comments' = 8, 'Map of ground occultation' = 9, 'Map of radar
beam height' = 10, 'Other' = 14, 'Missing value' = 15};
  enum 0-33-3 { 'Data not suspect' = 0, 'Data slightly suspect' = 1, 'Data
highly suspect' = 2, 'Data considered unfit for use' = 3, 'Quality
information not given' = 7};

 variables:

   Sequence {
     int time;
       :units = "minutes since 2014-03-01T09:00:00Z";
       :long_name = "time of observation";
       :_CoordinateAxisType = "Time";
     byte WMO block number;
       :missing_value = 127B; // byte
       :BUFR:TableB_descriptor = "0-1-1";
       :BUFR:bitWidth = 7; // int
     short WMO station number;
       :missing_value = 1023S; // short
       :standard_name = "station_WMO_id";
       :BUFR:TableB_descriptor = "0-1-2";
       :BUFR:bitWidth = 10; // int
     short Year;
       :units = "Year";
       :missing_value = 4095S; // short
       :BUFR:TableB_descriptor = "0-4-1";
       :BUFR:bitWidth = 12; // int
     byte Month;
       :units = "Month";
       :missing_value = 15B; // byte
       :BUFR:TableB_descriptor = "0-4-2";
       :BUFR:bitWidth = 4; // int
     byte Day;
       :units = "Day";
       :missing_value = 63B; // byte
       :BUFR:TableB_descriptor = "0-4-3";
       :BUFR:bitWidth = 6; // int
     byte Hour;
       :units = "Hour";
       :missing_value = 31B; // byte
       :BUFR:TableB_descriptor = "0-4-4";
       :BUFR:bitWidth = 5; // int
     byte Minute;
       :units = "Minute";
       :missing_value = 63B; // byte
       :BUFR:TableB_descriptor = "0-4-5";
       :BUFR:bitWidth = 6; // int
     byte *NOT FOUND;
       :missing_value = 0B; // byte
       :BUFR:TableB_descriptor = "0-30-196";
       :BUFR:bitWidth = 0; // int
     short Latitude (coarse accuracy);
       :units = "degrees_north";
       :missing_value = 32767S; // short
       :scale_factor = 0.01f; // float
       :add_offset = -90.0f; // float
       :_CoordinateAxisType = "Lat";
       :BUFR:TableB_descriptor = "0-5-2";
       :BUFR:bitWidth = 15; // int
     short Longitude (coarse accuracy);
       :units = "degrees_east";
       :_Unsigned = "true";
       :missing_value = 65535L; // long
       :scale_factor = 0.01f; // float
       :add_offset = -180.0f; // float
       :_CoordinateAxisType = "Lon";
       :BUFR:TableB_descriptor = "0-6-2";
       :BUFR:bitWidth = 16; // int
     short Latitude (coarse accuracy)-1;
       :units = "degrees_north";
       :missing_value = 32767S; // short
       :scale_factor = 0.01f; // float
       :add_offset = -90.0f; // float
       :_CoordinateAxisType = "Lat";
       :BUFR:TableB_descriptor = "0-5-2";
       :BUFR:bitWidth = 15; // int
     short Longitude (coarse accuracy)-1;
       :units = "degrees_east";
       :_Unsigned = "true";
       :missing_value = 65535L; // long
       :scale_factor = 0.01f; // float
       :add_offset = -180.0f; // float
       :_CoordinateAxisType = "Lon";
       :BUFR:TableB_descriptor = "0-6-2";
       :BUFR:bitWidth = 16; // int
     short Latitude (coarse accuracy)-2;
       :units = "degrees_north";
       :missing_value = 32767S; // short
       :scale_factor = 0.01f; // float
       :add_offset = -90.0f; // float
       :_CoordinateAxisType = "Lat";
       :BUFR:TableB_descriptor = "0-5-2";
       :BUFR:bitWidth = 15; // int
     short Longitude (coarse accuracy)-2;
       :units = "degrees_east";
       :_Unsigned = "true";
       :missing_value = 65535L; // long
       :scale_factor = 0.01f; // float
       :add_offset = -180.0f; // float
       :_CoordinateAxisType = "Lon";
       :BUFR:TableB_descriptor = "0-6-2";
       :BUFR:bitWidth = 16; // int
     short Latitude (coarse accuracy)-3;
       :units = "degrees_north";
       :missing_value = 32767S; // short
       :scale_factor = 0.01f; // float
       :add_offset = -90.0f; // float
       :_CoordinateAxisType = "Lat";
       :BUFR:TableB_descriptor = "0-5-2";
       :BUFR:bitWidth = 15; // int
     short Longitude (coarse accuracy)-3;
       :units = "degrees_east";
       :_Unsigned = "true";
       :missing_value = 65535L; // long
       :scale_factor = 0.01f; // float
       :add_offset = -180.0f; // float
       :_CoordinateAxisType = "Lon";
       :BUFR:TableB_descriptor = "0-6-2";
       :BUFR:bitWidth = 16; // int
     short Number of pixels per column;
       :missing_value = 4095S; // short
       :BUFR:TableB_descriptor = "0-30-22";
       :BUFR:bitWidth = 12; // int
     short Number of pixels per row;
       :missing_value = 4095S; // short
       :BUFR:TableB_descriptor = "0-30-21";
       :BUFR:bitWidth = 12; // int
     short Pixel size on horizontal - 1;
       :units = "m";
       :_Unsigned = "true";
       :missing_value = 65535L; // long
       :scale_factor = 10.0f; // float
       :BUFR:TableB_descriptor = "0-5-33";
       :BUFR:bitWidth = 16; // int
     short Pixel size on horizontal - 2;
       :units = "m";
       :_Unsigned = "true";
       :missing_value = 65535L; // long
       :scale_factor = 10.0f; // float
       :BUFR:TableB_descriptor = "0-6-33";
       :BUFR:bitWidth = 16; // int
     byte *NOT FOUND-1;
       :missing_value = 0B; // byte
       :BUFR:TableB_descriptor = "0-29-201";
       :BUFR:bitWidth = 0; // int
     byte *NOT FOUND-2;
       :missing_value = 0B; // byte
       :BUFR:TableB_descriptor = "0-29-193";
       :BUFR:bitWidth = 0; // int
     byte *NOT FOUND-3;
       :missing_value = 0B; // byte
       :BUFR:TableB_descriptor = "0-29-194";
       :BUFR:bitWidth = 0; // int
     byte *NOT FOUND-4;
       :missing_value = 0B; // byte
       :BUFR:TableB_descriptor = "0-29-195";
       :BUFR:bitWidth = 0; // int
     byte *NOT FOUND-5;
       :missing_value = 0B; // byte
       :BUFR:TableB_descriptor = "0-29-196";
       :BUFR:bitWidth = 0; // int
     byte *NOT FOUND-6;
       :missing_value = 0B; // byte
       :BUFR:TableB_descriptor = "0-29-199";
       :BUFR:bitWidth = 0; // int
     byte *NOT FOUND-7;
       :missing_value = 0B; // byte
       :BUFR:TableB_descriptor = "0-29-200";
       :BUFR:bitWidth = 0; // int
     enum 0-29-2 Co-ordinate grid type;
       :units = "CodeTable 0-29-2";
       :BUFR:CodeTable = "0-29-2 (0-29-2)";
       :BUFR:TableB_descriptor = "0-29-2";
       :BUFR:bitWidth = 3; // int
     enum 0-30-31 Picture type;
       :units = "CodeTable 0-30-31";
       :BUFR:CodeTable = "0-30-31 (0-30-31)";
       :BUFR:TableB_descriptor = "0-30-31";
       :BUFR:bitWidth = 4; // int
     enum 0-33-3 Quality information;
       :units = "CodeTable 0-33-3";
       :BUFR:CodeTable = "0-33-3 (0-33-3)";
       :BUFR:TableB_descriptor = "0-33-3";
       :BUFR:bitWidth = 3; // int
     short Radar rainfall intensity;
       :units = "m s-1";
       :missing_value = 4095S; // short
       :scale_factor = 1.0E-7f; // float
       :BUFR:TableB_descriptor = "0-21-36";
       :BUFR:bitWidth = 12; // int

     Sequence {
       short Radar rainfall intensity;
         :units = "m s-1";
         :missing_value = 4095S; // short
         :scale_factor = 1.0E-7f; // float
         :BUFR:TableB_descriptor = "0-21-36";
         :BUFR:bitWidth = 12; // int
     } seq1;

   } obs(*);


 :history = "Direct read of BUFR data by CDM version 4.1";
 :location = "D:\\01-03-2014-09-00_R_SRI_@@@@_@@@@.BUFR";
 :BUFR:edition = 3; // int
 :BUFR:categoryName = "Radar data";
 :BUFR:category = 6; // int
 :BUFR:subCategory = 0; // int
 :BUFR:localSubCategory = -1; // int
 :BUFR:centerName = "255.255 (Missing value)";
 :BUFR:center = 255; // int
 :BUFR:subCenter = 255; // int
 :BUFR:table = 0; // int
 :BUFR:tableVersion = 11; // int
 :BUFR:localTableVersion = 6; // int
 :WMO Header = "";
 :Conventions = "BUFR/CDM";
}


I've just tested my code with another file found on the net here and it
works:

https://groups.google.com/group/nctoolbox/attach/b16b17201b1484e6/5900.20030
601.surface?part=4

but with my files I've zero values. I've attached one of my files in this
mail.

Thanks in advance for your replies!

Gianfranco

 
 
 --
 Z-Light e Z-Pro: servizi zimbra per caselle con dominio email.it, per tutti i 
dettagli 
Clicca qui 
http://posta.email.it/caselle-di-posta-email-it/?utm_campaign=email_Zlight_Pro&utm_source=footer/f
 
 Sponsor:
 Outlet Casa e cucina: tanti prodotti a prezzi scontatissimi, sopri di piu'
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=13289&d=7-4

Attachment: 01-03-2014-00-00_R_SRI_@@@@_@@@@.BUFR
Description: Binary data

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