Skip to content

Commit

Permalink
by default, remove most files from fo dir after od
Browse files Browse the repository at this point in the history
  • Loading branch information
ntellis committed Jan 28, 2025
1 parent cfe08d5 commit bca9c78
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/adam_impact_study/fo_od.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
logger.setLevel(os.environ.get("ADAM_LOG_LEVEL", "INFO"))


fo_file_whitelist = [
"total.json",
"covar.json",
"elem_short.json",
"debug.txt" "observations.ades",
"environ.dat",
]


def observations_to_ades(observations: Observations) -> Tuple[str, ADESObservations]:
"""
Convert Observations to ADES format string.
Expand Down Expand Up @@ -102,6 +111,7 @@ def observations_to_ades(observations: Observations) -> Tuple[str, ADESObservati
def run_fo_od(
observations: Observations,
fo_result_dir: str,
fo_dir_cleanup: bool = True,
) -> Tuple[Orbits, ADESObservations, Optional[str]]:
"""Run Find_Orb orbit determination with directory-based paths
Expand Down Expand Up @@ -134,10 +144,14 @@ def run_fo_od(

orbit, rejected, error = fo(
ades_string,
clean_up=True,
out_dir=fo_result_dir,
)

if fo_dir_cleanup:
for file in os.listdir(fo_result_dir):
if file not in fo_file_whitelist:
os.remove(os.path.join(fo_result_dir, file))

# Re-assign orbit_id to the original value if we found an orbit
if len(orbit) > 0:
orbit = orbit.set_column("orbit_id", observations.orbit_id[:1])
Expand Down

0 comments on commit bca9c78

Please sign in to comment.