grd349/PBjam

Star class - output directory not present

grd349 opened this issue · 3 comments

When running

star.run_asy_peakbag(norders=6)

I get the following error:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<timed eval> in <module>()

~/Code/PBjam/pbjam/star.py in run_asy_peakbag(self, norders, make_plots, store_chains, nthreads)
    147         outpath = lambda x: os.path.join(*[self.path, x])
    148         self.asy_fit.summary.to_csv(outpath(f'asy_fit_summary_{self.ID}.csv'),
--> 149                                     index=True)
    150         self.asy_fit.modeID.to_csv(outpath(f'asy_fit_modeID_{self.ID}.csv'),
    151                                    index=False)

~/.local/lib/python3.6/site-packages/pandas/core/generic.py in to_csv(self, path_or_buf, sep, na_rep, float_format, columns, header, index, index_label, mode, encoding, compression, quoting, quotechar, line_terminator, chunksize, date_format, doublequote, escapechar, decimal)
   3226             decimal=decimal,
   3227         )
-> 3228         formatter.save()
   3229 
   3230         if path_or_buf is None:

~/.local/lib/python3.6/site-packages/pandas/io/formats/csvs.py in save(self)
    181                 self.mode,
    182                 encoding=self.encoding,
--> 183                 compression=self.compression,
    184             )
    185             close = True

~/.local/lib/python3.6/site-packages/pandas/io/common.py in _get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text)
    397         if encoding:
    398             # Encoding
--> 399             f = open(path_or_buf, mode, encoding=encoding, newline="")
    400         elif is_text:
    401             # No explicit encoding

FileNotFoundError: [Errno 2] No such file or directory: '/home/davies/Projects/pb-tess/Guy/167548586/asy_fit_summary_167548586.csv' 

I think we need a directory creation step to prevent this error.

And also for

star.run_peakbag()

Excellent work! :)