mirror of https://github.com/ecmwf/eccodes.git
ECC-188 PEP8ify python examples
This commit is contained in:
parent
d2309250a1
commit
2c0e9406bc
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Python implementation: bufr_attributes
|
# Python implementation: bufr_attributes
|
||||||
|
@ -51,10 +52,10 @@ def example():
|
||||||
# i.e. unpack the data values
|
# i.e. unpack the data values
|
||||||
codes_set(gid, 'unpack', 1)
|
codes_set(gid, 'unpack', 1)
|
||||||
|
|
||||||
#---------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# We will read the value and all the attributes available for
|
# We will read the value and all the attributes available for
|
||||||
# the 2m temperature.
|
# the 2m temperature.
|
||||||
#---------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# get the value
|
# get the value
|
||||||
key = 'airTemperatureAt2M'
|
key = 'airTemperatureAt2M'
|
||||||
try:
|
try:
|
||||||
|
@ -72,11 +73,11 @@ def example():
|
||||||
except CodesInternalError, err:
|
except CodesInternalError, err:
|
||||||
print 'Error with key="%s" : %s' % (key, err.msg)
|
print 'Error with key="%s" : %s' % (key, err.msg)
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# The 2m temperature data element in this message has an associated
|
# The 2m temperature data element in this message has an associated
|
||||||
# field: percentConfidence. Its value and attributes can be accessed
|
# field: percentConfidence. Its value and attributes can be accessed
|
||||||
# in a similar manner as was shown above for 2m temperature.
|
# in a similar manner as was shown above for 2m temperature.
|
||||||
#-------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
# get the value
|
# get the value
|
||||||
key = 'airTemperatureAt2M->percentConfidence'
|
key = 'airTemperatureAt2M->percentConfidence'
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -63,7 +64,7 @@ def example():
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
example()
|
example()
|
||||||
except CodesInternalError, err:
|
except CodesInternalError as err:
|
||||||
if VERBOSE:
|
if VERBOSE:
|
||||||
traceback.print_exc(file=sys.stderr)
|
traceback.print_exc(file=sys.stderr)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -18,7 +18,7 @@ from eccodes import *
|
||||||
|
|
||||||
def example(csvfile, input_filename, output_filename):
|
def example(csvfile, input_filename, output_filename):
|
||||||
|
|
||||||
fbufrin = open(input_filename, 'rb')
|
fbufrin = open(input_filename, 'rb')
|
||||||
fbufrout = open(output_filename, 'wb')
|
fbufrout = open(output_filename, 'wb')
|
||||||
|
|
||||||
print 'Using ecCodes version: ', codes_get_api_version()
|
print 'Using ecCodes version: ', codes_get_api_version()
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Python implementation: bufr_get_keys
|
# Python implementation: bufr_get_keys
|
||||||
|
@ -42,9 +43,9 @@ def example():
|
||||||
# i.e. unpack the data values
|
# i.e. unpack the data values
|
||||||
codes_set(gid, 'unpack', 1)
|
codes_set(gid, 'unpack', 1)
|
||||||
|
|
||||||
#-----------------------------------
|
# ----------------------------------
|
||||||
# get all the expanded data values
|
# get all the expanded data values
|
||||||
#-----------------------------------
|
# ----------------------------------
|
||||||
key = 'numericValues'
|
key = 'numericValues'
|
||||||
|
|
||||||
# get size
|
# get size
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Python implementation: bufr_get_keys
|
# Python implementation: bufr_get_keys
|
||||||
|
@ -42,9 +43,9 @@ def example():
|
||||||
# i.e. unpack the data values
|
# i.e. unpack the data values
|
||||||
codes_set(gid, 'unpack', 1)
|
codes_set(gid, 'unpack', 1)
|
||||||
|
|
||||||
#----------------------------------------------
|
# ---------------------------------------------
|
||||||
# get values for keys holding a single value
|
# get values for keys holding a single value
|
||||||
#----------------------------------------------
|
# ---------------------------------------------
|
||||||
# Native type integer
|
# Native type integer
|
||||||
key = 'blockNumber'
|
key = 'blockNumber'
|
||||||
|
|
||||||
|
@ -74,9 +75,9 @@ def example():
|
||||||
except CodesInternalError, err:
|
except CodesInternalError, err:
|
||||||
print 'Error with key="%s" : %s' % (key, err.msg)
|
print 'Error with key="%s" : %s' % (key, err.msg)
|
||||||
|
|
||||||
#---------------------------------
|
# --------------------------------
|
||||||
# get values for an array
|
# get values for an array
|
||||||
#---------------------------------
|
# --------------------------------
|
||||||
# Native type integer
|
# Native type integer
|
||||||
key = 'bufrdcExpandedDescriptors'
|
key = 'bufrdcExpandedDescriptors'
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Python implementation: bufr_keys_iterator
|
# Python implementation: bufr_keys_iterator
|
||||||
|
@ -59,8 +60,6 @@ def example():
|
||||||
|
|
||||||
# print key name
|
# print key name
|
||||||
keyname = codes_keys_iterator_get_name(iterid)
|
keyname = codes_keys_iterator_get_name(iterid)
|
||||||
#keyval = codes_get_string(iterid,keyname)
|
|
||||||
# print "%s = %s" % (keyname,keyval)
|
|
||||||
print " %s" % keyname
|
print " %s" % keyname
|
||||||
|
|
||||||
# delete the key iterator
|
# delete the key iterator
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -3,17 +3,20 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Python implementation: bufr_read_scatterometer
|
# Python implementation: bufr_read_scatterometer
|
||||||
#
|
#
|
||||||
# Description: how to read data for a given beam from scatterometer BUFR messages.
|
# Description: how to read data for a given beam from scatterometer BUFR
|
||||||
|
# messages.
|
||||||
#
|
#
|
||||||
# Please note that scatterometer data can be encoded in various ways in BUFR. Therefore the code
|
# Please note that scatterometer data can be encoded in various ways in BUFR.
|
||||||
# below might not work directly for other types of messages than the one used in the
|
# Therefore the code below might not work directly for other types of messages
|
||||||
# example. It is advised to use bufr_dump first to understand the structure of these messages.
|
# than the one used in the example. It is advised to use bufr_dump first to
|
||||||
|
# understand the structure of these messages.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,12 +49,13 @@ def example():
|
||||||
# i.e. unpack the data values
|
# i.e. unpack the data values
|
||||||
codes_set(gid, 'unpack', 1)
|
codes_set(gid, 'unpack', 1)
|
||||||
|
|
||||||
# The BUFR file contains a single message with 2016 subsets in a compressed form.
|
# The BUFR file contains a single message with 2016 subsets in a
|
||||||
# It means each subset has exactly the same structure: they store one location with
|
# compressed form. It means each subset has exactly the same structure:
|
||||||
# several beams and one backscatter value in each beam.
|
# 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
|
# To print the backScatter values for beamIdentifier=2 from all the
|
||||||
# we will simply access the key by condition (see below)
|
# subsets we will simply access the key by condition (see below)
|
||||||
|
|
||||||
# Get the total number of subsets.
|
# Get the total number of subsets.
|
||||||
numObs = codes_get(gid, "numberOfSubsets")
|
numObs = codes_get(gid, "numberOfSubsets")
|
||||||
|
@ -64,8 +68,8 @@ def example():
|
||||||
# Get longitude (for all the subsets)
|
# Get longitude (for all the subsets)
|
||||||
lon = codes_get_array(gid, "longitude")
|
lon = codes_get_array(gid, "longitude")
|
||||||
|
|
||||||
# Get backScatter for beam two. We use an access by condition for this key.
|
# Get backScatter for beam two. We use an access by condition for this
|
||||||
#(for all the subsets)
|
# key (for all the subsets).
|
||||||
bscat = codes_get_array(gid, "/beamIdentifier=2/backscatter")
|
bscat = codes_get_array(gid, "/beamIdentifier=2/backscatter")
|
||||||
|
|
||||||
# Check that all arrays are same size
|
# Check that all arrays are same size
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Python implementation: bufr_read_synop
|
# Python implementation: bufr_read_synop
|
||||||
|
@ -12,11 +13,10 @@
|
||||||
# Description: how to read data values from BUFR messages.
|
# Description: how to read data values from BUFR messages.
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
# Please note that SYNOP reports can be encoded in various ways in BUFR.
|
||||||
# Please note that SYNOP reports can be encoded in various ways in BUFR. Therefore the code
|
# Therefore the code below might not work directly for other types of SYNOP
|
||||||
# below might not work directly for other types of SYNOP messages than the one used in the
|
# messages than the one used in the example. It is advised to use bufr_dump to
|
||||||
# example. It is advised to use bufr_dump to understand the structure of the messages.
|
# understand the structure of the messages.
|
||||||
#
|
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
|
@ -55,7 +55,8 @@ def example():
|
||||||
# cloud block introduced by the key
|
# cloud block introduced by the key
|
||||||
# verticalSignificanceSurfaceObservations=1.
|
# verticalSignificanceSurfaceObservations=1.
|
||||||
# We know that this is the first occurrence of the keys we want to
|
# 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.
|
# read so in the list above we used the # (occurrence) operator
|
||||||
|
# accordingly.
|
||||||
|
|
||||||
cnt = 0
|
cnt = 0
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,21 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Python implementation: bufr_read_temp
|
# Python implementation: bufr_read_temp
|
||||||
#
|
#
|
||||||
# Description: how to read temperature significant levels from TEMP BUFR messages.
|
# 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
|
# Please note that TEMP reports can be encoded in various ways in BUFR.
|
||||||
# below might not work directly for other types of TEMP messages than the one used in the
|
# Therefore the code below might not work directly for other types of TEMP
|
||||||
# example. It is advised to use bufr_dump to understand the structure of the messages.
|
# 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 traceback
|
||||||
|
@ -60,23 +63,29 @@ def example():
|
||||||
# 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.
|
||||||
|
|
||||||
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_array(
|
||||||
|
gid, "/verticalSoundingSignificance=4/pressure")
|
||||||
|
|
||||||
# Get gepotential
|
# Get gepotential
|
||||||
sigt_geo = codes_get_array(gid, "/verticalSoundingSignificance=4/geopotential")
|
sigt_geo = codes_get_array(
|
||||||
|
gid, "/verticalSoundingSignificance=4/geopotential")
|
||||||
|
|
||||||
# Get temperature
|
# Get temperature
|
||||||
sigt_t = codes_get_array(gid, "/verticalSoundingSignificance=4/airTemperature")
|
sigt_t = codes_get_array(
|
||||||
|
gid, "/verticalSoundingSignificance=4/airTemperature")
|
||||||
|
|
||||||
# Get dew point
|
# Get dew point
|
||||||
sigt_td = codes_get_array(gid, "/verticalSoundingSignificance=4/dewpointTemperature")
|
sigt_td = codes_get_array(
|
||||||
|
gid, "/verticalSoundingSignificance=4/dewpointTemperature")
|
||||||
|
|
||||||
# Check that all arrays are same size
|
# Check that all arrays are same size
|
||||||
if len(sigt_pres) != numSigT or len(sigt_geo) != numSigT or len(sigt_t) != numSigT or len(sigt_td) != numSigT:
|
if len(sigt_pres) != numSigT or len(sigt_geo) != numSigT or \
|
||||||
|
len(sigt_t) != numSigT or len(sigt_td) != numSigT:
|
||||||
print 'inconsistent array dimension'
|
print 'inconsistent array dimension'
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@ -85,7 +94,9 @@ def example():
|
||||||
print "-------------------------------"
|
print "-------------------------------"
|
||||||
|
|
||||||
for i in xrange(numSigT):
|
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
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Python implementation: bufr_set_keys
|
# Python implementation: bufr_set_keys
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Python implementation: bufr_subset
|
# Python implementation: bufr_subset
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Python implementation: get_product_kind
|
# Python implementation: get_product_kind
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -4,11 +4,13 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Description: How to create and use an index to access GRIB messages from a file
|
# Description: How to create and use an index to access GRIB messages from
|
||||||
|
# a file
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
|
@ -68,7 +70,8 @@ def example():
|
||||||
gid = codes_new_from_index(iid)
|
gid = codes_new_from_index(iid)
|
||||||
if gid is None:
|
if gid is None:
|
||||||
break
|
break
|
||||||
print " ".join(["%s=%s" % (key, codes_get(gid, key)) for key in index_keys])
|
print " ".join(["%s=%s" % (key, codes_get(gid, key))
|
||||||
|
for key in index_keys])
|
||||||
codes_release(gid)
|
codes_release(gid)
|
||||||
|
|
||||||
codes_index_release(iid)
|
codes_index_release(iid)
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -26,7 +27,8 @@ def example():
|
||||||
for lat, lon in points:
|
for lat, lon in points:
|
||||||
nearest = codes_grib_find_nearest(gid, lat, lon)[0]
|
nearest = codes_grib_find_nearest(gid, lat, lon)[0]
|
||||||
print lat, lon
|
print lat, lon
|
||||||
print nearest.lat, nearest.lon, nearest.value, nearest.distance, nearest.index
|
print nearest.lat, nearest.lon, nearest.value, nearest.distance, \
|
||||||
|
nearest.index
|
||||||
|
|
||||||
four = codes_grib_find_nearest(gid, lat, lon, is_lsm=False, npoints=4)
|
four = codes_grib_find_nearest(gid, lat, lon, is_lsm=False, npoints=4)
|
||||||
for i in range(len(four)):
|
for i in range(len(four)):
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
|
@ -34,7 +35,8 @@ def example():
|
||||||
|
|
||||||
# Check counts of missing and non-missing values
|
# Check counts of missing and non-missing values
|
||||||
num_data = codes_get(gid, 'numberOfDataPoints', int)
|
num_data = codes_get(gid, 'numberOfDataPoints', int)
|
||||||
assert(codes_get(gid, 'numberOfCodedValues', int) == num_data - num_missing)
|
assert(codes_get(gid, 'numberOfCodedValues', int)
|
||||||
|
== num_data - num_missing)
|
||||||
assert(codes_get(gid, 'numberOfMissing', int) == num_missing)
|
assert(codes_get(gid, 'numberOfMissing', int) == num_missing)
|
||||||
|
|
||||||
codes_write(gid, fout)
|
codes_write(gid, fout)
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Python implementation: bufr_get_keys
|
# Python implementation: bufr_get_keys
|
||||||
|
@ -38,9 +39,9 @@ def example():
|
||||||
|
|
||||||
print "message: %s" % cnt
|
print "message: %s" % cnt
|
||||||
|
|
||||||
#----------------------------------------------
|
# ---------------------------------------------
|
||||||
# get values for keys holding a single value
|
# get values for keys holding a single value
|
||||||
#----------------------------------------------
|
# ---------------------------------------------
|
||||||
keys = ['TT', 'AA', 'II', 'CCCC', 'YY', 'GG', 'gg', 'BBB']
|
keys = ['TT', 'AA', 'II', 'CCCC', 'YY', 'GG', 'gg', 'BBB']
|
||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -3,13 +3,14 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Python implementation: metar_get_keys
|
# Python implementation: metar_get_keys
|
||||||
#
|
#
|
||||||
# Description: how to read values of different type of keys from METAR messages.
|
# Description: how to read values of different type of keys from METAR messages
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -38,9 +39,9 @@ def example():
|
||||||
|
|
||||||
print "message: %s" % cnt
|
print "message: %s" % cnt
|
||||||
|
|
||||||
#----------------------------------------------
|
# ---------------------------------------------
|
||||||
# get values for keys holding a single value
|
# get values for keys holding a single value
|
||||||
#----------------------------------------------
|
# ---------------------------------------------
|
||||||
keys = ['CCCC', 'latitude', 'longitude', 'dateTime',
|
keys = ['CCCC', 'latitude', 'longitude', 'dateTime',
|
||||||
'elevation', 'temperature', 'dewPointTemperature', 'qnh']
|
'elevation', 'temperature', 'dewPointTemperature', 'qnh']
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
# 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.
|
# 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
|
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
# granted to it by virtue of its status as an intergovernmental organisation
|
||||||
|
# nor does it submit to any jurisdiction.
|
||||||
#
|
#
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
Loading…
Reference in New Issue