Skip to content

Commit

Permalink
Fix missing parameter and call of non-existing method in image_ts.py
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaVorokh committed Feb 17, 2016
1 parent 424551c commit 7165503
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions gammapy/scripts/image_ts.py
Expand Up @@ -37,9 +37,6 @@ def image_ts_main(args=None):
"using the '--model' parameter.")
parser.add_argument('--model', type=str,
help='Input excess model FITS file name')
parser.add_argument('--threshold', type=float, default=None,
help="Minimal required initial (before fitting) TS value,"

This comment has been minimized.

Copy link
@OlgaVorokh

OlgaVorokh Feb 17, 2016

Author Owner

it conflicted with the signature of image_ts

def image_ts(input_file, output_file, psf, model, scales, downsample, residual,
morphology, width, overwrite):

I did a small investigation: the image_ts used to have a threshold parameter, but then it got deleted(not sure when since file was renamed and github.com history only works if you don't move file around)
I found an old commit gammapy@67c0bad where compute_ts_map have been replaced by compute_ts_map_multiscale, which doesn't have "threshold" parameter.
Based on this I believe threshold is not needed anymore.

" that the fit is done at all.")
parser.add_argument('--overwrite', action='store_true',
help='Overwrite output files.')
parser.add_argument("-l", "--loglevel", default='info',
Expand Down Expand Up @@ -81,17 +78,14 @@ def image_ts(input_file, output_file, psf, model, scales, downsample, residual,
results = compute_ts_map_multiscale(maps, psf_parameters, scales, downsample,
residual, morphology, width)

# TODO: changed to `Path` ... untested!
folder, filename = Path(output_file).split()
Path(folder).mkdir(exist_ok=False)


# Write results to file

This comment has been minimized.

Copy link
@OlgaVorokh

OlgaVorokh Feb 17, 2016

Author Owner

Path() doesn't have split() method. Moreover, I am not sure why we even create folder with exist_ok=False, because in the tutorial https://gammapy.readthedocs.org/en/latest/detect/index.html

gammapy-ts-image all.fits.gz ts_map_0.00.fits --scale 0

the folder is always going to be our current working directory, thus failing

header = maps[0].header
if len(results) > 1:
for scale, result in zip(scales, results):
# TODO: this is unnecessarily complex
# Simplify, e.g. by letting the user specify a `base_dir`.
filename_ = filename.replace('.fits', '_{0:.3f}.fits'.format(scale))
filename_ = output_file.replace('.fits', '_{0:.3f}.fits'.format(scale))
fn = Path(folder) / filename_
log.info('Writing {}'.format(fn))
result.write(str(fn), header, overwrite=overwrite)
Expand Down

0 comments on commit 7165503

Please sign in to comment.