Skip to content

Commit

Permalink
Merge pull request #374 from sblunt/issue370_fix
Browse files Browse the repository at this point in the history
fix for Result File From Resumed MCMC Fails to Save #370
  • Loading branch information
sblunt authored Aug 19, 2024
2 parents 0b8f27b + 63383fb commit 2072ffd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 3 additions & 5 deletions orbitize/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def load_results(self, filename, append=False):
iad_data = hf.get("IAD_datafile")
if iad_data is not None:

tmpfile = 'thisisprettyhackysorrylmao'
tmpfile = 'tmpfile_OkToDeleteAfterFitFinishes'
with open(tmpfile, 'w+') as f:
try:
for l in np.array(iad_data):
Expand All @@ -218,8 +218,6 @@ def load_results(self, filename, append=False):
renormalize_errors,
)

os.system('rm {}'.format(tmpfile))

# load Gaia data
try:
gaia_num = int(hf.attrs['gaia_num'])
Expand All @@ -232,14 +230,14 @@ def load_results(self, filename, append=False):
gaiagost_data = hf.get("Gaia_GOST")
if gaiagost_data is not None:

tmpfile = 'thisisprettyhackysorrylmao'
tmpfile = 'tmpfile_OkToDeleteAfterFitFinishes'
tmptbl = table.Table(np.array(gaiagost_data))
tmptbl.write(tmpfile, format="ascii", overwrite=True)

gaia = orbitize.gaia.HGCALogProb(int(hip_num), hipparcos_IAD, tmpfile)
hipparcos_IAD = None # HGCA handles hipparocs, so don't want to pass Hipparcos also into the system

os.system('rm {}'.format(tmpfile))

else:
hipparcos_IAD = None
gaia = None
Expand Down
5 changes: 4 additions & 1 deletion tests/test_hipparcos.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ def test_save_load_2021():
myResults = results.Results()
myResults.load_results(filename)

os.system("rm tmp*.hdf5")
filename = "tmp3.hdf5"
myResults.save_results(filename)

os.system("rm tmp*")


if __name__ == "__main__":
Expand Down

0 comments on commit 2072ffd

Please sign in to comment.