mirror of https://github.com/ecmwf/eccodes.git
Make C, Fortran and Python examples ECC-15
This commit is contained in:
parent
09a3156f6e
commit
e220456317
|
@ -67,9 +67,7 @@ int main(int argc,char* argv[])
|
||||||
airTemperature, dewpointTemperature,
|
airTemperature, dewpointTemperature,
|
||||||
windDirection, windSpeed and pressure. */
|
windDirection, windSpeed and pressure. */
|
||||||
|
|
||||||
/* -------------------------------------------------------
|
/* Get the number of the temperature significant levels.*/
|
||||||
Get the number of the temperature significant levels.
|
|
||||||
------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* We find out the number of temperature significant levels by
|
/* 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. */
|
||||||
|
@ -86,9 +84,7 @@ int main(int argc,char* argv[])
|
||||||
sigt_t = malloc(sigt_len*sizeof(double));
|
sigt_t = malloc(sigt_len*sizeof(double));
|
||||||
sigt_td = malloc(sigt_len*sizeof(double));
|
sigt_td = malloc(sigt_len*sizeof(double));
|
||||||
|
|
||||||
/* --------------------------
|
/* Get pressure */
|
||||||
Get pressure
|
|
||||||
----------------------------*/
|
|
||||||
|
|
||||||
sprintf(key_name,"/verticalSoundingSignificance=4/pressure");
|
sprintf(key_name,"/verticalSoundingSignificance=4/pressure");
|
||||||
|
|
||||||
|
@ -96,13 +92,11 @@ int main(int argc,char* argv[])
|
||||||
len=sigt_len;
|
len=sigt_len;
|
||||||
CODES_CHECK(codes_get_double_array(h,key_name,sigt_pres,&len),0);
|
CODES_CHECK(codes_get_double_array(h,key_name,sigt_pres,&len),0);
|
||||||
|
|
||||||
/* --------------------------
|
/* Get gepotential */
|
||||||
Get gepotential
|
|
||||||
----------------------------*/
|
|
||||||
|
|
||||||
sprintf(key_name,"/verticalSoundingSignificance=4/geopotential");
|
sprintf(key_name,"/verticalSoundingSignificance=4/geopotential");
|
||||||
|
|
||||||
/* Check the size*/
|
/* check the size*/
|
||||||
CODES_CHECK(codes_get_size(h,key_name,&len),0);
|
CODES_CHECK(codes_get_size(h,key_name,&len),0);
|
||||||
if(len != sigt_len)
|
if(len != sigt_len)
|
||||||
{
|
{
|
||||||
|
@ -113,13 +107,11 @@ int main(int argc,char* argv[])
|
||||||
/* get the values */
|
/* get the values */
|
||||||
CODES_CHECK(codes_get_double_array(h,key_name,sigt_geo,&len),0);
|
CODES_CHECK(codes_get_double_array(h,key_name,sigt_geo,&len),0);
|
||||||
|
|
||||||
/* --------------------------
|
/* Get temperature */
|
||||||
Get temperature
|
|
||||||
----------------------------*/
|
|
||||||
|
|
||||||
sprintf(key_name,"/verticalSoundingSignificance=4/airTemperature");
|
sprintf(key_name,"/verticalSoundingSignificance=4/airTemperature");
|
||||||
|
|
||||||
/* Check the size*/
|
/* check the size*/
|
||||||
if(len != sigt_len)
|
if(len != sigt_len)
|
||||||
{
|
{
|
||||||
printf("inconsistent number of temperature values found!\n");
|
printf("inconsistent number of temperature values found!\n");
|
||||||
|
@ -129,14 +121,11 @@ int main(int argc,char* argv[])
|
||||||
/* get the values */
|
/* get the values */
|
||||||
CODES_CHECK(codes_get_double_array(h,key_name,sigt_t,&len),0);
|
CODES_CHECK(codes_get_double_array(h,key_name,sigt_t,&len),0);
|
||||||
|
|
||||||
|
/* Get dew point */
|
||||||
/* --------------------------
|
|
||||||
Get dew point
|
|
||||||
----------------------------*/
|
|
||||||
|
|
||||||
sprintf(key_name,"/verticalSoundingSignificance=4/dewpointTemperature");
|
sprintf(key_name,"/verticalSoundingSignificance=4/dewpointTemperature");
|
||||||
|
|
||||||
/* Check the size*/
|
/* check the size*/
|
||||||
if(len != sigt_len)
|
if(len != sigt_len)
|
||||||
{
|
{
|
||||||
printf("inconsistent number of dewpoint temperature values found!\n");
|
printf("inconsistent number of dewpoint temperature values found!\n");
|
||||||
|
@ -146,10 +135,7 @@ int main(int argc,char* argv[])
|
||||||
/* get the values */
|
/* get the values */
|
||||||
CODES_CHECK(codes_get_double_array(h,key_name,sigt_td,&len),0);
|
CODES_CHECK(codes_get_double_array(h,key_name,sigt_td,&len),0);
|
||||||
|
|
||||||
|
/* Print the values */
|
||||||
/*--------------------------------
|
|
||||||
Print the values
|
|
||||||
---------------------------------*/
|
|
||||||
|
|
||||||
printf("lev pres geo t td\n");
|
printf("lev pres geo t td\n");
|
||||||
printf("-------------------------------\n");
|
printf("-------------------------------\n");
|
||||||
|
|
|
@ -49,9 +49,7 @@ def example():
|
||||||
# airTemperature, dewpointTemperature,
|
# airTemperature, dewpointTemperature,
|
||||||
# windDirection, windSpeed and pressure.
|
# windDirection, windSpeed and pressure.
|
||||||
|
|
||||||
#-------------------------------------------------------
|
|
||||||
# Get the number of the temperature significant levels.
|
# Get the number of the temperature significant levels.
|
||||||
#------------------------------------------------------
|
|
||||||
|
|
||||||
# We find out the number of temperature significant levels by
|
# 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.
|
||||||
|
@ -59,50 +57,40 @@ def example():
|
||||||
numSigT=codes_get_size(gid,"/verticalSoundingSignificance=4/pressure")
|
numSigT=codes_get_size(gid,"/verticalSoundingSignificance=4/pressure")
|
||||||
print ' Number of temperature significant levels %ld' % (numSigT)
|
print ' Number of temperature significant levels %ld' % (numSigT)
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# Get pressure
|
# Get pressure
|
||||||
# ----------------------------
|
|
||||||
|
|
||||||
sigt_pres=codes_get_array(gid,"/verticalSoundingSignificance=4/pressure")
|
sigt_pres=codes_get_double_array(gid,"/verticalSoundingSignificance=4/pressure")
|
||||||
|
|
||||||
#--------------------------------
|
|
||||||
# Get gepotential
|
# Get gepotential
|
||||||
#--------------------------------
|
|
||||||
|
|
||||||
sigt_geo=codes_get_array(gid,"/verticalSoundingSignificance=4/geopotential")
|
sigt_geo=codes_get_double_array(gid,"/verticalSoundingSignificance=4/geopotential")
|
||||||
|
|
||||||
if len(sigt_geo) != sigTNum :
|
if len(sigt_geo) != numSigT :
|
||||||
print "inconstitent number of geopotential values found!"
|
print "inconstitent number of geopotential values found!"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
#--------------------------------
|
|
||||||
# Get temperature
|
# Get temperature
|
||||||
#--------------------------------
|
|
||||||
|
|
||||||
sigt_t=codes_get_array(gid,"/verticalSoundingSignificance=4/airTemperature")
|
sigt_t=codes_get_double_array(gid,"/verticalSoundingSignificance=4/airTemperature")
|
||||||
|
|
||||||
if len(sigt_t) != sigTNum :
|
if len(sigt_t) != numSigT :
|
||||||
print "inconstitent number of temprature values found!"
|
print "inconstitent number of temprature values found!"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
#--------------------------------
|
|
||||||
# Get dew point
|
# Get dew point
|
||||||
#--------------------------------
|
|
||||||
|
|
||||||
sigt_td=codes_get_array(gid,"/verticalSoundingSignificance=4/dewpointTemperature")
|
sigt_td=codes_get_double_array(gid,"/verticalSoundingSignificance=4/dewpointTemperature")
|
||||||
|
|
||||||
if len(sigt_td) != sigTNum :
|
if len(sigt_td) != numSigT:
|
||||||
print "inconstitent number of dewpoint temperature values found!"
|
print "inconstitent number of dewpoint temperature values found!"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
#------------------------------------
|
|
||||||
# Print the values
|
# Print the values
|
||||||
# -----------------------------------
|
|
||||||
|
|
||||||
print "lev pres geo t td"
|
print "lev pres geo t td"
|
||||||
print "-------------------------------"
|
print "-------------------------------"
|
||||||
|
|
||||||
for i in xrange(sigTNum):
|
for i in xrange(numSigT):
|
||||||
print "%3d %6.0f %6.0f %.1f %.1f" % (i+1,sigt_pres[i],sigt_geo[i],sigt_t[i],sigt_td[i])
|
print "%3d %6.0f %6.0f %.1f %.1f" % (i+1,sigt_pres[i],sigt_geo[i],sigt_t[i],sigt_td[i])
|
||||||
|
|
||||||
cnt+=1
|
cnt+=1
|
||||||
|
|
Loading…
Reference in New Issue