Changeset 28023


Ignore:
Timestamp:
11/30/23 08:42:19 (16 months ago)
Author:
Cheng Gong
Message:

CHG: make the function to work for 2D grid as well

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/contrib/chenggong/modeldata/interpFromITSLIVE.m

    r27966 r28023  
    1 function [vx_out, vy_out] = interpFromITSLIVE(X,Y,Tstart,Tend,varargin)
     1function [vx_out, vy_out, time_out] = interpFromITSLIVE(X,Y,Tstart,Tend,varargin)
    22        %interpFromITSLIVE:
    33        %       Interpolate ITS_LIVE velocity data to the given mesh
    44        %
    55        %   Usage:
    6         %                [vx_out, vy_out] = interpFromITSLIVE(X,Y,Tstart,Tend,varargin)
     6        %                [vx_out, vy_out, time_out] = interpFromITSLIVE(X,Y,Tstart,Tend,varargin)
    77        %
    88        %       X, Y are the coordinates of the mesh
    99        %       Tstart and Tend decimal year of the start and end time
     10        %  vx_out and vy_out is (size(X), nt) tensor, depending on the dimension of X
    1011        %
    1112        %   Example:
    12         %                       [vx, vy] = interpFromITSLIVE(md.mesh.x,md.mesh.y, tstart, tend);
     13        %                       [vx, vy, t] = interpFromITSLIVE(md.mesh.x,md.mesh.y, tstart, tend);
    1314        %
    14         %   Options:
    1515        options    = pairoptions(varargin{:});
    1616
     
    3333
    3434        dataToLoad = {templist(dataInd).name};
    35         timeToload = dataTime(dataInd);
     35        time_out = dataTime(dataInd);
    3636
    3737        % Load x,y for GRE_G0240_0000.nc
     
    5656
    5757        % loop through all the files
    58         vx_out = zeros(numel(X)+1, numel(timeToload));
    59         vy_out = zeros(numel(X)+1, numel(timeToload));
     58        vx_out = zeros([size(X), numel(time_out)]);
     59        vy_out = zeros([size(X), numel(time_out)]);
    6060        for i = 1:length(dataToLoad)
    6161
     
    6666                vx(vx<-32760) = nan;
    6767                vy(vy<-32760) = nan;
    68                 vx_out(1:end-1,i) = InterpFromGrid(xh, yh, double(vx'), X, Y);
    69                 vx_out(end, i) = timeToload(i);
    70                 vy_out(1:end-1,i) = InterpFromGrid(xh, yh, double(vy'), X, Y);
    71                 vy_out(end, i) = timeToload(i);
     68                vx_out(:,:,i) = InterpFromGrid(xh, yh, double(vx'), X, Y);
     69                vy_out(:,:,i) = InterpFromGrid(xh, yh, double(vy'), X, Y);
    7270        end
     71
     72        vx_out = squeeze(vx_out);
     73        vy_out = squeeze(vy_out);
    7374end
    7475
Note: See TracChangeset for help on using the changeset viewer.