astropy / SPISEA

Stellar Population Synthesis Modeling
https://spisea.readthedocs.io/en/stable/index.html
64 stars 32 forks source link

Writing isochrones when a folder does not exist #8

Closed MichaelMedford closed 4 years ago

MichaelMedford commented 4 years ago

I have on more than one occasion generated an isochrone and upon attempting to save it, been hit with the following error:

/u/jlu/code/python/PopStar/popstar/synthetic.py in make_photometry(self, rebin, vega)
    828 
    829         if self.save_file != None:
--> 830             self.points.write(self.save_file, overwrite=True)
    831 
    832         return
...
FileNotFoundError: [Errno 2] No such file or directory: '/u/Michael/data/popsycle_run/isochrones/iso_5.01_0.00_00010_p00.fits'

Would you consider adding in something like the following in order to avoid this error:

isochrones_dir = '%s/isochrones' % output_dir

if not os.path.exists(isochrones_dir):
    os.makedirs(isochrones_dir)

This error occurs just when the isochrone is attempting to save when the folder that it is trying to write into does not exist. https://github.com/astropy/PyPopStar/blob/5d67a903428ddb1ca507fd87cf354eb51807f160/popstar/synthetic.py#L997

mwhosek commented 4 years ago

Thanks for the suggestion! synthetic.IsochronePhot will now make the user-specified iso_dir if it does not already exist. This small change has been added to the master branch, so you should be able to pull down the changes.