Skip to content

Commit

Permalink
Updated Future_Runs_Test.py script for faster plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
franklin1895 committed Nov 12, 2024
1 parent 0c8781c commit 601ea9b
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 33 deletions.
12 changes: 6 additions & 6 deletions data/Ocracoke_init_data/Ocracoke-CASCADE-parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ GrowthParamStart: false
HdDiffu: 0.75
Ki: 7.5e-06
Kr: 7.5e-05
LShoreface: 524.8348346135758
LShoreface: 523.9734307609483
MHW: 0.46
MaxShrubHeight: 5.3
MaxUpSlope: 0.25
Expand All @@ -31,15 +31,15 @@ Qs_min: 1.0
Qshrub_max: 0.15
RSLR_Constant: true
RSLR_const: 0.0056
Rat: -2.0
Rat: 0
Rin_i: 0.1
Rin_r: 2.0
SalineLimit: 5
Sandbag_elevation: 1.9
SeededRNG: true
Seedmax: 1000.0
Seedmin: 100.0
ShorefaceToe: 2099.9999999999995
ShorefaceToe: 1560.3448275999995
ShrubEl_max: 2.3
ShrubEl_min: 1.2
Shrub_ON: 0
Expand All @@ -53,8 +53,8 @@ UprootLimit: -0.2
beta: 0.04
disp_mu: -0.721891
disp_sigma: 1.5
dune_file: C:\Users\frank\PycharmProjects\CASCADE\data\Ocracoke_init_data\dunes\Dunes_2019\Domain_41_dune_2019.npy
elevation_file: C:\Users\frank\PycharmProjects\CASCADE\data\Ocracoke_init_data\elevations\Topography_2019\Domain_41_topography_2019.npy
dune_file: C:\Users\frank\PycharmProjects\CASCADE\data\Ocracoke_init_data\dunes\Sample_1_dune.npy
elevation_file: C:\Users\frank\PycharmProjects\CASCADE\data\Ocracoke_init_data\elevations\Topography_2019\Domain_49_topography_2019.npy
enable_sandbags: false
growth_param_file: growthparam_1000dam.npy
k_sf: 19324.753176079226
Expand All @@ -65,4 +65,4 @@ rmin: 0.55
s_sf_eq: 0.01698590034494604
sandbag_elevation: 1.8
sandbag_need: false
storm_file: C:\Users\frank\PycharmProjects\CASCADE\data\Ocracoke_init_data\storms\Synthetic_Storms\OCR_Future_StormList_2_baseline.npy
storm_file: C:\Users\frank\PycharmProjects\CASCADE\data\Ocracoke_init_data\storms\Synthetic_Storms\Ten_Percent_Storms\OCR_Future_StormList_99_10.npy
54 changes: 40 additions & 14 deletions scripts/ocracoke_ms/Future_Runs_Test.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import copy

import numpy as np
import time
import matplotlib.pyplot as plt
import pandas as pd
from scipy import stats as st
import os
import imageio

# Set color palette
Change_Rates = np.loadtxt('C:\\Users\\frank\\OneDrive - University of North Carolina at Chapel Hill\\Chapter 3\\Revised_Offshore_Datum\\All_Shoreline_Change_Rates.csv',skiprows=1,delimiter=',')
Subset_Change_Rates = np.loadtxt('C:\\Users\\frank\\OneDrive - University of North Carolina at Chapel Hill\\Chapter 3\\Revised_Offshore_Datum\\All_Annual_Change_Rates.csv',skiprows=1,delimiter=',')

os.chdir('C:\\Users\\frank\\OneDrive - University of North Carolina at Chapel Hill\\Chapter 3\\Model Runs\\Future Runs')
#os.chdir('C:\\Users\\frank\\OneDrive - University of North Carolina at Chapel Hill\\Chapter 3\\Model Runs\\Future Runs')
os.chdir('E:\\Model_Runs')


Save_Path = 'C:\\Users\\frank\\OneDrive - University of North Carolina at Chapel Hill\\Chapter 3\\Model Runs\\Summary_Values\\'

