### Install Utility Program Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/python/CMakeLists.txt Installs the `prepbufr2nc` utility program to the system's binary directory. ```cmake install( PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/utils/prepbufr2nc DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} ) ``` -------------------------------- ### Build and Install NCEPLIBS-bufr Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/README.md Use these CMake commands to configure, build, test, and install the NCEPLIBS-bufr library. Specify installation paths and master table directories. Python interoperability and testing can be enabled/disabled. ```bash cmake -S NCEPLIBS-bufr -B NCEPLIBS-bufr/build -DCMAKE_INSTALL_PREFIX=path1 -DMASTER_TABLE_DIR=path2 cmake --build NCEPLIBS-bufr/build -j4 ctest --test-dir NCEPLIBS-bufr/build cmake --install NCEPLIBS-bufr/build ``` -------------------------------- ### Install Utility Executables with CMake Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/utils/CMakeLists.txt Installs the compiled utility executables to the 'bin' directory. This command ensures that all executables listed in '_utils_execs' are available in the runtime environment after installation. ```cmake install(TARGETS ${_utils_execs} RUNTIME DESTINATION bin COMPONENT utilities) ``` -------------------------------- ### Build and Install NCEPLIBS-bufr Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/user_guide.md Clone the repository, configure the build using CMake, build the library, run tests, and install it. Various CMake options are available to customize the build process. ```bash git clone https://github.com/NOAA-EMC/NCEPLIBS-bufr cmake -S NCEPLIBS-bufr -B NCEPLIBS-bufr/build cmake --build NCEPLIBS-bufr/build ctest --test-dir NCEPLIBS-bufr/build cmake --install NCEPLIBS-bufr/build ``` -------------------------------- ### Install Python Package Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/python/CMakeLists.txt Installs the Python package and the compiled extension module to the site-packages directory. ```cmake install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ncepbufr DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/python${_PYVER}/site-packages ) install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/python${_PYVER}/site-packages FILES_MATCHING PATTERN "_bufrlib*.so" PATTERN "CMakeFiles" EXCLUDE ) ``` -------------------------------- ### Table B Descriptor Examples Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/master_tables.md Illustrates the application of the descriptor definition format with concrete examples, showing variations in whitespace usage. ```text 0-01-018 | 0 | 0 | 40 | CCITT IA5 | SSTN ; ; Short station or site name ``` ```text 0-01-041 | 5 | -1073741824 | 31 | m/s | PS00 ; ; Absolute platform velocity - first component ``` ```text 0-05-002 | 2 | -9000 | 15 | Degree(N+,S-) | CLAT ; ; Latitude (coarse accuracy) ``` ```text 0-07-002 | -1 | -40 | 16 | m | HMSL ; ; Height or altitude ``` -------------------------------- ### Install Testing Scripts Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/test/CMakeLists.txt Installs various testing utility scripts to the binary directory for use during the testing phase. This includes scripts for data manipulation and debugging. ```cmake list(APPEND test_scripts test_outtest.sh ) if(BUILD_UTILS) list(APPEND test_scripts test_gettab.sh test_binv.sh test_sinv.sh test_readbp.sh test_readmp.sh test_cmpbqm.sh test_split_by_subset.sh test_debufr.sh test_xbfmg.sh test_apxdx.sh ) endif() foreach(test_script ${test_scripts}) execute_process( COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/test_scripts/${test_script} ${CMAKE_BINARY_DIR}/bin/${test_script} ) endforeach() ``` -------------------------------- ### BUFR Subset Dump Example Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/python/test/Python_tutorial_bufr.ipynb Displays a sample output from `bufr.dump_subset()`, showing message type, parameter names, values, and descriptions. This can be very verbose. ```text MESSAGE TYPE NC031005 004001 YEAR 2018.0 YEAR YEAR 004002 MNTH 8.0 MONTH MONTH 004003 DAYS 1.0 DAY DAY 004004 HOUR 0.0 HOUR HOUR 004005 MINU 16.0 MINUTE MINUTE 035195 SEQNUM 317 ( 4)CCITT IA5 CHANNEL SEQUENCE NUMBER 035021 BUHD IOPX01 ( 6)CCITT IA5 BULLETIN BEING MONITORED (TTAAii) 035023 BORG KWBC ( 4)CCITT IA5 BULLETIN BEING MONITORED (CCCC) 035022 BULTIM 010029 ( 6)CCITT IA5 BULLETIN BEING MONITORED (YYGGgg) 035194 BBB MISSING ( 6)CCITT IA5 BULLETIN BEING MONITORED (BBB) 008202 RCTS 0.0 CODE TABLE RECEIPT TIME SIGNIFICANCE 004200 RCYR 2018.0 YEAR YEAR - TIME OF RECEIPT 004201 RCMO 8.0 MONTH MONTH - TIME OF RECEIPT 004202 RCDY 1.0 DAY DAY - TIME OF RECEIPT 004203 RCHR 0.0 HOUR HOUR - TIME OF RECEIPT 004204 RCMI 31.0 MINUTE MINUTE - TIME OF RECEIPT 033215 CORN 0.0 CODE TABLE CORRECTED REPORT INDICATOR 001087 WMOP 6903327.0 NUMERIC WMO marine observing platform extended identifie 001085 OPMM S2-X (20)CCITT IA5 Observing platform manufacturer's model 001086 OPMS 10151 ( 32)CCITT IA5 Observing platform manufacturer's serial number 002036 BUYTS 2.0 CODE TABLE Buoy type 002148 DCLS 8.0 CODE TABLE Data collection and/or location system 002149 BUYT 14.0 CODE TABLE Type of data buoy 022055 FCYN 28.0 NUMERIC Float cycle number 022056 DIPR 0.0 CODE TABLE Direction of profile 022067 IWTEMP 846.0 CODE TABLE INSTRUMENT TYPE FOR WATER TEMPERATURE PROFILE ME 005001 CLATH 59.34223 DEGREES LATITUDE (HIGH ACCURACY) 006001 CLONH -9.45180 DEGREES LONGITUDE (HIGH ACCURACY) 008080 QFQF 20.0 CODE TABLE Qualifier for GTSPP quality flag 033050 GGQF 1.0 CODE TABLE Global GTSPP quality flag (GLPFDATA) 636 REPLICATIONS ++++++ GLPFDATA REPLICATION # 1 ++++++ 007065 WPRES 10000.0 PA Water pressure 008080 QFQF 10.0 CODE TABLE Qualifier for GTSPP quality flag 033050 GGQF 1.0 CODE TABLE Global GTSPP quality flag 022045 SSTH 285.683 K Sea/water temperature 008080 QFQF 11.0 CODE TABLE Qualifier for GTSPP quality flag 033050 GGQF 1.0 CODE TABLE Global GTSPP quality flag 022064 SALNH 35.164 PART PER THOUSAND Salinity ``` -------------------------------- ### readbp Sample Output Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/utils.md Example output from the readbp utility when processing a prepbufr file. This shows the structure of a single report, including message details, station information, time, and data levels. ```text MESSAGE: ADPUPA 1 2 20081200 STATION: 89642 140.02 -66.67 TIME: 20081200 0.00 ELV: 43.00 PSL: ******** TYPE: 11. 177. 220. SOURCE: vH7B SEQUENCE ********** DATA: LVL CAT POB SPH TOB ZOB UOB VOB 1 3 1002.0(2) *******(*) *******(*) *******(*) -3.8(2) 8.2(2) 2 1 1000.0(2) *******(*) *******(*) *******(*) -3.8(2) 8.2(2) 3 1 925.0(2) *******(*) *******(*) *******(*) -5.1(2) 6.1(2) 4 1 850.0(2) *******(*) *******(*) *******(*) -4.2(2) 4.2(2) 5 1 700.0(2) *******(*) *******(*) *******(*) 3.1(2) 8.5(2) 6 1 500.0(2) *******(*) *******(*) *******(*) 21.2(2) 21.2(2) 7 1 400.0(2) *******(*) *******(*) *******(*) 29.1(2) 24.4(2) 8 1 300.0(2) *******(*) *******(*) *******(*) 26.9(2) 26.9(2) 9 5 273.0(2) *******(*) *******(*) *******(*) 21.9(2) 26.0(2) 10 1 250.0(2) *******(*) *******(*) *******(*) 29.5(2) 20.6(2) 11 5 200.0(2) *******(*) *******(*) *******(*) 29.5(2) 20.6(2) 12 1 150.0(2) *******(*) *******(*) *******(*) 35.5(2) 20.5(2) 13 1 100.0(2) *******(*) *******(*) *******(*) 42.6(2) 19.9(2) 14 1 70.0(2) *******(*) *******(*) *******(*) 49.8(2) 23.2(2) 15 1 50.0(2) *******(*) *******(*) *******(*) 57.1(2) 26.6(2) 16 1 30.0(2) *******(*) *******(*) *******(*) 70.5(2) 18.9(2) 17 1 20.0(2) *******(*) *******(*) *******(*) 83.1(2) 22.3(2) ``` -------------------------------- ### Example Table D Entry: Time (HHMM) Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/master_tables.md Shows a Table D entry for 'HHMM' (Hour and Minute), illustrating how time elements are represented. ```text 3-01-012 | HHMM ; ; | 0-04-004 > | Hour | 0-04-005 | Minute ``` -------------------------------- ### Example Code Table Entry with Dependencies Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/master_tables.md Illustrates a code table entry for the GSES mnemonic, showing how meanings depend on other FXY numbers. ```text 0-01-034 | GSES ; CODE | 0-01-031,0-01-033,0-01-035=39 | 0 > | No sub-centre | 225 > | Beijing | 226 > | Guangzhou | 228 > | Urumuqi | 0-01-031,0-01-033,0-01-035=80 | 0 > | No sub-centre | 101 > | Albania (NMC) | 102 > | National Research Council/Institute of Atmospheric Sciences and Climate (CNR-ISAC) | 0-01-031,0-01-033,0-01-035=7 | 0 > | No sub-centre | 1 > | NCEP Reanalysis Project | 2 > | NCEP Ensemble Products | 3 > | NCEP Central Operations | 4 > | Environmental Modeling Center | 5 > | Weather Prediction Center | 6 > | Ocean Prediction Center | 7 > | Climate Prediction Center | 8 > | Aviation Weather Center | 9 > | Storm Prediction Center | 10 > | National Hurricane Center | 11 > | NWS Techniques Development Laboratory | 12 > | NESDIS Office of Research and Applications | 13 > | Federal Aviation Administration | 14 > | NWS Meteorological Development Laboratory | 15 > | North American Regional Reanalysis Project | 16 > | Space Weather Prediction Center | 17 > | ESRL Global Systems Division | 0-01-031,0-01-033,0-01-035=46 | 0 > | No sub-centre | 10 > | Cachoeira Paulista (INPE) | 11 > | Cuiaba (INPE) | 12 > | Brasilia (INMET) | 13 > | Fortaleza (FUNCEME) | 14 > | Natal (Navy Hygrog. Centre) | 15 > | Manaus (SIVAM) | 16 > | Natal (INPE) | 17 > | Boa Vista | 25 > | São Paulo University - USP | 0-01-031,0-01-033,0-01-035=254 | 0 > | No sub-centre | 10 > | Tromso (Norway) | 20 > | Maspalomas (Spain) | 30 > | Kangerlussuaq (Greenland) | 40 > | Edmonton (Canada) | 50 > | Bedford (Canada) | 60 > | Gander (Canada) | 70 > | Monterey (USA) ``` -------------------------------- ### Example Table D Entry: Latitude and Longitude with Day and Time Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/master_tables.md Illustrates a complex Table D entry 'LTLONCDT' that combines latitude/longitude with day and time elements. ```text 3-01-025 | LTLONCDT ; ; | 3-01-023 > | Latitude and longitude (coarse accuracy) | 0-04-003 > | Day | 3-01-012 | Time ``` -------------------------------- ### Install BUFR Tables Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/tables/CMakeLists.txt This command copies the list of BUFR tables to the specified master table directory during the configuration phase. This ensures the tables are available for use, particularly with ctest. ```cmake file(COPY ${bufr_tables} DESTINATION ${MASTER_TABLE_DIR}) ``` -------------------------------- ### Import Libraries for BUFR Analysis Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/python/test/Python_tutorial_bufr.ipynb Import the required libraries for plotting, numerical operations, and BUFR file handling. Ensure these libraries are installed before running. ```python import matplotlib.pyplot as plt import numpy as np import ncepbufr ``` -------------------------------- ### Configure Doxygen and Build Docs Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/CMakeLists.txt This snippet configures Doxygen using a template file and creates a custom CMake target 'doc' to generate API documentation. Ensure Doxygen is installed and accessible in your environment. ```cmake set(package_base "${PROJECT_SOURCE_DIR}") set(build_base "${PROJECT_BINARY_DIR}") # Create doxyfile. set(abs_top_srcdir "${CMAKE_SOURCE_DIR}") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) # Build documentation with target all. add_custom_target(doc ALL ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API Documentation with Doxygen" VERBATIM) ``` -------------------------------- ### Example Table D Entry: Satellite Location and Velocity Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/master_tables.md Details a Table D entry for 'SATLOVEL' (Satellite location and velocity), showcasing a sequence with various time, data, and scale change elements. ```text 3-01-045 | SATLOVEL ; ; Satellite location and velocity | 3-01-011 > | Year, month, day | 3-01-012 > | Time (hour, minute) | 2-01-138 > | Change width to 16 bits | 2-02-131 > | Change scale to 3 | 0-04-006 > | Second | 2-01-000 > | Change width back to Table B | 2-02-000 > | Change scale back to Table B | 3-04-030 > | Location relative to the Earth's centre | 3-04-031 | Velocity relative to the Earth's centre ``` -------------------------------- ### Example Table D Entry: Latitude and Longitude (Coarse Accuracy) Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/master_tables.md Provides an example of a Table D entry for 'LTLONC' (Latitude and longitude, coarse accuracy), including its constituent elements. ```text 3-01-023 | LTLONC ; ; | 0-05-002 > | Latitude (coarse accuracy) | 0-06-002 | Longitude (coarse accuracy) ``` -------------------------------- ### Open BUFR file for input/output (Fortran) Source: https://context7.com/noaa-emc/nceplibs-bufr/llms.txt Opens a BUFR file and connects it to the library for reading, writing, or appending. Requires an associated DX BUFR table, either embedded or external. Use 'FIRST' to initialize without a file or 'QUIET' to change verbosity. ```Fortran integer :: lunit = 11 open(lunit, file='input.bufr', form='unformatted') call openbf(lunit, 'IN', lunit) ! lundx = lunit => embedded tables ! Fortran: Write a new BUFR file using an external DX table integer :: lout = 12, ltab = 13 open(lout, file='output.bufr', form='unformatted') open(ltab, file='bufrtab.txt', form='formatted') call openbf(lout, 'OUT', ltab) ! Fortran: Close when done call closbf(lunit) call closbf(lout) ``` -------------------------------- ### Check NumPy Version Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/python/CMakeLists.txt Executes a Python command to check the installed NumPy version. If NumPy is not found, the build fails. ```cmake execute_process( COMMAND ${Python3_EXECUTABLE} -c "import numpy; print(numpy.__version__)" OUTPUT_VARIABLE NUMPY_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET ) if(NOT NUMPY_VERSION) message(FATAL_ERROR "NumPy not found. Please install numpy.") endif() message(STATUS "NumPy version: ${NUMPY_VERSION}") ``` -------------------------------- ### Reading, Writing, and Inventorying BUFR Files with ncepbufr Source: https://context7.com/noaa-emc/nceplibs-bufr/llms.txt Demonstrates reading Argo profile data, writing surface observations, and creating an inventory of BUFR messages. Ensure BUFR files and necessary tables are accessible. ```python import numpy as np import ncepbufr # --- Reading: Argo profile data --- bufr = ncepbufr.open('data/xx005') # embedded DX table while bufr.advance() == 0: print(f"Msg: {bufr.msg_type} Date: {bufr.msg_date} Subsets: {bufr.subsets}") while bufr.load_subset() == 0: # Read scalars (no replication) loc = bufr.read_subset('CLATH CLONH') # shape (2, 1) lat, lon = loc[0, 0], loc[1, 0] # Read profile (delayed replication - default mode) profile = bufr.read_subset('WPRES SSTH SALNH') # shape (3, nlevs) depth = profile[0].compressed() / 10000.0 # Pa -> m temp = profile[1].compressed() - 273.15 # K -> C salinity = profile[2].compressed() if not np.ma.is_masked(lat): print(f" lat={lat:.3f} lon={lon:.3f} levels={len(depth)}") bufr.close() # --- Writing: surface observations --- bufr_out = ncepbufr.open('output.bufr', mode='w', table='bufrtab.ADPSFC') bufr_out.open_message('NC000007', 2024010100) data = np.array([[40.7128], [-74.0060], [10.0], [273.15], [101325.0]]) bufr_out.write_subset(data, 'CLAT CLON SELV TMDB PRES', end=True) bufr_out.close_message() bufr_out.close() # --- Inventory: list all messages without reading data --- bufr_inv = ncepbufr.open('data.bufr') for msg_type, msg_date, rcpt, nsub in bufr_inv.inventory(): print(f"{msg_type} {msg_date} subsets={nsub}") bufr_inv.close() # --- Print/dump subset contents --- bufr2 = ncepbufr.open('sfcshp.bufr') bufr2.advance() bufr2.load_subset() bufr2.print_subset() # human-readable mnemonic listing to stdout bufr2.dump_subset('out.txt') # write to file bufr2.close() ``` -------------------------------- ### CMPBQM Sample Output Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/utils.md Sample output from the CMPBQM utility when run on a prepbufr file. It details observation counts by quality marker for different variables. ```text DATA VALID AT 2020081100 PRESSURE typ tot 0-3 4-7 8 9 10 11 12 13 14 15 cka ckb ---------------------------------------------------------------------------------------- 120 32154| 31952| 0| 43| 2| 0 0 0 1 156 0| 0| 0 126 1169| 1169| 0| 0| 0| 0 0 0 0 0 0| 0| 0 130 602| 601| 0| 1| 0| 0 0 0 0 0 0| 0| 0 131 10321| 10321| 0| 0| 0| 0 0 0 0 0 0| 0| 0 133 86356| 86356| 0| 0| 0| 0 0 0 0 0 0| 0| 0 134 4170| 4170| 0| 0| 0| 0 0 0 0 0 0| 0| 0 135 208| 208| 0| 0| 0| 0 0 0 0 0 0| 0| 0 180 9296| 9026| 0| 6| 0| 0 0 0 0 203 61| 0| 0 181 23224| 20989| 0| 326| 10| 0 0 0 0 87 1812| 0| 0 183 3626| 0| 0| 12| 3582| 0 0 0 0 32 0| 0| 0 187 42698| 42300| 0| 112| 0| 0 0 0 0 286 0| 0| 0 220 39385| 39194| 0| 2| 0| 0 0 0 0 189 0| 0| 0 221 720| 720| 0| 0| 0| 0 0 0 0 0 0| 0| 0 224 16527| 16527| 0| 0| 0| 0 0 0 0 0 0| 0| 0 229 4| 4| 0| 0| 0| 0 0 0 0 0 0| 0| 0 230 166| 166| 0| 0| 0| 0 0 0 0 0 0| 0| 0 231 10319| 10319| 0| 0| 0| 0 0 0 0 0 0| 0| 0 233 86112| 86112| 0| 0| 0| 0 0 0 0 0 0| 0| 0 234 4170| 4170| 0| 0| 0| 0 0 0 0 0 0| 0| 0 235 208| 208| 0| 0| 0| 0 0 0 0 0 0| 0| 0 242 27875| 25521| 0| 0| 0| 0 0 0 2354 0 0| 0| 0 243 7040| 7040| 0| 0| 0| 0 0 0 0 0 0| 0| 0 250 58010| 52503| 0| 0| 0| 0 0 0 5507 0 0| 0| 0 252 53788| 48854| 0| 0| 0| 0 0 0 4934 0 0| 0| 0 253 13601| 13601| 0| 0| 0| 0 0 0 0 0 0| 0| 0 254 34156| 34156| 0| 0| 0| 0 0 0 0 0 0| 0| 0 257 8139| 8139| 0| 0| 0| 0 0 0 0 0 0| 0| 0 258 4127| 4127| 0| 0| 0| 0 0 0 0 0 0| 0| 0 259 5208| 5208| 0| 0| 0| 0 0 0 0 0 0| 0| 0 280 8310| 8049| 0| 0| 0| 0 0 0 0 203 58| 0| 0 281 22689| 20662| 0| 190| 0| 0 0 0 0 87 1750| 0| 0 282 240| 240| 0| 0| 0| 0 0 0 0 0 0| 0| 0 284 3542| 3497| 0| 12| 0| 0 0 0 0 32 1| 0| 0 287 42327| 41985| 0| 73| 0| 0 0 0 0 268 1| 0| 0 290231701|231701| 0| 0| 0| 0 0 0 0 0 0| 0| 0 SPECIFIC HUMIDTY 120 28995| 14978| 0| 1| 13528| 0 0 0 3 219 266| 0| 0 133 13662| 9428| 0| 0| 3623| 0 0 0 329 216 66| 0| 0 ``` -------------------------------- ### Create Fortran Test Executables Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/test/CMakeLists.txt Generates plain and numbered test executables for different kinds of Fortran builds. ```cmake foreach(kind ${test_kinds}) create_test_plain(test_misc ${kind}) create_test_plain(test_ufbrw ${kind}) create_test_plain(test_ufbcup ${kind}) foreach(innum RANGE 1 14) create_test(intest ${kind} ${innum}) endforeach() foreach(outnum RANGE 1 13) create_test(outtest ${kind} ${outnum}) endforeach() endforeach() ``` -------------------------------- ### Retrieve Replicated Mnemonics with ufbseq Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/dx_tables.md Example of using the ufbseq() subroutine to retrieve replicated mnemonics from a sequence. The str argument specifies the sequence name. ```fortran ufbseq(str='PRGPTMDP') ``` -------------------------------- ### Retrieve Replicated Mnemonics with ufbint Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/dx_tables.md Example of using the ufbint() subroutine to retrieve replicated mnemonics from a delayed replication sequence. The str argument specifies the mnemonics to retrieve. ```fortran ufbint(str='PRLC GEOP TMDB TMDP') ``` -------------------------------- ### Configure Source Files with CMake Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/utils/CMakeLists.txt Uses CMake's configure_file command to process input files (.in) and generate output files with variable substitution. This is useful for creating source files that depend on build-time configurations. ```cmake configure_file(${CMAKE_CURRENT_SOURCE_DIR}/debufr.c.in ${CMAKE_CURRENT_BINARY_DIR}/debufr.c @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sinv.F90.in ${CMAKE_CURRENT_BINARY_DIR}/sinv.F90 @ONLY) ``` -------------------------------- ### Read cloud amount/height for fixed replication (Fortran) Source: https://context7.com/noaa-emc/nceplibs-bufr/llms.txt Reads cloud amount and height for a fixed replication sequence using `ufbrep`. The second dimension of the data array must be at least as large as the replication count. ```fortran ! Fortran: Read cloud amount/height for a fixed replication sequence real*8 :: clddata(2, 10) integer :: nrep, lunit = 11 call readsb(lunit, iret) call ufbrep(lunit, clddata, 2, 10, nrep, 'CLAM HOCB') do k = 1, nrep write(*,'(2F10.2)') clddata(1,k), clddata(2,k) end do ``` -------------------------------- ### Example of 201YYY Operator Usage Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/dx_tables.md Demonstrates the use of the 201YYY operator to increase the bit width for a mnemonic. The operator adds a specified number of bits to the mnemonic's defined width. ```plaintext 201132 HINC 201000 ``` -------------------------------- ### readbp Usage Information Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/utils.md Displays the command-line arguments and options for the readbp utility. Use these flags to filter reports by station ID, location, subset name, or report type. ```bash Usage: readbp <-s> <-w> <-m> <-k> <-r> <-d> <-n> <-h> prep bufrfile Search filter and/or print prepbufr reports in various ways -s "station_id " print reports where "station_id" matches the report id up to the len of "station_id" -w "x1 x2 y1 y2" print reports within a lon/lat box -m "subset " print reports with this subset name -k "gsi rtype " print reports with this gsi report type -r "on29 rtype " print reports with this on29 report type -d print reports using ufdump - note: this works with any NCEP BUFR file -n no pause between reports output -h print only report headers Only a filename is required in which case step through the reports one at a time using "enter" ``` -------------------------------- ### Add C bort Test Executable Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/test/CMakeLists.txt Creates a C executable for testing the bort() functionality, linking it with the BUFR library and setting include directories. ```cmake set(test_name test_c_bort) add_executable(${test_name} ${test_name}.c) add_dependencies(${test_name} bufr_4) target_link_libraries(${test_name} PRIVATE bufr::bufr_4) target_include_directories(${test_name} PRIVATE "${CMAKE_BINARY_DIR}/src") ``` -------------------------------- ### Example Table D Entry: Surface Station Identification Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/master_tables.md Demonstrates a Table D entry for 'SFCSTNID' (Surface station identification), including its elements like WMO block number, station number, and station name. ```text 3-01-004 | SFCSTNID ; ; Surface station identification | 0-01-001 > | WMO block number | 0-01-002 > | WMO station number | 0-01-015 > | Station or site name | 0-02-001 | Type of station ``` -------------------------------- ### Read all elements of a profile sequence (Fortran) Source: https://context7.com/noaa-emc/nceplibs-bufr/llms.txt Reads all elements of a profile sequence at once using `ufbseq`. Useful when the full sequence structure is needed. ```fortran ! Fortran: Read all elements of a profile sequence at once real*8 :: seqdata(1800, 1000) integer :: nlevs, lunit = 11 call readsb(lunit, iret) call ufbseq(lunit, seqdata, 1800, 1000, nlevs, 'GLPFDATA') write(*,*) 'Profile levels:', nlevs ``` -------------------------------- ### Example Table D Entry: Wind Data at Pressure Level Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/master_tables.md Presents a Table D entry for 'WDPLRAOB' (Wind data at a pressure level with radiosonde position), including elements related to time, pressure, and wind characteristics. ```text 3-03-050 | WDPLRAOB ; ; Wind data at a pressure level with radiosonde position | 0-04-086 > | Long time period or displacement (since launch time) | 0-08-042 > | Extended vertical sounding significance | 0-07-004 > | Pressure | 0-05-015 > | Latitude displacement since launch site (high accuracy) | 0-06-015 > | Longitude displacement since launch site (high accuracy) | 0-11-001 > | Wind direction | 0-11-002 | Wind speed ``` -------------------------------- ### Build Utility Executables with CMake Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/utils/CMakeLists.txt Iterates through a list of source files to add executables, manage dependencies, and set linker languages for C source files. It ensures all utilities are linked against the 'bufr::bufr_4' library. ```cmake list(APPEND _utils_srcs apxdx.F90 binv.F90 cmpbqm.F90 ${CMAKE_CURRENT_BINARY_DIR}/sinv.F90 gettab.F90 readbp.F90 readmp.F90 split_by_subset.F90 xbfmg.c ) foreach(_src ${_utils_srcs}) get_filename_component(_exec "${_src}" NAME_WE) get_filename_component(_ext "${_src}" LAST_EXT) add_executable(${_exec} ${_src}) add_dependencies(${_exec} bufr::bufr_4) if(${_ext} MATCHES ".c") target_include_directories(${_exec} PRIVATE "${PROJECT_BINARY_DIR}/src") set_property(TARGET ${_exec} PROPERTY LINKER_LANGUAGE C) endif() target_link_libraries(${_exec} PRIVATE bufr::bufr_4) list(APPEND _utils_execs ${_exec}) endforeach() ``` -------------------------------- ### Build Debufr Utility with C and Fortran Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/utils/CMakeLists.txt Defines the 'debufr' executable, which is built from both a C source file and a Fortran source file. It specifies include directories and links against the 'bufr::bufr_4' library, setting the linker language to C. ```cmake set(_exec debufr) add_executable(${_exec} ${CMAKE_CURRENT_BINARY_DIR}/debufr.c debufr.F90) add_dependencies(${_exec} bufr::bufr_4) target_include_directories(${_exec} PRIVATE "${PROJECT_BINARY_DIR}/src") set_property(TARGET ${_exec} PROPERTY LINKER_LANGUAGE C) target_link_libraries(${_exec} PRIVATE bufr::bufr_4) list(APPEND _utils_execs ${_exec}) ``` -------------------------------- ### Example Code/Flag Table Entries Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/docs/master_tables.md Illustrates the format for defining code and flag table entries, including mnemonic identifiers and their associated values and meanings. The '>' character indicates continuation, and its absence marks the last entry for a mnemonic. ```plaintext 0-02-003 | A4ME ; CODE | 0 > | Pressure Instrument associated with wind measuring equipment | 1 > | Optical theodolite | 2 > | Radio theodolite | 3 > | Radar | 4 > | VLF-Omega | 5 > | Loran C | 6 > | Wind profiler | 7 > | Satellite navigation | 8 > | Radio-acoustic Sounding System (RASS) | 9 > | Sodar | 10 > | LIDAR | 14 | Pressure instrument associated with wind measuring equipment but pressure element failed during ascent ``` ```plaintext 0-02-008 | TOFSP ; CODE | 0 > | Fixed platform | 1 > | Mobile offshore drill ship | 2 > | Jack-up rig | 3 > | Semi-submersible platform | 4 > | FPSO (floating production storage and offloading unit) | 5 | Light vessel ``` ```plaintext 0-02-016 | RCONF ; FLAG | 1 > | Train regulator | 2 > | Light unit | 3 > | Parachute | 4 | Rooftop release ``` ```plaintext 0-02-017 | CAHM ; CODE | 0 > | No corrections | 1 > | Time lag correction provided by the manufacturer | 2 > | Solar radiation correction provided by the manufacturer | 3 > | Solar radiation and time lag correction provided by the manufacturer | 7 | GRUAN solar radiation and time lag correction ``` ```plaintext 0-02-022 | SDPT ; FLAG | 1 > | Processing technique not defined | 2 > | Automated statistical regression | 3 > | Clear path | 4 > | Partly cloudy path | 5 | Cloudy path ``` -------------------------------- ### Build Python Extension Module (Meson Backend) Source: https://github.com/noaa-emc/nceplibs-bufr/blob/develop/python/CMakeLists.txt Builds the Python extension module `_bufrlib` using `numpy.f2py` with the Meson backend. This is used for newer NumPy versions or Python versions 3.12 and above. ```cmake add_custom_target(python_mod ALL COMMAND ${CMAKE_COMMAND} -E env "LDFLAGS=-L${BUFR_LIB_DIR} -l${BUFR_LIB_NAME} -Wl,-rpath,${BUFR_LIB_DIR}" ${Python3_EXECUTABLE} -m numpy.f2py -c "${CMAKE_CURRENT_SOURCE_DIR}/_bufrlib.pyf" -m _bufrlib --backend meson DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/_bufrlib.pyf" bufr_4 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Building Python module _bufrlib with f2py (meson backend)" ) ```