fixed issue with taggibg

master
unknown 1 year ago
parent 3cec64493a
commit 7f770c045f

@ -35,7 +35,7 @@ args = parser.parse_args()
# Retrieve coastsnap/images directory set in coastsnap_sites.csv # Retrieve coastsnap/images directory set in coastsnap_sites.csv
code_images_dir = str(Path(os.getcwd()).parent) code_images_dir = str(Path(os.getcwd()).parent)
sites_csv_path = os.path.join(code_images_dir, "coastsnap_sites_tag.csv") sites_csv_path = os.path.join(code_images_dir, "coastsnap_sites_blacksmith.csv")
coastsnap_sites_csv = pd.read_csv(sites_csv_path) coastsnap_sites_csv = pd.read_csv(sites_csv_path)
images_parent_dir = coastsnap_sites_csv.parent_directory[0] images_parent_dir = coastsnap_sites_csv.parent_directory[0]
images_dir = os.path.join(images_parent_dir, "Images") images_dir = os.path.join(images_parent_dir, "Images")
@ -85,6 +85,8 @@ def loop_reregistered(site, tag, reregister_all):
except: # Site doesn't contain 'Processed'. Go to next site. except: # Site doesn't contain 'Processed'. Go to next site.
return return
# Loop through YEARS # Loop through YEARS
years_list = ['2019']
years_list.reverse()
for year in years_list: for year in years_list:
if not year.isdigit() and len(year) != 4: # Check folder name is in the format "YYYY" if not year.isdigit() and len(year) != 4: # Check folder name is in the format "YYYY"
continue continue
@ -120,6 +122,7 @@ def loop_reregistered(site, tag, reregister_all):
pathname = os.path.join(year_path, image_filename) pathname = os.path.join(year_path, image_filename)
image2tag = RegisteredImage(pathname, image_filename, registered_image_path) # Create image object image2tag = RegisteredImage(pathname, image_filename, registered_image_path) # Create image object
if i == 1: # Retrieve Tide Data once for each site if i == 1: # Retrieve Tide Data once for each site
tides_df = get_site_tide_data(images_parent_dir, site) tides_df = get_site_tide_data(images_parent_dir, site)
if isinstance(tides_df, pd.DataFrame): image2tag.get_tide(tides_df) if isinstance(tides_df, pd.DataFrame): image2tag.get_tide(tides_df)
@ -144,13 +147,15 @@ def main(site):
i=0 i=0
site_complete = False # A flag to stop tagging images when found site_complete = False # A flag to stop tagging images when found
image2tag = None image2tag = None
has_tide = False
photoshop_path = images_dir +'/'+ site + '/Photoshop' photoshop_path = images_dir +'/'+ site + '/Photoshop'
try: # Check if site contains 'Processed' directory try: # Check if site contains 'Processed' directory
years_list = os.listdir(photoshop_path) years_list = os.listdir(photoshop_path)
years_list.reverse() years_list.reverse()
except: # Site doesn't contain 'Processed'. Go to next site. except: # Site doesn't contain 'Processed'. Go to next site.
return return
years_list = ['2019']
years_list.reverse()
# Loop through YEARS # Loop through YEARS
for year in years_list: for year in years_list:
if not year.isdigit() and len(year) != 4: # Check folder name is in the format "YYYY" if not year.isdigit() and len(year) != 4: # Check folder name is in the format "YYYY"
@ -199,11 +204,12 @@ def main(site):
try: try:
tides_df = get_site_tide_data(images_parent_dir, site) tides_df = get_site_tide_data(images_parent_dir, site)
if isinstance(tides_df, pd.DataFrame): # Check if tide data exists if isinstance(tides_df, pd.DataFrame): # Check if tide data exists
image2tag.get_tide(tides_df) has_tide = True
except: except:
print("No tide data") print("No tide data")
if has_tide:
image2tag.get_tide(tides_df)
image2tag.create_tag() image2tag.create_tag()
tag_image(image2tag) tag_image(image2tag)

Loading…
Cancel
Save