ES-DOC / esdoc-cdf2cim

Maps NetCDF files to CIM documents
Other
1 stars 7 forks source link

Rationalise CMIP5 & 6 to CIM2 mappings #8

Closed sadielbartholomew closed 4 years ago

sadielbartholomew commented 4 years ago

Whilst @davidhassell & I were looking into the CDF2CIM process we observed that the CMIP6-to-CIM2 mapping constant which once-upon-a-time had genuine mappings to make, has become an effective container to store attributes & state whether they are mapped to themselves or to None.

This is a quick PR to organise (by mapped form) the mappings accordingly, & take a consistent approach for the CMIP5 mapping, increasing readability in the process (note since we're still in Python 2, the dict combination not look as clean & readable as it would/will in 3, as per the comments).

Reviewing aid

Since (I believe) there's no quick & simple end-to-end CDF2CIM way to review this has produced the same end result, here's a simple script I used to verify the new code gives the original mapping dictionaries:

import pprint

<copy (new) lines 79-184 to here, noting they are standalone constants>

pprint.pprint(CMIP6_TO_CIM2)
print("\n\n")
pprint.pprint(CMIP5_TO_CIM2)

which produces, as before (by eyeball):

$ python2 ~/esdoc-map-test
{'Conventions': None,
 'activity_id': None,
 'branch_method': None,
 'branch_time_in_child': None,
 'branch_time_in_parent': None,
 'comment': None,
 'contact': 'contact',
 'creation_date': None,
 'data_specs_version': None,
 'experiment': None,
 'experiment_id': 'experiment_id',
 'external_variables': None,
 'forcing_index': 'forcing_index',
 'frequency': None,
 'further_info_url': 'further_info_url',
 'grid': None,
 'grid_label': None,
 'grid_resolution': None,
 'history': None,
 'initialization_index': 'initialization_index',
 'institution': None,
 'institution_id': 'institution_id',
 'license': None,
 'mip_era': 'mip_era',
 'parent_activity_id': None,
 'parent_experiment_id': None,
 'parent_mip_era': None,
 'parent_source_id': None,
 'parent_time_units': None,
 'parent_variant_label': None,
 'physics_index': 'physics_index',
 'product': None,
 'realization_index': 'realization_index',
 'realm': None,
 'references': 'references',
 'source': None,
 'source_id': 'source_id',
 'source_type': None,
 'sub_experiment': None,
 'sub_experiment_id': 'sub_experiment_id',
 'table_id': None,
 'title': None,
 'tracking_id': None,
 'variable_id': None,
 'variant_info': 'variant_info',
 'variant_label': None}

{'branch_time': 'branch_time_in_parent',
 'contact': 'contact',
 'experiment_id': 'experiment_id',
 'forcing': 'forcing',
 'initialization_method': 'initialization_index',
 'institute_id': 'institute_id',
 'model_id': 'source_id',
 'parent_experiment_id': 'parent_experiment_id',
 'parent_experiment_rip': None,
 'physics_version': 'physics_index',
 'project_id': 'mip_era',
 'realization': 'realization_index',
 'references': 'references',
 'source': 'source'}
sadielbartholomew commented 4 years ago

(Just squashed in an update because I realised I had quoted None to give strings i.e. 'None' rather than a NoneType.)