ratt-ru / pyxis

Python Extensions for Interferometry Scripting
3 stars 5 forks source link

Meqtrees: NameError [name 'im' is not defined] #108

Closed kamva1 closed 2 years ago

kamva1 commented 2 years ago

so this happens when I am running the meqtrees simulation script. (e.g python simtime.py). This is on both ike and jake (python 2.7. see the output below:

'root namespace is', '__main__', None)
2022/06/08 11:01:30 PYXIS: ===[ Pyxis: Python eXtensions for Inteferometry Scripting (C) 2013 by Oleg Smirnov <oms@ska.ac.za> ]===
2022/06/08 11:01:30 PYXIS: VERBOSE=1 by default
2022/06/08 11:01:30 PYXIS: loading Pyxis into context '__main__'
2022/06/08 11:01:30 PYXIS: registered module 'mqt'
2022/06/08 11:01:30 PYXIS: registered module 'std'
2022/06/08 11:01:30 PYXIS: executing '/usr/bin/which casapy':
2022/06/08 11:01:30 WARNING: /usr/bin/which returned error code 1
2022/06/08 11:01:30 PYXIS: executing '/usr/bin/which casa':
2022/06/08 11:01:30 PYXIS: /usr/bin/which succeeded
2022/06/08 11:01:30 PYXIS: registered module 'ms'
2022/06/08 11:01:30 PYXIS: registered module 'imager'
2022/06/08 11:01:30 PYXIS: registered module 'im'
Warning: No Cattery package found.
If you have Cattery in a non-standard location, please set the MEQTREES_CATTERY_PATH environment
variable to point to it.
2022/06/08 11:01:30 PYXIS: registered module 'im.argo'
2022/06/08 11:01:30 PYXIS: registered module 'lsm'
2022/06/08 11:01:31 PYXIS: executing '/usr/bin/time meqtree-pipeliner.py --mt 2 -c tdlconf.profiles [Sim_source_radius] gridded_sky.source_flux=1.0 gridded_sky.grid_m0=0.0 ms_sel.msname=MeerKAT_Hires.MS_p0 turbo-sim.py =_tdl_job_1_simulate_MS':
### Starting meqserver
('### Attaching to configuration file', 'tdlconf.profiles')
('### Loading config section', 'Sim_source_radius')
### Setting option gridded_sky.source_flux=1.0
### Setting option gridded_sky.grid_m0=0.0
### Setting option ms_sel.msname=MeerKAT_Hires.MS_p0
('### Compiling', 'turbo-sim.py')
### (using previously set options)
  (Meow.MSUtils: found /usr/bin/lwimager, can use it for imaging.)
  (Meow.MSUtils: found image viewer /usr/bin/tigger)
  (Meow.MSUtils: found image viewer /usr/bin/kvis)
  (Meow.MSUtils: found image viewer /usr/bin/ds9)
Successful readonly open of autonoread-locked table MeerKAT_Hires.MS_p0: 25 columns, 151200 rows
Successful readonly open of autonoread-locked table /home/vanqa/Vanqa/Vanqa/MeerKAT_Hires.MS_p0/ANTENNA: 8 columns, 27 rows
Successful readonly open of default-locked table /home/vanqa/Vanqa/Vanqa/MeerKAT_Hires.MS_p0/OBSERVATION: 9 columns, 1 rows
Successful readonly open of autonoread-locked table /home/vanqa/Vanqa/Vanqa/MeerKAT_Hires.MS_p0/POLARIZATION: 4 columns, 1 rows
Successful readonly open of autonoread-locked table /home/vanqa/Vanqa/Vanqa/MeerKAT_Hires.MS_p0/DATA_DESCRIPTION: 3 columns, 1 rows
Successful readonly open of autonoread-locked table /home/vanqa/Vanqa/Vanqa/MeerKAT_Hires.MS_p0/SPECTRAL_WINDOW: 14 columns, 1 rows
Successful readonly open of autonoread-locked table /home/vanqa/Vanqa/Vanqa/MeerKAT_Hires.MS_p0/FIELD: 9 columns, 1 rows
  (Meow.MSUtils: found /usr/bin/lwimager, can use it for imaging.)
  (Meow.MSUtils: found image viewer /usr/bin/tigger)
  (Meow.MSUtils: found image viewer /usr/bin/kvis)
  (Meow.MSUtils: found image viewer /usr/bin/ds9)
