HCLIMcom / HCLIM2CMOR

Climate model output rewriting of HCLIM climate model data for CORDEX. Based on the COSMO-CLM routines.
GNU General Public License v3.0
0 stars 5 forks source link

Add handling of optional global attributes #27

Closed ljoakim closed 3 months ago

ljoakim commented 4 months ago

It seems indeed there are no handling of optional global attributes, as far as I can see. I suggest the following:

Have the three optional global attributes defined in the simulation config, and add them as global attributes in the output only if they are not the empty string. This should be straight-forward to fix.

Should any of the three values (comment,history,references) be set for our simulations?

ljoakim commented 4 months ago

@gnikulin @doblerone

doblerone commented 4 months ago

The optional global attributes are currently handled like this: If you want to include them, you need to add them to the list global_attr_list=Conventions,activity_id, ... in control_cmor_template.ini. However, then you also need to specify them there (further down). This is definitely a bit confusing and not flexible for cmorizing multiple simulations. I support your idea on having them in the simulation config and adding them only if not empty.

I think comment and history can be empty for our current simulations. @gnikulin What should references be? https://www.smhi.se/en/research/research-departments/climate-research-at-the-rossby-centre/harmonie-1.135580 or maybe https://github.com/Hirlam/HCLIM or something else?

gnikulin commented 3 months ago

We just discussed this issue here and seems that the best way is to create an optional global attribute list (to separate from the mandatory CORDEX-CMIP6 attributes) and add the optional attributes only if not empty. Currently, we have the 3 optional global attributes (comment, history and reference) and one (version_realization_info) needed only for re-runs and multiple realisations. Potentially, other optional attributes can be added in projects (as many as we want), e.g. we used c3s_disclaimer in the C3S Principles project.

Regarding reference, https://github.com/Hirlam/HCLIM is not a public resource and provides only technical documentation. https://www.smhi.se/en/research/research-departments/climate-research-at-the-rossby-centre/harmonie-1.135580 used to register HCLIM43-ALADIN (further_info_url) seems like the best option right now but it will be impossible to change it in netcdf files published on ESGF. We need to think about making the same HCLIM43 description available on Zenodo that provides a stable link.

ljoakim commented 3 months ago

A question about cosmetics:

We discussed having the global attributes in the output sorted alphabetically. The current list of required attributes in control_cmor_template.ini is sorted, and it's pretty straightforward to sort the complete attribute list including optional attributes (even if they are specified in a separate list) in code.

The few attributes which are added in code, it seems, are added at a very late stage in tools.py: frequency, variable_id, tracking_id and creation_date. They are written directly to the output file, and simply ends up at the end of the list. It will take some additional effort to get them sorted, but I assume you'd like to have them sorted among the global attributes as well?

doblerone commented 3 months ago

To me, that's really cosmetics. As long as the attributes are there, I don't really care about the order. I don't know where the original order had come from. Having them all ordered alphabetically is nice but if the last 4 entries are out of the order, that's fine with me too. What do you think @gnikulin ?

gnikulin commented 3 months ago

The original alphabetical order came from the CMIP6 DRS Table 1 and the CMIP6 CMOR provides almost all global attributes in alphabetical order as well despite license, cmor_version, tracking_id and history (if used) that are appended in the end of the global attribute list. In general, visually it's more convenient to quickly find a global attribute if they all are sorted in alphabetical order. For software it doesn't matter of course. I think for the simplicity we can leave the 4 above attributes in the end of the global attribute list.

ljoakim commented 3 months ago

Added a draft PR for this issue. Two things before draft status is removed:

  1. references: awaiting a decision
  2. comment: should METNo (the NorESM simulations) have a different comment than the rest? It's currently set to This simulation was performed by the Swedish Meteorological and Hydrological Institute in collaboration with the HCLIM-Community
gnikulin commented 3 months ago
  1. We can leave reference empty right now, should be fixed in coming days.
  2. We can also leave commentempty since all institutions involved in the simulations are explicitly described in institution e.g. "HARMONIE Climate Modelling Community (HCLIMcom) partner: Swedish Meteorological and Hydrological Institute (SMHI), Norrkoping, Sweden"