Skip to content

Commit f13e6b7

Browse files
committed
automated domain numbers
1 parent ad2b77a commit f13e6b7

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

scripts/input_preperation/background_erosion/generate_background_rates.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,20 @@
2929
# ============================================================
3030

3131
# Input file
32-
DSAS_CSV = r"C:\Users\hanna\PycharmProjects\CASCADE\data\hatteras_init\shoreline_change\dsas_1978_1997_CLEAN_DETAILED.csv"
32+
DSAS_CSV = r"/Users/rsahrae/PycharmProjects/PeaIsland/CASCADE/data/PeaIsland_init/Shoreline_change/dsas_1978_1997_CLEAN_DETAILED.csv"
3333

3434
# Output directory
35-
OUTPUT_DIR = r"C:\Users\hanna\PycharmProjects\CASCADE\output\background_rates"
35+
OUTPUT_DIR = r"/Users/rsahrae/PycharmProjects/PeaIsland/CASCADE/data/PeaIsland_init/background_erosion"
3636

37-
# CASCADE domain structure
38-
TOTAL_DOMAINS = 120 # Total including buffers
39-
NUM_REAL_DOMAINS = 90 # Real island domains
40-
NUM_LEFT_BUFFER = 15 # Number of left buffer domains
41-
NUM_RIGHT_BUFFER = 15 # Number of right buffer domains
37+
# --- YOUR STUDY AREA ---
38+
GIS_DOMAIN_MIN = 80
39+
GIS_DOMAIN_MAX = 120
40+
41+
NUM_LEFT_BUFFER = 15
42+
NUM_RIGHT_BUFFER = 15
43+
44+
NUM_REAL_DOMAINS = GIS_DOMAIN_MAX - GIS_DOMAIN_MIN + 1 # 41
45+
TOTAL_DOMAINS = NUM_REAL_DOMAINS + NUM_LEFT_BUFFER + NUM_RIGHT_BUFFER # 71
4246

4347
# IMPORTANT: Domain numbering
4448
# Your DSAS file should contain only GIS domains 1-90 (your study area)
@@ -82,15 +86,12 @@ def load_dsas_data(csv_path, domain_col, rate_col):
8286
print(f"Mean rate: {df[rate_col].mean():.3f} m/yr")
8387

8488
# Validate domain range
85-
max_domain = df[domain_col].max()
86-
if max_domain > 90:
87-
print(f"\n⚠️ WARNING: Found domains up to {max_domain:.0f}")
88-
print(f" Expected only domains 1-90 for your study area.")
89-
print(f" Domains 91+ may be from collaborator's area.")
90-
print(f" Filtering to domains 1-90 only...")
91-
df = df[df[domain_col] <= 90].copy()
92-
print(f" Filtered to {len(df)} records in domains 1-90")
93-
89+
print(f" Expected only domains 80-120 for your study area.")
90+
91+
df = df[(df[domain_col] >= GIS_DOMAIN_MIN) & (df[domain_col] <= GIS_DOMAIN_MAX)].copy()
92+
93+
print(f" Filtered to {len(df)} records in domains 1-90")
94+
9495
return df
9596

9697

@@ -112,7 +113,7 @@ def process_rates(df, domain_col, rate_col, num_real_domains,
112113
)
113114

114115
# Create continuous domain array (1 to NUM_REAL_DOMAINS)
115-
real_domains = np.arange(1, num_real_domains + 1)
116+
real_domains = np.arange(GIS_DOMAIN_MIN, GIS_DOMAIN_MAX + 1)
116117
continuous_rates = interp_func(real_domains)
117118

118119
print("\n" + "="*70)
@@ -218,7 +219,7 @@ def create_visualization(df, domain_col, rate_col, continuous_rates, smoothed_ra
218219
ax1.plot(df[domain_col], df[rate_col], 'o-',
219220
color='orange', linewidth=2, markersize=4, label='Observed LRR')
220221
ax1.axhline(y=0, color='gray', linestyle='--', alpha=0.5)
221-
ax1.set_xlabel('GIS Domain ID (1-90)')
222+
ax1.set_xlabel('GIS Domain ID (80-120)')
222223
ax1.set_ylabel('Shoreline Change Rate (m/yr)')
223224
ax1.set_title('Original Observed Data (LRR from DSAS)')
224225
ax1.legend()
@@ -233,7 +234,7 @@ def create_visualization(df, domain_col, rate_col, continuous_rates, smoothed_ra
233234
ax2.plot(real_domains, final_rates, '-', color='green',
234235
linewidth=2, label='Final (scaled & balanced)')
235236
ax2.axhline(y=0, color='gray', linestyle='--', alpha=0.5)
236-
ax2.set_xlabel('GIS Domain (1-90)')
237+
ax2.set_xlabel('GIS Domain (80-120)')
237238
ax2.set_ylabel('Shoreline Change Rate (m/yr)')
238239
ax2.set_title('Processing Steps')
239240
ax2.legend()

0 commit comments

Comments
 (0)