Package: reki
rekiA data tool for CEMC.Load GRIB2 data usingeccodesorcfgrib.InstallationDownload the latest source code from GitHub and install usingpip.If you are using system python, such asapps/python/3.6.3/gnuon HPC CMA-PI,please use--useroption to install on user directory.rekiuses ecCodes to decode GRIB files(which is needed byeccodesandcfgrib).Please install ecCodes through conda or other package source.Getting startedrekihas several functions to help users to find one filed from a local GRIB 2 file.load_message_from_filefromreki.format.grib.eccodesreturns a GRIB handler.Users can use it to get attrs or values with functions fromeccodes.For example, load 850hPa temperature from GRAPES GFS and get values from the returned message.>>>fromreki.format.grib.eccodesimportload_message_from_file>>>t=load_message_from_file(...     file_path="/g1/COMMONDATA/OPER/NWPC/GRAPES_GFS_GMF/Prod-grib/2020031721/ORIG/gmf.gra.2020031800105.grb2",...     parameter="t",...     level_type="isobaricInhPa",...     level=850,... )>>>data=eccodes.codes_get_double_array(t,"values")>>>data=data.reshape([720,1440])>>>dataarray([[249.19234375, 249.16234375, 249.16234375, ..., 249.15234375,249.19234375, 249.14234375],[249.45234375, 249.45234375, 249.42234375, ..., 249.45234375,249.44234375, 249.44234375],[249.69234375, 249.68234375, 249.68234375, ..., 249.70234375,249.67234375, 249.68234375],...,[235.33234375, 235.45234375, 235.62234375, ..., 235.47234375,235.63234375, 235.48234375],[235.78234375, 235.91234375, 235.64234375, ..., 235.80234375,235.72234375, 235.82234375],[235.66234375, 235.86234375, 235.82234375, ..., 235.85234375,235.68234375, 235.70234375]])NOTE: Please release the handler usingeccodes.codes_releasemanually.eccodesengine also provides some functions to load array from GRIB2 filein which GRIB2 message is loaded byeccodes-pythonand converted intoxarray.DataArraybynwpc-data.WARNING: This feature is under construction.>>>fromreki.format.grib.eccodesimportload_field_from_file>>>load_field_from_file(...     file_path="/sstorage1/COMMONDATA/OPER/NWPC/GRAPES_GFS_GMF/Prod-grib/2020031721/ORIG/gmf.gra.2020031800105.grb2",...     parameter="t",...     level_type="isobaricInhPa",...     level=850,... )<xarray.DataArray 't' (latitude: 720, longitude: 1440)>array([[249.19234375, 249.16234375, 249.16234375, ..., 249.15234375,249.19234375, 249.14234375],[249.45234375, 249.45234375, 249.42234375, ..., 249.45234375,249.44234375, 249.44234375],[249.69234375, 249.68234375, 249.68234375, ..., 249.70234375,249.67234375, 249.68234375],...,[235.33234375, 235.45234375, 235.62234375, ..., 235.47234375,235.63234375, 235.48234375],[235.78234375, 235.91234375, 235.64234375, ..., 235.80234375,235.72234375, 235.82234375],[235.66234375, 235.86234375, 235.82234375, ..., 235.85234375,235.68234375, 235.70234375]])Coordinates:time           datetime64[ns] 2020-03-18step           timedelta64[ns] 4 days 09:00:00valid_time     datetime64[ns] 2020-03-22T09:00:00isobaricInhPa  int64 850* latitude       (latitude) float64 89.88 89.62 89.38 ... -89.38 -89.62 -89.88* longitude      (longitude) float64 0.0 0.25 0.5 0.75 ... 359.2 359.5 359.8Attributes:GRIB_edition:                    2GRIB_centre:                     babjGRIB_subCentre:                  0GRIB_tablesVersion:              4GRIB_localTablesVersion:         1GRIB_dataType:                   fcGRIB_dataDate:                   20200318GRIB_dataTime:                   0GRIB_validityDate:               20200322GRIB_validityTime:               900GRIB_step:                       105GRIB_stepType:                   instantGRIB_stepUnits:                  1GRIB_stepRange:                  105GRIB_endStep:                    105GRIB_name:                       TemperatureGRIB_shortName:                  tGRIB_cfName:                     air_temperatureGRIB_discipline:                 0GRIB_parameterCategory:          0GRIB_parameterNumber:            0GRIB_gridType:                   regular_llGRIB_gridDefinitionDescription:  Latitude/longitudeGRIB_typeOfFirstFixedSurface:    plGRIB_typeOfLevel:                isobaricInhPaGRIB_level:                      850GRIB_numberOfPoints:             1036800GRIB_missingValue:               9999GRIB_units:                      Klong_name:                       Temperatureunits:                           KEnginesrekiloads GRIB2 file usingeccodesby default and also supportscfgrib.cfgribIf you don't care about loading speed, please usecfgribenginewith optionengine="cfgrib".Please install cfgrib before using this engine.Read 850hPa temperature from a GRAEPS GFS grib2 file usingshortNamekeyt.(shortNameis an ecCodes key. )>>>load_field_from_file(...     file_path="/g1/COMMONDATA/OPER/NWPC/GRAPES_GFS_GMF/Prod-grib/2020031721/ORIG/gmf.gra.2020031800105.grb2",...     parameter="t",...     level_type="isobaricInhPa",...     level=850,...     engine="cfgrib",... )<xarray.DataArray 't' (latitude: 720, longitude: 1440)>[1036800 values with dtype=float32]Coordinates:time           datetime64[ns] ...step           timedelta64[ns] ...isobaricInhPa  int64 ...* latitude       (latitude) float64 89.88 89.62 89.38 ... -89.38 -89.62 -89.88* longitude      (longitude) float64 0.0 0.25 0.5 0.75 ... 359.2 359.5 359.8valid_time     datetime64[ns] ...Attributes:GRIB_paramId:                             130GRIB_shortName:                           tGRIB_units:                               KGRIB_name:                                TemperatureGRIB_cfName:                              air_temperatureGRIB_cfVarName:                           tGRIB_dataType:                            fcGRIB_missingValue:                        9999GRIB_numberOfPoints:                      1036800GRIB_typeOfLevel:                         isobaricInhPaGRIB_NV:                                  0GRIB_stepUnits:                           1GRIB_stepType:                            instantGRIB_gridType:                            regular_llGRIB_gridDefinitionDescription:           Latitude/longitudeGRIB_Nx:                                  1440GRIB_iDirectionIncrementInDegrees:        0.25GRIB_iScansNegatively:                    0GRIB_longitudeOfFirstGridPointInDegrees:  0.0GRIB_longitudeOfLastGridPointInDegrees:   359.75GRIB_Ny:                                  720GRIB_jDirectionIncrementInDegrees:        0.25GRIB_jPointsAreConsecutive:               0GRIB_jScansPositively:                    0GRIB_latitudeOfFirstGridPointInDegrees:   89.875GRIB_latitudeOfLastGridPointInDegrees:    -89.875long_name:                                Temperatureunits:                                    Kstandard_name:                            air_temperatureIf the field doesn't have ashortName, usedictforparameter.Load a filed without shortName.>>>load_field_from_file(...     file_path="/g1/COMMONDATA/OPER/NWPC/GRAPES_GFS_GMF/Prod-grib/2020031721/ORIG/gmf.gra.2020031800105.grb2",...     parameter={...         "discipline": 0,...         "parameterCategory": 2,...         "parameterNumber": 225,...     },...     level_type="isobaricInhPa",...     level=850,... )<xarray.DataArray 'paramId_0' (latitude: 720, longitude: 1440)>[1036800 values with dtype=float32]Coordinates:time           datetime64[ns] ...step           timedelta64[ns] ...isobaricInhPa  int64 ...* latitude       (latitude) float64 89.88 89.62 89.38 ... -89.38 -89.62 -89.88* longitude      (longitude) float64 0.0 0.25 0.5 0.75 ... 359.2 359.5 359.8valid_time     datetime64[ns] ...Attributes:GRIB_paramId:                             0GRIB_dataType:                            fcGRIB_missingValue:                        9999GRIB_numberOfPoints:                      1036800GRIB_typeOfLevel:                         isobaricInhPaGRIB_NV:                                  0GRIB_stepUnits:                           1GRIB_stepType:                            instantGRIB_gridType:                            regular_llGRIB_gridDefinitionDescription:           Latitude/longitudeGRIB_Nx:                                  1440GRIB_iDirectionIncrementInDegrees:        0.25GRIB_iScansNegatively:                    0GRIB_longitudeOfFirstGridPointInDegrees:  0.0GRIB_longitudeOfLastGridPointInDegrees:   359.75GRIB_Ny:                                  720GRIB_jDirectionIncrementInDegrees:        0.25GRIB_jPointsAreConsecutive:               0GRIB_jScansPositively:                    0GRIB_latitudeOfFirstGridPointInDegrees:   89.875GRIB_latitudeOfLastGridPointInDegrees:    -89.875GRIB_discipline:                          0GRIB_parameterCategory:                   2GRIB_parameterNumber:                     225long_name:                                original GRIB paramId: 0units:                                    1ExamplesSeeexampledirectory for more examples.LICENSECopyright © 2020-2021, developers at cemc-oper.rekiis licensed underGPL v3.0