phenocam_snow.utils

get_site_names()

Gets all available PhenoCam site names.

Returns:

The list of PhenoCam site names, or None if an error occurred.

Return type:

List[str]|None

get_site_dates(site_name)

Gets the dates of the first and last images collected at a site.

Parameters:

site_name (str) – The name of the PhenoCam site to download from.

Returns:

A 2-tuple of the format (first_date, last_date), or (None, None) if an error occurred.

Return type:

Tuple[str,str]|Tuple[None, None]

download(site_name, dates, save_to, n_photos)

Downloads photos taken in some time range at a given site.

Parameters:
  • site_name (str) – The name of the site to download from.

  • dates (Tuple[str, str]) – A 2-tuple indicating the oldest and youngest allowable photos.

  • save_to (str) – The destination directory for downloaded images. If the directory already exists, it is NOT cleared. New photos are added to the directory, except for duplicates, which are skipped.

  • n_photos (int) – The number of photos to download.

download_from_log(source_log, save_to)

Downloads images that are listed in a log file.

Parameters:
  • source_log (str) – The log file to get image URLs from.

  • save_to (str) – The destination directory for downloaded images.

label_images_via_subdir(site_name, categories, img_dir, save_to)
Allows the user to label images by moving them into the appropriate

subdirectory.

Parameters:
  • site_name (str) – The name of the site.

  • categories (List[str]) – The image categories.

  • img_dir (str) – The directory containing the image subdirectories.

  • save_to (str) – The destination path for the labels file.

read_labels(labels_file)

Reads image-label pairs.

Parameters:

labels_file (str) – The path to the labels file.

Returns:

A pandas DataFrame where each row contains the timestamp of an image, the path to that image, its label as a string, and the integer encoding of that label.

Return type:

pd.DataFrame