Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #8. #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/SynthObs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np
import logging
from BayHunter import Targets
import os

logger = logging.getLogger()

Expand Down Expand Up @@ -106,14 +107,17 @@ def save_data(data, outfile=None):

if '%s' not in outfile:
name, ext = os.path.splitext(outfile)
outfile = name + '_%s.'+ext
outfile = name + '_%s' + ext # ext already contains the dot on a mac

for ref in data.keys():
x, y = data[ref]
with open(outfile % ref, 'w') as f:
for i in range(len(x)):
f.write('%.4f\t%.4f\n' % (x[i], y[i]))
logger.info('Data file saved: %s' % outfile % ref)
if isinstance(x, np.ndarray) and len(x) > 0: # check if targets exist
with open(outfile % ref, 'w') as f:
for i in range(len(x)):
f.write('%.4f\t%.4f\n' % (x[i], y[i]))
logger.info('Data file saved: %s' % outfile % ref)
else:
logger.info('Data file not saved (no x): %s' % outfile % ref)

@staticmethod
def save_model(h, vs, vpvs=1.73, outfile=None):
Expand Down