Skip to content

[BUG] Feed polarization fail when specified in E and N #70

@mkolopanis

Description

@mkolopanis

Describe the bug
vis_cpu does not appear to be able to handle UVBeam objects which have the feed array specified in E and N and a corresponding x_orientation definition. In my particular situation the beam is specified with E and N in upper case, in case the comparison/conversion already exists but is not case-insensitive.

To Reproduce
Steps to reproduce the behavior:

  1. have a uvbeam object with feed_array = ['E', 'N'] and x_orientation='east'
  2. attempt to simulate anything

Expected behavior
vis_cpu should check if the feeds are specified with either x/y or e/n and convert to the internal representation accordingly.

  • OS: Red Hat Enterprise Linux release 8.8 (Ootpa)
Exact Error
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[154], line 1
----> 1 vis_vc = simulate_vis(
      2     ants=antpos,
      3     fluxes=fluxes,
      4     ra=ra_new,
      5     dec=dec_new,
      6     freqs=freqs,
      7     lsts=np.array([lst.to_value("rad")]),
      8     beams=beams,
      9     beam_idx=beam_ids,
     10     polarized=False,
     11     precision=2,
     12 )

File /opt/devel/mkolopanis/envs/vis_cpu/lib/python3.10/site-packages/vis_cpu/wrapper.py:124, in simulate_vis(ants, fluxes, ra, dec, freqs, lsts, beams, polarized, precision, latitude, use_feed, use_gpu, beam_spline_opts, beam_idx, **backend_kwargs)
    121 eq2tops = np.array([conversions.eci_to_enu_matrix(lst, latitude) for lst in lsts])
    123 # Create beam pixel models (if requested)
--> 124 beams = [
    125     conversions.prepare_beam(beam, polarized=polarized, use_feed=use_feed)
    126     for beam in beams
    127 ]
    129 if polarized:
    130     vis = np.zeros(
    131         (freqs.size, lsts.size, nfeeds, nfeeds, nants, nants), dtype=complex_dtype
    132     )

File /opt/devel/mkolopanis/envs/vis_cpu/lib/python3.10/site-packages/vis_cpu/wrapper.py:125, in <listcomp>(.0)
    121 eq2tops = np.array([conversions.eci_to_enu_matrix(lst, latitude) for lst in lsts])
    123 # Create beam pixel models (if requested)
    124 beams = [
--> 125     conversions.prepare_beam(beam, polarized=polarized, use_feed=use_feed)
    126     for beam in beams
    127 ]
    129 if polarized:
    130     vis = np.zeros(
    131         (freqs.size, lsts.size, nfeeds, nfeeds, nants, nants), dtype=complex_dtype
    132     )

File /opt/devel/mkolopanis/envs/vis_cpu/lib/python3.10/site-packages/vis_cpu/conversions.py:291, in prepare_beam(uvbeam, polarized, use_feed)
    289 # Analytic beams have no concept of feeds, so assume they have a "single" feed
    290 if getattr(uvbeam_, "Nfeeds", 1) > 1:
--> 291     uvbeam_.select(feeds=[use_feed])
    293 if isinstance(uvbeam, UVBeam):
    294     uvbeam_.efield_to_power(calc_cross_pols=False)

File /opt/devel/mkolopanis/envs/vis_cpu/lib/python3.10/site-packages/pyuvdata/uvbeam/uvbeam.py:3656, in UVBeam.select(self, axis1_inds, axis2_inds, pixels, frequencies, freq_chans, feeds, polarizations, inplace, run_check, check_extra, run_check_acceptability)
   3651         feed_inds = np.append(
   3652             feed_inds,
   3653             np.where(beam_object.feed_array == x_orient_dict[f])[0],
   3654         )
   3655     else:
-> 3656         raise ValueError(
   3657             "Feed {f} is not present in the feed_array".format(f=f)
   3658         )
   3660 feed_inds = sorted(set(feed_inds))
   3661 beam_object.Nfeeds = len(feed_inds)

ValueError: Feed x is not present in the feed_array

image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions