@@ -80,20 +80,22 @@ def report(quantity,field=None,output=None,prefix=None,realise=False,
8080# nr -- int, optional, indicates that each realisation on input should be 
8181#   replicated nr times on output to file 
8282
83- #  if field.axis(-1,key=True)!='domtime ': 
83+ #  if field.axis(-1,key=True)!='axistime ': 
8484#    raise ProjectionError('time should be the last dimension') 
8585
86-   if  output   and   not  field :
86+   if  not  field :
8787    print (quantity )
88-     listfile = open (output + '/list' ,'a' )
89-     listfile .write (quantity + '\n ' )
90-     listfile .close ()
88+     if  output :
89+       listfile = open (output + '/list' ,'a' )
90+       listfile .write (quantity + '\n ' )
91+       listfile .close ()
9192    return 
9293
9394# Reshape as two-dimensional with time as the second dimension 
9495  nyr = field .axis ('T' ).size 
9596  timeaxis = field .axis ('T' ,key = True )
96-   axes = [key  for  key  in  field .domain_axes .keys () if  key != timeaxis ]
97+   axes = list (field .constructs .filter_by_type ('domain_axis' ,todict = 'True' ))
98+   axes = [axis  for  axis  in  axes  if  axis != timeaxis ]
9799  axes .append (timeaxis )
98100  field .transpose (axes ,inplace = True )
99101  data = field .array .reshape (field .size // nyr ,nyr )
@@ -379,17 +381,17 @@ def project_scenario(input,scenario,output=None,\
379381# Create a cf.Field with the shape of the quantities to be calculated 
380382# [component_realization,climate_realization,time] 
381383  template = cf .Field ()
382-   template .set_construct (cf .DomainAxis (nm ),'domcomp ' )
383-   template .set_construct (cf .DomainAxis (nt ),'domclim ' )
384-   template .set_construct (cf .DomainAxis (nyr ),'domtime ' )
384+   template .set_construct (cf .DomainAxis (nm ),'axiscomp ' )
385+   template .set_construct (cf .DomainAxis (nt ),'axisclim ' )
386+   template .set_construct (cf .DomainAxis (nyr ),'axistime ' )
385387  template .set_data (cf .Data (numpy .full ([nm ,nt ,nyr ],numpy .nan )),
386-     axes = ['domcomp ' ,'domclim ' ,'domtime ' ])
388+     axes = ['axiscomp ' ,'axisclim ' ,'axistime ' ])
387389  template .units = '1' 
388390  template .set_construct (txin [- 1 ].dim ('T' ))
389-   template .set_construct (climdim )
391+   template .set_construct (climdim , 'dimclim' )
390392  compdim = cf .DimensionCoordinate (data = cf .Data (numpy .arange (nm )),\
391393    properties = dict (standard_name = 'component_realization' ))
392-   template .set_construct (compdim )
394+   template .set_construct (compdim , 'dimcomp' )
393395
394396# Obtain ensembles of projected components as cf.Field objects and add them up 
395397  temperature = zt 
@@ -413,6 +415,7 @@ def project_scenario(input,scenario,output=None,\
413415  if  output :
414416    output = output + "/" + scenario + "_" 
415417    prefix = "%-10s " % scenario 
418+   else : prefix = '' 
416419  report ("temperature" ,temperature ,output ,prefix ,realise ,nr = nm )
417420  report ("expansion" ,expansion ,output ,prefix ,realise ,nr = nm )
418421  report ("glacier" ,glacier ,output ,prefix ,realise )
@@ -443,7 +446,7 @@ def project_glacier(it,zit,template,glaciermip):
443446  glmass = 412.0 - 96.3  # initial glacier mass, used to set a limit, from Tab 4.2 
444447  glmass = 1e-3 * glmass  # m SLE 
445448
446-   nr = template .axis ('domcomp ' ).size 
449+   nr = template .axis ('axiscomp ' ).size 
447450  if  glaciermip :
448451    if  glaciermip == 1 :
449452      glparm = [dict (name = 'SLA2012' ,factor = 3.39 ,exponent = 0.722 ,cvgl = 0.15 ),\
@@ -474,8 +477,8 @@ def project_glacier(it,zit,template,glaciermip):
474477      'must be a multiple of number of glacier methods' )
475478  nrpergl = int (nr / ngl ) # number of realisations per glacier method 
476479  r = cf .Field ()
477-   r .set_construct (template .axis ('domcomp ' ))
478-   r .set_construct (template .dim ('domcomp ' ))
480+   r .set_construct (template .axis ('axiscomp ' ))
481+   r .set_construct (template .dim ('dimcomp ' ))
479482  r .set_data (cf .Data (numpy .random .standard_normal (nr )))
480483  r .set_property ('units' ,'1' )
481484
@@ -510,14 +513,14 @@ def project_greensmb(zt,template):
510513  fnlogsd = 0.4  # random methodological error of the log factor 
511514  febound = [1 ,1.15 ] # bounds of uniform pdf of SMB elevation feedback factor 
512515
513-   nr = template .axis ('domcomp ' ).size 
516+   nr = template .axis ('axiscomp ' ).size 
514517# random log-normal factor 
515518  fn = numpy .exp (numpy .random .standard_normal (nr )* fnlogsd )
516519# elevation feedback factor 
517520  fe = numpy .random .sample (nr )* (febound [1 ]- febound [0 ])+ febound [0 ]
518521  ff = cf .Field ()
519-   ff .set_construct (template .axis ('domcomp ' ))
520-   ff .set_construct (template .dim ('domcomp ' ))
522+   ff .set_construct (template .axis ('axiscomp ' ))
523+   ff .set_construct (template .dim ('dimcomp ' ))
521524  ff .set_data (cf .Data (fn * fe ))
522525
523526  ztgreen = zt - dtgreen 
@@ -541,8 +544,8 @@ def project_antsmb(zit,template,fraction=None):
541544# template -- cf.Field with the required shape of the output 
542545# fraction -- array-like, random numbers for the SMB-dynamic feedback 
543546
544-   nr = template .axis ('domcomp ' ).size 
545-   nt = template .axis ('domclim ' ).size 
547+   nr = template .axis ('axiscomp ' ).size 
548+   nt = template .axis ('axisclim ' ).size 
546549# antsmb=template.copy() 
547550# nr,nt,nyr=antsmb.shape 
548551
@@ -570,10 +573,10 @@ def project_antsmb(zit,template,fraction=None):
570573# antsmb.data[:]=moaoKg*ainterfactor*zit.array.reshape(1,nt,-1)[:] 
571574
572575  z = cf .Field ()
573-   z .set_construct (template .axis ('domcomp ' ),'domcomp ' )
574-   z .set_construct (template .dim ('domcomp ' ))
575-   z .set_construct (template .axis ('domclim ' ),'domclim ' )
576-   z .set_construct (template .dim ('domclim ' ))
576+   z .set_construct (template .axis ('axiscomp ' ),'axiscomp ' )
577+   z .set_construct (template .dim ('dimcomp ' ))
578+   z .set_construct (template .axis ('axisclim ' ),'axisclim ' )
579+   z .set_construct (template .dim ('dimclim ' ))
577580  z .set_data (cf .Data (moaoKg * ainterfactor ))
578581  antsmb = z * zit 
579582
@@ -657,8 +660,8 @@ def time_projection(startratemean,startratepm,final,template,\
657660  time .set_data (timedata )
658661
659662# more general than nr,nt,nyr=template.shape 
660-   nr = template .axis ('domcomp ' ).size 
661-   nt = template .axis ('domclim ' ).size 
663+   nr = template .axis ('axiscomp ' ).size 
664+   nt = template .axis ('axisclim ' ).size 
662665  nyr = template .axis ('T' ).size 
663666  if  fraction  is  None :
664667    fraction = numpy .random .rand (nr ,nt )
@@ -667,10 +670,10 @@ def time_projection(startratemean,startratepm,final,template,\
667670  data = cf .Data (fraction .reshape (nr ,nt ))
668671
669672  fraction = cf .Field ()
670-   fraction .set_construct (template .axis ('domcomp ' ),'domcomp ' )
671-   fraction .set_construct (template .dim ('domcomp ' ))
672-   fraction .set_construct (template .axis ('domclim ' ),'domclim ' )
673-   fraction .set_construct (template .dim ('domclim ' ))
673+   fraction .set_construct (template .axis ('axiscomp ' ),'axiscomp ' )
674+   fraction .set_construct (template .dim ('dimcomp ' ))
675+   fraction .set_construct (template .axis ('axisclim ' ),'axisclim ' )
676+   fraction .set_construct (template .dim ('dimclim ' ))
674677  fraction .set_data (data )
675678
676679# Convert inputs to startrate (m yr-1) and afinal (m), where both are 2-element 
0 commit comments