clear;close all;clc; 

% This script is to search for the gauges in the upstrean of Pantanal

addpath('/Users/xudo627/donghui/CODE/Setup-E3SM-Mac/matlab-scripts-for-mosart/');
addpath('/Users/xudo627/donghui/mylib/m/');

[lon_gsim,lat_gsim,Sh,yr,mo,da,mu_gsim,sd,cv] = get_GSIM_discharge('BR_0002835',1);

[gsim,gsim2] = search_GSIM_gauge(Sh.X,Sh.Y,-57.5,-18.5,1);

[lon_gsim,lat_gsim,S2,yr,mo,da,mu_gsim,sd,cv] = get_GSIM_discharge(gsim,1);
plot(S2.X,S2.Y,'g-','LineWidth',2);


figure;
mu_gsim = mu_gsim(yr >= 2000);
plot(nanmean(reshape(mu_gsim,[12, length(mu_gsim)/12]),2),'k-'); grid on;