This commit is contained in:
Shahram Najm 2017-02-06 16:46:28 +00:00
parent 2e025d7623
commit e769ac8fd8
15 changed files with 78 additions and 78 deletions

View File

@ -51,14 +51,14 @@ 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);
/* ----------------------------------------------------------------
We will read the value and all the attributes available for
the 2m temperature.
-------------------------------------------------------------------*/
-------------------------------------------------------------------*/
/* get the value as double */
CODES_CHECK(codes_get_double(h, "airTemperatureAt2M", &doubleVal),0);
@ -90,11 +90,11 @@ int main(int argc,char* argv[])
CODES_CHECK(codes_get_long(h, "airTemperatureAt2M->width", &longVal),0);
printf(" airTemperatureAt2M->width: %ld\n",longVal);
/* --------------------------------------------------------------------
The 2m temperature data element in this message has an associated
field: percentConfidence. Its value and attributes can be accessed
in a similar manner as was shown above for 2m temperature.
-------------------------------------------------------------------*/
/* -----------------------------------------------------------------
The 2m temperature data element in this message has an associated
field: percentConfidence. Its value and attributes can be accessed
in a similar manner as was shown above for 2m temperature.
----------------------------------------------------------------- */
/* get the value as long */
CODES_CHECK(codes_get_long(h, "airTemperatureAt2M->percentConfidence", &longVal),0);
@ -126,7 +126,7 @@ int main(int argc,char* argv[])
CODES_CHECK(codes_get_long(h, "airTemperatureAt2M->percentConfidence->width", &longVal),0);
printf(" airTemperatureAt2M->percentConfidence->width: %ld\n",longVal);
/* free allocated arrays */
/* free allocated arrays */
free(units);
free(unitsPercent);

View File

@ -26,7 +26,7 @@ int main(int argc,char* argv[])
long *descriptors=NULL;
double *values = NULL;
char* typicalDate= NULL;
char* typicalDate= NULL;
long longVal;
double doubleVal;
size_t values_len=0, desc_len=0, len=0;
@ -51,11 +51,11 @@ 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);
/* read and print some data values */
/* read and print some data values */
/* long value */
CODES_CHECK(codes_get_long(h, "blockNumber", &longVal),0);

View File

@ -31,7 +31,7 @@ int main(int argc,char* argv[])
const char* infile = "../../data/bufr/syno_1.bufr";
in=fopen(infile,"r");
if (!in)
if (!in)
{
printf("ERROR: unable to open file %s\n", infile);
return 1;
@ -48,7 +48,7 @@ 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);
@ -62,7 +62,7 @@ int main(int argc,char* argv[])
printf(" --> value missing\n");
}
else
{
{
printf(" --> value present\n");
}

View File

@ -26,14 +26,14 @@ int main(int argc,char* argv[])
{
char* filename = NULL;
FILE* in = NULL;
/* message handle. Required in all the eccodes calls acting on a message.*/
codes_handle* h=NULL;
long longVal;
int err=0, cnt=0;
if (argc!=2) usage(argv[0]);
filename=argv[1];
in=fopen(filename,"r");
@ -41,7 +41,7 @@ int main(int argc,char* argv[])
printf("ERROR: unable to open file %s\n", filename);
return 1;
}
/* loop over the messages in the bufr file */
while ((h = codes_handle_new_from_file(NULL,in,PRODUCT_BUFR,&err)) != NULL || err != CODES_SUCCESS)
{
@ -52,39 +52,39 @@ int main(int argc,char* argv[])
}
printf("message: %d\n",cnt);
/* get and print some keys form the BUFR header */
/* get and print some keys form the BUFR header */
CODES_CHECK(codes_get_long(h,"dataCategory",&longVal),0);
printf(" dataCategory: %ld\n",longVal);
CODES_CHECK(codes_get_long(h,"dataSubCategory",&longVal),0);
printf(" dataSubCategory: %ld\n",longVal);
CODES_CHECK(codes_get_long(h,"typicalDate",&longVal),0);
printf(" typicalDate: %ld\n",longVal);
CODES_CHECK(codes_get_long(h,"bufrHeaderCentre",&longVal),0);
printf(" bufrHeaderCentre: %ld\n",longVal);
CODES_CHECK(codes_get_long(h,"bufrHeaderSubCentre",&longVal),0);
printf(" bufrHeaderSubCentre: %ld\n",longVal);
CODES_CHECK(codes_get_long(h,"masterTablesVersionNumber",&longVal),0);
printf(" masterTablesVersionNumber: %ld\n",longVal);
CODES_CHECK(codes_get_long(h,"localTablesVersionNumber",&longVal),0);
printf(" localTablesVersionNumber: %ld\n",longVal);
CODES_CHECK(codes_get_long(h,"numberOfSubsets",&longVal),0);
printf(" numberOfSubsets: %ld\n",longVal);
/* delete handle */
codes_handle_delete(h);
cnt++;
}
fclose(in);
return 0;
}

View File

