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