데이터 처리

조석 성분 분석

humming_stereo 2023. 3. 13. 17:25

* 우선 이 코드를 실행하기 위해선 "t_tide" 함수 툴과 매트랩 내장 툴박스인 "signal processing toolbox" 설치가 선행되어야 합니다.

* t_tide link (최신버전): https://www.eoas.ubc.ca/~rich/t_tide/t_tide_v1.5beta.zip

 

Rich Pawlowicz's Matlab Stuff

M_Map is a collection of routines that allow you to draw publication-quality maps in 18 different projections. M_Map includes a simple coastline and elevation database, and allows you to add your own data to those maps. Requires Matlab version 5 (or higher

www.eoas.ubc.ca


과정

1. 1년치 조석성과 데이터 다운로드

2. 조화분해

2. 그래프 생성

 - 조위, 분조(stem, errorbar)


1. 조석 데이터 다운로드

  1. 바다누리 해양정보 서비스 접속 : http://www.khoa.go.kr/oceangrid/khoa/intro.do
  2. 해양정보 다운로드
  3.  조석 성과 → 1시간 조위 → 월별 → 조위관측소
  4. 원하는 데이터 다운로드

2. 조화분해 (t_tide) manual

- 조석을 분석해 분조의 phase, frequency 추출


코드

addpath(genpath('../tool_box'));
%%
clc; clear; close all;
 
inp.in = '01_input';
inp.out = '02_figure';
 
if isfolder(inp.out) == 0
mkdir(inp.out)
end
 
%% data read
f.list = dir(fullfile(inp.in,'/*.txt'));
f.name = char(f.list.name);
 
dat.dnum=[];dat.dvec=[];dat.lev=[];
for ii = 1:12
tp.fid = fopen(fullfile(inp.in,f.name(ii,:)));
tp.format = '%f %s %s %s %s %s';
d.o = textscan(tp.fid,tp.format,'HeaderLines',5,'Delimiter','/: ');
 
%% data process
tp.lev = str2double(d.o{6});
d.lev = tp.lev/100-mean(tp.lev/100);
tp.time = strcat(num2str(d.o{1}),d.o{2:5});
for jj = 1:length(tp.time)
d.dnum(jj,1) = datenum(tp.time{jj,:},'yyyymmddHHMM');
d.dvec(jj,:) = datevec(d.dnum(jj));
end
dat.dnum = vertcat(dat.dnum,d.dnum);
dat.dvec = vertcat(dat.dvec,d.dvec);
dat.lev = vertcat(dat.lev,d.lev);
clear d tp
end
 
%% t_tide
tuk_time = dat.dnum;
tuk_elev = dat.lev;
snr = 5;
 
[tidestruc,pout] = t_tide(tuk_elev, ...
'interval',1, ...
'start',tuk_time(1), ...
'latitude',37+33/60, ...
'error','cboot', ...
'synthesis',snr^2);
 
r_value = tidestruc.tidecon(:,1);
e_value = tidestruc.tidecon(:,2);
r_phase = tidestruc.tidecon(:,3);
e_phase = tidestruc.tidecon(:,4);
freq = tidestruc.freq;
name = tidestruc.name;
 
 
%%
figure('Visible','on')
set(gcf,'color','w','Units','Normalized','OuterPosition',[0.0 0.2 .55 .7]);
 
subplot(3,1,1)
set(gca,'fontname','Arial','fontweight','bold','fontsize',15,'Box','on','Layer','top');
hold on;
% plot
plot(dat.dnum,dat.lev,'Color','k')
yline(0,'color','r')
xlim([dat.dnum(1) dat.dnum(end)-1])
xticks(linspace(dat.dnum(1),dat.dnum(end),13))
datetick('x','mm','keepticks','keeplimits')
ylim([-6 6])
yticks([-6:3:6])
xlabel('Time (Month)')
ylabel('Tide Level (m)')
title('Harmonic analysis in 2019','FontWeight','bold')
 
subplot(3,1,2)
set(gca,'fontname','Arial','fontweight','bold','fontsize',15,'Box','on','Layer','top','YScale', 'log');
hold on;
for ii = 1:length(freq)
if r_value(ii) < snr*e_value(ii)
stem(freq(ii),r_value(ii),'filled','Color','r');
else
stem(freq(ii),r_value(ii),'filled','Color','b');
text(freq(ii)+.002,r_value(ii),name(ii,:),'fontweight','bold')
end
end
ylim([1e-4 1e1])
yticks(10.^(-4:2:0))
xlabel('Frequency (cph)')
ylabel('Amplitude (m)')
 
subplot(3,1,3)
set(gca,'fontname','Arial','fontweight','bold','fontsize',15,'Box','on','Layer','top');
hold on;
for ii = 1:length(freq)
if r_value(ii) < snr*e_value(ii)
errorbar(freq(ii),r_phase(ii),e_phase(ii),'o','MarkerFaceColor','r','Color','r')
else
errorbar(freq(ii),r_phase(ii),e_phase(ii),'o','MarkerFaceColor','b','Color','b')
end
end
yticks([0:90:360])
ylim([-90 450])
xlabel('Frequency (cph)')
ylabel('Phase (deg)')
 
print(fullfile(inp.out,'figure'),'-dpng','-r200')