@ -15,7 +15,7 @@
*
*/
/*
/*
* Please note that scatterometer data can be encoded in various ways in BUFR. Therefore the code
* below might not work directly for other types of messages than the one used in the
* example. It is advised to use bufr_dump to understand the structure of the messages.
@ -58,19 +58,19 @@ int main(int argc,char* argv[])
/* We need to instruct ecCodes to expand the descriptors
* i.e. unpack the data values */
CODES_CHECK(codes_set_long(h,"unpack",1),0);
/* The BUFR file contains a single message with 2016 subsets in a compressed form.
* It means each subset has exactly the same structure: they store one location with
* several beams and one backscatter value in each beam.
*
* To print the backScatter values for beamIdentifier=2 from all the subsets
* several beams and one backscatter value in each beam.
*
* To print the backScatter values for beamIdentifier=2 from all the subsets
* we will simply access the key by condition (see below) */
/* Get the total number of subsets. */
CODES_CHECK(codes_get_long(h,"numberOfSubsets",&numObs),0);
printf("Number of values: %ld\n",numObs);
/* Allocate memory for the values to be read. Each
* parameter must have the same number of values. */
lat = (double*)malloc(numObs*sizeof(double));

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. It is advised to use bufr_dump to understand the structure of the messages.
@ -32,7 +32,7 @@ void usage(char* prog) {
int main(int argc,char* argv[])
{
FILE* in = NULL;
/* message handle. Required in all the eccodes calls acting on a message.*/
codes_handle* h=NULL;
@ -47,7 +47,7 @@ int main(int argc,char* argv[])
printf("ERROR: unable to open file %s\n", infile);
return 1;
}
/* loop over the messages in the bufr file */
while ((h = codes_handle_new_from_file(NULL,in,PRODUCT_BUFR,&err)) != NULL || err != CODES_SUCCESS)
{
@ -56,75 +56,75 @@ int main(int argc,char* argv[])
cnt++;
continue;
}
printf("message: %d\n",cnt);
/* we need to instruct ecCodes to unpack the data values */
CODES_CHECK(codes_set_long(h,"unpack",1),0);
/* station id*/
/* 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);
/* location*/
/* 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);
/* 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.
* 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,"#1#cloudAmount",&longVal),0);
printf(" cloudAmount (low and middle): %ld\n",longVal);
/* Height of cloud base */
CODES_CHECK(codes_get_long(h,"#1#heightOfBaseOfCloud",&longVal),0);
printf(" heightOfBaseOfCloud: %ld\n",longVal);
/* Cloud type (low clouds) */
CODES_CHECK(codes_get_long(h,"#1#cloudType",&longVal),0);
printf(" cloudType (low): %ld\n",longVal);
/* Cloud type (middle clouds) */
CODES_CHECK(codes_get_long(h,"#2#cloudType",&longVal),0);
printf(" cloudType (middle): %ld\n",longVal);
/* Cloud type (high clouds) */
CODES_CHECK(codes_get_long(h,"#3#cloudType",&longVal),0);
printf(" cloudType (high): %ld\n",longVal);
/* delete handle */
codes_handle_delete(h);
cnt++;
}
fclose(in);
return 0;
}

View File

@ -14,8 +14,8 @@
* 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.
@ -65,7 +65,7 @@ int main(int argc,char* argv[])
*
* In our BUFR message verticalSoundingSignificance is always followed by
* geopotential, airTemperature, dewpointTemperature,
* windDirection, windSpeed and pressure.
* windDirection, windSpeed and pressure.
* So in order to access any of these keys we need to use the
* condition: verticalSoundingSignificance=4.
*/

View File

@ -64,7 +64,7 @@ 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);*/

View File

@ -39,7 +39,7 @@ int main(int argc,char* argv[])
printf("ERROR: unable to open file %s\n", infile);
return 1;
}
while ((h = codes_handle_new_from_file(NULL,in,PRODUCT_ANY,&err)) != NULL || err != CODES_SUCCESS)
{
if (h == NULL) {
@ -51,10 +51,10 @@ int main(int argc,char* argv[])
CODES_CHECK(codes_get_length(h, "kindOfProduct", &len), 0);
kind = (char*)malloc(len*sizeof(char));
codes_get_string(h, "kindOfProduct", kind, &len);
printf(" product: %s\n", kind);
free(kind);
codes_handle_delete(h);
cnt++;

View File

@ -30,7 +30,7 @@ int main(int argc, char * argv[])
double min=1e13,max=-1e13,avg=0;
codes_index* index;
codes_handle* h=NULL;
if (argc<2) return 1;
/* create index of file contents for paramId and number */

View File

@ -139,7 +139,7 @@ int main(int argc, char** argv)
byte_val = malloc(keySize*sizeof(char));
GRIB_CHECK(codes_get_bytes(h, name, byte_val, &keySize), name);
}
codes_handle_delete(h);
return 0;

View File

@ -19,7 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include "eccodes.h"
#include "eccodes.h"
void usage(const char* prog) {
printf("Usage: %s grib_file\n",prog);

View File

@ -11,9 +11,9 @@
/*
* C Implementation: grib_precipitation
*
* Description: convert fields accumulated from 0 step in
* fields accumulated in the interval between
* a field and another. In the input file the fields
* Description: convert fields accumulated from 0 step in
* fields accumulated in the interval between
* a field and another. In the input file the fields
* must be in ascending order in the step.
* step must be the most external loop (slower varying index)
*

View File

@ -58,7 +58,7 @@ int main(int argc, char** argv)
/* But if your data array has a different size, then specify the grid geometry */
/* (e.g. keys Ni, Nj etc) and set the correct number of data values */
CODES_CHECK(codes_get_size(h, "values", &values_len),0);
values = (double*)malloc(values_len*sizeof(double));
d=10e-8;
e=d;

View File

@ -361,7 +361,7 @@ int main(int argc,const char** argv)
vdouble[ 484] = 1; vdouble[ 485] = 1; vdouble[ 486] = 1; vdouble[ 487] = 1;
vdouble[ 488] = 1; vdouble[ 489] = 1; vdouble[ 490] = 1; vdouble[ 491] = 1;
vdouble[ 492] = 1; vdouble[ 493] = 1; vdouble[ 494] = 1; vdouble[ 495] = 1;
CODES_CHECK(codes_set_double_array(h,"values",vdouble,size),0);
free(vdouble);
CODES_CHECK(codes_set_long(h,"dirty_statistics",1),0);