Using LSM module from Tigger (1.4.2) 1.4.2 at /usr/lib/python2.7/dist-packages/Tigger (in path)
Successful readonly open of default-locked table MeerKAT_Hires.MS_p0: 25 columns, 151200 rows
Successful readonly open of default-locked table MeerKAT_Hires.MS_p0: 25 columns, 151200 rows
Successful readonly open of default-locked table MeerKAT_Hires.MS_p0: 25 columns, 151200 rows
Successful readonly open of default-locked table MeerKAT_Hires.MS_p0: 25 columns, 151200 rows
('### ', 'TDL script successfully compiled. 1414 node definitions\n  (of which 3 are root nodes) sent to meqserver.')
### Running TDL job "_tdl_job_1_simulate_MS"
Meow.ReadVisHeader
('### Job result:', None)
### Stopping the meqserver
### All your batch are belong to us. Bye!
28.27user 12.20system 0:30.24elapsed 133%CPU (0avgtext+0avgdata 416892maxresident)k
0inputs+3402200outputs (0major+298714minor)pagefaults 0swaps
2022/06/08 11:02:01 PYXIS: meqtree-pipeliner.py succeeded
Visibility column shape: (151200, 360, 4)
Successful readonly open of default-locked table /home/vanqa/Vanqa/Vanqa/MeerKAT_Hires.MS_p0/SPECTRAL_WINDOW: 14 columns, 1 rows
2022/06/08 11:02:33 PYXIS: registered module 'im.lwimager'
Traceback (most recent call last):
  File "sim_time.py", line 138, in <module>
    sim_now()
  File "sim_time.py", line 124, in sim_now
    weight = "natural")#,basename_image='sim_img_%d.fits'%k, dirty_image = 'sim_img_%d.fits'%k);
  File "/usr/lib/python2.7/dist-packages/Pyxides/imager.py", line 92, in make_image
    call_imager = eval( 'im.%s.make_image'%(imager.lower()) )
  File "<string>", line 1, in <module>
NameError: name 'im' is not defined

@o-smirnov

o-smirnov commented 2 years ago

@kamva1, once again, full sequence of commands please, from the moment you log in.

kamva1 commented 2 years ago

On server ike : I go inside my working directory (e.g cd vanqa/Vanqa/Vanqa) -- here I have all the files and scripts I am using to run my main script (sim_time.py). Then I run on the working directory( python sim_time.py) and when running this, I get the above error.

kamva1 commented 2 years ago

@o-smirnov Please find this on ike: /home/vanqa/Vanqa/Vanqa/sim_time.py

with all other scripts imported into this one.

bennahugo commented 2 years ago

I've set up a reproducer here based on the input. I had to port the scripts to python3 for this with minor modifications. It looks like the imager module of pyxis no longer works as intended -- don't think this is part of the test as far as I know: The scripts are here: (venv) hugo@jake:~/mtbuild/test-vanqa$

You should activate ~/mtbuild/venv for the python3 build of MT

You can then run his sim_time.py script.

which yields the same error as the 2.7 system packages above:

('### Job result:', None)
### Stopping the meqserver
### All your batch are belong to us. Bye!
11.49user 6.55system 0:16.61elapsed 108%CPU (0avgtext+0avgdata 178664maxresident)k
0inputs+9488outputs (0major+105126minor)pagefaults 0swaps
2022/06/08 15:06:57 PYXIS: meqtree-pipeliner.py succeeded
Visibility column shape: (151200, 1, 4)
Successful readonly open of default-locked table /home/hugo/mtbuild/test-vanqa/MeerKAT_hires.MS/SPECTRAL_WINDOW: 14 columns, 1 rows
Saved plot to Pyplots0.png
2022/06/08 15:06:57 PYXIS: registered module 'im.lwimager'
Traceback (most recent call last):
  File "sim_time.py", line 152, in <module>
    sim_now()
  File "sim_time.py", line 138, in sim_now
    weight = "natural")#,basename_image='sim_img_%d.fits'%k, dirty_image = 'sim_img_%d.fits'%k);
  File "/home/hugo/mtbuild/venv/lib/python3.6/site-packages/Pyxides/imager.py", line 92, in make_image
    call_imager = eval( 'im.%s.make_image'%(imager.lower()) )
  File "<string>", line 1, in <module>
