sandialabs / SNL-ESSC

Sandia National Laboratories - Extreme Sea State Contour
Apache License 2.0
3 stars 1 forks source link

example file of Extreme SeaState Contour v1 #2

Closed Yuepeng9 closed 4 years ago

Yuepeng9 commented 4 years ago

I am very interested in learning the Extreme Sea State Contour method. I have downloaded the Matlab codes from GitHub. But I did not find "NDBC46022_1996_2012_Hs_Te.mat" that you used in the code as a example.

I am a beginner of ocean data analysis. Could you please send me this data file so that I can follow your code and learn this method quickly?

Thanks very much, and have a great day!

kmruehl commented 4 years ago

@Yuepeng9 Thank you for posting your question as an issue on GitHub. We are looking into the issue and will get back to you shortly.

aubreyeckert commented 4 years ago

@Yuepeng9 Thank you for your inquiry. The name of the .mat file that you mentioned was provided as an example. The user should provide a dataset matching the description in the code documentation in order to run the analysis (Data must be in .mat format and must include three vectors of input values: DateNum, Hs, and Te or Tp). Data can be provided from any source, but we have been using data downloaded from the NDBC website (https://www.ndbc.noaa.gov/) that is pre-processed to match the required format.

Alternatively, you can also check out the WDRT toolbox (http://wec-sim.github.io/WDRT/), which contains a Python ESSC module. This toolbox includes the capabilities to pull data directly from the NDBC site and run contour analyses.

Yuepeng9 commented 4 years ago

Thanks a lot, aubreyeckert.

Per your advise, I need to create a mat format file with the DateNum which is converted from date and time info provided in NDBC files as below. But if the NDBC has some data missing, do I need to fill the missing data with N/A?

YY MM DD hh WVHT APD
82 1 18 19 4.8 8.3
82 1 18 20 5.2 9
82 1 18 21 5.4 8.6
82 1 18 22 5.2 8.6
82 1 18 23 4.4 8.2
82 1 19 0 5.3 8.6
82 1 19 1 4.4 7.7
82 1 19 2 4.5 8.2
82 1 19 3 4.8 8.5
82 1 19 4 4.8 8.8
82 1 19 5 4.6 8.6
82 1 19 6 4.4 8.6
82 1 19 7 4.3 8.4
82 1 19 8 4.9 9.2
82 1 19 9 5.4 9.5
82 1 19 10 5.1 8.9
82 1 19 11 5.3 8.9
82 1 19 12 5.6 9
82 1 19 13 4.9 8.5
82 1 19 14 4.6 8.7
aubreyeckert commented 4 years ago

@Yuepeng9 If there is missing NDBC data, you can eliminate the rows where the data should be in your data file. However, if there is a significant amount of data missing, the accuracy of the calculated contour will be at risk.

Yuepeng9 commented 4 years ago

Hi aubreyeckert,

Thanks for your response. In order to run the example, I created a .mat file with the same name in the ESSC Matlab code, however, I could not complete run with the error of : "Unrecognized function or variable 'Hs'.

Error in Extreme_SeaState_Contour_v1 (line 165) NaNrem = find(isnan(Hs)|isnan(T)); % Find NaN data in either Hs or T"

could you please advise what was wrong?

Thanks

Pam

kmruehl commented 4 years ago

@Yuepeng9 can you upload the *.mat file so that we can reproduce the error. Thank you.

Yuepeng9 commented 4 years ago

mat file.zip

Yuepeng9 commented 4 years ago

Hi Kelley, I could not upload the .mat format file, therefore I created a zip file and uploaded it. Thank you for your assistance and patience.

Pam

aubreyeckert commented 4 years ago

@Yuepeng9 It looks like your variable in your .mat named "Te" should be named "T". Please let me know if this correction fixes the problem.

Yuepeng9 commented 4 years ago

Hi aubreyeckert, Per your advise, I have named the Te with T, but when I ran the Extreme_SeaState_Contour_v1, it still poped up the the same error message as before:

**"Unrecognized function or variable 'Hs'.

Error in Extreme_SeaState_Contour_v1 (line 165) NaNrem = find(isnan(Hs)|isnan(T)); % Find NaN data in either Hs or T"**

Could you please provide me with further advise?

Thanks

Pam

aubreyeckert commented 4 years ago

@Yuepeng9 I believe the issue is that your variables are saved in a table format in the .mat file that you provided. As specified in the code documentation, these should be separate vectors (i.e., not saved in a table). You can extract the vectors from the table with the command Hs = NDBC4602219962012HsTe.Hs, for example, and resave as a new .mat file including all three vectors.

There also appears to be a few anomalous data points in your data for which Hs has a value of 0 and Te has a nonzero value. These data points seem to be errors and do not seem physically realistic. These can be removed by adding the following code to the beginning of the ESSC script (after line 168 should work):

Zerorem = find(Hs==0); DateNum(Zerorem) = []; Hs(Zerorem) = []; T(Zerorem) = [];

If this removal doesn't happen, the distribution fitting will fail with an error.

One final note is that the code was developed in 2015 and is only expected to run without error for the 2015 version of Matlab. If you are running a different version of Matlab, follow the error message prompts to use updated functions. In particular, in the function "princomp_rotation.m," line 29 should be updated to use "pca" instead of "princomp" as dictated by Matlab error messages. You may have other issues to debug depending on the version of Matlab you are using and should follow Matlab's error message directions to debug.

Yuepeng9 commented 4 years ago

Hi aubreyeckert,

After having revised per your advice, the ESSC works very well now. Thank you very much, and have a great day!

Pam

kmruehl commented 4 years ago

@aubreyeckert thanks for resolving this issue