-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotHorizontalX.m
More file actions
60 lines (50 loc) · 1.88 KB
/
plotHorizontalX.m
File metadata and controls
60 lines (50 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function plotHorizontalX(figNumber, wrfdata,timestep, clim,cmap,fieldName, fieldUnits, outputdir, savePlots)
% Plots horizontal cross sections through WRF arrays.
%
% INPUT:
% figNumber - well, figure number
% wrfdata - Matlab data structure obtained from readWRF function
% timestep - integer timestep of the plot
% clim - color limits [min max] for plot
% cmap - colormap name ('jet' or othercolor('Spectral10') or ...)
% fieldName - 'U10', 'V10', 'PSFC' etc.
% fieldUnits - '[m/s]', '[mbar]', etc.
% outputdir - directory where the plots will be saved
% savePlots - logical flag whether to save the plots as .png or not
% set figure params:
width = 0.75;
fntsize=18;
% set domain limits:
latmin = min(min(min(wrfdata.lats)));
latmax = max(max(max(wrfdata.lats)));
lonmin = min(min(min(wrfdata.lons)));
lonmax = max(max(max(wrfdata.lons)));
% datestrings used for titles and filenames:
datestring1 = datestr(wrfdata.times(timestep),'yyyy mm dd HH:MM');
datestring2 = datestr(wrfdata.times(timestep),'yyyymmddHHMM');
data = wrfdata.(fieldName);
% plot figure:
figure(figNumber);clf; hold on
pcolor(wrfdata.lons(:,:,timestep)',wrfdata.lats(:,:,timestep)',data(:,:,timestep)'); shading flat
caxis(clim)
colormap(cmap)
colorbar
% add coastline:
S = shaperead(which('mediterranean.shp'),'UseGeoCoords',true);
geoshow([S.Lat], [S.Lon],'Color','black','LineWidth',width);
title({['BRIFS WRF ' fieldName ' ' fieldUnits ' at date: ']; datestring1},'fontsize',fntsize)
% add contours:
[C,h] = contour(wrfdata.lons(:,:,timestep)',wrfdata.lats(:,:,timestep)',data(:,:,timestep)',20,'linecolor',[.5 .5 .5])
set(h,'ShowText','on','TextStep',get(h,'LevelStep')*1)
% set plot limits:
xlim([lonmin,lonmax])
ylim([latmin,latmax])
set(gca,'fontsize',fntsize)
box on
if savePlots
% save image:
pngname = [outputdir fieldName '_' datestring2 wrfdata.nestingLevelString '.png'];
saveas(gcf,pngname,'png')
end
% close all
end