Ignore:
Timestamp:
11/15/23 12:14:04 (16 months ago)
Author:
Mathieu Morlighem
Message:

merged trunk-jpl and trunk for revision 28011

Location:
issm/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk

  • issm/trunk/src

  • issm/trunk/src/m/classes/SMBd18opdd.py

    r25836 r28013  
    1313          SMBd18opdd = SMBd18opdd()
    1414    """
    15     def __init__(self):  # {{{
     15    def __init__(self, *args):  # {{{
    1616        self.desfac = 0.
    1717        self.s0p = float('NaN')
     
    3838        self.steps_per_step = 1
    3939        self.averaging = 0
    40 
    41     #set defaults
    42         self.setdefaultparameters()
    4340        self.requested_outputs = []
    44     #}}}
     41
     42        if len(args) == 0:
     43            self.setdefaultparameters()
     44        else:
     45            raise Exception('constructor not supported')
     46    # }}}
    4547    def __repr__(self):  # {{{
    46         string = "   surface forcings parameters:"
    47 
    48         string = "%s\n%s" % (string, fielddisplay(self, 'isd18opd', 'is delta18o parametrisation from present day temperature and precipitation activated (0 or 1, default is 0)'))
    49         string = "%s\n%s" % (string, fielddisplay(self, 'issetpddfac', 'is user passing in defined pdd factors (0 or 1, default is 0)'))
    50         string = "%s\n%s" % (string, fielddisplay(self, 'desfac', 'desertification elevation factor (between 0 and 1, default is 0.5) [m]'))
    51         string = "%s\n%s" % (string, fielddisplay(self, 's0p', 'should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]'))
    52         string = "%s\n%s" % (string, fielddisplay(self, 's0t', 'should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]'))
    53         string = "%s\n%s" % (string, fielddisplay(self, 'rlaps', 'present day lapse rate [degree/km]'))
    54         if self.isd18opd:
    55             string = "%s\n%s" % (string, fielddisplay(self, 'temperatures_presentday', 'monthly present day surface temperatures [K], required if delta18o/mungsm is activated'))
    56             string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_presentday', 'monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated'))
    57             string = "%s\n%s" % (string, fielddisplay(self, 'istemperaturescaled', 'if delta18o parametrisation from present day temperature and precipitation is activated, is temperature scaled to delta18o value? (0 or 1, default is 1)'))
    58             string = "%s\n%s" % (string, fielddisplay(self, 'isprecipscaled', 'if delta18o parametrisation from present day temperature and precipitation is activated, is precipitation scaled to delta18o value? (0 or 1, default is 1)'))
     48        s = '   surface forcings parameters:\n'
     49        s += '{}\n'.format(fielddisplay(self, 'isd18opd', 'is delta18o parametrisation from present day temperature and precipitation activated (0 or 1, default is 0)'))
     50        s += '{}\n'.format(fielddisplay(self, 'issetpddfac', 'is user passing in defined pdd factors (0 or 1, default is 0)'))
     51        s += '{}\n'.format(fielddisplay(self, 'desfac', 'desertification elevation factor (between 0 and 1, default is 0.5) [m]'))
     52        s += '{}\n'.format(ielddisplay(self, 's0p', 'should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]'))
     53        s += '{}\n'.format(fielddisplay(self, 's0t', 'should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]'))
     54        s += '{}\n'.format(fielddisplay(self, 'rlaps', 'present day lapse rate [degree/km]'))
     55
     56        if self.isd18opd:
     57            s += '{}\n'.format(fielddisplay(self, 'temperatures_presentday', 'monthly present day surface temperatures [K], required if delta18o/mungsm is activated'))
     58            s += '{}\n'.format(fielddisplay(self, 'precipitations_presentday', 'monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated'))
     59            s += '{}\n'.format(fielddisplay(self, 'istemperaturescaled', 'if delta18o parametrisation from present day temperature and precipitation is activated, is temperature scaled to delta18o value? (0 or 1, default is 1)'))
     60            s += '{}\n'.format(fielddisplay(self, 'isprecipscaled', 'if delta18o parametrisation from present day temperature and precipitation is activated, is precipitation scaled to delta18o value? (0 or 1, default is 1)'))
    5961
    6062            if self.istemperaturescaled == 0:
    61                 string = "%s\n%s" % (string, fielddisplay(self, 'temperatures_reconstructed', 'monthly historical surface temperatures [K], required if delta18o/mungsm/d18opd is activated and istemperaturescaled is not activated'))
     63                s += '{}\n'.format(fielddisplay(self, 'temperatures_reconstructed', 'monthly historical surface temperatures [K], required if delta18o/mungsm/d18opd is activated and istemperaturescaled is not activated'))
    6264
    6365            if self.isprecipscaled == 0:
    64                 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_reconstructed', 'monthly historical precipitation [m/yr water eq], required if delta18o/mungsm/d18opd is activated and isprecipscaled is not activated'))
    65 
    66             string = "%s\n%s" % (string, fielddisplay(self, 'delta18o', 'delta18o [per mil], required if pdd is activated and delta18o activated'))
    67             string = "%s\n%s" % (string, fielddisplay(self, 'dpermil', 'degree per mil, required if d18opd is activated'))
    68             string = "%s\n%s" % (string, fielddisplay(self, 'f', 'precip/temperature scaling factor, required if d18opd is activated'))
     66                s += '{}\n'.format(fielddisplay(self, 'precipitations_reconstructed', 'monthly historical precipitation [m/yr water eq], required if delta18o/mungsm/d18opd is activated and isprecipscaled is not activated'))
     67
     68            s += '{}\n'.format(fielddisplay(self, 'delta18o', 'delta18o [per mil], required if pdd is activated and delta18o activated'))
     69            s += '{}\n'.format(fielddisplay(self, 'dpermil', 'degree per mil, required if d18opd is activated'))
     70            s += '{}\n'.format(fielddisplay(self, 'f', 'precip/temperature scaling factor, required if d18opd is activated'))
    6971
    7072        if self.issetpddfac == 1:
    71             string = "%s\n%s" % (string, fielddisplay(self, 'pddfac_snow', 'Pdd factor for snow for all the domain [mm ice equiv/day/degree C]'))
    72             string = "%s\n%s" % (string, fielddisplay(self, 'pddfac_ice', 'Pdd factor for ice for all the domain [mm ice equiv/day/degree C]'))
    73         string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'))
    74         string = "%s\n%s" % (string, fielddisplay(self, 'averaging', 'averaging methods from short to long steps'))
    75         string = "%s\n\t\t%s" % (string, '0: Arithmetic (default)')
    76         string = "%s\n\t\t%s" % (string, '1: Geometric')
    77         string = "%s\n\t\t%s" % (string, '2: Harmonic')
    78 
    79         string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested'))
    80 
    81         return string
    82     #}}}
     73            s += '{}\n'.format(fielddisplay(self, 'pddfac_snow', 'Pdd factor for snow for all the domain [mm ice equiv/day/degree C]'))
     74            s += '{}\n'.format(fielddisplay(self, 'pddfac_ice', 'Pdd factor for ice for all the domain [mm ice equiv/day/degree C]'))
     75
     76        s += '{}\n'.format(fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'))
     77        s += '{}\n'.format(fielddisplay(self, 'averaging', 'averaging methods from short to long steps'))
     78        s += '\t\t{}\n'.format('0: Arithmetic (default)')
     79        s += '\t\t{}\n'.format('1: Geometric')
     80        s += '\t\t{}\n'.format('2: Harmonic')
     81        s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested'))
     82        return s
     83    # }}}
    8384    def extrude(self, md):  # {{{
    8485        if self.isd18opd:
     
    9394        self.s0t = project3d(md, 'vector', self.s0t, 'type', 'node')
    9495        return self
    95     #}}}
     96    # }}}
    9697    def defaultoutputs(self, md):  # {{{
    97         return []
    98     #}}}
     98        return ['SmbMassBalance']
     99    # }}}
    99100    def initialize(self, md):  # {{{
    100101        if np.all(np.isnan(self.s0p)):
     
    108109    # }}}
    109110    def setdefaultparameters(self):  # {{{
    110         #pdd method not used in default mode
     111        # pdd method not used in default mode
    111112        self.ismungsm = 0
    112113        self.isd18opd = 1
     
    119120        self.f = 0.169
    120121        self.issetpddfac = 0
     122        self.requested_outputs = ['default']
    121123        return self
    122     #}}}
     124    # }}}
    123125    def checkconsistency(self, md, solution, analyses):  # {{{
    124126        if 'MasstransportAnalysis' in analyses:
     
    197199            WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'pddfac_ice', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
    198200
    199     #process requested outputs
     201        # Process requested outputs
    200202        outputs = self.requested_outputs
    201203        indices = [i for i, x in enumerate(outputs) if x == 'default']
     
    204206            outputs = outputscopy
    205207        WriteData(fid, prefix, 'data', outputs, 'name', 'md.smb.requested_outputs', 'format', 'StringArray')
    206 
    207     # }}}
     208    # }}}
Note: See TracChangeset for help on using the changeset viewer.