Skip to content

Commit

Permalink
added yaml
Browse files Browse the repository at this point in the history
major changes to main_PartB.py, addition of .yaml configuration file to simplify execution.
  • Loading branch information
SashaNasonova committed Aug 28, 2024
1 parent 33baa5e commit 9fdc9d2
Show file tree
Hide file tree
Showing 7 changed files with 406 additions and 331 deletions.
Binary file modified __pycache__/burnsev_gee.cpython-310.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions burnsev_eval_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ def summary(root=None,filename=None):
for sheet_name, df in all_outputs.items():
df.to_excel(writer, sheet_name=sheet_name, index=False)

root = r'E:\burnSeverity\interim_2024\Nfires_Aug13_eval'
filename = 'pre_mosaicMetadata.csv'
root = r'E:\burnSeverity\interim_2024\for_Don'
filename = 'post_mosaicMetadata.csv'
summary(root,filename)
23 changes: 15 additions & 8 deletions burnsev_gee.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def get_cloud(img1):

#firelist = [firenumber]

if opt['override']:
if opt['overrideflag']:
dattype = opt['override'][firenumber]['sensor']
else:
dattype = opt['dattype']
Expand Down Expand Up @@ -278,7 +278,7 @@ def get_cloud(img1):

######### Find pre-fire images
# TO DO: add an option for multiple date ranges
if opt['override']:
if opt['overrideflag']:
startdate = (datetime.strptime(opt['override'][firenumber]['pre_mosaic'],'%Y-%m-%d') + timedelta(days=-2)).strftime('%Y-%m-%d') ## for reruns
enddate = (datetime.strptime(opt['override'][firenumber]['pre_mosaic'],'%Y-%m-%d') + timedelta(days=2)).strftime('%Y-%m-%d') ## for reruns
else:
Expand All @@ -287,6 +287,10 @@ def get_cloud(img1):
enddate = fires_df[fires_df[opt['fn']] == firenumber].iloc[0][opt['preT2']]
searchd[opt['preT2']] = enddate

#print pre-fire search interval
print('Pre T1: ', startdate)
print('Pre T2: ', enddate)

# Search archive
cld =100 #cloud cover percentage
searchd['cld_pre'] = cld
Expand Down Expand Up @@ -470,14 +474,14 @@ def classify_cc(img1):

#if greater than 90% coverage not available print error and exit
if max(meta_df_ext['percent_coverage']) < 90:
if opt['override']:
if opt['overrideflag']:
print('Override selected. Warning! Pre-image has less than 90% coverage!')
pass
else:
raise Exception('No post-fire scenes available with coverage >=90%')

if min(full_cov['percent_cc']) > 10:
if opt['override']:
if opt['overrideflag']:
print('Override selected. Warning! Pre-image has more than 10% cloud cover!')
pass
else:
Expand All @@ -504,7 +508,7 @@ def classify_cc(img1):

######### Find post-fire images
# TO DO: add an option for multiple date ranges
if opt['override']:
if opt['overrideflag']:
startdate = (datetime.strptime(opt['override'][firenumber]['post_mosaic'],'%Y-%m-%d') + timedelta(days=-2)).strftime('%Y-%m-%d') ## for reruns
enddate = (datetime.strptime(opt['override'][firenumber]['post_mosaic'],'%Y-%m-%d') + timedelta(days=2)).strftime('%Y-%m-%d') ## for reruns
else:
Expand All @@ -513,6 +517,9 @@ def classify_cc(img1):
enddate = fires_df[fires_df[opt['fn']] == firenumber].iloc[0][opt['postT2']]
searchd['post_T2'] = enddate

print('Post T1: ', startdate)
print('Post T2: ', enddate)

# Search archive
cld = 100 #cloud cover percentage
searchd['cld_post'] = cld
Expand Down Expand Up @@ -673,14 +680,14 @@ def strDate(string):

#if greater than 90% coverage not available print error and exit
if max(meta_df_ext['percent_coverage']) < 90:
if opt['override']:
if opt['overrideflag']:
print('Override selected. Warning! Post-image has less than 90% coverage!')
pass
else:
raise Exception('No post-fire scenes available with coverage >=90%')

if min(full_cov['percent_cc']) > 20:
if opt['override']:
if opt['overrideflag']:
print('Override selected. Warning! Post-image has more than 20% cloud cover!')
pass
else:
Expand Down Expand Up @@ -722,7 +729,7 @@ def strDate(string):
post_scenes_info = post_meta_scenes.loc[post_meta_scenes['date'] == post_mosaic_date]['system:index'].tolist()

#check if over-riding automatic selection
if opt['override']:
if opt['overrideflag']:
print('Overriding')
pre_mosaic_date = opt['override'][firenumber]['pre_mosaic'] ## for reruns
post_mosaic_date = opt['override'][firenumber]['post_mosaic'] ## for reruns
Expand Down
55 changes: 55 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Configuration settings for burn severity script

# Google Earth Engine settings (Operational: 'rsfaibfall2024', Test: 'burn-severity-2024')
gee:
account: 'burn-severity-2024'

# Paths for boundary files
paths:
bc_boundary: 'C:\Data\Datasets\BC_Boundary_Terrestrial_gcs_simplify.shp'
code_loc: 'C:\Dev\git\burnSeverity'

# Shapefile field names
shapefile_fields:
fn: 'FIRE_NUMBE'
preT1: 'pre_T1'
preT2: 'pre_T2'
postT1: 'post_T1'
postT2: 'post_T2'
areaha: 'FIRE_SIZE_'

# Directories and file paths
inputs:
root: 'E:\burnSeverity\interim_2024\for_Don'
fires_poly: 'perims.shp'
dattype:
- 'S2'
- 'L8'
- 'L9'
proc: 'SR'

# Processing options
process:
mask_clouds: false
eval_only: false
#Export pre-fire alternates
pre_flag: true
#Export post-fire alternates
post_flag: true
post_aot: true
export_data: false

# Debug
debug:
enable: false
debug_list:
- 'N71144'

# Override settings
override:
enable: false
details:
N51117:
pre_mosaic: '2023-08-03'
post_mosaic: '2024-08-12'
sensor: 'L9'
Loading

0 comments on commit 9fdc9d2

Please sign in to comment.