Read/write MS

Anime stores all information necessary to compute and apply instrument models to data in a custom structure of Arrays (see CjlObservation). All relevant data are read from the MS into this struct using loadms.

Load necessary modules

relativepath = "../../../"

include(joinpath(relativepath, "src", "Anime.jl"))
using .Anime

For this example, we will load an MS from the test/data/ directory.

msname = joinpath(relativepath, "test", "data", "eht1.ms")
stations = joinpath(relativepath, "inputs", "eht_2017.stations")
corruptseed = 456
tropseed = 54364
tropwetonly = false
correff = 0.88
tropattenuate = true
tropskynoise = true
tropmeandelays = true
tropturbulence = true
polvisframe = "sky"
polmode = "gp"
ptginterval = 5.0
ptgscale = 2.0
ptgmode = "gp"
gainsmode = "gp"
bpfile = joinpath(relativepath, "test", "data", "eht_2017.bandpass")
delim = ","
ignorerepeated = false

obs = loadms(msname, stations, corruptseed, tropseed, tropwetonly, correff, tropattenuate, tropskynoise, tropmeandelays, tropturbulence, polvisframe,
polmode, ptginterval, ptgscale, ptgmode, gainsmode, bpfile, delim=",", ignorerepeated=false)
Main.Anime.CjlObservation{Float64}("../../../test/data/eht1.ms", [-1.0273637f0 + 0.7004192f0im 0.00022555549f0 + 0.000236881f0im; 0.00084277225f0 + 0.00015272002f0im -1.0286585f0 + 0.70050967f0im;;; -1.0268914f0 + 0.70096505f0im -0.00037109957f0 - 7.938013f-5im; -0.00015597435f0 + 0.00017940946f0im -1.0270165f0 + 0.70179135f0im;;; -1.0264783f0 + 0.7030251f0im -0.0008015804f0 - 0.00023954225f0im; 0.00075147906f0 + 0.00029436644f0im -1.0263323f0 + 0.7032508f0im;;; … ;;; -1.0026518f0 + 0.7298038f0im 0.00075719744f0 - 0.0002195926f0im; -0.00021225783f0 + 0.00026368516f0im -1.0022856f0 + 0.72896194f0im;;; -1.0029718f0 + 0.7298837f0im -0.00054098084f0 + 0.00037843187f0im; -0.00077896315f0 - 0.00047400512f0im -1.0028898f0 + 0.72879726f0im;;; -1.0017743f0 + 0.7316947f0im -0.0009820868f0 - 7.177364f-5im; -0.00017453257f0 - 0.00041243472f0im -1.0010175f0 + 0.7306092f0im;;;; -0.50845253f0 + 0.6172963f0im 0.004093032f0 + 0.0068043573f0im; 0.0030970995f0 - 0.0006632369f0im -0.51168233f0 + 0.6162545f0im;;; -0.28692132f0 + 0.74844706f0im 0.00041666414f0 - 0.0016706279f0im; -0.004037518f0 + 0.00039616274f0im -0.28683165f0 + 0.75162196f0im;;; -0.032331094f0 + 0.79899156f0im 0.0005483622f0 - 0.0018148221f0im; -0.0020069683f0 - 0.0008557663f0im -0.01992612f0 + 0.8008866f0im;;; … ;;; 0.45190036f0 - 0.6542451f0im -0.0032726706f0 - 0.00012370224f0im; -0.0018764437f0 + 0.002139818f0im 0.45640397f0 - 0.65307325f0im;;; 0.22021052f0 - 0.75910276f0im -0.001552463f0 + 0.0018921307f0im; -0.0034744751f0 + 0.0005440766f0im 0.22640191f0 - 0.7628464f0im;;; -0.037598107f0 - 0.7923575f0im 0.0032136566f0 - 0.0014646426f0im; 0.0003017699f0 - 0.00040607277f0im -0.03579648f0 - 0.7901896f0im;;;; 0.13687864f0 - 0.9357863f0im -0.0007599427f0 + 0.00031076383f0im; -0.00029040492f0 - 0.0007969525f0im 0.1380428f0 - 0.9370943f0im;;; -0.9000588f0 + 0.29234886f0im -0.00040028774f0 + 0.0005337137f0im; 0.000942737f0 - 0.00029417445f0im -0.8990714f0 + 0.29478502f0im;;; 0.6638538f0 + 0.67272323f0im -0.00074885465f0 - 0.0005365417f0im; -7.630215f-5 + 0.0017965352f0im 0.6646188f0 + 0.6738753f0im;;; … ;;; -0.7156004f0 + 0.6126726f0im 0.001441895f0 - 0.00036166882f0im; -0.00033091556f0 + 0.0006213338f0im -0.7143266f0 + 0.60846215f0im;;; 0.86425245f0 + 0.36743325f0im 0.00040938405f0 - 0.0011692178f0im; 0.00044748335f0 + 3.895992f-5im 0.8665995f0 + 0.367503f0im;;; -0.059872814f0 - 0.9378186f0im -0.0010753846f0 + 0.0013258456f0im; -0.0020627473f0 + 0.0011654833f0im -0.05924886f0 - 0.936285f0im;;;; … ;;;; -0.9444557f0 - 0.028162302f0im 0.0001697395f0 - 0.005198098f0im; -0.0029194371f0 + 0.0010504747f0im -0.9392885f0 - 0.03258081f0im;;; -0.09423134f0 - 0.9408622f0im 0.009036051f0 - 0.0039186436f0im; -0.0011799693f0 - 0.005911376f0im -0.0911177f0 - 0.9549771f0im;;; 0.9223252f0 - 0.2084643f0im 0.006971996f0 + 0.00546776f0im; 0.00081147463f0 + 0.008187355f0im 0.92526937f0 - 0.20246372f0im;;; … ;;; 0.37771526f0 + 0.84558505f0im -0.001344226f0 - 0.0069346935f0im; -0.0052010408f0 + 0.0017656451f0im 0.39244896f0 + 0.8608624f0im;;; -0.8047717f0 + 0.49276406f0im -0.01338096f0 - 0.0027289472f0im; 0.0048290226f0 + 0.00038420712f0im -0.7999995f0 + 0.49375582f0im;;; -0.5804104f0 - 0.73876244f0im 0.006392474f0 + 0.00086454034f0im; 0.00025767874f0 - 0.00929447f0im -0.59148246f0 - 0.7299932f0im;;;; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im;;; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im;;; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im;;; … ;;; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im;;; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im;;; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im;;;; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im;;; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im;;; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im;;; … ;;; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im;;; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im;;; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im; 0.0f0 + 0.0f0im 0.0f0 + 0.0f0im], [0 0; 0 0;;; 0 0; 0 0;;; 0 0; 0 0;;; … ;;; 0 0; 0 0;;; 0 0; 0 0;;; 0 0; 0 0;;;; 0 0; 0 0;;; 0 0; 0 0;;; 0 0; 0 0;;; … ;;; 0 0; 0 0;;; 0 0; 0 0;;; 0 0; 0 0;;;; 0 0; 0 0;;; 0 0; 0 0;;; 0 0; 0 0;;; … ;;; 0 0; 0 0;;; 0 0; 0 0;;; 0 0; 0 0;;;; … ;;;; 0 0; 0 0;;; 0 0; 0 0;;; 0 0; 0 0;;; … ;;; 0 0; 0 0;;; 0 0; 0 0;;; 0 0; 0 0;;;; 1 1; 1 1;;; 1 1; 1 1;;; 1 1; 1 1;;; … ;;; 1 1; 1 1;;; 1 1; 1 1;;; 1 1; 1 1;;;; 1 1; 1 1;;; 1 1; 1 1;;; 1 1; 1 1;;; … ;;; 1 1; 1 1;;; 1 1; 1 1;;; 1 1; 1 1], Bool[0, 0, 0, 0, 1, 0, 0, 0, 1, 0  …  0, 0, 0, 1, 0, 0, 1, 0, 1, 1], Int32[0, 0, 0, 0, 0, 1, 1, 1, 1, 2  …  1, 1, 1, 1, 2, 2, 2, 3, 3, 4], Int32[1, 2, 3, 4, 5, 2, 3, 4, 5, 3  …  2, 3, 4, 5, 3, 4, 5, 4, 5, 5], [1010.8907438744791 1.5853914960023356e6 … -422007.2710556276 7.5229688321110895e6; -2212.7067047883756 -6.572110724709125e6 … -1.3266222772181071e6 -6930.498330703005; -1015.6189355906099 2.4081356408148813e6 … 5.68679298748029e6 7.898500058948814e6], [5.126284839e9, 5.126284839e9, 5.126284839e9, 5.126284839e9, 5.126284839e9, 5.126284839e9, 5.126284839e9, 5.126284839e9, 5.126284839e9, 5.126284839e9  …  5.126285835e9, 5.126285835e9, 5.126285835e9, 5.126285835e9, 5.126285835e9, 5.126285835e9, 5.126285835e9, 5.126285835e9, 5.126285835e9, 5.126285835e9], 4.0, Int32[1, 1, 1, 1, 1, 1, 1, 1, 1, 1  …  2, 2, 2, 2, 2, 2, 2, 2, 2, 2], 32, [2.2803125e11, 2.2809375e11, 2.2815625e11, 2.2821875e11, 2.2828125e11, 2.2834375e11, 2.2840625e11, 2.2846875e11, 2.2853125e11, 2.2859375e11  …  2.2940625e11, 2.2946875e11, 2.2953125e11, 2.2959375e11, 2.2965625e11, 2.2971875e11, 2.2978125e11, 2.2984375e11, 2.2990625e11, 2.2996875e11], 6.25e7, [-3.007099035872154; 0.21626588079481426;;], [2.2250608136e6 2.2250395297e6 … 5.08896774544e6 -5.464555493e6; -5.44005959994e6 -5.4411976292e6 … -301681.18586 -2.492927989e6; -2.48168115054e6 -2.4793033597e6 … 3.82501220561e6 2.150797176e6], 6×25 DataFrame
 Row │ station  x_m         y_m         z_m         dishdiameter_m  sefd_Jy  p ⋯
     │ String3  Float64     Float64     Float64     Int64           Float64  F ⋯
─────┼──────────────────────────────────────────────────────────────────────────
   1 │ AA        2.22506e6  -5.44006e6  -2.48168e6              73     60.0    ⋯
   2 │ AP        2.22504e6  -5.4412e6   -2.4793e6               12   3300.0
   3 │ AZ       -1.8288e6   -5.05441e6   3.42787e6              10   7700.0
   4 │ LM       -7.68716e5  -5.98851e6   2.06335e6              32   2400.0
   5 │ PV        5.08897e6  -3.01681e5   3.82501e6              30   1000.0    ⋯
   6 │ SM       -5.46456e6  -2.49293e6   2.1508e6               15   3300.0
                                                              19 columns omitted, false, 0.88, true, true, true, true, "sky", "gp", 5.0, 2.0, "gp", "gp", "../../../test/data/eht_2017.bandpass", Random.Xoshiro(0x67ee04b076833a4b, 0xf08ba7386ea77850, 0xbbb0dce8549bf925, 0xdeb6475526b824ae), Random.Xoshiro(0x1861b6afd6e3c538, 0x851b58994e9a0d10, 0xf40f2e2c1725de81, 0x8fa8adf8bbc504f6))

All subsequent computations are performed on this structure until the user calls postprocessms to write the results back to the MS. This function optionally accepts an HDF5 file containing the noise to be used for populating the WEIGHT and SIGMA arrays in the MS. If no HDF5 file is provided, these arrays are initialized to 1.0 and 0.0 respectively.

We first load a pre-existing HDF5 file containing instrument models generated according to the dimensions required by eht1.ms that was loaded in the previous step.

h5file = joinpath(relativepath, "test", "data", "insmodel1.h5")

postprocessms(obs, h5file=h5file)
[ Info: Populating weight and sigma spectrum arrays...
[ Info: Write arrays to disk... 🙆

The above function call writes the contents of obs back into the MS.

Note

Currently Casacore.jl does not provide a way to cleanly close and release the read-write lock to an MS. If further processing is required using a different library such as casatools it is recommended to do that in a new REPL session.


This page was generated using Literate.jl.