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

Dev0 #50

Merged
merged 8 commits into from
Oct 13, 2024
Merged

Dev0 #50

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependencies:
- python=>3.9
- xarray
- matplotlib>=3.1
- numpy>=1.17
- numpy>=2.0
- pandas>=2.2.1
- pip
- scipy
Expand Down
9 changes: 8 additions & 1 deletion examples/example_report.py → examples/example_report_AI.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from docx.shared import Inches
import warnings
warnings.filterwarnings("ignore")
import google.generativeai as genai
import os
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
model = genai.GenerativeModel(model_name="gemini-1.5-flash")

df = readNora10File('../tests/data/NORA_test.txt')

Expand Down Expand Up @@ -49,10 +53,13 @@

# Add the first table
df = tables.table_monthly_non_exceedance(ds,var= 'W10',step_var=2,output_file=None)
doc.add_heading('Table 1: Monthly non-exceedance', level=2)
response = model.generate_content("Write one sentence caption to the table:"+str(df))
#doc.add_heading('Table 1: Monthly non-exceedance', level=2)
doc.add_heading('Table 1:'+response.text, level=2)
table1 = doc.add_table(rows=df.shape[0] + 1, cols=df.shape[1])
table1.style = 'Table Grid'


# Add the header row for the first table
hdr_cells = table1.rows[0].cells
for i, column in enumerate(df.columns):
Expand Down
11 changes: 0 additions & 11 deletions examples/nb_hour_below_thr.csv

This file was deleted.

Binary file removed examples/nb_hour_below_thr.png
Binary file not shown.
12 changes: 8 additions & 4 deletions metocean_stats/stats/aux_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,17 @@ def Hs_Tp_curve(data,pdf_Hs,pdf_Hs_Tp,f_Hs_Tp,h,t,interval,X=100):

# Find index of Hs=value
epsilon = abs(h - rve_X)
param = find_peaks(1/epsilon) # to find the index of bottom
index = param[0][0] # the index of Hs=value
param, prov = find_peaks(1/epsilon) # to find the index of bottom
if len(param) == 0:
param = [np.argmax(1/epsilon)]
index = param[0] # the index of Hs=value

# Find peak of pdf at Hs=RVE of X year
pdf_Hs_Tp_X = pdf_Hs_Tp[index,:] # Find pdf at RVE of X year
param = find_peaks(pdf_Hs_Tp_X) # find the peak
index = param[0][0]
param, prov = find_peaks(pdf_Hs_Tp_X) # find the peak
if len(param) == 0:
param = [np.argmax(pdf_Hs_Tp_X)]
index = param[0]
f_Hs_Tp_100=pdf_Hs_Tp_X[index]


Expand Down
9 changes: 0 additions & 9 deletions tests/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ def test_plot_prob_non_exceedance_fitted_3p_weibull(ds=ds):
else:
raise ValueError("FigValue is not correct")

#def test_scatter_diagram(ds=ds):
# output_file = 'test_scatter_diagram.csv'
# df = tables.scatter_diagram(ds, var1='HS', step_var1=1, var2='TP', step_var2=1, output_file=output_file)
# if os.path.exists(output_file):
# os.remove(output_file)
# if df.shape[0] == 14:
# pass
# else:
# raise ValueError("Shape is not correct")

def test_plot_monthly_stats(ds=ds):
output_file = 'test_monthly_stats.png'
Expand Down
16 changes: 7 additions & 9 deletions tests/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
depth = ['0m', '1m', '2.5m', '5m', '10m', '15m', '20m', '25m', '30m', '40m', '50m', '75m', '100m', '150m', '200m']


#def test_scatter_diagram(ds=ds):
# output_file = 'test_scatter_diagram.csv'
# df = tables.scatter_diagram(ds, var1='HS', step_var1=1, var2='TP', step_var2=1, output_file=output_file)
# if os.path.exists(output_file):
# os.remove(output_file)
# if df.shape[0] == 14:
# pass
# else:
# raise ValueError("Shape is not correct")
def test_scatter_diagram(ds=ds):
output_file = 'test_scatter_diagram.csv'
df = tables.scatter_diagram(ds, var1='HS', step_var1=1, var2='TP', step_var2=1, output_file=output_file)
if os.path.exists(output_file):
os.remove(output_file)
assert df.shape[0] == 14


def test_table_var_sorted_by_hs(ds=ds):
output_file = 'test_var_sorted_by_hs.csv'
Expand Down
Loading