Expand All @@ -37,7 +35,7 @@ def Process_Batch(Base_Name,
name_list = []

# IL
for runs in range(0,5):
for runs in range(0,100):
name_list.append(str(Base_Name)+'_S'+str(runs)+'_'+str(Sink_Name))

nt_run = 126
Expand Down Expand Up @@ -100,10 +98,25 @@ def Process_Batch(Base_Name,
Mean_Island_Interior_Change = np.mean(island_width_change_TS, axis=0)


Break_Section,Break_Domain_Location = Find_Most_Common_Drowning_Area(Drowned_Domains=Drowning_Domain_Locations)
Break_Section,Break_Domain_Location, Section_Nums = Find_Most_Common_Drowning_Area(Drowned_Domains=Drowning_Domain_Locations)

Avg_Break_Year = np.mean(Model_Run_Years)

# Collate all data from 100 model runs
All_Values_Dict = {'All_EP_Change':All_EP_Change,
'All_Roadway_Abandonment':All_Roadway_Abandonment,
'Relocation_TS':Relocation_TS,
'Frequency_TS':Frequency_TS,
'Sandbag_Duration_TS':sandbag_duration_TS,
'Number_Sandbags_TS':number_sandbags_TS,
'Island_Width_Change_TS':island_width_change_TS,
'Model_Run_Years':Model_Run_Years,
#'Break_Domain_Locations':Section_Nums
}

All_Values_Data_Frame = pd.DataFrame(All_Values_Dict)


Export_Values_Dict = {
'Mean_Shoreline_Change_Rate':Mean_Shoreline_Change_Rate,
'Mean_Roadway_Abandonment':Mean_Roadway_Abandonment,
Expand All @@ -121,14 +134,27 @@ def Process_Batch(Base_Name,

Full_Save_Path = Save_Path+Base_Name+'_'+Sink_Name+'.csv'

Export_DF.to_csv(Full_Save_Path)
#Export_DF.to_csv(Full_Save_Path)

# Save yearly data as .pkl
Full_Save_Path_PKL = Save_Path+Base_Name+'_'+Sink_Name+'.pkl'
All_Values_Data_Frame.to_pickle(Full_Save_Path_PKL)


return(Export_DF)

def Find_Most_Common_Drowning_Area(Drowned_Domains):
# Set the numbers that comprise the 6 groups
Greatest_Len = -50
Most_Common_Break = -50

All_Len = [0,
0,
0,
0,
0,
0]

if len(Drowned_Domains) > 0:
Section_1 = range(11,20)
Section_2 = range(20,30)
Expand Down Expand Up @@ -189,17 +215,17 @@ def Find_Most_Common_Drowning_Area(Drowned_Domains):
Long_Len = copy.deepcopy(All_Len[most])

Most_Common_Break = st.mode(All_Breaks[Greatest_Len-1])[0][0]
return(Greatest_Len,Most_Common_Break)
return(Greatest_Len,Most_Common_Break, All_Len)

def Process_Data(run_name_batch):
cascade_list = []
Island_Drowning_Location_List = []
Years_Modeled_List = []
for k in range(0,len(run_name_batch)):
# --------- plot ---------
output = np.load(run_name_batch[k] + ".npz", allow_pickle=True)
cascade = output["cascade"]
cascade = cascade[0]
output = np.load(run_name_batch[k] + ".npz", allow_pickle=True)["cascade"]
cascade = output[0]
#cascade = cascade[0]
cascade_list.append(copy.deepcopy(cascade))
b3d = cascade.barrier3d
ny = np.size(b3d)
Expand All @@ -215,7 +241,7 @@ def Process_Data(run_name_batch):
Island_Drowning_Location_List.append(copy.deepcopy(drown - 4))
#Island_Drowning[run_name_batch[k]] = drowned_cells
else:
years_modeled = nt_run
years_modeled = cascade._nt
final_year_index = years_modeled-1
#Island_Drowning[run_name_batch[k]] = False
Years_Modeled_List.append(copy.deepcopy(years_modeled))
Expand Down Expand Up @@ -326,7 +352,7 @@ def Calculate_Sandbag_Years(cascade, years_modeled,buffer_length, number_barrier
Mean_Sandbag_Length_List.append(copy.deepcopy(Mean_Sandbag_Length))
return (Number_Sandbag_Emplacements_List,Mean_Sandbag_Length_List,Sandbag_Emplacement_Domains)

Output_DF = Process_Batch(Base_Name = Base_Name_List[1],Sink_Name =Sink_Name[0],Save_Path = Save_Path)
Output_DF = Process_Batch(Base_Name = Base_Name_List[3],Sink_Name =Sink_Name[1],Save_Path = Save_Path)

print('Hello')

Expand Down
2 changes: 1 addition & 1 deletion scripts/ocracoke_ms/MISC_Future_Test_Runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
nourishment_volume = 100

# RSLR Data
RSLR_Type = 'I'
RSLR_Type = 'IH'

if RSLR_Type == 'IL':
RSLR_Data = np.load('C:\\Users\\frank\\PycharmProjects\\CASCADE\\data\\Ocracoke_init_data\\RSLR\\Int_Low_SLR.npy')
Expand Down
18 changes: 9 additions & 9 deletions scripts/ocracoke_ms/Test_Changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

run_name_batch = []
run_name_batch.append('OCR_IL_Nourishment_S0_Accretional_Sink_Test_N5_Fixed_Beach_T6')
run_name_batch.append('OCR_IL_Nourishment_S0_Erosional_Sink_Test_N5_Fixed_Beach_T6')
run_name_batch.append('OCR_IL_Nourishment_S1_Accretional_Sink_Test_N5_Fixed_Beach_T6')
run_name_batch.append('OCR_IL_Nourishment_S1_Erosional_Sink_Test_N5_Fixed_Beach_T6')
run_name_batch.append('OCR_IL_Nourishment_S2_Accretional_Sink_Test_N5_Fixed_Beach_T6')
run_name_batch.append('OCR_IL_Nourishment_S2_Erosional_Sink_Test_N5_Fixed_Beach_T6')
run_name_batch.append('OCR_IL_Nourishment_S3_Accretional_Sink_Test_N5_Fixed_Beach_T6')
run_name_batch.append('OCR_IL_Nourishment_S3_Erosional_Sink_Test_N5_Fixed_Beach_T6')
run_name_batch.append('OCR_IL_Nourishment_S4_Accretional_Sink_Test_N5_Fixed_Beach_T6')
run_name_batch.append('OCR_IL_Nourishment_S4_Erosional_Sink_Test_N5_Fixed_Beach_T6')
#run_name_batch.append('OCR_IL_Nourishment_S0_Erosional_Sink_Test_N5_Fixed_Beach_T6')
#run_name_batch.append('OCR_IL_Nourishment_S1_Accretional_Sink_Test_N5_Fixed_Beach_T6')
#run_name_batch.append('OCR_IL_Nourishment_S1_Erosional_Sink_Test_N5_Fixed_Beach_T6')
#run_name_batch.append('OCR_IL_Nourishment_S2_Accretional_Sink_Test_N5_Fixed_Beach_T6')
#run_name_batch.append('OCR_IL_Nourishment_S2_Erosional_Sink_Test_N5_Fixed_Beach_T6')
#run_name_batch.append('OCR_IL_Nourishment_S3_Accretional_Sink_Test_N5_Fixed_Beach_T6')
#run_name_batch.append('OCR_IL_Nourishment_S3_Erosional_Sink_Test_N5_Fixed_Beach_T6')
#run_name_batch.append('OCR_IL_Nourishment_S4_Accretional_Sink_Test_N5_Fixed_Beach_T6')
#run_name_batch.append('OCR_IL_Nourishment_S4_Erosional_Sink_Test_N5_Fixed_Beach_T6')
#run_name_batch.append('OCR_IH_Nourishment_S0_Accretional_Sink_Test_N5')
#run_name_batch.append('OCR_IH_Status_Quo_S0_Accretional_Sink_Test_N1')

Expand Down
6 changes: 3 additions & 3 deletions scripts/ocracoke_ms/run_forward_batch_forward_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
Sink_Options = ['Accretional_Sink','Erosional_Sink']

run_name = []
for snames in range(0,100):
for snames in range(4,100):
if Storms == 'Baseline':
name_base = 'OCR_'+str(RSLR_Type)+str(Management_name)+'S'+str(snames)
else:
Expand All @@ -66,10 +66,10 @@

s_file = []
if Storms == 'Baseline':
for storm_num in range(0,100):
for storm_num in range(4,100):
s_file.append(copy.deepcopy('C:\\Users\\frank\\PycharmProjects\\CASCADE\\data\\Ocracoke_init_data\\storms\\Synthetic_Storms\\OCR_Future_StormList_'+str(storm_num)+'_baseline.npy'))
else:
for storm_num in range(0, 100):
for storm_num in range(4, 100):
s_file.append(copy.deepcopy(
'C:\\Users\\frank\\PycharmProjects\\CASCADE\\data\\Ocracoke_init_data\\storms\\Synthetic_Storms\\Ten_Percent_Storms\\OCR_Future_StormList_' + str(
storm_num) + '_10.npy'))
Expand Down

0 comments on commit 601ea9b

Please sign in to comment.