Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with using dynamic water level correction #289

Closed
Jiangchao3 opened this issue Jun 7, 2023 · 11 comments
Closed

Issue with using dynamic water level correction #289

Jiangchao3 opened this issue Jun 7, 2023 · 11 comments

Comments

@Jiangchao3
Copy link
Contributor

Hi @WPringle ,

I am trying to using the dynamic water level correction, met with two problems, the following is my code:

station=m.f15.elvstaloc; [idx,dst]=ourKNNsearch(m.p',station',1); time_vector=3600*[1:144]; offset_nodes=idx; offset_values=offset; m=Make_offset63(m,time_vector,offset_nodes,offset_values);

problem 1: How to appropriately set the time_vector?
the offset timeseries has 144 time step at 1 h intervels, I try to set time_vector = 3600*[1:144], time intervel is a duration, cause error when write the offset63 file:

image

image

when I set m.offset63.time_interval = 3600; , the error don't occur.

problem 2: offset value in the generated offset.63 file is not corresponding to the value I give
the following is the offset timeseries I give:

image

but the offset value in the offset.63 value is as following:

image

Hope can get the feedback from you about how to correctly use it.

@WPringle
Copy link
Collaborator

WPringle commented Jun 8, 2023

@Jiangchao3 The time_vector needs to be a datetime vector, not a float vector like you have. The time_interval is using the "seconds" function to convert datetime to a float inside. It seems to be doing some weird thing where it gives a duration if you provide a float. I guess you can make a catch so you don't have to provide a datetime vector, and assumes what you provide is in seconds.

@Jiangchao3
Copy link
Contributor Author

@WPringle Thanks, I will have a try and let you know the result.

@Jiangchao3
Copy link
Contributor Author

Hi @WPringle, I use a datetime vector for time_interval, it works well.

t1 = datetime(2017,9,6,1,0,0); t2 = datetime(2017,9,12,0,0,0); time_vector = t1:hours(1):t2;

But the offset time series in the generated offset.63 file still have been rounded:

image

the following is the original offset data:

image

I guess all the values less than 0.5 are rounded down to 0, while numbers greater than 0.5 are rounded up to 1.
Does this make sense?

I look through the source code in writeoffset63, i thinkt he source code do not have any problem,
for tt = 1: f63dat.num_times fprintf(fid,'%d \t %12.6f \n',[f63dat.offset_nodes; f63dat.offset_values(tt,:)]); fprintf(fid,'%s \n','##'); end

but why the generated file have such a digital error? a bit confused.

@Jiangchao3
Copy link
Contributor Author

Jiangchao3 commented Jun 8, 2023

@WPringle in additon, how to understand the concept of
dynamicWaterLevelCorrectionRampStart and dynamicWaterLevelCorrectionRampEnd?

if my bia correction period start from t1 = datetime(2017,9,6,1,0,0) and end at t2 = datetime(2017,9,12,0,0,0),

so should I set dynamicWaterLevelCorrectionRampStart as the time t1 relative from the coldstart time
and set dynamicWaterLevelCorrectionRampEnd as the time t2 relative from the coldstart time?

or just give it one or two days to spin up for the dynamic water level correction like tidal rampup?

I am not sure if I understand it correctly, although there is a example about it on https://wiki.adcirc.org/Dynamic_water_level_correction#Controlling_Water_Level_Correction

@WPringle
Copy link
Collaborator

WPringle commented Jun 9, 2023

@Jiangchao3 What do the values in msh.offset63 look like?

The ramp is like the tidal ramp, just give it like a couple of days spinup.

@Jiangchao3
Copy link
Contributor Author

Hi @WPringle , in msh.offset63, the values is as following:

image

@WPringle
Copy link
Collaborator

WPringle commented Jun 9, 2023

how does msh.offset63 (the struct) look?

@Jiangchao3
Copy link
Contributor Author

I am sorry i am not in the office right now, i can share the msh object tomorrow morning for inspecting more details.

but i think the msh.offset63 (struct) is just like the following, except the time_intervel has been updated using a datetime

image

@Jiangchao3
Copy link
Contributor Author

Hi @WPringle ,Here is my msh object with offset63 and the original data for offset time series

the following is my code to deal with the offset.

%% Make dynamic water level offset file
% read into offset dataset
offset_values = readtable('/data/users/qiujch24/OceanMesh2D/florida/validation_irma/offset.csv')
offset_values = table2array(offset_values);
offset_values = offset_values(:, 2:3);
offset_values = single(offset_values);
station = m.f15.elvstaloc;
[offset_nodes,dst] = ourKNNsearch(m.p',station',1);
t1 = datetime(2017,9,6,1,0,0);
t2 = datetime(2017,9,12,0,0,0);
time_vector = t1:hours(1):t2;
m = Make_offset63(m,time_vector,offset_nodes,offset_values);
m.f15.controllist(2).var(1).val = 'fort.fortset.63';
m.f15.controllist(2).var(3).val = 1243600; % RampStart
m.f15.controllist(2).var(4).val = 2243600; % RampEnd
%%

m.zip

really appreciate with you for help check it out

@WPringle
Copy link
Collaborator

WPringle commented Jun 9, 2023

@Jiangchao3 I found the problem, it is a bit esoteric. When the offset_nodes are of type int, it converts the offset_values to type int when they are combined during the writing process.

You can see the fix in #287

@Jiangchao3
Copy link
Contributor Author

clear,thanks very much @WPringle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants