@@ -148,6 +148,17 @@ def test_gts_header():
148148 codes_gts_header (False )
149149
150150
151+ def test_extract_offsets ():
152+ fpath = get_sample_fullpath ("BUFR4.tmpl" )
153+ if fpath is None :
154+ return
155+ is_strict = True
156+ offsets = codes_extract_offsets (fpath , CODES_PRODUCT_ANY , is_strict )
157+ offsets_list = list (offsets )
158+ assert len (offsets_list ) == 1
159+ assert offsets_list [0 ] == 0
160+
161+
151162# ---------------------------------------------
152163# GRIB
153164# ---------------------------------------------
@@ -389,28 +400,6 @@ def test_grib_nearest_multiple():
389400 assert nearest [1 ].index == 2500
390401
391402
392- def test_grib_nearest2 ():
393- gid = codes_grib_new_from_samples ("gg_sfc_grib2" )
394- lat , lon = 40 , 20
395- flags = CODES_GRIB_NEAREST_SAME_GRID | CODES_GRIB_NEAREST_SAME_POINT
396- nid = codes_grib_nearest_new (gid )
397- assert nid > 0
398- nearest = codes_grib_nearest_find (nid , gid , lat , lon , flags )
399- assert len (nearest ) == 4
400- expected_indexes = (2679 , 2678 , 2517 , 2516 )
401- returned_indexes = (
402- nearest [0 ].index ,
403- nearest [1 ].index ,
404- nearest [2 ].index ,
405- nearest [3 ].index ,
406- )
407- assert sorted (expected_indexes ) == sorted (returned_indexes )
408- assert math .isclose (nearest [0 ].value , 295.22085 , abs_tol = 0.0001 )
409- assert math .isclose (nearest [2 ].distance , 24.16520 , abs_tol = 0.0001 )
410- codes_release (gid )
411- codes_grib_nearest_delete (nid )
412-
413-
414403def test_grib_ecc_1042 ():
415404 # Issue ECC-1042: Python3 interface writes integer arrays incorrectly
416405 gid = codes_grib_new_from_samples ("regular_ll_sfc_grib2" )
@@ -698,7 +687,6 @@ def test_bufr_get_message_offset():
698687 assert codes_get_message_offset (gid ) == 0
699688
700689
701- # Experimental features
702690def test_codes_bufr_key_is_header ():
703691 bid = codes_bufr_new_from_samples ("BUFR4_local_satellite" )
704692 assert codes_bufr_key_is_header (bid , "edition" )
@@ -714,17 +702,6 @@ def test_codes_bufr_key_is_header():
714702 assert not codes_bufr_key_is_header (bid , "#6#brightnessTemperature" )
715703
716704
717- def test_extract_offsets ():
718- fpath = get_sample_fullpath ("BUFR4.tmpl" )
719- if fpath is None :
720- return
721- is_strict = True
722- offsets = codes_extract_offsets (fpath , CODES_PRODUCT_ANY , is_strict )
723- offsets_list = list (offsets )
724- assert len (offsets_list ) == 1
725- assert offsets_list [0 ] == 0
726-
727-
728705def test_bufr_extract_headers ():
729706 fpath = get_sample_fullpath ("BUFR4_local.tmpl" )
730707 if fpath is None :
@@ -739,3 +716,30 @@ def test_bufr_extract_headers():
739716 assert header ["ident" ].strip () == "91334"
740717 assert header ["rdbtimeSecond" ] == 19
741718 assert math .isclose (header ["localLongitude" ], 151.83 )
719+
720+
721+ # ---------------------------------------------
722+ # Experimental features
723+ # ---------------------------------------------
724+ def test_grib_nearest2 ():
725+ if "codes_grib_nearest_new" not in dir (eccodes ):
726+ return
727+ gid = codes_grib_new_from_samples ("gg_sfc_grib2" )
728+ lat , lon = 40 , 20
729+ flags = CODES_GRIB_NEAREST_SAME_GRID | CODES_GRIB_NEAREST_SAME_POINT
730+ nid = codes_grib_nearest_new (gid )
731+ assert nid > 0
732+ nearest = codes_grib_nearest_find (nid , gid , lat , lon , flags )
733+ assert len (nearest ) == 4
734+ expected_indexes = (2679 , 2678 , 2517 , 2516 )
735+ returned_indexes = (
736+ nearest [0 ].index ,
737+ nearest [1 ].index ,
738+ nearest [2 ].index ,
739+ nearest [3 ].index ,
740+ )
741+ assert sorted (expected_indexes ) == sorted (returned_indexes )
742+ assert math .isclose (nearest [0 ].value , 295.22085 , abs_tol = 0.0001 )
743+ assert math .isclose (nearest [2 ].distance , 24.16520 , abs_tol = 0.0001 )
744+ codes_release (gid )
745+ codes_grib_nearest_delete (nid )
0 commit comments