NameError: name 'im' is not defined
bennahugo commented 2 years ago

I suggest porting this issue over to pyxis. It is not a meqtrees problem per say

o-smirnov commented 2 years ago

@kamva1 could you please try this with the issue-108 branch of pyxis.

bennahugo commented 2 years ago

that does not work. Imports are missing. I'm testing a fix now, so far so good I just need to make sure it passes all other tests

bennahugo commented 2 years ago

Ok it runs through under the python3 and all tests pass locally. No guarantees for py2.7 -- I don't think the package will still work with python2.7, there has been lots of changes since then including to the hashbangs at the top which are needed to run in environments without python2.

...
Successful readonly open of default-locked table /home/hugo/mtbuild/test-vanqa/MeerKAT_hires.MS/SPECTRAL_WINDOW: 14 columns, 1 rows
Saved plot to Pyplots5.png
2022/06/08 15:57:05 INFO: im.lwimager.make_image: making dirty image ./plots-spw0/spw0-s1--lwimager.dirty.fits
2022/06/08 15:57:05 PYXIS: executing '/usr/bin/time lwimager stokes=IQUV mode=channel fixed=0 gain=0.1 npix=512 weight=natural cellsize=10.arcsec cachesize=4096 ms=MeerKAT_lores_100s.MS threshold=0 niter=0 wprojplanes=0 robust=0 chanstep=1 img_chanstep=0 nchan=0 phasecenter=j2000,0h0m,-40d0m chanstart=0 data=CORRECTED_DATA img_chanstart=0 img_nchan=1 image=./plots-spw0/spw0-s1--lwimager.dirty.fits.img operation=image spwid=0 field=0':
lwimager: Version 1.4.0
2022-06-08 13:57:06     INFO    Imager::open()  Opening MeasurementSet /home/hugo/mtbuild/test-vanqa/MeerKAT_lores_100s.MS
2022-06-08 13:57:06     INFO    imager::data selection  Selecting data
2022-06-08 13:57:06     INFO    imager::data selection  Selected 1404 out of 1512 visibilities.
2022-06-08 13:57:06     INFO    Imager::selectDataChannel()     Selecting channel 0 for spw 0
2022-06-08 13:57:06     INFO    imager::defineimage()   Defining image properties:nx=512 ny=512 cellx='10arcsec' celly='10arcsec' stokes=IQUV' mode=channel nchan=1 start=0 step=0 spwids=[0] fieldid=-1 facets=1 frame=1 distance='0m'
2022-06-08 13:57:06     INFO    imager::defineimage()    phaseCenter='00:00:00.00,  320.00.00.00, ' mStart='Radialvelocity: 0' qStep='1 km/s'' mFreqStart='Frequency: 0
2022-06-08 13:57:06     INFO    imager::weight()        Weighting MS: Imaging weights will be changed
2022-06-08 13:57:06     INFO    imager::weight()        Natural weighting
2022-06-08 13:57:06     INFO    imager::setoptions()    Setting processing options
2022-06-08 13:57:06     INFO    imager::makeimage()     Calculating image (without full skyequation)
2022-06-08 13:57:06     INFO    imager::makeimage()     Making dirty image from corrected data 
2022-06-08 13:57:06     INFO    imager::makeimage()     Image is : ./plots-spw0/spw0-s1--lwimager.dirty.fits.img
2022-06-08 13:57:06     INFO    imager::createFTMachine()       Performing interferometric gridding...
lwimager normally ended
0.45user 0.25system 0:00.44elapsed 157%CPU (0avgtext+0avgdata 86352maxresident)k
0inputs+24992outputs (0major+12402minor)pagefaults 0swaps
2022/06/08 15:57:06 PYXIS: lwimager succeeded
2022/06/08 15:57:06 ERROR: FITS::./plots-spw0/spw0-s1--lwimager.dirty.fits.img
57.293335