torrance / Casacore.jl

A high level Julia interface to Casacore
MIT License
9 stars 0 forks source link

Closing MS cleanly #9

Open iniyannatarajan opened 1 year ago

iniyannatarajan commented 1 year ago

I am using some casatools and casatasks with PythonCall for some functionality currently unavailable in Casacore.jl. Once I open an MS in Update mode and write some data into it, it seems like there is no way to close or free it for further manipulation by a different module. Is there a clean way to close an MS so that I can use casatools/casatasks on it?

For instance, I write some data into an MS using Casacore.jl and then want to use exportuvfits() on it. This is what I get when I call exportuvfits from my code:

[ Info: Creating test.uvfits from test.ms...
2023-08-02 17:51:06     SEVERE  exportuvfits::ms::open  Exception Reported: RegularFileIO: error in open or create of file /home/iniyan/software/dev/Anime.jl/examples/output/test.ms/table.f2: No such file or directory
2023-08-02 17:51:06     SEVERE  exportuvfits::::casa    Task exportuvfits raised an exception of class RuntimeError with the following message: RegularFileIO: error in open or create of file /home/iniyan/software/dev/Anime.jl/examples/output/test.ms/table.f2: No such file or directory
ERROR: LoadError: Python: RuntimeError: RegularFileIO: error in open or create of file /home/iniyan/software/dev/Anime.jl/examples/output/test.ms/table.f2: No such file or directory
Python stacktrace:
 [1] open
   @ casatools.__casac__.ms ~/software/dev/Anime.jl/.CondaPkg/env/lib/python3.8/site-packages/casatools/__casac__/ms.py:151
 [2] open
   @ casatools.ms ~/software/dev/Anime.jl/.CondaPkg/env/lib/python3.8/site-packages/casatools/ms.py:79
 [3] exportuvfits
   @ casatasks.private.task_exportuvfits ~/software/dev/Anime.jl/.CondaPkg/env/lib/python3.8/site-packages/casatasks/private/task_exportuvfits.py:15
 [4] __call__
   @ casatasks.exportuvfits ~/software/dev/Anime.jl/.CondaPkg/env/lib/python3.8/site-packages/casatasks/exportuvfits.py:182
Stacktrace:
 [1] pythrow()
   @ PythonCall ~/.julia/packages/PythonCall/1f5yE/src/err.jl:94
 [2] errcheck
   @ ~/.julia/packages/PythonCall/1f5yE/src/err.jl:10 [inlined]
 [3] pycallargs
   @ ~/.julia/packages/PythonCall/1f5yE/src/abstract/object.jl:211 [inlined]
 [4] pycall(::PythonCall.Py; kwargs::Base.Pairs{Symbol, String, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:vis, :fitsfile, :datacolumn), Tuple{String, String, String}}})
   @ PythonCall ~/.julia/packages/PythonCall/1f5yE/src/abstract/object.jl:222
 [5] pycall
   @ ~/.julia/packages/PythonCall/1f5yE/src/abstract/object.jl:218 [inlined]
 [6] #_#11
   @ ~/.julia/packages/PythonCall/1f5yE/src/Py.jl:341 [inlined]
 [7] mstouvfits(msname::String, uvfits::String, datacolumn::String; field::String, spw::String, antenna::String, timerange::String, overwrite::Bool)
   @ Main.Anime ~/software/dev/Anime.jl/src/storageutils/generatems.jl:165
 [8] mstouvfits(msname::String, uvfits::String, datacolumn::String)
   @ Main.Anime ~/software/dev/Anime.jl/src/storageutils/generatems.jl:156
 [9] top-level scope
   @ ~/software/dev/Anime.jl/examples/AnimeExample.jl:127
in expression starting at /home/iniyan/software/dev/Anime.jl/examples/AnimeExample.jl:127

But if I

  1. exit the script and run exportuvfits manually or
  2. avoid opening the MS in Update mode with Casacore.jl and run exportuvfits() from within my script

then I do not get any errors. Any ideas? Thanks for your help!