Skip to content

Commit

Permalink
fix backwards sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
scottstanie committed Oct 5, 2023
1 parent 4697832 commit fd4b080
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
20 changes: 20 additions & 0 deletions src/dolphin/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,26 @@ def get_raster_bounds(
return (left, bottom, right, top)


def get_raster_metadata(filename: Filename, domain: str = ""):
"""Get metadata from a raster file.
Parameters
----------
filename : Filename
Path to the file to load.
domain : str, optional
Domain to get metadata for. Default is "" (all domains).
Returns
-------
dict
Dictionary of metadata.
"""
ds = gdal.Open(fspath(filename))
md = ds.GetMetadata(domain)
return md


def rowcol_to_xy(
row: int,
col: int,
Expand Down
6 changes: 3 additions & 3 deletions src/dolphin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ def sort_key(file_date_tuple):
except TypeError:
return (-1, dates)

date_file_tuples = [(get_dates(f, fmt=file_date_fmt), f) for f in files]
date_files = sorted([fd_tuple for fd_tuple in date_file_tuples], key=sort_key)
file_date_tuples = [(f, get_dates(f, fmt=file_date_fmt)) for f in files]
file_dates = sorted([fd_tuple for fd_tuple in file_date_tuples], key=sort_key)

# Unpack the sorted pairs with new sorted values
dates, file_list = zip(*date_files) # type: ignore
file_list, dates = zip(*file_dates) # type: ignore
return list(file_list), list(dates)


Expand Down

0 comments on commit fd4b080

Please sign in to comment.