Ignore:
Timestamp:
01/07/15 08:48:32 (10 years ago)
Author:
Mathieu Morlighem
Message:

NEW: merging cost functions

File:
1 edited

Legend:

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

    r17918 r18994  
    11import numpy
    2 import copy
    32from fielddisplay import fielddisplay
    43from EnumDefinitions import *
     
    65from checkfield import checkfield
    76from WriteData import WriteData
     7from supportedcontrols import supportedcontrols
     8from supportedcostfunctions import supportedcostfunctions
     9from marshallcostfunctions import marshallcostfunctions
    810
    911class m1qn3inversion(object):
     
    119121                md = checkfield(md,'fieldname','inversion.iscontrol','values',[0,1])
    120122                md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0,1])
    121                 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',['BalancethicknessThickeningRate','FrictionCoefficient','MaterialsRheologyBbar','DamageDbar','Vx','Vy','Thickness'])
     123                md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols())
    122124                md = checkfield(md,'fieldname','inversion.maxsteps','numel',[1],'>=',0)
    123125                md = checkfield(md,'fieldname','inversion.maxiter','numel',[1],'>=',0)
    124126                md = checkfield(md,'fieldname','inversion.dxmin','numel',[1],'>',0.)
    125127                md = checkfield(md,'fieldname','inversion.gttol','numel',[1],'>',0.)
    126                 md = checkfield(md,'fieldname','inversion.cost_functions','size',[num_costfunc],'values',[101,102,103,104,105,201,501,502,503,504,505])
     128                md = checkfield(md,'fieldname','inversion.cost_functions','size',[num_costfunc],'values',supportedcostfunctions())
    127129                md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices,num_costfunc],'>=',0)
    128130                md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices,num_controls])
     
    166168                #process cost functions
    167169                num_cost_functions=numpy.size(self.cost_functions)
    168                 data=copy.deepcopy(self.cost_functions)
    169                 pos=[i for i,x in enumerate(self.cost_functions) if x==101];
    170                 for i in pos: data[i]=SurfaceAbsVelMisfitEnum()       
    171                 pos=[i for i,x in enumerate(self.cost_functions) if x==102];
    172                 for i in pos: data[i]=SurfaceRelVelMisfitEnum()       
    173                 pos=[i for i,x in enumerate(self.cost_functions) if x==103];
    174                 for i in pos: data[i]=SurfaceLogVelMisfitEnum()       
    175                 pos=[i for i,x in enumerate(self.cost_functions) if x==104];
    176                 for i in pos: data[i]=SurfaceLogVxVyMisfitEnum()       
    177                 pos=[i for i,x in enumerate(self.cost_functions) if x==105];
    178                 for i in pos: data[i]=SurfaceAverageVelMisfitEnum()   
    179                 pos=[i for i,x in enumerate(self.cost_functions) if x==201];
    180                 for i in pos: data[i]=ThicknessAbsMisfitEnum()         
    181                 pos=[i for i,x in enumerate(self.cost_functions) if x==501];
    182                 for i in pos: data[i]=DragCoefficientAbsGradientEnum()
    183                 pos=[i for i,x in enumerate(self.cost_functions) if x==502];
    184                 for i in pos: data[i]=RheologyBbarAbsGradientEnum()   
    185                 pos=[i for i,x in enumerate(self.cost_functions) if x==503];
    186                 for i in pos: data[i]=ThicknessAbsGradientEnum()       
    187                 pos=[i for i,x in enumerate(self.cost_functions) if x==504];
    188                 for i in pos: data[i]=ThicknessAlongGradientEnum()     
    189                 pos=[i for i,x in enumerate(self.cost_functions) if x==505];
    190                 for i in pos: data[i]=ThicknessAcrossGradientEnum()   
     170                data=marshallcostfunctions(self.cost_functions)
    191171                WriteData(fid,'data',numpy.array(data).reshape(1,-1),'enum',InversionCostFunctionsEnum(),'format','DoubleMat','mattype',3)
    192172                WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer')
Note: See TracChangeset for help on using the changeset viewer.