xradio 0.0.54__py3-none-any.whl → 0.0.55__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -599,36 +599,6 @@ def _get_mask_names(infile: str) -> list:
599
599
  return mymasks
600
600
 
601
601
 
602
- def _get_beam(imageinfo: dict, nchan: int, npol: int) -> Union[np.ndarray, None]:
603
- """Returns None if the image has no beam(s)"""
604
- x = ["perplanebeams", "restoringbeam"]
605
- r = None
606
- for z in x:
607
- if z in imageinfo:
608
- r = z
609
- break
610
- if r is None:
611
- return None
612
- beam = imageinfo[r]
613
- beam_array = np.zeros([1, nchan, npol, 3])
614
- if r == "perplanebeams":
615
- for c in range(nchan):
616
- for p in range(npol):
617
- k = nchan * p + c
618
- b = _casacore_q_to_xradio_q(beam["*" + str(k)])
619
- beam_dict = _convert_beam_to_rad(b)
620
- beam_array[0][c][p][0] = beam_dict["major"]["data"]
621
- beam_array[0][c][p][1] = beam_dict["minor"]["data"]
622
- beam_array[0][c][p][2] = beam_dict["pa"]["data"]
623
- elif r == "restoringbeam":
624
- b = _casacore_q_to_xradio_q(beam)
625
- beam_dict = _convert_beam_to_rad(b)
626
- beam_array[0, :, :, 0] = beam_dict["major"]["data"]
627
- beam_array[0, :, :, 1] = beam_dict["minor"]["data"]
628
- beam_array[0, :, :, 2] = beam_dict["pa"]["data"]
629
- return beam_array
630
-
631
-
632
602
  def _get_persistent_block(
633
603
  infile: str,
634
604
  shapes: tuple,
@@ -834,25 +804,46 @@ def _get_velocity_values_attrs(
834
804
  )
835
805
 
836
806
 
837
- def _multibeam_array(
838
- xds: xr.Dataset, img_full_path: str, as_dask_array: bool
807
+ def _get_beam(
808
+ img_full_path: str, nchan: int, npol: int, as_dask_array: bool
839
809
  ) -> Union[xr.DataArray, None]:
840
810
  # the image may have multiple beams
841
811
  with _open_image_ro(img_full_path) as casa_image:
842
812
  imageinfo = casa_image.info()["imageinfo"]
843
- mb = _get_beam(
844
- imageinfo, nchan=xds.sizes["frequency"], npol=xds.sizes["polarization"]
845
- )
846
- if mb is not None:
847
- if as_dask_array:
848
- mb = da.array(mb)
849
- xdb = xr.DataArray(mb, dims=["time", "frequency", "polarization", "beam_param"])
850
- xdb = xdb.rename("BEAM")
851
- xdb = xdb.assign_coords(beam_param=["major", "minor", "pa"])
852
- xdb.attrs["units"] = "rad"
853
- return xdb
854
- else:
813
+ x = ["perplanebeams", "restoringbeam"]
814
+ r = None
815
+ for z in x:
816
+ if z in imageinfo:
817
+ r = z
818
+ break
819
+ if r is None:
855
820
  return None
821
+ beam = imageinfo[r]
822
+ beam_array = np.zeros([1, nchan, npol, 3])
823
+ if r == "perplanebeams":
824
+ for c in range(nchan):
825
+ for p in range(npol):
826
+ k = nchan * p + c
827
+ b = _casacore_q_to_xradio_q(beam["*" + str(k)])
828
+ beam_dict = _convert_beam_to_rad(b)
829
+ beam_array[0][c][p][0] = beam_dict["major"]["data"]
830
+ beam_array[0][c][p][1] = beam_dict["minor"]["data"]
831
+ beam_array[0][c][p][2] = beam_dict["pa"]["data"]
832
+ elif r == "restoringbeam":
833
+ b = _casacore_q_to_xradio_q(beam)
834
+ beam_dict = _convert_beam_to_rad(b)
835
+ beam_array[0, :, :, 0] = beam_dict["major"]["data"]
836
+ beam_array[0, :, :, 1] = beam_dict["minor"]["data"]
837
+ beam_array[0, :, :, 2] = beam_dict["pa"]["data"]
838
+ if as_dask_array:
839
+ beam_array = da.array(beam_array)
840
+ xdb = xr.DataArray(
841
+ beam_array, dims=["time", "frequency", "polarization", "beam_param"]
842
+ )
843
+ xdb = xdb.rename("BEAM")
844
+ xdb = xdb.assign_coords(beam_param=["major", "minor", "pa"])
845
+ xdb.attrs["units"] = "rad"
846
+ return xdb
856
847
 
857
848
 
858
849
  ###########################################################################
@@ -21,7 +21,7 @@ from ._casacore.xds_from_casacore import (
21
21
  _get_persistent_block,
22
22
  _get_starts_shapes_slices,
23
23
  _get_transpose_list,
24
- _multibeam_array,
24
+ _get_beam,
25
25
  _read_image_array,
26
26
  )
27
27
  from ._casacore.xds_to_casacore import (
@@ -42,6 +42,8 @@ def _load_casa_image_block(infile: str, block_des: dict, do_sky_coords) -> xr.Da
42
42
  cshape = casa_image.shape()
43
43
  ret = _casa_image_to_xds_coords(image_full_path, False, do_sky_coords)
44
44
  xds = ret["xds"].isel(block_des)
45
+ nchan = ret["xds"].dims["frequency"]
46
+ npol = ret["xds"].dims["polarization"]
45
47
  starts, shapes, slices = _get_starts_shapes_slices(block_des, coords, cshape)
46
48
  dimorder = _get_xds_dim_order(ret["sphr_dims"])
47
49
  transpose_list, new_axes = _get_transpose_list(coords)
@@ -60,13 +62,14 @@ def _load_casa_image_block(infile: str, block_des: dict, do_sky_coords) -> xr.Da
60
62
  # data vars are all caps by convention
61
63
  xds = _add_mask(xds, m.upper(), block, dimorder)
62
64
  xds.attrs = _casa_image_to_xds_attrs(image_full_path)
63
- mb = _multibeam_array(xds, image_full_path, False)
64
- if mb is not None:
65
- selectors = {}
66
- for k in ("time", "frequency", "polarization"):
67
- if k in block_des:
68
- selectors[k] = block_des[k]
69
- xds["BEAM"] = mb.isel(selectors)
65
+ beam = _get_beam(image_full_path, nchan, npol, False)
66
+ if beam is not None:
67
+ selectors = {
68
+ k: block_des[k]
69
+ for k in ("time", "frequency", "polarization")
70
+ if k in block_des
71
+ }
72
+ xds["BEAM"] = beam.isel(selectors)
70
73
  return xds
71
74
 
72
75
 
@@ -97,9 +100,11 @@ def _read_casa_image(
97
100
  # data var names are all caps by convention
98
101
  xds = _add_mask(xds, m.upper(), ary, dimorder)
99
102
  xds.attrs = _casa_image_to_xds_attrs(img_full_path)
100
- mb = _multibeam_array(xds, img_full_path, True)
101
- if mb is not None:
102
- xds["BEAM"] = mb
103
+ beam = _get_beam(
104
+ img_full_path, xds.dims["frequency"], xds.dims["polarization"], True
105
+ )
106
+ if beam is not None:
107
+ xds["BEAM"] = beam
103
108
  # xds = _add_coord_attrs(xds, ret["icoords"], ret["dir_axes"])
104
109
  xds = _dask_arrayize_dv(xds)
105
110
  return xds
xradio/image/image.py CHANGED
@@ -159,7 +159,7 @@ def load_image(infile: str, block_des: dict = {}, do_sky_coords=True) -> xr.Data
159
159
  do_casa = False
160
160
  if do_casa:
161
161
  # comment next line when done debugging
162
- # return _load_casa_image_block(infile, bd, do_sky_coords)
162
+ # return _load_casa_image_block(infile, selection, do_sky_coords)
163
163
  try:
164
164
  return _load_casa_image_block(infile, selection, do_sky_coords)
165
165
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xradio
3
- Version: 0.0.54
3
+ Version: 0.0.55
4
4
  Summary: Xarray Radio Astronomy Data IO
5
5
  Author-email: Jan-Willem Steeb <jsteeb@nrao.edu>, Federico Montesino Pouzols <pouzols@eso.edu>, Dave Mehringer <dmehring@nrao.edu>, Peter Wortmann <peter.wortmann@skao.int>
6
6
  License: BSD 3-Clause License
@@ -8,16 +8,16 @@ xradio/_utils/_casacore/tables.py,sha256=aq6E_4RRAHdTBCwMKrVil1cWhFU2O980DNH9IlR
8
8
  xradio/_utils/zarr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  xradio/_utils/zarr/common.py,sha256=egj3Zma0BUK0msOBDozMa-62rHrcxrjCNE5XkkZUq70,5332
10
10
  xradio/image/__init__.py,sha256=HAD0GfopIbhdxOYckyW6S9US_dSWmZrwIl3FHUzZwrE,435
11
- xradio/image/image.py,sha256=Zk1OE-ixqE2epKmKtlyERG8byB41K5sOZLi0JD0bJis,14572
11
+ xradio/image/image.py,sha256=bPgjJoQaur10XEnK7nw66YG68tRKFmdXFlER7GjWh64,14579
12
12
  xradio/image/_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- xradio/image/_util/casacore.py,sha256=eaiMcr546p7k9SU2s3pQDgpFyS94xW3Z1ZR3yXxVEfc,4375
13
+ xradio/image/_util/casacore.py,sha256=vhmPz5tCUXTN46oQLuTxkdHTxI_9qR_RfHUEeqPn9SU,4511
14
14
  xradio/image/_util/common.py,sha256=y2QJXTHowvjqwNPG5a-cOzl0WneH7c8c9jAVSKQeK2w,8429
15
15
  xradio/image/_util/fits.py,sha256=gyGm06fuCKqVGK7uv-ObvQNfFawUDsIOa_nQyklM3Aw,329
16
16
  xradio/image/_util/image_factory.py,sha256=Mm0ZDraD0WoNpGqy98EneFr1PxgfyNZNQwquIH2t0nc,8610
17
17
  xradio/image/_util/zarr.py,sha256=lhQqVRC1GEWClG3zRbuDr2IlQBfXeDqaLUJIN-MVMxA,1652
18
18
  xradio/image/_util/_casacore/__init__.py,sha256=OlsiRE40o1jSbBI4khgQQzgfDYbAlOMKIhO4UFlbGhg,41
19
19
  xradio/image/_util/_casacore/common.py,sha256=Z7Jl3AU7jVcgjNtCnvL7CCXJQAxXeEtowXBmSShuAv4,1329
20
- xradio/image/_util/_casacore/xds_from_casacore.py,sha256=ZLgOsQ9n-2sjho5xWeYk1I59QLBH0pqNrxAhF07HxSY,43172
20
+ xradio/image/_util/_casacore/xds_from_casacore.py,sha256=uc2jQRAjKIOMh6OO8qIJs7vrNC_J6jI3bObRdL_4fP4,42865
21
21
  xradio/image/_util/_casacore/xds_to_casacore.py,sha256=snHCcbZQZtv329KNMd-RjYXG3pfNQeJQbOWKduY1uQc,17085
22
22
  xradio/image/_util/_fits/xds_from_fits.py,sha256=n2tAIOK5GoIKzYBqfwCjZULFYSz2x74aeVkCo0vmOL4,29191
23
23
  xradio/image/_util/_zarr/common.py,sha256=ltlj3uFa-uv8lXlDtV79QnfNmfm0tyhXN5FDAjZtjzg,308
@@ -70,8 +70,8 @@ xradio/schema/metamodel.py,sha256=WjtW7pAVzcjLRWifRH3sQoOiN6TV810hARpOIz1M_gw,38
70
70
  xradio/schema/typing.py,sha256=8-o6fZd99kJ4FVdgBYRTIRJ-wDqpcUNXzCTfJvl3TIw,10439
71
71
  xradio/sphinx/__init__.py,sha256=VGY-7Ty3q67qpnBee0-znbiJ-Iy0F93UO--IpjEdHXc,380
72
72
  xradio/sphinx/schema_table.py,sha256=uq33habbAbReqnEG6ASKSd4UOMZGUzA3qoTX45rq84U,12373
73
- xradio-0.0.54.dist-info/licenses/LICENSE.txt,sha256=9CYIJt7riOXo9AD0eXBZviLxo_HebD-2JJI8oiWtzfg,1807
74
- xradio-0.0.54.dist-info/METADATA,sha256=wGZFgvOO0xPUPXAUlVlrxyrYVXsUmD6fP7hOFn9mNOk,5574
75
- xradio-0.0.54.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
76
- xradio-0.0.54.dist-info/top_level.txt,sha256=dQu27fGBZJ2Yk-gW5XeD-dZ76Xa4Xcvk60Vz-dwXp7k,7
77
- xradio-0.0.54.dist-info/RECORD,,
73
+ xradio-0.0.55.dist-info/licenses/LICENSE.txt,sha256=9CYIJt7riOXo9AD0eXBZviLxo_HebD-2JJI8oiWtzfg,1807
74
+ xradio-0.0.55.dist-info/METADATA,sha256=iF5gDBadJWPQKJFcBEJpMUev97YRCCi1nArYtLDgWHw,5574
75
+ xradio-0.0.55.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
76
+ xradio-0.0.55.dist-info/top_level.txt,sha256=dQu27fGBZJ2Yk-gW5XeD-dZ76Xa4Xcvk60Vz-dwXp7k,7
77
+ xradio-0.0.55.dist-info/RECORD,,