Skip to content

Incorrect behaviour when trying to add image not overlapping with Source

Hi,

I am trying to create a bunch of Source files with various sets of images. The images might not cover all of the MUSE cube. The behaviour of MPDAF is then odd and I suspect unintended:

Here I load a source from one part of the sky and an image from another (this is of course extreme): In [2]: s = Source.from_file('Groups/COSMOS-GR83/Source/grp83-869250.fits')

In [3]: img = Image('IMAGE-UDF-10.fits')

Add the image to the source - as it is not overlapping I should get an error or None returned

In [4]: s.add_image(img, name='Test')

It does however work:

In [5]: s.images

Out[5]: 7 images: SEG_MUSE_WHITE MUSE_WHITE MASK_UNION Test MASK_INTER MASK_SKY SEG_DISC

But the value of the image is a ValueError object:

In [6]: s.images['Test'] Out[6]: ValueError('The center must be within the image')

If I now try to write the object to disk, I get:

/Users/jarle/anaconda/lib/python2.7/site-packages/mpdaf-2.1.dev2235-py2.7-macosx-10.5-x86_64.egg/mpdaf/sdetect/source.pyc in _write_mpdaf_obj(obj, type_, name, hdulist)
  367 def _write_mpdaf_obj(obj, type_, name, hdulist):
  368     ext_name = '{}_{}_DATA'.format(type_, name)
  --> 369     hdu = obj.get_data_hdu(name=ext_name, savemask='nan')
  370     _insert_or_update_hdu(hdulist, ext_name, hdu)
  371 

AttributeError: 'exceptions.ValueError' object has no attribute 'get_data_hdu'

Which of course is very reasonable. There is of course a work-around, but I think in this case MPDAF should just complain that the centre is outside the image and not add the image (whether you throw an exception or not is not a major issue with me).

I am using mpdaf-2.1.dev2235 at the moment.

Cheers, Jarle.