Metadata storage within data variables in NetCDF4-BEAM

I’m trying to use python to process products output by SNAP as NetCDF4-BEAM files using xarray and NetCDF4-python, and I’ve found something odd in the way the output is formatted. Some of the metadata is stored in the global attribute space, but some is stored in the attribute fields of two specific data variables, ‘crs’ and ‘metadata’. Since these variables are just single integers, they cause routines which expect the data variables to be made up of 2-dimensional arrays to trip up. This means they need to be dropped from the structure before any methods such as, say, masking, can be applied.

This isn’t a huge problem, it just seems odd that this was the method chosen to store the metadata for NetCDF4-BEAM. I was curious as to the rationale behind storing it this way. I also can’t find any documentation on the BEAM profile for NetCDF, and if there are any specification documents or similar floating around then it’d be great to be able to see them.

There is no specification for NetCDF4-BEAM. We are also not very happy with this format. Also we are not satisfied with the general approach of reading and writing NetCDF files.
Maybe products in NetCDF4 format (without BEAM) are more convenient for you. If the change of the format is in your hands.

But you are right. Even though crs and metadata are there since 5 years, using scalar variables seems to be the wrong approach for this inforamtion.

Thanks for the quick response! I picked the NetCDF format since it has good support from libraries like xarray, but I can work with whatever SNAP exports to and I can find the libraries to wrangle, really.