Skip to content

Commit

Permalink
Merge pull request #112 from sblunt/improve_read_error_msg
Browse files Browse the repository at this point in the history
Add exception messages for when input dates are in JD and when orbitize can't find input file.
  • Loading branch information
sblunt committed Jul 3, 2019
2 parents 1daf4c2 + ac71f84 commit a8bee56
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion orbitize/read_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def read_file(filename):
dtype=(float,int,float,float,float,float,'S5'))

# read file
input_table = read(filename)
try:
input_table = read(filename)
except:
raise Exception('Unable to read file: {}. \n Please check file path and format.'.format(filename))
num_measurements = len(input_table)

# Decide if input was given in the orbitize style
Expand Down Expand Up @@ -159,8 +162,14 @@ def read_file(filename):
# loop through each row and format table
index=0
for row in input_table:
# First check if epoch is a number
try:
float_epoch = np.float(row['epoch'])
except:
raise Exception('Problem reading epoch in the input file. Epoch should be given in MJD.')
# check epoch format and put in MJD
if row['epoch'] > 2400000.5: # assume this is in JD
print('Converting input epochs from JD to MJD.\n')
MJD = row['epoch'] - 2400000.5
else:
MJD = row['epoch']
Expand Down

0 comments on commit a8bee56

Please sign in to comment.