From 4c6d3a3eee600c44760f9f63d7c6f9c18b3ff37d Mon Sep 17 00:00:00 2001 From: Joseph Zhang Date: Mon, 29 Jul 2024 20:13:26 -0400 Subject: [PATCH] Update HA script for FES to handle the exception case where points are located very close to prime meridian --- docs/input-output/param.md | 2 +- src/Utility/Tides/gen_harm_FES.m | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/input-output/param.md b/docs/input-output/param.md index ebeae0e3..a95f6aeb 100644 --- a/docs/input-output/param.md +++ b/docs/input-output/param.md @@ -153,7 +153,7 @@ If `iprecip_off_bnd`/=0, preciptation will be turned off near land boundary. Thi ### stemp_stc (double), stemp_dz(1:2) (double) Option to account for sediment-water heat exchange on bottom temperature. - `stemp_stc` is heat transfer coefficient W.m-2.K-1 (so `stemp_stc=0` would turn this option off). + `stemp_stc` is heat transfer coefficient $W/m^2/K$ (so `stemp_stc=0` would turn this option off). stemp_dz(1) is the equivalent sediment buffer depth (m) for heat into sediment, and stemp_dz(2) is the equivalent sediment buffer depth (m) for heat out of sediment. diff --git a/src/Utility/Tides/gen_harm_FES.m b/src/Utility/Tides/gen_harm_FES.m index b9d5e9b1..a161c85e 100644 --- a/src/Utility/Tides/gen_harm_FES.m +++ b/src/Utility/Tides/gen_harm_FES.m @@ -14,7 +14,7 @@ %const={'s2','m2','n2','k2','k1','p1','o1','q1','m4'}; %List of open bnd seg's that contain lon/lat of open bnd nodes -open_ll={'fg.bp.1'}; %,'fg.bp.2','fg.bp.3'}; +open_ll={'fg.bp.1','fg.bp.2'}; %,'fg.bp.3','fg.bp.4','fg.bp.5','fg.bp.6'}; for iseg=1:length(open_ll) %----------------------------------------------------------- @@ -72,15 +72,27 @@ for j=1:npt lon2=open(j,2); if(lon2<0); lon2=lon2+360; end; lat2=open(j,3); - I=find(lon>=lon2,1); %find 1st entry J=find(lat>=lat2,1); - if(I<=1 || J<=1) - disp('Failed to find an interval'); [j lon2 lat2 I J] - error('Bomb out'); + if(J<=1) + disp('Failed to find an interval for lat'); [j lon2 lat2 J] + error('Bomb out(1)'); end - - ratx=(lon(I)-lon2)/(lon(I)-lon(I-1)); raty=(lat(J)-lat2)/(lat(J)-lat(J-1)); + + %Handle case with pt very close to prime meridian + if(lon2max(lon)) + disp(['Point ' num2str(j) ' very close to prime meridian']); + disp('Its lon:'); [lon2 min(lon) max(lon)] + I=length(lon); + ratx=0; + else + I=find(lon>=lon2,1); %find 1st entry + if(I<=1) + disp('Failed to find an interval for lon'); [j lon2 lat2 I J] + error('Bomb out'); + end + ratx=(lon(I)-lon2)/(lon(I)-lon(I-1)); + end %Check junks amp_max=max([amp0(I-1,J-1);amp0(I,J-1);amp0(I-1,J);amp0(I,J)]); amp_min=min([amp0(I-1,J-1);amp0(I,J-1);amp0(I-1,J);amp0(I,J)]);