Harp.Variable dimensions

Greetings Sander,

I wish to create ncdf files using the harp.Variable via the python interface. I have ozone profiles, however I have to different sized vertical dimensions, one in 10 layers and the other in 16 layers. The code complains if I add a second variable using the [‘time’, ‘vertical’] dimension whose vertical legth is different from the previous one. I tried assigning one of the profiles as [‘time’,‘independent’] to trick the system, but it replies that :
Error: variable ‘‘RetrievedOzoneProfileIn10Layers’’ could not be exported (unsupported dimension ‘independent’)

Is there a way to “cheat” and have a harp product where the vertical dimension can be of varying length?

Many thanks
MariLiza

The way to do this is to use the maximum length for the vertical dimension and pad elements at the end with NaN for shorter profiles. This approach is also documented in the HARP conventions.

Thanks Sander, I was looking at the python interface convention and missed the link you emailed me!

Greetings again Sander,

Following the topic above, I would like to add some global attributes to the ncdf file I am creating, such as information on the algorithm, the data provider, and such like. I read in the documentation that:

Note that files using the HARP data format can include global attributes in addition to the ones mentioned above. However, such attributes will be ignored when the product is imported.

However, I fail to see how this will be accomplished, I am missing the syntax. I am performing the following set of operations:

product = harp.Product()
product.SomeDataArray = harp.Variable(array, dims, description)

productlist.append(product)
output = harp.concatenate(productlist)
harp.export_product(output, OutFile.nc)

I am guessing that I need to define this in the harp.Product initialisation in some manner or other?

Many thanks and best wishes,
MariLiza

The HARP software itself does not allow exporting additional attributes.
If you want to store additional information, then you would have to create the netcdf file yourself (using e.g. the python netcdf library).
It is actually perfectly valid to create your HARP compatible files without using the HARP software itself (this is probably recommended if you want to add your own metadata on top of it).

Trying to write a HARP compatible file without the HARP software will take a bit more effort, since you will have to create some standard global attributes yourself (such as the Conventions and datetime_start/datetime_stop attributes).

If you want a quick solution then you could just reopen the created HARP file with the netcdf library and add any missing attributes (but then your code would depend on both the HARP library and the netcdf library).

Thanks Sander. I actually do not know how to make nc files using the standard python libraries, only via the harp tool. I do not think that the users of this dataset will need harp-compliant files in any case, so I will add the attributes using the nominal python libraries, thanks again. Time for me to learn new things.
MariLiza