Changeset 27453


Ignore:
Timestamp:
12/06/22 11:07:54 (2 years ago)
Author:
jdquinn
Message:

CHG: MATLAB > Python translations; cleanup

Location:
issm/trunk-jpl/src/m
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/SMBd18opdd.m

    r27405 r27453  
    172172                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tdiff','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts);
    173173                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','sealev','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts);
    174                         WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer');
    175                         WriteData(fid, prefix, 'object', self, 'fieldname', 'averaging', 'format', 'Integer');
     174                        WriteData(fid,prefix,'object',self,'fieldname','steps_per_step','format','Integer');
     175                        WriteData(fid,prefix,'object',self,'fieldname','averaging','format','Integer');
    176176
    177177                        if self.isd18opd
  • issm/trunk-jpl/src/m/classes/SMBd18opdd.py

    r27415 r27453  
    4040        self.requested_outputs = []
    4141
    42         # Set defaults
    43         self.setdefaultparameters()
     42        if len(args) == 0:
     43            self.setdefaultparameters()
     44        else:
     45            raise Exception('constructor not supported')
    4446    #}}}
    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
     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
    8283    #}}}
    8384    def extrude(self, md):  # {{{
     
    205206            outputs = outputscopy
    206207        WriteData(fid, prefix, 'data', outputs, 'name', 'md.smb.requested_outputs', 'format', 'StringArray')
    207 
    208208    # }}}
  • issm/trunk-jpl/src/m/classes/SMBdebrisML.m

    r27403 r27453  
    1111        end
    1212        methods
    13                 function self = SMBhenning(varargin) % {{{
     13                function self = SMBdebrisML(varargin) % {{{
    1414                        switch nargin
    1515                                case 0
     
    5757
    5858                        WriteData(fid,prefix,'name','md.smb.model','data',14,'format','Integer');
    59                         WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer');
    60                         WriteData(fid, prefix, 'object', self, 'fieldname', 'averaging', 'format', 'Integer');
     59                        WriteData(fid,prefix,'object',self,'fieldname','steps_per_step','format','Integer');
     60                        WriteData(fid,prefix,'object',self,'fieldname','averaging','format','Integer');
    6161
    6262                        %process requested outputs
  • issm/trunk-jpl/src/m/classes/SMBforcing.m

    r27404 r27453  
    5454                        md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]);
    5555                        md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1);
    56                         md = checkfield(md, 'fieldname', 'smb.averaging', 'numel', [1], 'values', [0, 1, 2]);
     56                        md = checkfield(md,'fieldname','smb.averaging','numel',[1],'values',[0 1 2]);
    5757                end % }}}
    5858                function disp(self) % {{{
     
    7171
    7272                        WriteData(fid,prefix,'name','md.smb.model','data',1,'format','Integer');
    73                         WriteData(fid,prefix,'object',self,'class','smb','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    74                         WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer');
    75                         WriteData(fid, prefix, 'object', self, 'fieldname', 'averaging', 'format', 'Integer');
     73                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts);
     74                        WriteData(fid,prefix,'object',self,'fieldname','steps_per_step','format','Integer');
     75                        WriteData(fid,prefix,'object',self,'fieldname','averaging','format','Integer');
    7676
    7777                        %process requested outputs
  • issm/trunk-jpl/src/m/classes/SMBforcing.py

    r27417 r27453  
    2020        self.averaging = 0
    2121
    22         if len(args) == 0:
     22        nargs = len(args)
     23        if nargs == 0:
     24            self.setdefaultparameters()
     25        elif nargs == 1:
     26            # TODO: Replace the following with constructor
    2327            self.setdefaultparameters()
    2428        else:
     
    3034        s += '{}\n'.format(fielddisplay(self, 'mass_balance', 'surface mass balance [m/yr ice eq]'))
    3135        s += '{}\n'.format(fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'))
    32         s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested'))
    3336        s += '{}\n'.format(fielddisplay(self, 'averaging', 'averaging methods from short to long steps'))
    3437        s += '\t\t{}\n'.format('0: Arithmetic (default)')
    3538        s += '\t\t{}\n'.format('1: Geometric')
    3639        s += '\t\t{}\n'.format('2: Harmonic')
     40        s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested'))
    3741        return s
    3842    #}}}
  • issm/trunk-jpl/src/m/classes/SMBhenning.m

    r27403 r27453  
    7373                        WriteData(fid,prefix,'name','md.smb.model','data',7,'format','Integer');
    7474                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','smbref','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    75                         WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer');
    76                         WriteData(fid, prefix, 'object', self, 'fieldname', 'averaging', 'format', 'Integer');
     75                        WriteData(fid,prefix,'object',self,'fieldname','steps_per_step','format','Integer');
     76                        WriteData(fid,prefix,'object',self,'fieldname','averaging','format','Integer');
    7777
    7878                        %process requested outputs
  • issm/trunk-jpl/src/m/classes/SMBsemic.m

    r27409 r27453  
    1212                dailywindspeed          = NaN;
    1313                dailypressure           = NaN;
    14                 dailyairdensity = NaN;
     14                dailyairdensity         = NaN;
    1515                dailyairhumidity        = NaN;
    1616                dailytemperature        = NaN;
    1717                desfac                          = 0;
    18                 rlaps                                   = 0;
     18                rlaps                           = 0;
    1919                rdl                                     = 0;
    20                 s0gcm                                   = NaN;
    21                 steps_per_step = 1;
    22                 averaging = 0;
    23                 requested_outputs = {};
     20                s0gcm                           = NaN;
     21                steps_per_step          = 1;
     22                averaging                       = 0;
     23                requested_outputs       = {};
    2424        end
    2525        methods
     
    115115                function marshall(self,prefix,md,fid) % {{{
    116116
     117                        yts=md.constants.yts;
     118
    117119                        WriteData(fid,prefix,'name','md.smb.model','data',12,'format','Integer');
    118120
     
    121123                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','rlaps','format','Double');
    122124                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','rdl','format','Double');
    123                         WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailysnowfall','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    124                         WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailyrainfall','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    125                         WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailydsradiation','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    126                         WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailydlradiation','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    127                         WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailywindspeed','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    128                         WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailypressure','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    129                         WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailyairdensity','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    130                         WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailyairhumidity','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    131                         WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailytemperature','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    132                         WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer');
    133                         WriteData(fid, prefix, 'object', self, 'fieldname', 'averaging', 'format', 'Integer');
     125                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailysnowfall','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts);
     126                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailyrainfall','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts);
     127                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailydsradiation','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts);
     128                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailydlradiation','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts);
     129                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailywindspeed','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts);
     130                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailypressure','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts);
     131                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailyairdensity','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts);
     132                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailyairhumidity','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts);
     133                        WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailytemperature','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',yts);
     134                        WriteData(fid,prefix,'object',self,'fieldname','steps_per_step','format','Integer');
     135                        WriteData(fid,prefix,'object',self,'fieldname','averaging','format','Integer');
    134136                        %process requested outputs
    135137                        outputs = self.requested_outputs;
  • issm/trunk-jpl/src/m/classes/debris.py

    r27424 r27453  
    88
    99class debris(object):
    10     """DEBRIS class definition
     10    """debris class definition
    1111
    1212    Usage:
  • issm/trunk-jpl/src/m/classes/frontalforcings.m

    r27010 r27453  
    1 %FRONTAL FORCINGS class definition
     1%FRONTALFORCINGS class definition
    22%
    33%   Usage:
  • issm/trunk-jpl/src/m/classes/frontalforcings.py

    r27423 r27453  
    88
    99class frontalforcings(object):
    10     """
    11     FRONTAL FORCINGS class definition
     10    """frontalforcings class definition
    1211
    13        Usage:
    14           frontalforcings = frontalforcings()
     12    Usage:
     13        frontalforcings = frontalforcings()
    1514    """
    1615
  • issm/trunk-jpl/src/m/classes/lovenumbers.py

    r27417 r27453  
    88
    99class lovenumbers(object):  #{{{
    10     """LOVENUMBERS class definition
     10    """lovenumbers class definition
    1111
    1212    Usage:
  • issm/trunk-jpl/src/m/classes/model.py

    r27430 r27453  
    7575
    7676class model(object):
    77     """MODEL - class definition
     77    """model class definition
    7878
    7979    Usage:
  • issm/trunk-jpl/src/m/classes/sampling.py

    r27419 r27453  
    1010
    1111class sampling(object):
    12     """SAMPLING class definition
     12    """sampling class definition
    1313
    1414    Usage:
  • issm/trunk-jpl/src/m/classes/solidearthsettings.py

    r27417 r27453  
    77
    88class solidearthsettings(object):
    9     """SOLIDEARTHSETTINGS class definition
     9    """solidearthsettings class definition
    1010
    1111    Usage:
  • issm/trunk-jpl/src/m/classes/transient.py

    r27417 r27453  
    3030        self.requested_outputs = []
    3131
    32         self.setdefaultparameters()
     32        if len(args) == 0:
     33            self.setdefaultparameters()
     34        else:
     35            raise Exception('constructor not supported')
    3336    # }}}
    3437
  • issm/trunk-jpl/src/m/coordsystems/gmtmask.py

    r27368 r27453  
    1010
    1111def gmtmask(lat, long, *args):
    12     '''
    13     GMTMASK - figure out which lat, long points are on the ocean
     12    """GMTMASK - figure out which lat, long points are on the ocean
    1413
    15         Usage:
    16             mask.ocean = gmtmask(md.mesh.lat, md.mesh.long)
    17     '''
     14    Usage:
     15        mask.ocean = gmtmask(md.mesh.lat, md.mesh.long)
     16    """
    1817    lenlat = len(lat)
    1918    mask = np.empty(lenlat)
     
    3029        print(('gmtmask: num vertices ' + str(lenlat)))
    3130
    32     #Check lat and long size is not more than 50,000. If so, recursively call gmtmask:
     31    # Check lat and long size is not more than 50,000. If so, recursively call gmtmask.
    3332    if lenlat > 50000:
    3433        for i in range(int(ceil(lenlat / 50000))):
     
    3938        return mask
    4039
    41     #First, write our lat, long file for gmt:
     40    # First, write our lat, long file for gmt
    4241    nv = lenlat
    4342    #print(np.transpose([int, lat, np.arange(1, nv + 1)]))
    4443    np.savetxt('./all_vertices.txt', np.transpose([long, lat, np.arange(1, nv + 1)]), delimiter='\t', fmt='%.10f')
    4544
    46     #figure out which vertices are on the ocean, which one on the continent:
     45    # Figure out which vertices are on the ocean, which one on the continent:
    4746    subprocess.call('gmt select ./all_vertices.txt -h0 -Df -R0/360/-90/90 -A0 -JQ180/200 -Nk/s/s/k/s > ./oce_vertices.txt', shell=True)
    4847
    49     #read the con_vertices.txt file and flag our mesh vertices on the continent
     48    # Read the con_vertices.txt file and flag our mesh vertices on the continent
    5049    fid = open('./oce_vertices.txt', 'r')
    5150    line = fid.readline()
Note: See TracChangeset for help on using the changeset viewer.