mirror of https://github.com/ecmwf/eccodes.git
ECC-10: Creating a handle from a file
This commit is contained in:
parent
6381a240bd
commit
bc5b883c21
|
@ -29,7 +29,7 @@ program clone
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,igrib_in)
|
||||
call codes_grib_new_from_file(infile,igrib_in)
|
||||
|
||||
call codes_get(igrib_in,"Ni", nx)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ program copy
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,igrib_in)
|
||||
call codes_grib_new_from_file(infile,igrib_in)
|
||||
|
||||
call codes_get_message_size(igrib_in, byte_size)
|
||||
allocate(message(byte_size), stat=err)
|
||||
|
|
|
@ -21,8 +21,8 @@ program copy_namespace
|
|||
call codes_open_file(file2,'../../data/regular_latlon_surface.grib1','r')
|
||||
call codes_open_file(file3,'out.grib','w')
|
||||
|
||||
call codes_new_from_file(file1,igrib1)
|
||||
call codes_new_from_file(file2,igrib2)
|
||||
call codes_grib_new_from_file(file1,igrib1)
|
||||
call codes_grib_new_from_file(file2,igrib2)
|
||||
|
||||
call codes_clone(igrib2,igrib3)
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ program get
|
|||
|
||||
! Load the messages from the file.
|
||||
DO i=1,n
|
||||
call codes_new_from_file(ifile,igrib(i), iret)
|
||||
call codes_grib_new_from_file(ifile,igrib(i), iret)
|
||||
END DO
|
||||
|
||||
! we can close the file
|
||||
|
|
|
@ -35,7 +35,7 @@ program get
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(ifile,igrib, iret)
|
||||
call codes_grib_new_from_file(ifile,igrib, iret)
|
||||
|
||||
LOOP: DO WHILE (iret /= CODES_END_OF_FILE)
|
||||
|
||||
|
@ -114,7 +114,7 @@ program get
|
|||
|
||||
call codes_release(igrib)
|
||||
|
||||
call codes_new_from_file(ifile,igrib, iret)
|
||||
call codes_grib_new_from_file(ifile,igrib, iret)
|
||||
|
||||
end do LOOP
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ implicit none
|
|||
|
||||
! Loop on all the messages in a file.
|
||||
|
||||
call codes_new_from_file(ifile,igrib,iret)
|
||||
call codes_grib_new_from_file(ifile,igrib,iret)
|
||||
|
||||
do while (iret/=CODES_END_OF_FILE)
|
||||
count1=count1+1
|
||||
|
@ -57,7 +57,7 @@ implicit none
|
|||
deallocate(values)
|
||||
|
||||
call codes_release(igrib)
|
||||
call codes_new_from_file(ifile,igrib, iret)
|
||||
call codes_grib_new_from_file(ifile,igrib, iret)
|
||||
|
||||
end do
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ implicit none
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(ifile,igrib)
|
||||
call codes_grib_new_from_file(ifile,igrib)
|
||||
|
||||
! get as a integer
|
||||
call codes_get(igrib,'numberOfPointsAlongAParallel', &
|
||||
|
|
|
@ -25,7 +25,7 @@ program get_pl
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,igrib)
|
||||
call codes_grib_new_from_file(infile,igrib)
|
||||
|
||||
! set PVPresent as an integer
|
||||
call codes_get(igrib,'PLPresent',PLPresent)
|
||||
|
|
|
@ -26,7 +26,7 @@ program get_pv
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,igrib)
|
||||
call codes_grib_new_from_file(infile,igrib)
|
||||
|
||||
! set PVPresent as an integer
|
||||
call codes_get(igrib,'PVPresent',PVPresent)
|
||||
|
|
|
@ -28,7 +28,7 @@ program get_set_uuid
|
|||
|
||||
! Load first grib message from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file (infile, igrib, iret)
|
||||
call codes_grib_new_from_file (infile, igrib, iret)
|
||||
|
||||
uuid_string_expected = '08b1e836bc6911e1951fb51b5624ad8d'
|
||||
count1 = 0
|
||||
|
@ -70,7 +70,7 @@ program get_set_uuid
|
|||
|
||||
call codes_release (igrib)
|
||||
call codes_release (ogrib)
|
||||
call codes_new_from_file (infile, igrib, iret)
|
||||
call codes_grib_new_from_file (infile, igrib, iret)
|
||||
end do
|
||||
|
||||
call codes_close_file (infile)
|
||||
|
|
|
@ -27,7 +27,7 @@ implicit none
|
|||
|
||||
! Loop on all the messages in a file.
|
||||
|
||||
call codes_new_from_file(ifile,igrib,iret)
|
||||
call codes_grib_new_from_file(ifile,igrib,iret)
|
||||
|
||||
LOOP: DO WHILE (iret/=CODES_END_OF_FILE)
|
||||
! get as a real8
|
||||
|
@ -61,7 +61,7 @@ implicit none
|
|||
call grib_iterator_delete(iter)
|
||||
call codes_release(igrib)
|
||||
|
||||
call codes_new_from_file(ifile,igrib, iret)
|
||||
call codes_grib_new_from_file(ifile,igrib, iret)
|
||||
|
||||
end do LOOP
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ program keys_iterator
|
|||
|
||||
! Loop on all the messages in a file.
|
||||
|
||||
call codes_new_from_file(ifile,igrib, iret)
|
||||
call codes_grib_new_from_file(ifile,igrib, iret)
|
||||
|
||||
do while (iret /= CODES_END_OF_FILE)
|
||||
|
||||
|
@ -54,7 +54,7 @@ program keys_iterator
|
|||
|
||||
call codes_keys_iterator_delete(kiter)
|
||||
call codes_release(igrib)
|
||||
call codes_new_from_file(ifile,igrib, iret)
|
||||
call codes_grib_new_from_file(ifile,igrib, iret)
|
||||
end do
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ program keys_iterator
|
|||
grib_count=0
|
||||
! Loop on all the messages in a file.
|
||||
|
||||
call codes_new_from_file(ifile,igrib)
|
||||
call codes_grib_new_from_file(ifile,igrib)
|
||||
|
||||
do while (igrib .ne. -1)
|
||||
|
||||
|
@ -60,7 +60,7 @@ program keys_iterator
|
|||
|
||||
call codes_keys_iterator_delete(kiter)
|
||||
call codes_release(igrib)
|
||||
call codes_new_from_file(ifile,igrib, iret)
|
||||
call codes_grib_new_from_file(ifile,igrib, iret)
|
||||
end do
|
||||
|
||||
call codes_close_file(ifile)
|
||||
|
|
|
@ -31,7 +31,7 @@ program multi
|
|||
! turn off support for multi fields messages */
|
||||
!call codes_grib_multi_support_off()
|
||||
|
||||
call codes_new_from_file(ifile,igrib, iret)
|
||||
call codes_grib_new_from_file(ifile,igrib, iret)
|
||||
! Loop on all the messages in a file.
|
||||
|
||||
write(*,*) 'step'
|
||||
|
@ -40,7 +40,7 @@ program multi
|
|||
call codes_get(igrib,'step', step)
|
||||
write(*,'(i3)') step
|
||||
|
||||
call codes_new_from_file(ifile,igrib, iret)
|
||||
call codes_grib_new_from_file(ifile,igrib, iret)
|
||||
|
||||
end do
|
||||
call codes_close_file(ifile)
|
||||
|
|
|
@ -31,7 +31,7 @@ program multi
|
|||
! turn off support for multi fields messages */
|
||||
!call codes_grib_multi_support_off()
|
||||
|
||||
call codes_new_from_file(ifile,igrib)
|
||||
call codes_grib_new_from_file(ifile,igrib)
|
||||
! Loop on all the messages in a file.
|
||||
|
||||
do while (igrib .ne. -1)
|
||||
|
@ -60,7 +60,7 @@ program multi
|
|||
endif
|
||||
|
||||
call codes_release(igrib)
|
||||
call codes_new_from_file(ifile,igrib, iret)
|
||||
call codes_grib_new_from_file(ifile,igrib, iret)
|
||||
|
||||
end do
|
||||
call codes_close_file(ifile)
|
||||
|
|
|
@ -29,7 +29,7 @@ program multi_write
|
|||
|
||||
! a grib message is loaded from file
|
||||
! in_gribid is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,in_gribid)
|
||||
call codes_grib_new_from_file(infile,in_gribid)
|
||||
|
||||
startsection=4
|
||||
do step=0,240,12
|
||||
|
|
|
@ -47,7 +47,7 @@ program find
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,igrib)
|
||||
call codes_grib_new_from_file(infile,igrib)
|
||||
|
||||
|
||||
call codes_grib_find_nearest(igrib, .true., lats, lons, nearest_lats, nearest_lons,lsm_values, distances, indexes)
|
||||
|
@ -58,7 +58,7 @@ program find
|
|||
! will apply it to another GRIB
|
||||
call codes_open_file(infile, &
|
||||
'../../data/reduced_gaussian_pressure_level.grib1','r')
|
||||
call codes_new_from_file(infile,igrib)
|
||||
call codes_grib_new_from_file(infile,igrib)
|
||||
|
||||
call codes_get_element(igrib,"values", indexes, values)
|
||||
call codes_release(igrib)
|
||||
|
|
|
@ -27,12 +27,12 @@ use eccodes
|
|||
|
||||
! Loop on all the messages in a file.
|
||||
|
||||
call codes_new_from_file(ifile,igrib, iret)
|
||||
call codes_grib_new_from_file(ifile,igrib, iret)
|
||||
|
||||
do while (iret==CODES_SUCCESS)
|
||||
count1=count1+1
|
||||
print *, "===== Message #",count1
|
||||
call codes_new_from_file(ifile,igrib, iret)
|
||||
call codes_grib_new_from_file(ifile,igrib, iret)
|
||||
|
||||
end do
|
||||
if (iret /= CODES_END_OF_FILE) then
|
||||
|
|
|
@ -32,7 +32,7 @@ program precision
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,igrib)
|
||||
call codes_grib_new_from_file(infile,igrib)
|
||||
|
||||
! bitsPerValue before changing the packing parameters
|
||||
call codes_get(igrib,'bitsPerValue',bitsPerValue1)
|
||||
|
|
|
@ -30,7 +30,7 @@ program precision
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,igrib)
|
||||
call codes_grib_new_from_file(infile,igrib)
|
||||
|
||||
! bitsPerValue before changing the packing parameters
|
||||
call codes_get(igrib,'bitsPerValue',bitsPerValue1)
|
||||
|
|
|
@ -30,7 +30,7 @@ call codes_open_file(ifile, &
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(ifile,igrib)
|
||||
call codes_grib_new_from_file(ifile,igrib)
|
||||
|
||||
! get the size of the values array
|
||||
call codes_get_size(igrib,'values',numPoints)
|
||||
|
|
|
@ -31,7 +31,7 @@ call codes_open_file(ifile, &
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(ifile,igrib)
|
||||
call codes_grib_new_from_file(ifile,igrib)
|
||||
|
||||
|
||||
! get the size of the values array
|
||||
|
|
|
@ -39,7 +39,7 @@ program sample
|
|||
call codes_open_file(outfile, 'out.samples.grib1','w')
|
||||
call codes_open_file(datafile,'../../data/tp_ecmwf.grib','r')
|
||||
|
||||
call codes_new_from_file(datafile,igribdata,err)
|
||||
call codes_grib_new_from_file(datafile,igribdata,err)
|
||||
|
||||
call codes_get_size(igribdata,'values',size1)
|
||||
allocate(v(size1))
|
||||
|
@ -69,7 +69,7 @@ program sample
|
|||
|
||||
call codes_write(igribclone,outfile)
|
||||
|
||||
call codes_new_from_file(datafile,igribdata,err)
|
||||
call codes_grib_new_from_file(datafile,igribdata,err)
|
||||
|
||||
if (err==0) then
|
||||
call codes_get(igribdata,'values',v2)
|
||||
|
|
|
@ -30,7 +30,7 @@ program set
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,igrib)
|
||||
call codes_grib_new_from_file(infile,igrib)
|
||||
|
||||
call codes_set(igrib,'dataDate',date1)
|
||||
! set centre as a integer */
|
||||
|
|
|
@ -36,7 +36,7 @@ program set_bitmap
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,igrib)
|
||||
call codes_grib_new_from_file(infile,igrib)
|
||||
|
||||
! The missingValue is not coded in the message.
|
||||
! It is a value we define as a placeholder for a missing value
|
||||
|
|
|
@ -34,7 +34,7 @@ program set
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,igrib)
|
||||
call codes_grib_new_from_file(infile,igrib)
|
||||
|
||||
! set centre as a long */
|
||||
centre=80
|
||||
|
|
|
@ -23,7 +23,7 @@ program set
|
|||
|
||||
call codes_open_file(outfile, 'out_gvc.grib2','w')
|
||||
|
||||
call codes_new_from_file(infile,igrib)
|
||||
call codes_grib_new_from_file(infile,igrib)
|
||||
|
||||
! Individual ensemble forecast
|
||||
call codes_set(igrib,'productDefinitionTemplateNumber', 11)
|
||||
|
|
|
@ -29,7 +29,7 @@ program set
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,igrib)
|
||||
call codes_grib_new_from_file(infile,igrib)
|
||||
|
||||
call codes_set(igrib,'typeOfFirstFixedSurface','sfc')
|
||||
call codes_set_missing(igrib,'scaleFactorOfFirstFixedSurface')
|
||||
|
|
|
@ -30,7 +30,7 @@ program set
|
|||
|
||||
! a new grib message is loaded from file
|
||||
! igrib is the grib id to be used in subsequent calls
|
||||
call codes_new_from_file(infile,igrib)
|
||||
call codes_grib_new_from_file(infile,igrib)
|
||||
|
||||
call codes_set(igrib,'typeOfFirstFixedSurface','sfc')
|
||||
call codes_set_missing(igrib,'scaleFactorOfFirstFixedSurface')
|
||||
|
|
|
@ -20,7 +20,7 @@ def example():
|
|||
out = open(sys.argv[2],'w')
|
||||
|
||||
while 1:
|
||||
gid = codes_new_from_file(f)
|
||||
gid = codes_grib_new_from_file(f)
|
||||
if gid is None: break
|
||||
|
||||
message = codes_get_message(gid)
|
||||
|
|
|
@ -22,7 +22,7 @@ def example():
|
|||
fin = open(INPUT)
|
||||
fout = open(OUTPUT,'w')
|
||||
|
||||
gid = codes_new_from_file(fin)
|
||||
gid = codes_grib_new_from_file(fin)
|
||||
|
||||
nx = codes_get(gid,'Ni')
|
||||
ny = codes_get(gid,'Nj')
|
||||
|
|
|
@ -20,7 +20,7 @@ def example():
|
|||
f = open(INPUT)
|
||||
|
||||
mcount = codes_count_in_file(f)
|
||||
gid_list = [codes_new_from_file(f) for i in range(mcount)]
|
||||
gid_list = [codes_grib_new_from_file(f) for i in range(mcount)]
|
||||
|
||||
f.close()
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ def example():
|
|||
]
|
||||
|
||||
while 1:
|
||||
gid = codes_new_from_file(f)
|
||||
gid = codes_grib_new_from_file(f)
|
||||
if gid is None: break
|
||||
|
||||
for key in keys:
|
||||
|
|
|
@ -19,7 +19,7 @@ def example(INPUT):
|
|||
f = open(INPUT)
|
||||
|
||||
while 1:
|
||||
gid = codes_new_from_file(f)
|
||||
gid = codes_grib_new_from_file(f)
|
||||
if gid is None: break
|
||||
|
||||
iterid = codes_grib_iterator_new(gid,0)
|
||||
|
|
|
@ -20,7 +20,7 @@ def example():
|
|||
f = open(INPUT)
|
||||
|
||||
while 1:
|
||||
gid = codes_new_from_file(f)
|
||||
gid = codes_grib_new_from_file(f)
|
||||
if gid is None: break
|
||||
|
||||
iterid = codes_keys_iterator_new(gid,'ls')
|
||||
|
|
|
@ -21,7 +21,7 @@ def example():
|
|||
fin = open(INPUT)
|
||||
fout = open(OUTPUT,'w')
|
||||
|
||||
gid = codes_new_from_file(fin)
|
||||
gid = codes_grib_new_from_file(fin)
|
||||
|
||||
mgid = codes_grib_multi_new()
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ def example():
|
|||
points = ((30,-20),(13,234))
|
||||
|
||||
f = open(INPUT)
|
||||
gid = codes_new_from_file(f)
|
||||
gid = codes_grib_new_from_file(f)
|
||||
|
||||
for lat,lon in points:
|
||||
nearest = codes_grib_find_nearest(gid,lat,lon)[0]
|
||||
|
|
|
@ -18,7 +18,7 @@ VERBOSE=1 # verbose error reporting
|
|||
|
||||
def example():
|
||||
f = open(INPUT)
|
||||
gid = codes_new_from_file(f)
|
||||
gid = codes_grib_new_from_file(f)
|
||||
|
||||
values = codes_get_values(gid)
|
||||
for i in xrange(len(values)):
|
||||
|
|
|
@ -34,7 +34,7 @@ def example():
|
|||
|
||||
prev_vals = None
|
||||
while 1:
|
||||
gid = codes_new_from_file(fin)
|
||||
gid = codes_grib_new_from_file(fin)
|
||||
if gid is None: break
|
||||
|
||||
curr_vals = codes_get_values(gid)
|
||||
|
|
|
@ -19,7 +19,7 @@ VERBOSE=1 # verbose error reporting
|
|||
def example():
|
||||
fin = open(INPUT)
|
||||
fout = open(OUTPUT,'w')
|
||||
gid = codes_new_from_file(fin)
|
||||
gid = codes_grib_new_from_file(fin)
|
||||
|
||||
dt = date.today()
|
||||
today = "%d%02d%02d" % (dt.year,dt.month,dt.day)
|
||||
|
|
|
@ -18,7 +18,7 @@ VERBOSE = 1 # verbose error reporting
|
|||
def example():
|
||||
fin = open(INPUT)
|
||||
fout = open(OUTPUT,'w')
|
||||
gid = codes_new_from_file(fin)
|
||||
gid = codes_grib_new_from_file(fin)
|
||||
|
||||
codes_set(gid,'missingValue', MISSING)
|
||||
values = codes_get_values(gid)
|
||||
|
|
|
@ -21,7 +21,7 @@ def example():
|
|||
fin = open(INPUT)
|
||||
fout = open(OUTPUT,'w')
|
||||
|
||||
gid = codes_new_from_file(fin)
|
||||
gid = codes_grib_new_from_file(fin)
|
||||
|
||||
codes_set_long(gid, "scaledValueOfFirstFixedSurface", 15);
|
||||
codes_set_long(gid, "scaleFactorOfFirstFixedSurface", 1)
|
||||
|
|
|
@ -17,6 +17,11 @@ module eccodes
|
|||
include "eccodes_constants.h"
|
||||
include "eccodes_visibility.h"
|
||||
|
||||
integer, parameter,public :: CODES_PRODUCT_GRIB = 1
|
||||
integer, parameter,public :: CODES_PRODUCT_BUFR = 2
|
||||
integer, parameter,public :: CODES_PRODUCT_ANY = 3
|
||||
|
||||
|
||||
!> Create a new message in memory from an integer or character array containting the coded message.
|
||||
!>
|
||||
!> The message can be accessed through its gribid and it will be available\n
|
||||
|
|
|
@ -504,17 +504,35 @@ subroutine codes_headers_only_new_from_file ( ifile, gribid , status)
|
|||
call grib_headers_only_new_from_file ( ifile, gribid , status)
|
||||
end subroutine codes_headers_only_new_from_file
|
||||
|
||||
!------------------
|
||||
subroutine codes_new_from_file (ifile, gribid , product_kind, status)
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
integer(kind=kindOfInt),intent(out) :: gribid
|
||||
integer(kind=kindOfInt),intent(in) :: product_kind
|
||||
integer(kind=kindOfInt),optional,intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
if (product_kind == CODES_PRODUCT_GRIB) then
|
||||
call codes_grib_new_from_file ( ifile, gribid , status)
|
||||
else if (product_kind == CODES_PRODUCT_BUFR) then
|
||||
call codes_bufr_new_from_file ( ifile, gribid , status)
|
||||
else
|
||||
! CODES_PRODUCT_ANY - Not yet implemented
|
||||
call grib_check(1,'codes_new_from_file','invalid product_kind')
|
||||
end if
|
||||
end subroutine codes_new_from_file
|
||||
|
||||
!
|
||||
subroutine codes_new_from_file ( ifile, gribid , status)
|
||||
subroutine codes_grib_new_from_file ( ifile, gribid , status)
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
integer(kind=kindOfInt),intent(out) :: gribid
|
||||
integer(kind=kindOfInt),optional,intent(out) :: status
|
||||
integer(kind=kindOfInt) :: iret
|
||||
|
||||
call grib_new_from_file ( ifile, gribid , status)
|
||||
end subroutine codes_new_from_file
|
||||
end subroutine codes_grib_new_from_file
|
||||
|
||||
!! TODO: temporary fix for BUFR
|
||||
!
|
||||
subroutine codes_bufr_new_from_file ( ifile, bufrid , status)
|
||||
integer(kind=kindOfInt),intent(in) :: ifile
|
||||
integer(kind=kindOfInt),intent(out) :: bufrid
|
||||
|
|
|
@ -12,7 +12,8 @@ public :: codes_keys_iterator_get_name, &
|
|||
codes_keys_iterator_rewind
|
||||
public :: codes_new_from_message, &
|
||||
codes_new_from_samples, codes_new_from_file, &
|
||||
codes_read_from_file,codes_headers_only_new_from_file
|
||||
codes_grib_new_from_file, codes_bufr_new_from_file, &
|
||||
codes_read_from_file,codes_headers_only_new_from_file
|
||||
public :: codes_release
|
||||
public :: codes_dump
|
||||
public :: codes_get_error_string
|
||||
|
@ -23,4 +24,4 @@ public :: codes_check
|
|||
public :: codes_clone, codes_copy_namespace
|
||||
public :: codes_index_get,codes_index_select,&
|
||||
codes_index_create,codes_index_get_size,codes_index_release,&
|
||||
codes_grib_util_sections_copy
|
||||
codes_grib_util_sections_copy
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
from gribapi import GRIB_CHECK as CODES_CHECK
|
||||
from gribapi import grib_new_from_file as codes_new_from_file
|
||||
|
||||
# TODO: temporary
|
||||
from gribapi import grib_new_from_file as codes_grib_new_from_file
|
||||
from gribapi import bufr_new_from_file as codes_bufr_new_from_file
|
||||
|
||||
from gribapi import grib_count_in_file as codes_count_in_file
|
||||
|
|
|
@ -42,6 +42,13 @@ KEYTYPES = {
|
|||
3:str,
|
||||
}
|
||||
|
||||
CODES_PRODUCT_GRIB=1
|
||||
""" GRIB product kind """
|
||||
CODES_PRODUCT_BUFR=2
|
||||
""" BUFR product kind """
|
||||
CODES_PRODUCT_ANY=3
|
||||
""" Generic product kind """
|
||||
|
||||
# GRIB-51 Skip function arguments type checking if the
|
||||
# environment variable is defined
|
||||
no_type_checks = os.environ.get('GRIB_API_PYTHON_NO_TYPE_CHECKS') is not None
|
||||
|
@ -173,6 +180,14 @@ def gts_new_from_file(fileobj, headers_only = False):
|
|||
else:
|
||||
return gribid
|
||||
|
||||
@require(fileobj=file,product_kind=int)
|
||||
def codes_new_from_file(fileobj, product_kind, headers_only = False):
|
||||
if product_kind == CODES_PRODUCT_GRIB:
|
||||
return grib_new_from_file(fileobj, headers_only)
|
||||
if product_kind == CODES_PRODUCT_BUFR:
|
||||
return bufr_new_from_file(fileobj, headers_only)
|
||||
raise Exception("Invalid product kind: " + product_kind)
|
||||
|
||||
@require(fileobj=file)
|
||||
def bufr_new_from_file(fileobj, headers_only = False):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue