NCEPLIBS-g2c icon indicating copy to clipboard operation
NCEPLIBS-g2c copied to clipboard

A better way to handle GRIB codes?

Open edwardhartnett opened this issue 3 years ago • 10 comments
trafficstars

Here we can find XML versions of the GRIB codes: https://community.wmo.int/activity-areas/wis/latest-version

Here's a sample:

	<GRIB2_CodeFlag_en>
		<Title_en>Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table</Title_en>
		<CodeFlag>0</CodeFlag>
		<MeaningParameterDescription_en>Meteorological products</MeaningParameterDescription_en>
		<Status>Operational</Status>
	</GRIB2_CodeFlag_en>
	<GRIB2_CodeFlag_en>
		<Title_en>Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table</Title_en>
		<CodeFlag>1</CodeFlag>
		<MeaningParameterDescription_en>Hydrological products</MeaningParameterDescription_en>
		<Status>Operational</Status>
	</GRIB2_CodeFlag_en>
	<GRIB2_CodeFlag_en>
		<Title_en>Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table</Title_en>
		<CodeFlag>2</CodeFlag>
		<MeaningParameterDescription_en>Land surface products</MeaningParameterDescription_en>
		<Status>Operational</Status>
	</GRIB2_CodeFlag_en>

So we can download these XML files (there are 2 for GRIB2) in the repo. Then we can find and use an XML parser library. Then g2c could read the XML and serve up all the code information. This would be very helpful for g2c, and for other applications using g2c.

In a further refactor, the g2tmpl project could just call the g2c library to get the codes, instead of maintaining them in Fortran code.

One problem is that we seem to have also defined our own "keys" which have to be maintained as well. I'm not sure yet how to cope with that.

The advantage is that we could use the WMO XML files directly, getting their updates and changes whenever they make them, automatically.

We would also still have to support any local codes as well.

@BoiVuong-NOAA @Hang-Lei-NOAA any comments on this idea?

edwardhartnett avatar Aug 24 '22 23:08 edwardhartnett

This is good idea to use XML files in the repo. But, I do not know how UPP code use the g2tmpl lib in GFS, NAM, RRFS, and UFS models. You need to check with developers.

BoiVuong-NOAA avatar Aug 25 '22 12:08 BoiVuong-NOAA

g2tmpl users will not see any change.

After ingesting the codes into g2c, the g2tmpl Fortran functions can be changed to get their results from the g2c library.

Users of g2tmpl would not see any difference, but the codes would move to the C library and be served from there to any other software that needs them, including g2tmpl.

edwardhartnett avatar Aug 25 '22 12:08 edwardhartnett

That is great.

BoiVuong-NOAA avatar Aug 25 '22 13:08 BoiVuong-NOAA

I do not like the fact that this requires external library to parse xml files. I think this just adds unnecessary complexity. Why do we need to read xml files instead of equivalent text files.

DusanJovic-NOAA avatar Aug 30 '22 13:08 DusanJovic-NOAA

What equivalent text files?

edwardhartnett avatar Aug 30 '22 13:08 edwardhartnett

These two, available from the same place the xml files are available from (WMO).

Template.txt

CodeFlag.txt

DusanJovic-NOAA avatar Aug 30 '22 13:08 DusanJovic-NOAA

Those links take me to a sharepoint site for which I do not have permissions. Are these documents on the web?

edwardhartnett avatar Aug 30 '22 13:08 edwardhartnett

I see the text versions are available here: https://wmoomm.sharepoint.com/sites/wmocpdb/eve_activityarea/Forms/AllItems.aspx?id=%2Fsites%2Fwmocpdb%2Feve%5Factivityarea%2FWMO%20Codes%2FWMO306%5FvI2%2FAllVERSIONS%2F2022%2D05%2D15%2FGRIB2%2D29%2E1&p=true&ga=1

I will ponder...

edwardhartnett avatar Aug 30 '22 13:08 edwardhartnett

Or here: https://github.com/wmo-im/GRIB2/tree/master/txt

DusanJovic-NOAA avatar Aug 30 '22 14:08 DusanJovic-NOAA

This is related to #345

edwardhartnett avatar Jun 17 '24 07:06 edwardhartnett