Changeset 25272


Ignore:
Timestamp:
07/13/20 18:37:40 (5 years ago)
Author:
Eric.Larour
Message:

CHG: done a lot of work on these MME classes.

Location:
issm/trunk-jpl/src/m/contrib/larour
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/contrib/larour/ismip6.m

    r25061 r25272  
    188188
    189189                end % }}}
    190                 function interpolate(self,field,ismip2mesh,ismip2mesh_correction) % {{{
     190                function interpolate(self,md,field,ismip2mesh,ismip2mesh_correction) % {{{
    191191
    192192                        for i=1:self.n,
     
    202202                                end
    203203
    204                                 %map onto mesh:
    205                                 hg=ismip2mesh_correction.*(ismip2mesh*ht);
    206                                 pos=find(isnan(hg)); hg(pos)=0;
     204                                %map onto mesh: correct only for thicknesses
     205                                hg=ismip2mesh_correction.*(ismip2mesh*ht) ;
    207206
    208207                                %keep field:
    209208                                if strcmpi(field,'lithk'),
     209                                        pos=find(isnan(hg)); hg(pos)=0;
    210210                                        self.thickness{i}=hg;
    211                                         self.deltathickness{i}=diff(hg,1,2);
    212                                 end
     211                                end
     212                                if strcmpi(field,'sftgif'),
     213                                        hge=ones(md.mesh.numberofvertices,size(hg,2));
     214                                        for j=1:size(hg,2),
     215                                                hgj=hg(:,j);
     216                                                pos=find(hgj>0);
     217                                                hge(md.mesh.elements(pos,:),j)=-1;
     218                                        end
     219                                        self.icemask{i}=hge;
     220                                end
     221                                if strcmpi(field,'sftgrf'),
     222                                        hge=-ones(md.mesh.numberofvertices,size(hg,2));
     223                                        for j=1:size(hg,2),
     224                                                hgj=hg(:,j);
     225                                                pos=find(hgj>0);
     226                                                hge(md.mesh.elements(pos,:),j)=1;
     227                                        end
     228                                        self.oceanmask{i}=hge;
     229                                end
     230
    213231                                self.time{i}=t;
    214232                                self.timestart{i}=t0;
     
    217235                        end
    218236                end  % }}}
     237                function part=partition(self,md,part,value) % {{{
     238
     239                        for i=1:self.n,
     240                                dh=self.deltathickness{i};
     241                                for j=1:size(dh,2),
     242                                        dhj=dh(:,j);
     243                                        pos=find(dhj);
     244                                        part(pos)=value;
     245                                end
     246                        end
     247
     248                end  % }}}
    219249        end
    220250end
  • issm/trunk-jpl/src/m/contrib/larour/oceanmip.m

    r25001 r25272  
    4242                                        disp(['reading file ' file]);
    4343                                       
    44                                         %figure out time interval:
     44                                        %figure out time interval and remove historical:
    4545                                        time=ncread(file,'time');
    46                                         pos=find(time>2000); time=time(pos); nt=length(time);
    47                                        
     46                                        pos=find(diff(time)<0);
     47                                        if isempty(pos),
     48                                                pos=(length(time)-12*100+1):length(time);
     49                                        else
     50                                                pos=[(pos+1):length(time)];
     51                                        end
     52                                        time2=time(pos);
     53                                        pos2=find(time2<=2099 & time2>=2006);
     54                                        pos=pos(pos2);
     55                                        time=time(pos); nt=length(time);
     56
    4857                                        %reduce datasets:
    4958                                        time=floor(time(12:12:nt));
     
    5564                                        for i=12:12:nt,
    5665                                                year=i/12;
    57                                                 zosm(:,:,year)=mean(zos(:,:,i-11:i),3);
     66                                                zosm(:,:,year)=mean(zos(:,:,(i-11):i),3);
    5867                                        end
    5968                                        self.zos{end+1}=zosm; clear zos;
    6069
    6170                                        %zostoga:
    62                                         zostoga=ncread(file,'zostoga');
    63                                         zostogam=zeros(nt/12);
     71                                        zostoga=ncread(file,'zostoga'); zostoga=zostoga(pos);
     72                                        zostogam=zeros(nt/12,1);
    6473                                        for i=12:12:nt,
    6574                                                year=i/12;
     
    155164                end
    156165                %}}}
    157                 function [pbo,time]= bottompressure(self,model,gridded) % {{{
     166                function [rate,time]= zostoga_mean(self) % {{{
     167                        series=zeros(length(self.time{1}),self.n);
     168                        for i=1:self.n,
     169                                series(:,i)=self.zostoga{i};
     170                        end
     171                        rate=mean(series,2);
     172                        time=self.time{1};
     173                end
     174                %}}}
     175                function [rate,time]= zostoga_std(self) % {{{
     176                        series=zeros(length(self.time{1}),self.n);
     177                        for i=1:self.n,
     178                                series(:,i)=self.zostoga{i};
     179                        end
     180                        rate=std(series,1,2);
     181                        time=self.time{1};
     182                end
     183                %}}}
     184                function [average,stddev,time]= zostoga_stats(self) % {{{
     185                        series=zeros(length(self.time{1}),self.n);
     186                        for i=1:self.n,
     187                                series(:,i)=self.zostoga{i};
     188                        end
     189                        average=mean(series,2);
     190                        stddev=std(series,1,2);
     191                        time=self.time{1};
     192                end
     193                %}}}
     194        function array= bottompressure(self,model,gridded) % {{{
    158195                        for i=1:self.n,
    159196                                if strcmpi(model,self.model{i}),
     
    164201                                        end
    165202                                        time=self.time{i};
     203                                        array=[pbo;time];
    166204                                        break;
    167205                                end
     
    169207                end
    170208                %}}}
     209        function arrays= dbottompressures(self) % {{{
     210                arrays=cell(self.n,1);
     211                for i=1:self.n,
     212                        pbo=self.mesh_pbo{i}; pbo=pbo/1000; %in meters
     213                        dpbo=diff(pbo,1,2);
     214                        time=self.time{i};
     215                        time=time(1:end-1);
     216                        array=[dpbo;dtime];
     217                        arrays{i}=array;
     218                end
     219        end %}}}
     220        function arrays= dzoss(self) % {{{
     221                arrays=cell(self.n,1);
     222                for i=1:self.n,
     223                        zos=self.mesh_zos{i}; zos=zos/1000; %in meters
     224                        dzos=diff(zos,1,2);
     225                        time=self.time{i};time=time(1:end-1);
     226                        array=[dzos;time];
     227                        arrays{i}=array;
     228                end
     229        end     %}}}
     230        function arrays= dzostogass(self) % {{{
     231                arrays=cell(self.n,1);
     232                for i=1:self.n,
     233                        zostoga=self.zostoga{i}; zos=zos/1000; %in meters
     234                        dzostoga=diff(dzostoga);
     235                        time=self.time{i};time=time(1:end-1);
     236                        array=[dzostoga;time];
     237                        arrays{i}=array;
     238                end
     239        end     %}}}
    171240                function [lat,long]= latlong(self,model) % {{{
    172241                        for i=1:self.n,
Note: See TracChangeset for help on using the changeset viewer.