This commit is contained in:
Enrico Fucile 2015-03-25 11:51:12 +00:00
commit 9baba01364
28 changed files with 395 additions and 119 deletions

View File

@ -1,6 +1,6 @@
#examples
GRIB (
!GRIB (
grib_clone
grib_ensemble_index
grib_get_keys
@ -26,9 +26,9 @@ BUFR (
bufr_keys_iterator
bufr_missing
bufr_read_header
bufr_read_scatterometer
bufr_read_synop
bufr_read_temp
bufr_set_keys
bufr_subset
)

View File

@ -10,13 +10,14 @@ use strict;
#The root page of examples in confluence!!!
my $rootPage="Command line tools";
my $unique;
#---------------------------------
# Read arguments
#---------------------------------
#GetOptions("inDir=s" => \$inRootDir)
# or die("Error in command line arguments\n");
GetOptions("unique=s" => \$unique)
or die("Error in command line arguments\n");
#----------------------------------
# Dirs
@ -63,30 +64,36 @@ foreach my $cType (keys %allTools) {
print "--> Genarate parent page\n";
my $parentPage=parentPageTitle($cType);
makeParentPage($rootPage,$parentPage,$htmlDir,$cType,@tools);
unless($unique) {
makeParentPage($rootPage,$parentPage,$htmlDir,$cType,@tools);
}
#--------------------------------
# Loop for the tools
#--------------------------------
foreach my $name (@tools) {
print "-------------------------------\n--> tool: ".$name."\n";
if($unique eq "" or $name eq $unique) {
print "-------------------------------\n--> tool: ".$name."\n";
my $fOut=$htmlDir."/".$cType."_".$name.".html";
open(OUT,">$fOut") or die "$fOut: $!";
my $fOut=$htmlDir."/".$cType."_".$name.".html";
open(OUT,">$fOut") or die "$fOut: $!";
my $str=getDoc($name);
my $str=getDoc($name);
$str=$str.getExample($name);
$str=$str.getExample($name);
print OUT $str;
print OUT $str;
close OUT;
close OUT;
#Upload the file to confluence
my $pageTitle=toolsPageTitle($name);
confUtils::loadToConf($fOut,$pageTitle,$parentPage);
#Upload the file to confluence
my $pageTitle=toolsPageTitle($name);
confUtils::loadToConf($fOut,$pageTitle,$parentPage);
}
}
}
@ -125,7 +132,7 @@ sub read_config {
$line =~ s/\"//g;
my ($a)=($line =~ /(\S+)\s*\(/);
if($a and $a !~ /\!/) {
if($a and ($a !~ /\!/)) {
$actType=$a;
#print "type: ".$a."\n";
#$res{$actType};

View File

@ -20,11 +20,17 @@ BUFR (
bufr_dump
bufr_filter
bufr_get
bufr_index_build
bufr_ls
bufr_set
)
Generic (
!GTS (
gts_copy
gts_dump
gts_filter
gts_ls
)
!Generic (
codes_count desc
codes_info desc
)

View File

@ -41,6 +41,7 @@ list( APPEND test_bins
bufr_keys_iterator
bufr_missing
bufr_read_header
bufr_read_scatterometer
bufr_read_synop
bufr_read_temp
bufr_set_keys
@ -80,6 +81,7 @@ list( APPEND tests
bufr_keys_iterator
bufr_missing
bufr_read_header
bufr_read_scatterometer
bufr_read_synop
bufr_read_temp
bufr_set_keys

View File

@ -22,6 +22,7 @@ TESTS = grib_iterator.sh \
bufr_expanded.sh \
bufr_get_keys.sh \
bufr_read_header.sh \
bufr_read_scatterometer.sh \
bufr_read_synop.sh \
bufr_set_keys.sh \
bufr_subset.sh \
@ -63,6 +64,7 @@ noinst_PROGRAMS = c_grib_nearest \
c_bufr_expanded \
c_bufr_get_keys \
c_bufr_read_header \
c_bufr_read_scatterometer \
c_bufr_read_synop \
c_bufr_get_keys \
c_bufr_subset \
@ -109,6 +111,7 @@ c_bufr_get_keys_SOURCES = bufr_get_keys.c
c_bufr_keys_iterator_SOURCES = bufr_keys_iterator.c
c_bufr_missing_SOURCES = bufr_missing.c
c_bufr_read_header_SOURCES = bufr_read_header.c
c_bufr_read_scatterometer_SOURCES = bufr_read_scatterometer.c
c_bufr_read_synop_SOURCES = bufr_read_synop.c
c_bufr_read_temp_SOURCES = bufr_read_temp.c
c_bufr_set_keys_SOURCES = bufr_set_keys.c

View File

@ -18,7 +18,7 @@
/*
* Please note that SYNOP reports can be encoded in various ways in BUFR. Therefore the code
* below might not work directly for other types of SYNOP messages than the one used in the
* example.
* example. It is advised to use bufr_dump to understand the structure of the messages.
*/
@ -78,18 +78,46 @@ int main(int argc,char* argv[])
/* 2m temperature */
CODES_CHECK(codes_get_double(h,"airTemperatureAt2M",&doubleVal),0);
printf(" airTemperatureAt2M %f\n",doubleVal);
printf(" airTemperatureAt2M: %f\n",doubleVal);
/* 2m dewpoint temperature */
CODES_CHECK(codes_get_double(h,"dewpointTemperatureAt2M",&doubleVal),0);
printf(" dewpointTemperatureAt2M %f\n",doubleVal);
printf(" dewpointTemperatureAt2M: %f\n",doubleVal);
/* 10 wind */
CODES_CHECK(codes_get_double(h,"windSpeedAt10M",&doubleVal),0);
printf(" windSpeedAt10M %f\n",doubleVal);
printf(" windSpeedAt10M: %f\n",doubleVal);
CODES_CHECK(codes_get_double(h,"windDirectionAt10M",&doubleVal),0);
printf(" windDirectionAt10M %f\n",doubleVal);
printf(" windDirectionAt10M: %f\n",doubleVal);
/* The cloud information is stored in several blocks in the
* SYNOP message and the same key means a different thing in different
* parts of the message. In this example we will read the first
* cloud block introduced by the key
* verticalSignificanceSurfaceObservations=1.
* We know that this is the first occurrence of the keys we want to
* read so we will use the # (occurrence) operator accordingly. */
/* Cloud amount (low and middleclouds) */
CODES_CHECK(codes_get_long(h,"cloudAmount#1",&longVal),0);
printf(" cloudAmount (low and middle): %ld\n",longVal);
/* Height of cloud base */
CODES_CHECK(codes_get_long(h,"heightOfBaseOfCloud#1",&longVal),0);
printf(" heightOfBaseOfCloud: %ld\n",longVal);
/* Cloud type (low clouds) */
CODES_CHECK(codes_get_long(h,"cloudType#1",&longVal),0);
printf(" cloudType (low): %ld\n",longVal);
/* Cloud type (middle clouds) */
CODES_CHECK(codes_get_long(h,"cloudType#2",&longVal),0);
printf(" cloudType (middle): %ld\n",longVal);
/* Cloud type (high clouds) */
CODES_CHECK(codes_get_long(h,"cloudType#3",&longVal),0);
printf(" cloudType (high): %ld\n",longVal);
/* delete handle */
codes_handle_delete(h);

View File

@ -24,7 +24,7 @@ rm -f $fTmp | true
REDIRECT=/dev/null
#Write the values into a file and compare with reference
${examples_dir}c_bufr_read_synop 2> $REDIRECT > $fTmp
${examples_dir}c_bufr_read_synop #2> $REDIRECT > $fTmp
#TODO: check the output

View File

@ -14,6 +14,12 @@
* Description: how to read temperature significant levels from TEMP BUFR messages.
*
*/
/*
* Please note that TEMP reports can be encoded in various ways in BUFR. Therefore the code
* below might not work directly for other types of TEMP messages than the one used in the
* example. It is advised to use bufr_dump to understand the structure of the messages.
*/
#include "eccodes.h"
@ -21,11 +27,9 @@ int main(int argc,char* argv[])
{
FILE* in = NULL;
/* message handle. Required in all the eccodes calls acting on a message.*/
/* Message handle. Required in all the eccodes calls acting on a message.*/
codes_handle* h=NULL;
char* units= NULL;
char* unitsPercent= NULL;
double *sigt_pres=NULL, *sigt_geo=NULL, *sigt_t=NULL;
double *sigt_td=NULL;
long longVal;
@ -42,7 +46,7 @@ int main(int argc,char* argv[])
return 1;
}
/* loop over the messages in the bufr file */
/* Loop over the messages in the bufr file */
while ((h = codes_handle_new_from_file(NULL,in,PRODUCT_BUFR,&err)) != NULL || err != CODES_SUCCESS)
{
if (h == NULL) {
@ -53,23 +57,25 @@ int main(int argc,char* argv[])
printf("message: %d\n",cnt);
/* we need to instruct ecCodes to expand the descriptors
/* We need to instruct ecCodes to expand the descriptors
i.e. unpack the data values */
CODES_CHECK(codes_set_long(h,"unpack",1),0);
/* In what follows we rely on the fact that for
temperature significant levels the value of key
verticalSoundingSignificance is 4 (see flag table 8001 for details).
We also make use of the fact that in our BUFR message
verticalSoundingSignificance is always followed by geopotential,
airTemperature, dewpointTemperature,
windDirection, windSpeed and pressure. */
* temperature significant levels the value of key
* verticalSoundingSignificance is 4 (see flag table 8001 for details).
*
* In our BUFR message verticalSoundingSignificance is always followed by
* geopotential, airTemperature, dewpointTemperature,
* windDirection, windSpeed and pressure.
* So in order to access any of these keys we need to use the
* condition: verticalSoundingSignificance=4.
*/
/* Get the number of the temperature significant levels.*/
/* We find out the number of temperature significant levels by
counting how many pressure values we have on these levels. */
* counting how many pressure values we have on these levels.*/
sprintf(key_name,"/verticalSoundingSignificance=4/pressure");
CODES_CHECK(codes_get_size(h,key_name,&sigt_len),0);
@ -77,7 +83,7 @@ int main(int argc,char* argv[])
printf("Number of T significant levels: %ld\n",sigt_len);
/* Allocate memory for the values to be read. Each
parameter must have the same number of values. */
* parameter must have the same number of values. */
sigt_pres = malloc(sigt_len*sizeof(double));
sigt_geo = malloc(sigt_len*sizeof(double));
sigt_t = malloc(sigt_len*sizeof(double));
@ -86,14 +92,14 @@ int main(int argc,char* argv[])
/* Get pressure */
sprintf(key_name,"/verticalSoundingSignificance=4/pressure");
/* get the values */
/* Get the values */
len=sigt_len;
CODES_CHECK(codes_get_double_array(h,key_name,sigt_pres,&len),0);
/* Get geopotential */
sprintf(key_name,"/verticalSoundingSignificance=4/geopotential");
/* check the size*/
/* Check the size*/
CODES_CHECK(codes_get_size(h,key_name,&len),0);
if(len != sigt_len)
{
@ -101,33 +107,33 @@ int main(int argc,char* argv[])
return 1;
}
/* get the values */
/* Get the values */
CODES_CHECK(codes_get_double_array(h,key_name,sigt_geo,&len),0);
/* Get temperature */
sprintf(key_name,"/verticalSoundingSignificance=4/airTemperature");
/* check the size*/
/* Check the size*/
if(len != sigt_len)
{
printf("inconsistent number of temperature values found!\n");
return 1;
}
/* get the values */
/* Get the values */
CODES_CHECK(codes_get_double_array(h,key_name,sigt_t,&len),0);
/* Get dew point */
sprintf(key_name,"/verticalSoundingSignificance=4/dewpointTemperature");
/* check the size*/
/* Check the size*/
if(len != sigt_len)
{
printf("inconsistent number of dewpoint temperature values found!\n");
return 1;
}
/* get the values */
/* Get the values */
CODES_CHECK(codes_get_double_array(h,key_name,sigt_td,&len),0);
/* Print the values */
@ -140,10 +146,10 @@ int main(int argc,char* argv[])
i+1,sigt_pres[i],sigt_geo[i],sigt_t[i],sigt_td[i]);
}
/* delete handle */
/* Delete handle */
codes_handle_delete(h);
/*Release memory*/
/* Release memory */
free(sigt_pres);
free(sigt_geo);
free(sigt_t);

View File

@ -14,8 +14,7 @@
! Please note that SYNOP reports can be encoded in various ways in BUFR. Therefore the code
! below might not work directly for other types of SYNOP messages than the one used in the
! example.
! example. It is advised to bufr_dump to understand the structure of the messages.
!
!
@ -28,6 +27,7 @@ integer :: ibufr
integer :: count=0
integer(kind=4) :: blockNumber,stationNumber
real(kind=8) :: lat,lon,t2m,td2m,ws,wdir
integer(kind=4) :: cloudAmount,cloudBaseHeight,lowCloud,midCloud,highCloud
call codes_open_file(ifile,'../../data/bufr/syno_multi.bufr','r')
@ -74,8 +74,35 @@ real(kind=8) :: lat,lon,t2m,td2m,ws,wdir
write(*,*) ' windSpeedAt10M:',ws
call codes_get(ibufr,'windDirectionAt10M',wdir);
write(*,*) ' windDirectionAt10M',wdir
write(*,*) ' windDirectionAt10M:',wdir
! The cloud information is stored in several blocks in the
! SYNOP message and the same key means a different thing in different
! parts of the message. In this example we will read the first
! cloud block introduced by the key
! verticalSignificanceSurfaceObservations=1.
! We know that this is the first occurrence of the keys we want to
! read so we will use the # (occurrence) operator accordingly.
! Cloud amount (low and middleclouds)
call codes_get(ibufr,'cloudAmount#1',cloudAmount)
write(*,*) ' cloudAmount (low and middle):',cloudAmount
! Height of cloud base
call codes_get(ibufr,'heightOfBaseOfCloud#1',cloudBaseHeight)
write(*,*) ' heightOfBaseOfCloud:',cloudBaseHeight
! Cloud type (low clouds)
call codes_get(ibufr,'cloudType#1',lowCloud)
write(*,*) ' cloudType (low):',lowCloud
! Cloud type (middle clouds)
call codes_get(ibufr,'cloudType#2',midCloud)
write(*,*) ' cloudType (middle):',midCloud
! Cloud type (high clouds)
call codes_get(ibufr,'cloudType#3',highCloud)
write(*,*) ' cloudType (high):',highCloud
! release the bufr message
call codes_release(ibufr)

View File

@ -12,7 +12,10 @@
!
! Description: how to read temperature significant levels from TEMP BUFR messages.
!
!
! Please note that SYNOP reports can be encoded in various ways in BUFR. Therefore the code
! below might not work directly for other types of TEMP messages than the one used in the
! example. It is advised to bufr_dump to understand the structure of the messages.
program bufr_read_temp
use eccodes
implicit none
@ -41,11 +44,13 @@ character(len=128) :: keyName
! In what follows we rely on the fact that for
! temperature significant levels the value of key
! verticalSoundingSignificance is 4 (see flag table 8001 for details).
! We also make use of the fact that in our BUFR message
! verticalSoundingSignificance is always followed by geopotential,
! airTemperature, dewpointTemperature,
! windDirection, windSpeed and pressure.
!
! In our BUFR message verticalSoundingSignificance is always followed by
! geopotential, airTemperature, dewpointTemperature,
! windDirection, windSpeed and pressure.
!
! So in order to access any of these keys we need to use the
! condition: verticalSoundingSignificance=4.
! ---- Get pressure ---------------------------
call codes_get(ibufr,'/verticalSoundingSignificance=4/pressure',presVal);

View File

@ -55,18 +55,20 @@ def example():
#---------------------------------------------------------------
#get the value
key='airTemperatureAt2M'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
# print the values of the attributes of the key. Attributes themselves
# are keys as well. Their name is constructed like:
# keyname->attributename
for attr in attrs:
key='airTemperatureAt2M' + "->" + attr
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
#--------------------------------------------------------------------
# The 2m temperature data element in this message has an associated
@ -76,17 +78,18 @@ def example():
#get the value
key='airTemperatureAt2M->percentConfidence'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
# print the values of the attributes of the key.
for attr in attrs:
key='airTemperatureAt2M->percentConfidence' + "->" + attr
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
cnt+=1

View File

@ -45,27 +45,32 @@ def example():
#----------------------------------------------
#Native type integer
key='blockNumber'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
#Native type integer
key='stationNumber'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
#Native type float
key='airTemperatureAt2M'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
#Native type string
key='typicalDate'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
#---------------------------------
# get values for an array

View File

@ -51,9 +51,11 @@ def example():
# print the values for the selected keys from the message
for key in keys:
if not codes_is_defined(gid,key): raise Exception("Key " + key + " was not defined")
print ' %s: %s' % (key,codes_get(gid,key))
try:
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
cnt+=1
# delete handle

View File

@ -16,10 +16,10 @@ REDIRECT=/dev/null
#Write the values into a file and compare with reference
$PYTHON bufr_read_header.py 2> $REDIRECT > $fRes
#We compare output to the reference by ignoring the whitespaces
#We compare output to the reference by ignoring the whitespaces
diff -w $fRef $fRes >$REDIRECT 2> $REDIRECT
cat $fRes
#cat $fRes
#Clean up
rm -f $fRes

View File

@ -15,7 +15,7 @@
#
# Please note that SYNOP reports can be encoded in various ways in BUFR. Therefore the code
# below might not work directly for other types of SYNOP messages than the one used in the
# example.
# example. It is advised to use bufr_dump to understand the structure of the messages.
#
import traceback
@ -40,9 +40,22 @@ def example():
'airTemperatureAt2M',
'dewpointTemperatureAt2M',
'windSpeedAt10M',
'windDirectionAt10M'
'windDirectionAt10M',
'cloudAmount#1', #cloud amount (low and mid level)
'heightOfBaseOfCloud#1',
'cloudType#1', #cloud type (low clouds)
'cloudType#2', #cloud type (middle clouds)
'cloudType#3' #cloud type (highclouds)
]
# The cloud information is stored in several blocks in the
# SYNOP message and the same key means a different thing in different
# parts of the message. In this example we will read the first
# cloud block introduced by the key
# verticalSignificanceSurfaceObservations=1.
# We know that this is the first occurrence of the keys we want to
# read so in the list above we used the # (occurrence) operator accordingly.
cnt=0
# loop for the messages in the file
@ -60,10 +73,9 @@ def example():
# print the values for the selected keys from the message
for key in keys:
try:
print ' %s: %s' % (key,codes_get(gid,key))
print ' %s: %s' % (key,codes_get(gid,key))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
print err
print 'Error with key="%s" : %s' % (key,err.msg)
cnt+=1

View File

@ -24,7 +24,7 @@ rm -f $fTmp | true
REDIRECT=/dev/null
#Write the values into a file and compare with reference
$PYTHON bufr_read_synop.py #2> $REDIRECT > $fTmp
$PYTHON bufr_read_synop.py 2> $REDIRECT > $fTmp
#TODO: check the output

View File

@ -12,6 +12,10 @@
# Description: how to read temperature significant levels from TEMP BUFR messages.
#
#
# Please note that TEMP reports can be encoded in various ways in BUFR. Therefore the code
# below might not work directly for other types of TEMP messages than the one used in the
# example. It is advised to use bufr_dump to understand the structure of the messages.
#
import traceback
import sys

View File

@ -24,7 +24,7 @@ rm -f $fTmp | true
REDIRECT=/dev/null
#Write the key values into a file
$PYTHON bufr_read_temp.py #2> $REDIRECT > $fTmp
$PYTHON bufr_read_temp.py 2> $REDIRECT > $fTmp
#TODO: check the results

View File

@ -53,10 +53,11 @@ def example():
print ' set bufrHeaderCentre to: %d' % val
key='bufrHeaderCentre'
if not codes_is_defined(gid,key):
raise Exception("Key: " + key + " was not defined")
codes_set(gid,key,val)
try:
print ' %s: %s' % (key,codes_set(gid,key,val))
except CodesInternalError,err:
print 'Error with key="%s" : %s' % (key,err.msg)
#check bufrHeaderCentre's value
print ' %s''s new value is: %d' % (key,codes_get(gid,key))

View File

@ -16,6 +16,15 @@ if( HAVE_PYTHON )
#if( HAVE_PYTHON AND SWIG_FOUND AND PYTHONLIBS_FOUND )
if( HAVE_PYTHON AND PYTHONLIBS_FOUND )
set(PYTHON_DEST "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/eccodes" )
file( RELATIVE_PATH relative_rpath "${CMAKE_INSTALL_PREFIX}/${PYTHON_DEST}" "${${PNAME}_FULL_INSTALL_LIB_DIR}" )
# debug_var( relative_rpath )
ecbuild_append_to_rpath( ${relative_rpath} )
ecbuild_append_to_rpath( "../../lib" ) # for ctest to find the libs
# preparing for generating setup.py -- this may not be needed as cmake can do the swig + shared libs without libtool
if( NUMPY_FOUND )
@ -80,8 +89,6 @@ if( HAVE_PYTHON )
add_custom_target(copy_swig_py ALL DEPENDS ${_swig_py})
#######################
set(PYTHON_DEST "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/eccodes" )
install(TARGETS _gribapi_swig DESTINATION ${PYTHON_DEST} )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gribapi_swig.py DESTINATION ${PYTHON_DEST})

View File

@ -216,6 +216,26 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) {
}
static int str_eq(const char* a, const char* b)
{
if ( a && b && (strcmp(a,b)==0) )
return 1;
return 0;
}
static void dump_codetable(grib_codetable* atable)
{
grib_codetable* next = NULL;
int count = 0;
next=atable;
while(next) {
printf("[%.2d] CodeTable Dump: f0=%s f1=%s\n", count, next->filename[0], next->filename[1]);
count++;
next = next->next;
}
}
static grib_codetable* load_table(grib_accessor_codetable* self)
{
size_t size = 0;
@ -256,13 +276,25 @@ static grib_codetable* load_table(grib_accessor_codetable* self)
localFilename=grib_context_full_defs_path(c,localRecomposed);
}
/*printf("%s: Looking in cache: f=%s lf=%s\n", self->att.name, filename, localFilename);*/
next=c->codetable;
while(next) {
if((filename && next->filename[0] && strcmp(filename,next->filename[0]) == 0) &&
if ((filename && next->filename[0] && strcmp(filename,next->filename[0]) == 0) &&
((localFilename==0 && next->filename[1]==NULL) ||
((localFilename!=0 && next->filename[1]!=NULL)
&& strcmp(localFilename,next->filename[1]) ==0)) )
{
return next;
}
/* Special case: see GRIB-735 */
if (filename==NULL && localFilename!=NULL)
{
if ( str_eq(localFilename, next->filename[0]) ||
str_eq(localFilename, next->filename[1]) )
{
return next;
}
}
next = next->next;
}
@ -277,9 +309,13 @@ static grib_codetable* load_table(grib_accessor_codetable* self)
t = (grib_codetable*)grib_context_malloc_clear_persistent(c,sizeof(grib_codetable) +
(size-1)*sizeof(code_table_entry));
if (filename!=0) grib_load_codetable(c,filename,recomposed,size,t);
if (filename!=0)
grib_load_codetable(c,filename,recomposed,size,t);
if (localFilename!=0) grib_load_codetable(c,localFilename,localRecomposed,size,t);
if (localFilename!=0)
grib_load_codetable(c,localFilename,localRecomposed,size,t);
/*dump_codetable(c->codetable);*/
if (t->filename[0]==NULL && t->filename[1]==NULL) {
grib_context_free_persistent(c,t);
@ -291,11 +327,11 @@ static grib_codetable* load_table(grib_accessor_codetable* self)
}
static int grib_load_codetable(grib_context* c,const char* filename,
const char* recomposed_name,size_t size,grib_codetable* t) {
const char* recomposed_name,size_t size,grib_codetable* t)
{
char line[1024];
FILE *f = NULL;
int lineNumber = 0;
grib_context_log(c,GRIB_LOG_DEBUG,"Loading code table from %s",filename);
f=fopen(filename, "r");
@ -558,11 +594,12 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t *len)
typedef int (*cmpproc)(const char*, const char*);
#ifndef ECCODES_ON_WINDOWS
cmpproc cmp = a->flags | GRIB_ACCESSOR_FLAG_LOWERCASE ? grib_strcasecmp : strcmp;
cmpproc cmp = (a->flags | GRIB_ACCESSOR_FLAG_LOWERCASE) ? grib_strcasecmp : strcmp;
#else
/* Microsoft Windows Visual Studio support */
cmpproc cmp = a->flags | GRIB_ACCESSOR_FLAG_LOWERCASE ? stricmp : strcmp;
cmpproc cmp = (a->flags | GRIB_ACCESSOR_FLAG_LOWERCASE) ? stricmp : strcmp;
#endif
if(!self->table) self->table = load_table(self);
table=self->table;

View File

@ -25,15 +25,14 @@ do
# Test descriptors: compare output of filter (res) with reference file (ref)
res_desc=$file.desc.test
ref_desc=$file.desc.ref
[ -f "$ref_desc" ]
diff_desc=$file.desc.diff
rm -f $res_desc
${tools_dir}bufr_filter bufrdc_desc_ref.filter $file 2> $REDIRECT > $res_desc
diff $ref_desc $res_desc > $diff_desc 2> $diff_desc
if [ -f "$ref_desc" ]; then
diff $ref_desc $res_desc > $diff_desc 2> $diff_desc
fi
rm -f $res_desc $diff_desc
done

View File

@ -30,9 +30,11 @@ do
${tools_dir}bufr_filter bufrdc_num_ref.filter $file 2> $REDIRECT > $res_num
# Cannot use plain diff. We need to compare FLOAT NUMBERS with a tolerance
perl number_compare.pl $ref_num $res_num >$REDIRECT 2> $REDIRECT
#numdiff $ref_num $res_num >$REDIRECT 2> $REDIRECT
if [ -f "$ref_num" ]; then
# Cannot use plain diff. We need to compare FLOAT NUMBERS with a tolerance
perl number_compare.pl $ref_num $res_num >$REDIRECT 2> $REDIRECT
#numdiff $ref_num $res_num >$REDIRECT 2> $REDIRECT
fi
done

View File

@ -1,12 +1,17 @@
#!/bin/sh
set -e
echo "-# To copy only the synop messages from a file\\n"
echo "-# To copy only the SYNOP messages from a file\\n"
echo "\verbatim"
echo "> bufr_copy -w dataCategory=0 in.bufr out.bufr"
echo "\endverbatim\\n"
echo "-# To copy only the non-synop messages from a file\\n"
echo "-# To copy only the non-SYNOP messages from a file\\n"
echo "\verbatim"
echo "> bufr_copy -w dataCategory!=0 in.bufr out.bufr"
echo "\endverbatim\\n"
echo "-# Use the square brackets to insert the value of a key in the name of the output file. \\n"
echo "\verbatim"
echo ">bufr_copy in.bufr out_[dataCategory].bufr "
echo "\endverbatim\\n"

View File

@ -1,8 +1,25 @@
#!/bin/sh
set -e
echo "-# To dump bufr messages into a JSON format.\\n"
echo "-# To dump BUFR messages into a flat JSON format.\\n"
echo "\\verbatim"
echo ">bufr_dump -jf ../data/bufr/aaen_51.bufr"
echo ">bufr_dump -jf ../data/bufr/aaen_55.bufr"
echo "\\endverbatim\\n"
echo "-# To dump BUFR messages into a structured JSON format.\\n"
echo "\\verbatim"
echo ">bufr_dump -js ../data/bufr/aaen_55.bufr"
echo "\\endverbatim\\n"
echo "-# To dump in a WMO documentation style with hexadecimal octet values (-H).\\n"
echo "\\verbatim"
echo ">bufr_dump -OH ../data/bufr/syno_1.bufr"
echo "\\endverbatim\\n"
echo "-# To add key type information (-t).\\n"
echo "\\verbatim"
echo ">bufr_dump -OtH ../data/bufr/syno_1.bufr"
echo "\\endverbatim\\n"

10
tools/bufr_get.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
set -e
echo "-# bufr_get fails if a key is not found.\\n "
echo "\\verbatim "
echo ">bufr_get -p centreName ../data/bufr/syno_1.bufr"
set +e
./grib_get -p gcentreName ../data/bufr/syno_1.bufr
set -e
echo "\\endverbatim "

82
tools/bufr_ls.sh Executable file
View File

@ -0,0 +1,82 @@
#!/bin/sh
#Default options
echo "-# Without options a <b>default list of keys</b> is printed. \\n"
echo "The default list can be different depending on the type of BUFR message. \\n"
echo "\\verbatim "
echo "> bufr_ls ../data/bufr/syno_multi.bufr \\n"
echo "\\endverbatim\\n "
echo "The result is: \\n"
echo "\\verbatim "
./bufr_ls ../data/bufr/syno_multi.bufr
echo "\\endverbatim\\n "
#Wildcards
echo "-# It is allowed to use <b>wildcards</b> in filenames. \\n"
echo "\\verbatim "
echo "> bufr_ls ../data/bufr/syno_*.bufr \\n"
echo "\\endverbatim\\n "
#echo "The result is: \\n"
#echo "\\verbatim "
#./bufr_ls ../data/bufr/syno_*.bufr
#echo "\\endverbatim\\n "
#Custom keys
echo "-# To list only a specific set of keys use the <b>-p</b> option. \\n"
echo "\\verbatim "
echo "> bufr_ls -p totalLength,bufrHeaderCentre,bufrHeaderSubCentre ../data/bufr/syno_multi.bufr \\n"
echo "\\endverbatim\\n "
#echo "The result is: \\n"
#echo "\\verbatim "
#./bufr_ls -p totalLength,bufrHeaderCentre,bufrHeaderSubCentre ../data/bufr/syno_multi.bufr
#echo "\\endverbatim\\n "
#Where
echo "-# To list only a subset of messages use the <b>-w</b> (where option).\\n "
echo "Only the 12 UTC messages are listed with the following line.\\n "
echo "\\verbatim "
echo "> bufr_ls -w typicalTime=\"120000\" ../data/bufr/syno_*.bufr"
#./bufr_ls -w typicalTime="120000" ../data/bufr/syno_*.bufr
echo "\\endverbatim\\n "
#Where
echo "-# All the non-12 UTC messages are listed as follows:\\n "
echo "\\verbatim "
echo "> bufr_ls -w typicalTime!=\"120000\" ../data/bufr/syno_*.bufr"
echo "\\endverbatim\\n "
#echo "The result is: \\n"
#echo "\\verbatim "
#./bufr_ls -w typicalTime!="120000" ../data/bufr/syno_*.bufr
#echo "\\endverbatim\\n "
echo "-# To list only the scond message from a BUFR file:\\n "
echo "\\verbatim "
echo "> bufr_ls -w count=2 ../data/bufr/syno_multi.bufr"
#./bufr_ls -w count=2 ../data/bufr/syno_multi.bufr
echo "\\endverbatim\\n "

6
tools/bufr_set.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
echo "-# Set key <i>bufrHeaderCentre</i> in the header and print its value after the change: \\n"
echo "\\verbatim "
echo "> bufr_set -v -p bufrHeaderCentre -s bufrHeaderCentre=222 ../data/bufr/syno_1.bufr out.bufr \\n"
echo "\\endverbatim\\n "