source: CMIP6dreqbuild/trunk/srcMisc/sx2_extra.py @ 700

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreqbuild/trunk/srcMisc/sx2_extra.py@701
Revision 700, 5.1 KB checked in by mjuckes, 4 years ago (diff)

fixing SIMIP issues ...

Line 
1
2import collections, re
3
4
5l1 = [u'ISMIP6.new_LImon', u'PMIP.PMIP-LIclim', u'HighResMIP.6hrPlev_extr_dr', u'LUMIP.Lmon_Lut', u'FAFMIP.fafOyr', u'PMIP.PMIP-day', u'DynVar.DYVR_daily', u'C4MIP.C_LandT2', u'PMIP.PMIP-aeroclim', u'PMIP.PMIP-aero', u'C4MIP.C_LandT1', u'HighResMIP.1hrLev', u'PMIP.PMIP-Omon', 'C4MIP.L_day', u'FAFMIP.fafOmonB', u'CFMIP.cfDayExtra', u'CFMIP.cfDay_2d_new', u'PMIP.PMIP-Oclim', u'ISMIP6.new_Omon', u'ISMIP6.new_fx', u'CFMIP.aeroDay_2d', u'HighResMIP.Amon_ext', u'HighResMIP.1hr_energy', u'HighResMIP.day_jet', u'C4MIP.C_Hist', u'CFMIP.cfSites_new', u'PMIP.PMIP-Amon', u'HighResMIP.6hrPlev_intense', u'CFMIP.cfMonExtra', u'LS3MIP.LCmon', u'GeoMIP.aeroGeo', u'PMIP.PMIP-Lmon', u'HighResMIP.3hr_cloud', u'HighResMIP.1ts', u'ISMIP6.icesheetmon', u'HighResMIP.Amon_sparc', u'C4MIP.C_Ocean_T1', u'HighResMIP.Amon_conv', u'LUMIP.Lyr_Lut', u'HighResMIP.1hr_strat', u'HighResMIP.3hr_extr', u'PMIP.PMIP-Lclim', u'CFMIP.cf3hr_sim', u'FAFMIP.fafOmon', u'FAFMIP.fafOyrB', u'RFMIP.aero_irf', u'PMIP.PMIP-Aclim', u'LS3MIP.LWday', u'C4MIP.C_Basic', u'CFMIP.cfMon_3dstd_new', u'HighResMIP.3hrPlev', u'ISMIP6.icesheetyear', u'C4MIP.C_Ocean_T2', 'C4MIP.L_3hr', u'RFMIP.OfflineRad', u'VolMIP.VIRF', u'HighResMIP.6hrPlev_extr', u'PMIP.PMIP-OIclim', u'PMIP.PMIP-6hr', u'HighResMIP.Amon_diag', 'DynVar.DYVR_monthly', 'LS3MIP.LEday', 'DAMIP.new_monthly','DCPP.DCPP-day', u'DCPP.DCPP-6hr', 'DCPP.DCPP-mon', 'DynVar.DYVR_zg', 'SIMIP.seaicemon', 'SIMIP.seaiceday' ]
6
7l1p = [
8'DynVar.DYVR_daily_d',
9'DynVar.DYVR_daily_c',
10'DynVar.DYVR_daily_b',
11'DynVar.DYVR_daily_a',
12'DAMIP.DAMIP_6hrPlev_p2',
13'DAMIP.DAMIP_Amon_new',
14'DynVar.DYVR_monthly_d',
15'DynVar.DYVR_monthly_a',
16'DynVar.DYVR_monthly_c',
17'DynVar.DYVR_monthly_b',
18'DAMIP.DAMIP_day',
19'CFMIP.cf3hr_sim_new',
20'DAMIP.DAMIP_3hr_p2',
21'DAMIP.DAMIP_Omon_p2',
22'DAMIP.DAMIP_day_zm',
23'DAMIP.DAMIP_emMon',
24'CFMIP.cf1hrClimMon',
25'DAMIP.DAMIP_emMonZ',
26'DAMIP.DAMIP_aermonthly',
27'ISMIP6.LImongre',
28'ISMIP6.LIyrgre',
29'ISMIP6.LImonant',
30'ISMIP6.LIyrant']
31
32l2p = [
33'DynVar-daily-d',
34'DynVar-daily-c',
35'DynVar-daily-b',
36'DynVar-daily-a',
37'DAMIP-6hrPlev-p2',
38'DAMIP-Amon-new',
39'DynVar-monthly-d',
40'DynVar-monthly-a',
41'DynVar-monthly-c',
42'DynVar-monthly-b',
43'DAMIP-day',
44'cf3hr-sim-new',
45'DAMIP-3hr-p2',
46'DAMIP-Omon-p2',
47'DAMIP-day-zm',
48'DAMIP-emMon',
49'cf1hrClimMon',
50'DAMIP-emMonZ',
51'DAMIP-aermonthly',
52'ISMIP6-LImongre',
53'ISMIP6-LIyrgre',
54'ISMIP6-LImonant',
55'ISMIP6-LIyrant']
56
57l2 = [u'ISMIP6-LImon', u'PMIP-LIclim', u'HighResMIP-6hrPlevExtrDr', u'LUMIP-LmonLut', u'FAFMIP-fafOyr', u'PMIP-day', u'DynVar-day', u'C4MIP-LandT2', u'PMIP-aeroclim', u'PMIP-aero', u'C4MIP-LandT1', u'HighResMIP-1hrLev', u'PMIP-Omon', 'C4MIP-day', u'FAFMIP-OmonB', u'CFMIP-cfDayExtra', u'CFMIP-cfDay2dNew', u'PMIP-Oclim', u'ISMIP6-OmonNew', u'ISMIP6-fxNew', u'CFMIP-aeroDay2d', u'HighResMIP-AmonExt', u'HighResMIP-1hrEnergy', u'HighResMIP-dayJet', u'C4MIP-Hist', u'CFMIP-cfSitesNew', u'PMIP-Amon', u'HighResMIP-6hrPlevIntense', u'CFMIP-cfMonExtra', u'LS3MIP-LCmon', u'GeoMIP-aeroGeo', u'PMIP-Lmon', u'HighResMIP-3hrCloud', u'HighResMIP-1ts', u'ISMIP6-icesheetmon', u'HighResMIP-AmonSparc', u'C4MIP-OceanT1', u'HighResMIP-AmonConv', u'LUMIP-LyrLut', u'HighResMIP-1hrStrat', u'HighResMIP-3hrExtr', u'PMIP-Lclim', u'CFMIP-cf3hrSim', u'FAFMIP-Omon', u'FAFMIP-OyrB', u'RFMIP-aeroIrf', u'PMIP-Aclim', u'LS3MIP-LWday', u'C4MIP-Basic', u'CFMIP-cfMon3dstdNew', u'HighResMIP-3hrPlev', u'ISMIP6-icesheetyear', u'C4MIP-OceanT2', 'C4MIP-3hr', u'RFMIP-OfflineRad', u'VolMIP-VIRF', u'HighResMIP-6hrPlevExtr', u'PMIP-OIclim', u'PMIP-6hr', u'HighResMIP-AmonDiag', 'DynVar-mon', 'LS3MIP-LEday', 'DAMIP-newMonthly','DCPP-day', u'DCPP-6hr', 'DCPP-mon', 'DynVar-DYVRzg', 'SIMIP-seaicemon', 'SIMIP-seaiceday']
58
59l1 += l1p
60l2 += l2p
61
62r1 = re.compile( '^([a-zA-Z0-9-]*)$' )
63lf = []
64for i in l2:
65  if r1.match( i ) == None:
66    lf.append(i)
67
68assert len(lf) == 0,'Element(s) of l2 not matching constraint: %s' % str(lf)
69print 'INFO.001.0001: All elements of l2 checked against character constraint'
70
71assert len(l1) == len(l2), 'key and value lists (l1,l2) have different lengths: %s, %s' % (len(l1),len(l2))
72len1 = len(l1)
73
74class c1(object):
75  def __init__(self):
76    self.a = collections.defaultdict(int)
77lk1 = collections.defaultdict( c1 )
78lk2 = collections.defaultdict( c1 )
79for i in range(len1):
80  lk1[l2[i]].a[l1[i]] += 1
81  lk2[l1[i]].a[l2[i]] += 1
82
83k2 = lk2.keys()
84k2.sort()
85k1 = lk1.keys()
86k1.sort()
87ldup = []
88lmult = []
89for k in k1:
90  if len( lk1[k].a.keys() ) > 1:
91    ldup.append(k)
92  for kk in lk1[k].a.keys():
93    if lk1[k].a[kk] > 1:
94      lmult.append( (k,kk) )
95
96assert len(ldup) == 0, 'Ambiguous mappings in lk1: %s' % str(ldup)
97
98ldup = []
99lmult2 = []
100for k in k2:
101  if len( lk2[k].a.keys() ) > 1:
102    ldup.append(k)
103  for kk in lk2[k].a.keys():
104    if lk2[k].a[kk] > 1:
105      lmult2.append( (k,kk) )
106
107assert len(ldup) == 0, 'Ambiguous mappings in lk2: %s' % str(ldup)
108print 'INFO.001.0002: Checked for ambiguous mappings '
109
110assert len(lmult) == 0 and len(lmult2) == 0, 'Multiple mappings found: %s, %s' % (str(lmult),str(lmult2))
111
112class map(dict):
113  def __init__(self):
114    self.__inv__ = {}
115
116  def set(self,a,b):
117    self.__setitem__(a,b)
118    self.__inv__[b] = a
119
120  def inv(self,k):
121    return self.__inv__[k]
122
123ngmap = map()
124for k in k2:
125  ngmap.set( k, lk2[k].a.keys()[0] )
Note: See TracBrowser for help on using the repository browser.