Skip to content

Commit

Permalink
Update fits_tools.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsteve committed Nov 18, 2024
1 parent 9ed516f commit 39d5545
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions padre_meddea/io/fits_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import re
import git
from git import InvalidGitRepositoryError

from astropy.io import ascii
import astropy.io.fits as fits
Expand Down Expand Up @@ -78,20 +79,23 @@ def add_process_info_to_header(header: fits.Header, n=1) -> fits.Header:
get_std_comment(f"PRLIB{n}A"),
)
header[f"PRVER{n}A"] = (padre_meddea.__version__, get_std_comment(f"PRVER{n}A"))
repo = git.Repo(search_parent_directories=True)
header[f"PRHSH{n}A"] = (
repo.head.object.hexsha,
get_std_comment(f"PRHSH{n}A"),
)
header[f"PRBRA{n}A"] = (
repo.active_branch.name,
get_std_comment(f"PRBRA{n}A"),
)
commits = list(repo.iter_commits("main", max_count=1))
header[f"PRVER{n}B"] = (
Time(commits[0].committed_datetime).fits,
get_std_comment(f"PRVER{n}B"),
)
try:
repo = git.Repo(padre_meddea.__file__, search_parent_directories=True)
header[f"PRHSH{n}A"] = (
repo.head.object.hexsha,
get_std_comment(f"PRHSH{n}A"),
)
header[f"PRBRA{n}A"] = (
repo.active_branch.name,
get_std_comment(f"PRBRA{n}A"),
)
commits = list(repo.iter_commits("main", max_count=1))
header[f"PRVER{n}B"] = (
Time(commits[0].committed_datetime).fits,
get_std_comment(f"PRVER{n}B"),
)
except InvalidGitRepositoryError:
pass
# primary_hdr["PRLOG1"] add log information, need to do this after the fact
# primary_hdr["PRENV1"] add information about processing env, need to do this after the fact
return header

0 comments on commit 39d5545

Please sign in to comment.