Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mkolopanis opened this issue Oct 26, 2023 · 0 comments
Open

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

mkolopanis opened this issue Oct 26, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@mkolopanis
Copy link
Member

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

@steven-murray steven-murray added the bug Something isn't working label Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants