mirror of https://github.com/ecmwf/eccodes.git
ECC-86: Rename all grib related API examples (Part 12)
This commit is contained in:
commit
a21744156d
|
@ -1,6 +1,6 @@
|
|||
#examples
|
||||
|
||||
GRIB (
|
||||
!GRIB (
|
||||
grib_clone
|
||||
grib_ensemble_index
|
||||
grib_get_keys
|
||||
|
@ -18,7 +18,7 @@ GRIB (
|
|||
set_pv
|
||||
grib_set_keys
|
||||
)
|
||||
!BUFR (
|
||||
BUFR (
|
||||
bufr_attributes
|
||||
bufr_clone
|
||||
bufr_expanded
|
||||
|
@ -27,6 +27,7 @@ GRIB (
|
|||
bufr_missing
|
||||
bufr_print_header
|
||||
bufr_print_data
|
||||
bufr_read_temp
|
||||
bufr_set_keys
|
||||
bufr_subset
|
||||
)
|
||||
|
|
|
@ -15,6 +15,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "eccodes.h"
|
||||
|
||||
void usage(char* prog) {
|
||||
|
@ -55,20 +62,35 @@ int main(int argc,char* argv[])
|
|||
/* we need to instruct ecCodes to unpack the data values */
|
||||
CODES_CHECK(codes_set_long(h,"unpack",1),0);
|
||||
|
||||
/* read and print some data values. This example was written for a SYNOP
|
||||
BUFR file!! */
|
||||
|
||||
/* station id*/
|
||||
CODES_CHECK(codes_get_long(h,"blockNumber",&longVal),0);
|
||||
printf(" blockNumber: %ld\n",longVal);
|
||||
|
||||
CODES_CHECK(codes_get_long(h,"stationNumber",&longVal),0);
|
||||
printf(" stationNumber: %ld\n",longVal);
|
||||
|
||||
/* in the current BUFR message this key represents the 2m temperature.
|
||||
it might not be available in other type of SYNOP messages */
|
||||
/* location*/
|
||||
CODES_CHECK(codes_get_double(h,"latitude",&doubleVal),0);
|
||||
printf(" latitude: %f\n",doubleVal);
|
||||
|
||||
CODES_CHECK(codes_get_double(h,"longitude",&doubleVal),0);
|
||||
printf(" longitude: %f\n",doubleVal);
|
||||
|
||||
/* 2m temperature */
|
||||
CODES_CHECK(codes_get_double(h,"airTemperatureAt2M",&doubleVal),0);
|
||||
printf(" airTemperatureAt2M %f\n",doubleVal);
|
||||
|
||||
/* 2m dewpoint temperature */
|
||||
CODES_CHECK(codes_get_double(h,"dewpointTemperatureAt2M",&doubleVal),0);
|
||||
printf(" dewpointTemperatureAt2M %f\n",doubleVal);
|
||||
|
||||
/* 10 wind */
|
||||
CODES_CHECK(codes_get_double(h,"windSpeedAt10M",&doubleVal),0);
|
||||
printf(" windSpeedAt10M %f\n",doubleVal);
|
||||
|
||||
CODES_CHECK(codes_get_double(h,"windDirectionAt10M",&doubleVal),0);
|
||||
printf(" windDirectionAt10M %f\n",doubleVal);
|
||||
|
||||
/* delete handle */
|
||||
codes_handle_delete(h);
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ list( APPEND tests
|
|||
bufr_expanded
|
||||
bufr_get_keys
|
||||
bufr_keys_iterator
|
||||
bufr_print_header
|
||||
bufr_print_data
|
||||
bufr_read_header
|
||||
bufr_read_synop
|
||||
bufr_read_temp
|
||||
bufr_set_keys
|
||||
bufr_subset
|
||||
|
|
|
@ -5,15 +5,15 @@ TESTS = copy_message.sh grib_get_keys.sh get_data.sh get_pl.sh get_pv.sh grib_ke
|
|||
grib_nearest.sh precision.sh multi_write.sh multi.sh grib_print_data.sh grib_set_keys.sh \
|
||||
grib_set_bitmap.sh set_missing.sh set_pv.sh samples.sh count_messages.sh read_message.sh \
|
||||
read_from_file.sh index.sh get_set_uuid.sh bufr_attributes.sh bufr_clone.sh \
|
||||
bufr_expanded.sh bufr_get_keys.sh bufr_print_header.sh bufr_print_data.sh \
|
||||
bufr_expanded.sh bufr_get_keys.sh bufr_read_header.sh bufr_read_synop.sh \
|
||||
bufr_set_keys.sh bufr_keys_iterator.sh bufr_subset.sh get_product_kind.sh bufr_read_temp.sh
|
||||
|
||||
noinst_PROGRAMS = f_index f_copy_message f_grib_get_keys f_get_data f_get_pl f_get_pv f_grib_keys_iterator \
|
||||
f_multi_write f_multi f_grib_nearest f_precision f_grib_print_data f_grib_set_keys \
|
||||
f_grib_set_bitmap f_set_missing f_set_pv f_samples f_count_messages f_read_message \
|
||||
f_read_from_file f_new_from_file f_copy_namespace f_get_set_uuid f_set_gvc \
|
||||
f_grib_clone f_bufr_clone f_bufr_expanded f_bufr_get_keys f_bufr_print_header \
|
||||
f_bufr_print_data f_bufr_set_keys f_bufr_keys_iterator f_bufr_subset f_bufr_attributes \
|
||||
f_grib_clone f_bufr_clone f_bufr_expanded f_bufr_get_keys f_bufr_read_header \
|
||||
f_bufr_read_synop f_bufr_set_keys f_bufr_keys_iterator f_bufr_subset f_bufr_attributes \
|
||||
f_get_product_kind f_bufr_read_temp
|
||||
|
||||
f_index_SOURCES=index.f90
|
||||
|
@ -46,8 +46,8 @@ f_bufr_clone_SOURCES=bufr_clone.f90
|
|||
f_bufr_expanded_SOURCES=bufr_expanded.f90
|
||||
f_bufr_get_keys_SOURCES=bufr_get_keys.f90
|
||||
f_bufr_keys_iterator_SOURCES=bufr_keys_iterator.f90
|
||||
f_bufr_print_header_SOURCES=bufr_print_header.f90
|
||||
f_bufr_print_data_SOURCES=bufr_print_data.f90
|
||||
f_bufr_read_header_SOURCES=bufr_read_header.f90
|
||||
f_bufr_read_synop_SOURCES=bufr_read_synop.f90
|
||||
f_bufr_read_temp_SOURCES=bufr_read_temp.f90
|
||||
f_bufr_set_keys_SOURCES=bufr_set_keys.f90
|
||||
f_bufr_subset_SOURCES=bufr_subset.f90
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
! Description: how to read the header of BUFR messages.
|
||||
!
|
||||
!
|
||||
program bufr_print_header
|
||||
program bufr_read_header
|
||||
use eccodes
|
||||
implicit none
|
||||
integer :: ifile
|
||||
|
@ -74,4 +74,4 @@ integer(kind=4) :: numberofsubsets
|
|||
call codes_close_file(ifile)
|
||||
|
||||
|
||||
end program bufr_print_header
|
||||
end program bufr_read_header
|
|
@ -10,7 +10,7 @@
|
|||
. ./include.sh
|
||||
|
||||
#Define a common label for all the tmp files
|
||||
label="bufr_print_header_test_f"
|
||||
label="bufr_read_header_test_f"
|
||||
|
||||
#Prepare tmp file
|
||||
fTmp=${label}.tmp.txt
|
||||
|
@ -27,7 +27,7 @@ fRef=${f}.header.ref
|
|||
REDIRECT=/dev/null
|
||||
|
||||
#Write the values into a file and compare with reference
|
||||
${examples_dir}/f_bufr_print_header $f 2> $REDIRECT > $fTmp
|
||||
${examples_dir}/f_bufr_read_header $f 2> $REDIRECT > $fTmp
|
||||
|
||||
#We compare output to the reference by ignoring the whitespaces
|
||||
diff -w $fRef $fTmp >$REDIRECT 2> $REDIRECT
|
|
@ -8,12 +8,18 @@
|
|||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
!
|
||||
!
|
||||
! FOTRAN 90 Implementation: bufr_print_data
|
||||
! FOTRAN 90 Implementation: bufr_read_synop
|
||||
!
|
||||
! Description: how to read data values from BUFR messages.
|
||||
! Description: how to read SYNOP 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 SYNOP messages than the one used in the
|
||||
! example.
|
||||
|
||||
|
||||
!
|
||||
!
|
||||
program bufr_print_data
|
||||
program bufr_read_synop
|
||||
use eccodes
|
||||
implicit none
|
||||
integer :: ifile
|
||||
|
@ -21,7 +27,7 @@ integer :: iret
|
|||
integer :: ibufr
|
||||
integer :: count=0
|
||||
integer(kind=4) :: blockNumber,stationNumber
|
||||
real(kind=8) :: t2m
|
||||
real(kind=8) :: lat,lon,t2m,td2m,ws,wdir
|
||||
|
||||
call codes_open_file(ifile,'../../data/bufr/syno_multi.bufr','r')
|
||||
|
||||
|
@ -35,24 +41,42 @@ real(kind=8) :: t2m
|
|||
|
||||
! we need to instruct ecCodes to expand all the descriptors
|
||||
! i.e. unpack the data values
|
||||
call codes_set(ibufr,"unpack",1);
|
||||
call codes_set(ibufr,"unpack",1)
|
||||
|
||||
!read and print some data values. This example was written
|
||||
! for a SYNOP BUFR file!
|
||||
|
||||
! get wmo block number
|
||||
call codes_get(ibufr,'blockNumber',blockNumber);
|
||||
! wmo block number
|
||||
call codes_get(ibufr,'blockNumber',blockNumber)
|
||||
write(*,*) ' blockNumber:',blockNumber
|
||||
|
||||
! get station number
|
||||
call codes_get(ibufr,'stationNumber',stationNumber);
|
||||
! station number
|
||||
call codes_get(ibufr,'stationNumber',stationNumber)
|
||||
write(*,*) ' stationNumber:',stationNumber
|
||||
|
||||
! in the current BUFR message this key represents the 2m temperature.
|
||||
! it might not be available in other type of SYNOP messages
|
||||
! location
|
||||
call codes_get(ibufr,'latitude',lat)
|
||||
write(*,*) ' latitude:',lat
|
||||
|
||||
call codes_get(ibufr,'longitude',lat)
|
||||
write(*,*) ' longitude:',lat
|
||||
|
||||
! 2m temperature
|
||||
call codes_get(ibufr,'airTemperatureAt2M',t2m);
|
||||
write(*,*) ' airTemperatureAt2M:',t2m
|
||||
|
||||
! 2m dewpoint temperature
|
||||
call codes_get(ibufr,'dewpointTemperatureAt2M',td2m);
|
||||
write(*,*) ' dewpointTemperatureAt2M:',td2m
|
||||
|
||||
! 10m wind
|
||||
call codes_get(ibufr,'windSpeedAt10M',ws);
|
||||
write(*,*) ' windSpeedAt10M:',ws
|
||||
|
||||
call codes_get(ibufr,'windDirectionAt10M',wdir);
|
||||
write(*,*) ' windDirectionAt10M',wdir
|
||||
|
||||
|
||||
! release the bufr message
|
||||
call codes_release(ibufr)
|
||||
|
||||
|
@ -67,4 +91,5 @@ real(kind=8) :: t2m
|
|||
call codes_close_file(ifile)
|
||||
|
||||
|
||||
end program bufr_print_data
|
||||
end program bufr_read_synop
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
|
||||
#Define a common label for all the tmp files
|
||||
label="bufr_print_data_test_f"
|
||||
label="bufr_read_synop_test_f"
|
||||
|
||||
#Define tmp file
|
||||
fTmp=${label}".tmp.txt"
|
||||
|
@ -24,7 +24,7 @@ rm -f $fTmp | true
|
|||
REDIRECT=/dev/null
|
||||
|
||||
#Write the values into a file and compare with reference
|
||||
${examples_dir}/f_bufr_print_data 2> $REDIRECT > $fTmp
|
||||
${examples_dir}/f_bufr_read_synop #2> $REDIRECT > $fTmp
|
||||
|
||||
#TODO: check the output
|
||||
|
|
@ -44,8 +44,8 @@ list( APPEND tests
|
|||
bufr_expanded
|
||||
bufr_get_keys
|
||||
bufr_keys_iterator
|
||||
bufr_print_header
|
||||
bufr_print_data
|
||||
bufr_read_header
|
||||
bufr_read_synop
|
||||
bufr_read_temp
|
||||
bufr_set_keys
|
||||
bufr_subset
|
||||
|
|
|
@ -4,7 +4,7 @@ AM_CFLAGS = @WARN_PEDANTIC@ @WERROR@
|
|||
TESTS = grib_clone.sh count_messages.sh grib_get_keys.sh index.sh grib_iterator.sh \
|
||||
grib_keys_iterator.sh multi_write.sh grib_nearest.sh grib_print_data.sh \
|
||||
samples.sh grib_set_keys.sh set_missing.sh binary_message.sh grib_set_bitmap.sh \
|
||||
bufr_print_header.sh bufr_print_data.sh bufr_clone.sh bufr_get_keys.sh \
|
||||
bufr_read_header.sh bufr_read_synop.sh bufr_clone.sh bufr_get_keys.sh \
|
||||
bufr_set_keys.sh bufr_expanded.sh bufr_keys_iterator.sh bufr_subset.sh \
|
||||
bufr_attributes.sh get_product_kind.sh bufr_read_temp.sh
|
||||
TESTS_ENVIRONMENT = TOPBUILDDIR=$(top_builddir) PYTHON=$(PYTHON)
|
||||
|
@ -18,11 +18,12 @@ INCLUDES = -I$(top_builddir)/src
|
|||
LDADD = $(top_builddir)/src/libeccodes.la
|
||||
DEPENDENCIES = $(LDADD)
|
||||
|
||||
<<<<<<< HEAD
|
||||
EXTRA_DIST = $(TESTS) include.sh grib_clone.py count_messages.py grib_get_keys.py index.py \
|
||||
grib_iterator.py grib_keys_iterator.py multi_write.py \
|
||||
grib_nearest.py grib_print_data.py samples.py grib_set_keys.py \
|
||||
set_missing.py binary_message.py set_pv.py grib_set_bitmap.py \
|
||||
bufr_print_header.py bufr_print_data.py \
|
||||
bufr_read_header.py bufr_read_synop.py \
|
||||
bufr_clone.py bufr_get_keys.py bufr_set_keys.py \
|
||||
bufr_expanded.py bufr_keys_iterator.py bufr_subset.py bufr_attributes.py \
|
||||
get_product_kind.py bufr_read_temp.py \
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
|
||||
#
|
||||
# Python implementation: bufr_print_header
|
||||
# Python implementation: bufr_read_header
|
||||
#
|
||||
# Description: how to read the header from BUFR messages.
|
||||
#
|
|
@ -14,12 +14,12 @@ fRes=$f".header.test.p"
|
|||
REDIRECT=/dev/null
|
||||
|
||||
#Write the values into a file and compare with reference
|
||||
$PYTHON bufr_print_header.py 2> $REDIRECT > $fRes
|
||||
$PYTHON bufr_read_header.py 2> $REDIRECT > $fRes
|
||||
|
||||
#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
|
|
@ -7,10 +7,15 @@
|
|||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
|
||||
#
|
||||
# Python implementation: bufr_print_data
|
||||
# Python implementation: bufr_read_synop
|
||||
#
|
||||
# Description: how to read data values from 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 SYNOP messages than the one used in the
|
||||
# example.
|
||||
#
|
||||
|
||||
import traceback
|
||||
|
@ -30,7 +35,12 @@ def example():
|
|||
keys = [
|
||||
'blockNumber',
|
||||
'stationNumber',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'airTemperatureAt2M',
|
||||
'dewpointTemperatureAt2M',
|
||||
'windSpeedAt10M',
|
||||
'windDirectionAt10M'
|
||||
]
|
||||
|
||||
cnt=0
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
|
||||
#Define a common label for all the tmp files
|
||||
label="bufr_print_data_test_p"
|
||||
label="bufr_read_synop_test_p"
|
||||
|
||||
#Define tmp file
|
||||
fTmp=${label}".tmp.txt"
|
||||
|
@ -24,7 +24,7 @@ rm -f $fTmp | true
|
|||
REDIRECT=/dev/null
|
||||
|
||||
#Write the values into a file and compare with reference
|
||||
$PYTHON bufr_print_data.py 2> $REDIRECT > $fTmp
|
||||
$PYTHON bufr_read_synop.py #2> $REDIRECT > $fTmp
|
||||
|
||||
#TODO: check the output
|
||||
|
|
@ -42,6 +42,7 @@ list( APPEND tests2
|
|||
bufr_filter
|
||||
bufr_json
|
||||
bufr_ls
|
||||
gts_ls
|
||||
bufr_set
|
||||
ieee
|
||||
grib1to2
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
TESTS = definitions.sh calendar.sh \
|
||||
bufrdc_desc_ref.sh bufrdc_ref.sh bufr_dump.sh bufr_filter.sh \
|
||||
bufr_json.sh bufr_compare.sh bufr_copy.sh bufr_count.sh bufr_get.sh bufr_ls.sh bufr_set.sh \
|
||||
gts_ls.sh \
|
||||
ieee.sh grib1to2.sh \
|
||||
unit_tests.sh \
|
||||
grib2to1.sh badgrib.sh ls.sh filter.sh \
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/sh
|
||||
# Copyright 2005-2015 ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
#
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
#
|
||||
|
||||
. ./include.sh
|
||||
|
||||
#Enter data dir
|
||||
cd ${data_dir}/gts
|
||||
|
||||
#Define a common label for all the tmp files
|
||||
label="gts_ls_test"
|
||||
|
||||
#Create log file
|
||||
fLog=${label}".log"
|
||||
rm -f $fLog
|
||||
touch $fLog
|
||||
|
||||
#Define tmp file
|
||||
fTmp=${label}".tmp.txt"
|
||||
rm -f $fTmp
|
||||
|
||||
#----------------------------------------------
|
||||
# Test default "ls" on all the gts data files
|
||||
#----------------------------------------------
|
||||
gts_file=EGRR20150317121020_00493212.DAT
|
||||
f=$gts_file
|
||||
|
||||
echo $f >> $fLog
|
||||
${tools_dir}/gts_ls $f >> $fLog
|
||||
|
||||
#-------------------------------------------
|
||||
# Test "-p" switch
|
||||
#-------------------------------------------
|
||||
ref_ls=$f".ls.ref"
|
||||
res_ls=$f".ls.test"
|
||||
REDIRECT=/dev/null
|
||||
|
||||
${tools_dir}/gts_ls -p TT,AA,II,CCCC,YY,GG,gg,BBB $f 2> $REDIRECT > $res_ls
|
||||
|
||||
diff $ref_ls $res_ls >$REDIRECT 2> $REDIRECT
|
||||
|
||||
rm -f $fLog $res_ls
|
Loading…
Reference in New Issue