function [] = plot_psd(x, f, t, time, spectraltime_axis, B_output, fN, ax1, ax2, pt1, pt2, units)

global  fs utc_or_mlt

global fntsize xstr titlestr fstr

figure(fN)

% % define figure properties: font size, resolution, and margins
%fntsize=15;
% res=170;
% xsize=6*res;
% ysize=2.5*res;
% lmarg=0.5*res;
% bmarg=0.5*res;
% widthv=5.1*res;
% heightv=1.7*res;
if strcmp(utc_or_mlt,'UTC')
xstr = 'Universal Time (hh:mm)';
elseif strcmp(utc_or_mlt,'MLT')
xstr = 'Mean Local Time (hh:mm)';
end

clims=[3 10]; % color scale limits

if strcmp(pt1,'on')
% Plot PSD
%figure
%subplot(2,2,1)
axes(ax1); % Left, top
imagesc(datenum(spectraltime_axis),f,log(abs(x)),clims);axis xy; colormap(jet); % plot psd
ylim([0 fs/2]); % set ylim to the nyquist frequency
xlim([datenum(spectraltime_axis(1)) datenum(spectraltime_axis(end))]);
datetick(ax1,'x','hh:00');
%set(gca,'XTick',[0 3 6 9 12 15 18 21 24]); % set tick labels
xlabel(xstr, 'fontsize', fntsize, 'fontname', 'helvetica'); % label axes and title
ylabel(fstr, 'fontsize', fntsize, 'fontname', 'helvetica');
title(titlestr, 'fontsize', fntsize, 'fontname', 'helvetica');
end

if strcmp(pt2,'on')
% Plot time series below
axes(ax2) % Left, middle
plot(time,B_output); % plot ICM time series
%xl=datetime([year(time(1)) year(time(end))], [month(time(1)) month(time(end))], [day(time(1)) day(time(end))],[hour(time(1)) hour(time(end))], [minute(time(1)) minute(time(end))], [second(time(1)) second(time(end))]);
%xlim([datenum(xl(1)) datenum(xl(2))]); %rawtime_axis(1) rawtime_axis(end)]); % set x axis limits
xlim([time(1) time(end)]);
%set(gca,'XTick',[0 3 6 9 12 15 18 21 24]); % set tick labels
datetick(ax2,'x','hh:00');
xlabel(xstr, 'fontsize', fntsize, 'fontname', 'helvetica'); % label axes
ylabel(strcat('B (',units,')'));
end

end