Changeset 22809


Ignore:
Timestamp:
05/29/18 14:07:24 (7 years ago)
Author:
adhikari
Message:

CHG: functions are located in a seperate directory etc

Location:
issm/trunk-jpl/examples
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/examples/EsaGRACE/runme.m

    r22803 r22809  
    11
    22clear all;
    3 steps=[0]; % [1:5];
     3steps=[0:5]; % [1:5];
    44
    55if any(steps==0) % Download GRACE land_mass data {{{
  • issm/trunk-jpl/examples/SlrGRACE/runme.m

    r22804 r22809  
    11
    22clear all;
    3 steps=[5]; % [1:6];
     3addpath('../Data','../Functions');
     4
     5steps=[7]; % [0:7];
    46
    57if any(steps==0) % Download GRACE land_mass data {{{
     
    1113        cd(f,'allData/tellus/L3/land_mass/RL05/netcdf/');
    1214   mget(f,'GRCTellus.JPL.200204_201701.LND.RL05_1.DSTvSCS1411.nc');
     15
     16        !mv *.nc '../Data/'
    1317
    1418        % display the content of the netcdf file.
     
    3236        md.mesh=gmshplanet('radius',radius*1e-3,'resolution',resolution*1e-3); % attributes should be in km.
    3337
    34         for i=1:numrefine,
     38        for i=1:numrefine; % refine mesh... {{{
    3539
    3640                %figure out mask:
     
    6670                %use distance to the coastline to refine mesh:
    6771                md.mesh=gmshplanet('radius',radius*1e-3,'resolution',resolution*1e-3,'refine',md.mesh,'refinemetric',dist);
    68         end
     72        end % }}}
    6973
    7074        %figure out mask:
     
    156160        md.slr.rotation=1;
    157161
    158         % Request outputs
    159 %       md.slr.requested_outputs = {'SlrUmotion','SlrNmotion','SlrEmotion'};
    160        
    161162        % Cluster info
    162163        md.cluster=generic('name',oshostname(),'np',3);
     
    206207                F.Method = 'linear';
    207208                F.ExtrapolationMethod = 'linear';
    208 
     209               
    209210                % Do the interpolation to get gridded solutions...
    210211                sol_grid = F(lat_grid, lon_grid);
     
    214215                set(0,'DefaultAxesFontSize',18,'DefaultAxesLineWidth',1,'DefaultTextFontSize',18,'DefaultLineMarkerSize',8)
    215216                figure1=figure('Position', [100, 100, 1000, 500]);
    216                 gcf;
    217                 load coast;
    218                 cla;
    219                 pcolor(lon_grid,lat_grid,sol_grid); shading flat; hold on;
     217                gcf; load coast; cla;
     218                pcolor(lon_grid,lat_grid,sol_grid); shading flat; hold on;
     219                % mask out land or oceans {{{
     220                if (kk==1)
     221                        geoshow(flipud(lat),flipud(long),'DisplayType','polygon','FaceColor','white');
     222                else
     223                        geoshow(lat,long,'DisplayType','polygon','FaceColor','white');
     224                end % }}}
    220225                plot(long,lat,'k'); hold off;
     226                % define colormap, caxis, xlim etc {{{
    221227                c1=colorbar;
    222                 colormap(jet);
     228                colormap('haxby');
     229                caxis([-floor(min(abs(min(sol)),abs(max(sol)))) floor(min(abs(min(sol)),abs(max(sol))))])
    223230                xlim([-180 180]);
    224231                ylim([-90 90]);
     232                % }}}
    225233                grid on;
    226234                title(sol_name(kk));
     
    237245
    238246        % read GRACE data during the chosen time period << steps=2 >>
    239         disp('Projecting grace loads onto the mesh...');
     247        disp('Projecting loads onto the mesh...');
    240248        time_range = 2007 + [15 350]/365;
    241249        water_load = grace(md.mesh.elements,md.mesh.lat,md.mesh.long,time_range(1),time_range(2));
     
    261269        md.settings.output_frequency=1;
    262270
    263         % Request outputs
    264         md.slr.requested_outputs = {'SlrUmotion','SlrNmotion','SlrEmotion'};
    265        
    266271        % Cluster info
    267272        md.cluster=generic('name',oshostname(),'np',3);
     
    271276        md=solve(md,'tr');
    272277
    273 end % }}}
    274 
     278        save ./Models/SlrGRACE.Transient md;
     279
     280end % }}}
     281
     282if any(steps==7) % Plot transient {{{
     283        disp('   Step 7: Plot transient');
     284        md = loadmodel('./Models/SlrGRACE.Transient');
     285
     286        time = md.slr.deltathickness(end,:); % year
     287
     288        % loads and solutions.
     289        for tt=1:length(time)
     290                gmsl(tt) = md.results.TransientSolution(tt).SealevelEustatic*1000;      % GMSL rate mm/yr
     291                sol1(:,tt) = md.slr.deltathickness(1:end-1,tt)*100;                                             % ice equivalent height [cm/yr]
     292                %% something weired happened here!!! first month solution is duplicated. Use offset of 1. Will fix it asap!
     293           sol2(:,tt) = md.results.TransientSolution(tt+1).Sealevel*1000;                       % mm/yr
     294        end
     295        sol_name = {'Change in water equivalent height [cm]', 'Relative sea-level [mm]'};
     296        movie_name = {'movie_loads.avi','movie_fingerprints.avi'};
     297
     298        res = 1.0; % degree
     299
     300        % Make a grid of lats and lons, based on the min and max of the original vectors
     301        [lat_grid, lon_grid] = meshgrid(linspace(-90,90,180/res), linspace(-180,180,360/res));
     302        sol_grid = zeros(size(lat_grid));
     303
     304        for kk=1:2
     305                sol=eval(sprintf('sol%d',kk));
     306       
     307                % if data are on elements, map those on to the vertices {{{
     308                if length(sol)==md.mesh.numberofelements
     309                        % map on to the vertices
     310                        for jj=1:md.mesh.numberofelements
     311                                ii=(jj-1)*3;
     312                                pp(ii+1:ii+3)=md.mesh.elements(jj,:);
     313                        end
     314                        for jj=1:md.mesh.numberofvertices
     315                                pos=ceil(find(pp==jj)/3);
     316                                temp2(jj,:)=mean(sol(pos,:));
     317                        end
     318                        sol=temp2;
     319                end % }}}
     320
     321                vidObj = VideoWriter(movie_name{kk});
     322                vidObj.FrameRate=2; % frames per second
     323                open(vidObj);
     324
     325                for jj=1:length(time)
     326                        % Make a interpolation object
     327                        F = scatteredInterpolant(md.mesh.lat,md.mesh.long,sol(:,jj));
     328                        F.Method = 'linear';
     329                        F.ExtrapolationMethod = 'linear';
     330                       
     331                        % Do the interpolation to get gridded solutions...
     332                        sol_grid = F(lat_grid, lon_grid);
     333                        sol_grid(isnan(sol_grid))=0;
     334                        sol_grid(lat_grid>85 & sol_grid==0) =NaN; % set polar unphysical 0s to Nan
     335
     336                        set(0,'DefaultAxesFontSize',18,'DefaultAxesLineWidth',1,'DefaultTextFontSize',18,'DefaultLineMarkerSize',8)
     337                        figure1=figure('Position', [100, 100, 1000, 500]);
     338                        gcf; load coast; cla;
     339                        pcolor(lon_grid,lat_grid,sol_grid); shading flat; hold on;
     340                        % mask out land or oceans {{{
     341                        if (kk==1)
     342                                geoshow(flipud(lat),flipud(long),'DisplayType','polygon','FaceColor','white');
     343                        else
     344                                geoshow(lat,long,'DisplayType','polygon','FaceColor','white');
     345                        end % }}}
     346                        plot(long,lat,'k'); hold off;
     347                        % define colormap, caxis, xlim etc {{{
     348                        c1=colorbar;
     349                        colormap('haxby');
     350                        caxis([-floor(min(abs(min(min(sol))),abs(max(max(sol))))) floor(min(abs(min(min(sol))),abs(max(max(sol)))))])
     351                        xlim([-180 180]);
     352                        ylim([-90 90]);
     353                        % }}}
     354                        grid on;
     355                        title(sol_name(kk));
     356                        set(gcf,'color','w');
     357                        writeVideo(vidObj,getframe(gcf));
     358                        close % close current figure
     359                end
     360
     361                % Close the file.
     362                close(vidObj);
     363        end
     364        !open *.avi;
     365       
     366        % plot GMSL time series
     367        plot(time,gmsl,'-*','linewidth',3); grid on;
     368        xlabel('# month');
     369        ylabel('GMSL [mm/yr]');
     370        set(gcf,'color','w');
     371
     372        %export_fig('Fig7.pdf');
     373
     374end % }}}
     375
Note: See TracChangeset for help on using the changeset viewer.