Page 1 of 1

restor: beam fit failed

PostPosted: Fri Sep 19, 2014 6:45 pm
by andrew
Hi all,

I've been imaging some ATCA data recently and all goes well on my linux64 machine which is running MIRIAD built from source with some of the array sizes increased. However, when I run it on another linux64 machine running a binary installation of MIRIAD I get the error message "Beam fit failed" when I get to the restor task in my pipeline. Using the same map, beam and model created from the binary install but running restor on the source code install does not reproduce the error and the image is restored without an issue.

I had a quick look at the source to find out more about the error and it seems that this can happen when one of three things happen (from subs/nllsqu.for): a singular matrix is encountered, max number of iterations is exceeded, or it fails to find better solution. I don't think that the max number of iterations are being exceeded considering this is not a customisable parameter that I changed when compiling the source code install - but I could be wrong! I am unsure on what causes the other errors and would really appreciate some help.

At this time, I need to use the machine with the binary install for the imaging so simply using the working source install I have isn't an option. If you need the data products that are causing this error I can supply those on request (together they are quite large and I can't upload them right now).

Regards,
Andrew

Re: restor: beam fit failed

PostPosted: Fri Sep 19, 2014 11:08 pm
by ste616
Hi Andrew,

What are the pixel dimensions of the dirty beam image that you are using?

A possible way of getting around this limitation is by doing the restoring beam fit yourself using imfit. Input the dirty beam image into imfit and use object=beam. Take the major and minor axes numbers from the output and put them in as the fwhm parameter in restor, and the position angle from imfit goes in as restor's pa.

Re: restor: beam fit failed

PostPosted: Fri Sep 26, 2014 4:11 pm
by andrew
Hi Jamie,

Thanks for your reply. The beam image is pretty large at 12055 px square.

Using imfit appears to work, thanks! Out of curiosity, why does imfit succeed in fitting the beam but restor fails?

Re: restor: beam fit failed

PostPosted: Fri Sep 26, 2014 4:23 pm
by Mark.Wieringa
Hi Andrew,

Restor allocates a small internal array to copy the central part of the beam into for fitting. If the central patch is too elongated or flat to fit with the available pixels, it fails. Imfit can handle larger regions.
I made restor a bit more tolerant of elongated beams in June this year, are you running the latest version of restor? It should print:
restor: Revision 1.11, 2014/06/20 05:36:13 UTC

When I tested it, it worked for beams of more than a single cut, but you may have found another failure mode due to the large size of your beam.
If so, reducing the number of pixels per beam (increasing the cellsize) may work too.

Cheers,

Mark

Re: restor: beam fit failed

PostPosted: Thu Aug 11, 2016 5:44 pm
by liuby
Hi Jamie,

It seems that the fwhm & pa can only be printed on the screen?
Can they also be output to some variables so that enabling coding with imfit?

Thank you!

ste616 wrote:Hi Andrew,

What are the pixel dimensions of the dirty beam image that you are using?

A possible way of getting around this limitation is by doing the restoring beam fit yourself using imfit. Input the dirty beam image into imfit and use object=beam. Take the major and minor axes numbers from the output and put them in as the fwhm parameter in restor, and the position angle from imfit goes in as restor's pa.

Re: restor: beam fit failed

PostPosted: Fri Aug 12, 2016 10:09 am
by ste616
I'm not sure I know what you mean by "output to some variables", since no Miriad task does this. Do you mean to a log file? Or are you trying to use mirpy and the output isn't being stored? If you can be a bit more specific about what you'd like we'll try to help.

Generally, I use Perl for all my Miriad scripting, and I simply scrape the screen output of the Miriad tasks within the scripts and use regular expressions to match what I expect the output to be.

Re: restor: beam fit failed

PostPosted: Fri Aug 12, 2016 11:31 am
by Mark.Wieringa
If you want to capture values printed by miriad, a python option is mirpy
( see https://atcaforum.atnf.csiro.au/viewtopic.php?f=16&t=19 )

Here is my filter for restor:
Code: Select all
from mirpy import miriad
#filter for restor
def restor_filt(output):
  beam=dict(fwma=[],fwmi=[],pa=[])
  for line in output.split('\n'):
    if 'fwhm' in line:
      beam['fwma'] = float(line.split()[-4])
      beam['fwmi'] = float(line.split()[-2])
    if 'angle' in line:
      beam['pa'] = float(line.split()[-2])
  return (beam,output)
miriad.set_filter('restor',restor_filt)


Cheers,

Mark