|
|
|
@ -9,14 +9,13 @@ coastsnap_sites_csv = pd.read_csv(sites_csv_path)
|
|
|
|
|
images_parent_dir = coastsnap_sites_csv.parent_directory[0]
|
|
|
|
|
images_dir = os.path.join(images_parent_dir, "Images")
|
|
|
|
|
|
|
|
|
|
stats_csv = pd.DataFrame(columns = ['site','# processed', '# photoshop', '# registered', 'stability', 'most recently deleted', 'latest_processed', 'latest_registered'] )
|
|
|
|
|
stats_csv = pd.DataFrame(columns = ['site','# processed', '# photoshop', '# registered', 'stability', 'most recently deleted'] )
|
|
|
|
|
|
|
|
|
|
print("Retrieving snapshot for:")
|
|
|
|
|
for site in os.listdir(images_dir): # Loop through SITES
|
|
|
|
|
i=0
|
|
|
|
|
latest_processed_found = False
|
|
|
|
|
print(site)
|
|
|
|
|
to_append = [site, 0, 0, 0, 0, 'None deleted',None,None]
|
|
|
|
|
to_append = [site, 0, 0, 0, 0, 'None deleted']
|
|
|
|
|
processed = False
|
|
|
|
|
photoshop = False
|
|
|
|
|
registered = False
|
|
|
|
@ -66,23 +65,8 @@ for site in os.listdir(images_dir): # Loop through SITES
|
|
|
|
|
year_path = os.path.join(photoshop_path, year)
|
|
|
|
|
image_list = os.listdir(year_path)
|
|
|
|
|
image_list.reverse()
|
|
|
|
|
|
|
|
|
|
# Add latest processed image date
|
|
|
|
|
try:
|
|
|
|
|
if os.path.isfile(year_path + '/' + image_list[0]) and latest_processed_found == False:
|
|
|
|
|
latest_processed_found = True
|
|
|
|
|
print(image_list[0])
|
|
|
|
|
filename_list1 = image_list[0].split(".")
|
|
|
|
|
date = filename_list1[3].split("_")
|
|
|
|
|
image_date1 = date[0] + '-' + '{:02d}'.format(strptime(filename_list1[2],'%b').tm_mon) +'-'+ filename_list1[5]
|
|
|
|
|
to_append[6] = image_date1
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
for image_filename in image_list: # Loop through IMAGES
|
|
|
|
|
|
|
|
|
|
# Grab the latest image date in Processed
|
|
|
|
|
|
|
|
|
|
year_path = year_path.replace('Photoshop', 'Registered')
|
|
|
|
|
image_filename_no_suffix = image_filename.replace("_tagged","");
|
|
|
|
|
registered_image_path = year_path + '/' + image_filename_no_suffix[:-4] + '_registered.jpg'
|
|
|
|
@ -90,22 +74,9 @@ for site in os.listdir(images_dir): # Loop through SITES
|
|
|
|
|
# Finding the Latest Deleted Image Logic:
|
|
|
|
|
# Iterate through 'Images/Processed'
|
|
|
|
|
if os.path.isfile(registered_image_path): # Find the latest registered image.
|
|
|
|
|
|
|
|
|
|
# Add latest registered image date
|
|
|
|
|
try:
|
|
|
|
|
if latest_registered_image_found == False:
|
|
|
|
|
|
|
|
|
|
filename_list2 = image_filename.split(".")
|
|
|
|
|
date = filename_list2[3].split("_")
|
|
|
|
|
image_date2 = date[0] + '-' + '{:02d}'.format(strptime(filename_list2[2],'%b').tm_mon) +'-'+ filename_list2[5]
|
|
|
|
|
to_append[7] = image_date2
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
latest_registered_image_found = True # This is so the latest deleted image
|
|
|
|
|
# isn't just the most recent image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (latest_registered_image_found and # Check if latest registered image has been found
|
|
|
|
|
not latest_deleted_image_found and # Check if latest deleted image has already been found
|
|
|
|
|
not os.path.isfile(registered_image_path) and # Check if photoshop registered image is also in 'Images/Registered'
|
|
|
|
@ -140,7 +111,7 @@ for i, row in stats_csv.iterrows():
|
|
|
|
|
if stats_csv.at[i, '# photoshop'] != 0:
|
|
|
|
|
stability = "{0:.0%}".format(stats_csv.at[i, '# registered'] / stats_csv.at[i, '# photoshop'])
|
|
|
|
|
else:
|
|
|
|
|
stability = None # or whatever value makes sense in your context
|
|
|
|
|
stability = 'NaN' # or whatever value makes sense in your context
|
|
|
|
|
stats_csv.at[i,'stability'] = stability
|
|
|
|
|
|
|
|
|
|
stats_csv.set_index('site', inplace = True)
|
|
|
|
|