Changeset 27970
- Timestamp:
- 10/26/23 12:27:53 (17 months ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/SMBgradients.m
r27967 r27970 48 48 md = checkfield(md,'fieldname','smb.smbref','timeseries',1,'NaN',1,'Inf',1); 49 49 if max(max(abs(md.smb.smbref(1:end-1,:))))<1 50 51 50 disp('!!! Warning: SMBgradients now expects smbref to be in m/yr ice eq. instead of mm/yr water eq.'); 51 end 52 52 md = checkfield(md,'fieldname','smb.b_pos','timeseries',1,'NaN',1,'Inf',1); 53 53 md = checkfield(md,'fieldname','smb.b_neg','timeseries',1,'NaN',1,'Inf',1); … … 61 61 62 62 disp(sprintf('\n SMB gradients parameters:')); 63 fielddisplay(self,'href',' 64 fielddisplay(self,'smbref',' 65 fielddisplay(self,'b_pos',' 66 fielddisplay(self,'b_neg',' 63 fielddisplay(self,'href','reference elevation from which deviation is used to calculate SMB adjustment in smb gradients method [m]'); 64 fielddisplay(self,'smbref','reference smb from which deviation is calculated in smb gradients method [m/yr ice equiv]'); 65 fielddisplay(self,'b_pos','slope of hs - smb regression line for accumulation regime required if smb gradients is activated'); 66 fielddisplay(self,'b_neg','slope of hs - smb regression line for ablation regime required if smb gradients is activated'); 67 67 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 68 68 fielddisplay(self, 'averaging', 'averaging methods from short to long steps'); … … 90 90 pos = find(ismember(outputs,'default')); 91 91 if ~isempty(pos), 92 outputs(pos) = []; %remove 'default' from outputs92 outputs(pos) = []; %remove 'default' from outputs 93 93 outputs = [outputs defaultoutputs(self,md)]; %add defaults 94 94 end -
issm/trunk-jpl/src/m/classes/SMBgradients.py
r27458 r27970 1 import numpy as np 1 2 from fielddisplay import fielddisplay 2 3 from checkfield import checkfield … … 5 6 6 7 class SMBgradients(object): 7 """ 8 SMBgradients Class definition 8 """SMBgradients Class definition 9 9 10 11 10 Usage: 11 SMBgradients = SMBgradients(); 12 12 """ 13 13 14 14 def __init__(self): # {{{ 15 self.href = float('NaN')16 self.smbref = float('NaN')17 self.b_pos = float('NaN')18 self.b_neg = float('NaN')15 self.href = np.nan 16 self.smbref = np.nan 17 self.b_pos = np.nan 18 self.b_neg = np.nan 19 19 self.steps_per_step = 1 20 20 self.averaging = 0 … … 26 26 27 27 def __repr__(self): # {{{ 28 string = " surface forcings parameters:" 28 s = ' surface forcings parameters:\n' 29 s += '{}\n'.format(fielddisplay(self, 'issmbgradients', 'is smb gradients method activated (0 or 1, default is 0)')) 30 s += '{}\n'.format(fielddisplay(self, 'href', 'reference elevation from which deviation is used to calculate SMB adjustment in smb gradients method')) 31 s += '{}\n'.format(fielddisplay(self, 'smbref', 'reference smb from which deviation is calculated in smb gradients method [m/yr ice equiv]')) 32 s += '{}\n'.format(fielddisplay(self, 'b_pos', 'slope of hs - smb regression line for accumulation regime required if smb gradients is activated')) 33 s += '{}\n'.format(fielddisplay(self, 'b_neg', 'slope of hs - smb regression line for ablation regime required if smb gradients is activated')) 34 s += '{}\n'.format(fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 35 s += '{}\n'.format(fielddisplay(self, 'averaging', 'averaging methods from short to long steps')) 36 s += '\t\t{}\n'.format('0: Arithmetic (default)') 37 s += '\t\t{}\n'.format('1: Geometric') 38 s += '\t\t{}\n'.format('2: Harmonic') 39 s += '{}\n'.format(fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 29 40 30 string = "%s\n%s" % (string, fielddisplay(self, 'issmbgradients', 'is smb gradients method activated (0 or 1, default is 0)')) 31 string = "%s\n%s" % (string, fielddisplay(self, 'href', ' reference elevation from which deviation is used to calculate SMB adjustment in smb gradients method')) 32 string = "%s\n%s" % (string, fielddisplay(self, 'smbref', ' reference smb from which deviation is calculated in smb gradients method')) 33 string = "%s\n%s" % (string, fielddisplay(self, 'b_pos', ' slope of hs - smb regression line for accumulation regime required if smb gradients is activated')) 34 string = "%s\n%s" % (string, fielddisplay(self, 'b_neg', ' slope of hs - smb regression line for ablation regime required if smb gradients is activated')) 35 string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 36 string = "%s\n%s" % (string, fielddisplay(self, 'averaging', 'averaging methods from short to long steps')) 37 string = "%s\n\t\t%s" % (string, '0: Arithmetic (default)') 38 string = "%s\n\t\t%s" % (string, '1: Geometric') 39 string = "%s\n\t\t%s" % (string, '2: Harmonic') 40 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 41 42 return string 41 return s 43 42 # }}} 44 43 45 44 def extrude(self, md): # {{{ 46 # Nothing for now45 # Nothing for now 47 46 return self 48 47 # }}} … … 59 58 60 59 def initialize(self, md): # {{{ 61 # Nothing for now60 # Nothing for now 62 61 return self 63 62 # }}} 64 63 65 def checkconsistency(self, md, solution, analyses): 64 def checkconsistency(self, md, solution, analyses): # {{{ 66 65 if 'MasstransportAnalysis' in analyses: 67 66 md = checkfield(md, 'fieldname', 'smb.href', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 68 67 md = checkfield(md, 'fieldname', 'smb.smbref', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 68 if np.max(np.max(np.abs(md.smb.smbref[0:-1,]))) < 1: 69 print('!!! Warning: SMBgradients now expects smbref to be in m/yr ice eq. instead of mm/yr water eq.') 69 70 md = checkfield(md, 'fieldname', 'smb.b_pos', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 70 71 md = checkfield(md, 'fieldname', 'smb.b_neg', 'timeseries', 1, 'NaN', 1, 'Inf', 1) … … 76 77 # }}} 77 78 78 def marshall(self, prefix, md, fid): 79 def marshall(self, prefix, md, fid): # {{{ 79 80 yts = md.constants.yts 80 81 … … 87 88 WriteData(fid, prefix, 'object', self, 'fieldname', 'averaging', 'format', 'Integer') 88 89 89 # process requested outputs90 # Process requested outputs 90 91 outputs = self.requested_outputs 91 92 indices = [i for i, x in enumerate(outputs) if x == 'default'] … … 94 95 outputs = outputscopy 95 96 WriteData(fid, prefix, 'data', outputs, 'name', 'md.smb.requested_outputs', 'format', 'StringArray') 96 97 97 # }}} -
issm/trunk-jpl/test/NightlyRun/test328.py
r24633 r27970 14 14 md = setflowequation(md, 'SSA', 'all') 15 15 md.smb = SMBgradients() 16 md.smb.b_pos = -100. + 0.00005 * md.mesh.x - 0.0001 * md.mesh.y17 md.smb.b_neg = 250. + 0.000051 * md.mesh.x - 0.00011 * md.mesh.y16 md.smb.b_pos = (-100. + 0.00005 * md.mesh.x - 0.0001 * md.mesh.y) / 1000. * md.materials.rho_freshwater / md.materials.rho_ice 17 md.smb.b_neg = (250. + 0.000051 * md.mesh.x - 0.00011 * md.mesh.y) / 1000. * md.materials.rho_freshwater / md.materials.rho_ice 18 18 md.transient.requested_outputs = ['default', 'TotalSmb'] 19 19 md.smb.href = copy.deepcopy(md.geometry.surface) 20 md.smb.smbref = 1000. - 0.001 * md.mesh.x - 0.005 * md.mesh.y20 md.smb.smbref= (1000. - 0.001 * md.mesh.x - 0.005 * md.mesh.y) / 1000. * md.materials.rho_freshwater / md.materials.rho_ice 21 21 md.cluster = generic('name', gethostname(), 'np', 3) 22 22 md = solve(md, 'Transient') -
issm/trunk-jpl/test/NightlyRun/test329.py
r24261 r27970 15 15 md = setflowequation(md, 'HO', 'all') 16 16 md.smb = SMBgradients() 17 md.smb.b_pos = -100. + 0.00005 * md.mesh.x - 0.0001 * md.mesh.y18 md.smb.b_neg = 250. + 0.000051 * md.mesh.x - 0.00011 * md.mesh.y17 md.smb.b_pos = (-100. + 0.00005 * md.mesh.x - 0.0001 * md.mesh.y) / 1000. * md.materials.rho_freshwater / md.materials.rho_ice 18 md.smb.b_neg = (250. + 0.000051 * md.mesh.x - 0.00011 * md.mesh.y) / 1000. * md.materials.rho_freshwater / md.materials.rho_ice 19 19 md.smb.href = copy.deepcopy(md.geometry.surface) 20 md.smb.smbref = 1000. - 0.001 * md.mesh.x - 0.005 * md.mesh.y20 md.smb.smbref = (1000. - 0.001 * md.mesh.x - 0.005 * md.mesh.y) / 1000. * md.materials.rho_freshwater / md.materials.rho_ice 21 21 md.transient.requested_outputs = ['default', 'TotalSmb'] 22 22 md.cluster = generic('name', gethostname(), 'np', 3)
Note:
See TracChangeset
for help on using the changeset viewer.