jzuhone / pyxsim

Simulating X-ray observations from astrophysical sources.
http://hea-www.cfa.harvard.edu/~jzuhone/pyxsim
Other
20 stars 8 forks source link

events.write_simput_file cannot save the file in any special path. #13

Closed tekkamanmaverick closed 3 years ago

tekkamanmaverick commented 6 years ago

Hi John, If I use events.write_simput_file(path+name, overwrite=True) to write the fits file, the next operation soxs.instrument_simulator will not find the phlist.fits. The path which is path/path is not match. So write_simput_file can only save the file in the current path.

jzuhone commented 6 years ago

Can you put a short script here that reproduces this and the exact error message you get?

tekkamanmaverick commented 6 years ago

In [13]: events_z.write_simput_file("./test/sloshing", overwrite=True) pyxsim : [INFO ] 2018-09-11 09:18:27,417 Writing SIMPUT catalog file ./test/sloshing_simput.fits and SIMPUT photon list file ./test/sloshing_phlist.fits.

In [14]: soxs.instrument_simulator("./test/sloshing_simput.fits", "evt.fits", (1 ...: 00.0, "ks"), "acisi_cy0",[45., 30.], overwrite=True) soxs : [INFO ] 2018-09-11 09:19:14,882 Making observation of source in evt.fits.

IOError Traceback (most recent call last)

in () ----> 1 soxs.instrument_simulator("./test/sloshing_simput.fits", "evt.fits", (100.0, "ks"), "acisi_cy0",[45., 30.], overwrite=True) /work/share/software/miniconda2/lib/python2.7/site-packages/soxs/instrument.pyc in instrument_simulator(input_events, out_file, exp_time, instrument, sky_center, overwrite, instr_bkgnd, foreground, ptsrc_bkgnd, bkgnd_file, no_dither, dither_params, roll_angle, subpixel_res, prng) 925 no_dither=no_dither, dither_params=dither_params, 926 roll_angle=roll_angle, subpixel_res=subpixel_res, --> 927 prng=prng) 928 # If the user wants backgrounds, either make the background or add an already existing 929 # background event file. It may be necessary to reproject events to a new coordinate system. /work/share/software/miniconda2/lib/python2.7/site-packages/soxs/instrument.pyc in generate_events(input_events, exp_time, instrument, sky_center, no_dither, dither_params, roll_angle, subpixel_res, prng) 433 elif isinstance(input_events, string_types): 434 # Assume this is a SIMPUT catalog --> 435 event_list, parameters = read_simput_catalog(input_events) 436 437 try: /work/share/software/miniconda2/lib/python2.7/site-packages/soxs/simput.pyc in read_simput_catalog(simput_file) 35 f_simput.close() 36 for phlist_file in phlist_files: ---> 37 f_phlist = pyfits.open(os.path.join(simput_dir, phlist_file)) 38 evt = {} 39 for key in ["ra", "dec", "energy"]: /work/share/software/miniconda2/lib/python2.7/site-packages/astropy/io/fits/hdu/hdulist.pyc in fitsopen(name, mode, memmap, save_backup, cache, lazy_load_hdus, **kwargs) 146 147 return HDUList.fromfile(name, mode, memmap, save_backup, cache, --> 148 lazy_load_hdus, **kwargs) 149 150 /work/share/software/miniconda2/lib/python2.7/site-packages/astropy/io/fits/hdu/hdulist.pyc in fromfile(cls, fileobj, mode, memmap, save_backup, cache, lazy_load_hdus, **kwargs) 397 return cls._readfrom(fileobj=fileobj, mode=mode, memmap=memmap, 398 save_backup=save_backup, cache=cache, --> 399 lazy_load_hdus=lazy_load_hdus, **kwargs) 400 401 @classmethod /work/share/software/miniconda2/lib/python2.7/site-packages/astropy/io/fits/hdu/hdulist.pyc in _readfrom(cls, fileobj, data, mode, memmap, save_backup, cache, lazy_load_hdus, **kwargs) 985 if not isinstance(fileobj, _File): 986 # instantiate a FITS file object (ffo) --> 987 fileobj = _File(fileobj, mode=mode, memmap=memmap, cache=cache) 988 # The Astropy mode is determined by the _File initializer if the 989 # supplied mode was None /work/share/software/miniconda2/lib/python2.7/site-packages/astropy/utils/decorators.pyc in wrapper(*args, **kwargs) 506 # one with the name of the new argument to the function 507 kwargs[new_name[i]] = value --> 508 return function(*args, **kwargs) 509 510 return wrapper /work/share/software/miniconda2/lib/python2.7/site-packages/astropy/io/fits/file.pyc in __init__(self, fileobj, mode, memmap, overwrite, cache) 148 self._open_fileobj(fileobj, mode, overwrite) 149 elif isinstance(fileobj, string_types): --> 150 self._open_filename(fileobj, mode, overwrite) 151 else: 152 self._open_filelike(fileobj, mode, overwrite) /work/share/software/miniconda2/lib/python2.7/site-packages/astropy/io/fits/file.pyc in _open_filename(self, filename, mode, overwrite) 504 self._file = bz2.BZ2File(self.name, bzip2_mode) 505 else: --> 506 self._file = fileobj_open(self.name, IO_FITS_MODES[mode]) 507 self.close_on_error = True 508 /work/share/software/miniconda2/lib/python2.7/site-packages/astropy/io/fits/util.pyc in fileobj_open(filename, mode) 393 """ 394 --> 395 return open(filename, mode) 396 else: 397 def fileobj_open(filename, mode): IOError: [Errno 2] No such file or directory: '/work/simulation/pyXSIM/2.2.0/test/./test/sloshing_phlist.fits'
jzuhone commented 5 years ago

I thought about this today a bit, and I decided I need to research how the SIMPUT library handles this because I'm not sure if their files support absolute paths or not (I suspect they do).

jzuhone commented 3 years ago

This was resolved in pyXSIM 3.0, so closing.