Error running multiscale gaussian normalization code

Dear all,
I am using a Sunpy Jupyter notebook called multiscale_gaussian_normalization.ipnb. When I run it calling a fits file stored locally, I am able to plot the map but the code fails at the stage when the sunkit_image.enhance.mgn is called. The error message is shown in the included screen grab. Does anyone know what I could try to do to fix the error as I am at a loss.

Many thanks.

Hi Deb,

Thanks very much for reporting this. You can solve your immediate issue by first normalizing your AIA map by the exposure time before passing it to the enhance.mgn function,

aia_norm_map = aia_map / aia_map.exposure_time
out = enhance.mgn(

The MGN algorithm of Morgan and Druckmüller (2014) actually expects intensities that are first normalized by exposure time as noted in the paragraph just above Eq. 1 of that paper. However, it looks like this is not documented in the mgn function in sunkit-image. Clearly both better error messages and better documentation are needed here!

The actual reason for this error occurring is that the square root function here is trying to write data to an array that has type int16 as inherited from the data type of the input AIA data array. However, the result of the square root function has type float32. By first normalizing the data by the exposure time, the data is converted to a float before being passed in and thus there is type mismatch.

I hope that helps!




Hi Will,
Thanks very much for your quick and straight forward response. I have produced my first MGN map! It is also my first experience with this forum. Full marks.