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

shave error when not specifying low enough frequency in source model #57

Open
marinanderson opened this issue Oct 25, 2016 · 1 comment

Comments

@marinanderson
Copy link
Collaborator

I just noticed that ttcal-0.2.0 errors out if you attempt to shave a near-field source using a source model flux where the minimum specified frequency does not go below the lowest frequency of the measurement set. Using a sources.json file that looks like your example in the TTCal docs,
[
{
"name": "Noisy Power Lines",
"sys": "WGS84",
"long": -118.31478,
"lat": 37.14540,
"el": 1226.709,
"rfi-frequencies": [3.0e7, 3.75e7, 4.5e7, 5.25e7, 6.0e7],
"rfi-I": [1.0, 2.0, 3.0, 4.0, 5.0]
}
]

will produce the following error when used to shave subband 0:

$ ttcal-0.2.0 shave --input 00-T1al.ms --sources sources.json --minuvw 10 --maxiter 30 --tolerance 1e-4
Running shave on 00-T1al.ms
ERROR: LoadError: BoundsError: attempt to access 5-element Array{TTCal.StokesVector,1}:
TTCal.StokesVector(1.0,0.0,0.0,0.0)
TTCal.StokesVector(2.0,0.0,0.0,0.0)
TTCal.StokesVector(3.0,0.0,0.0,0.0)
TTCal.StokesVector(4.0,0.0,0.0,0.0)
TTCal.StokesVector(5.0,0.0,0.0,0.0)
at index [0]
in genvis_onesource! at /opt/astro/mwe/ttcal-0.2.0/julia-packages/v0.4/TTCal/src/genvis.jl:142
in genvis at /opt/astro/mwe/ttcal-0.2.0/julia-packages/v0.4/TTCal/src/genvis.jl:25
in shave! at /opt/astro/mwe/ttcal-0.2.0/julia-packages/v0.4/TTCal/src/peel.jl:86
in run_shave at /opt/astro/mwe/ttcal-0.2.0/julia-packages/v0.4/TTCal/src/commandline.jl:267
in main at /opt/astro/mwe/ttcal-0.2.0/julia-packages/v0.4/TTCal/src/commandline.jl:199
in include at ./boot.jl:261
in include_from_node1 at ./loading.jl:320
in process_options at ./client.jl:280
in _start at ./client.jl:378
while loading /opt/astro/mwe/ttcal-0.2.0/julia-packages/v0.4/TTCal/src/ttcal.jl, in expression starting on line 19

If I change the first element of “rfi-frequencies” from 3.0e7 —> 2.0e7, it runs without a hitch. Also, this error does not happen for measurement sets where the top of the subband is higher than the highest frequency specified in the source model — i.e. running shave on subband 21 with the same sources.json above does not produce an error.

This isn’t impacting me (I can easily change my sources.json file!), but just wanted to give a heads up!

  • Marin
@mweastwood
Copy link
Owner

The error is here:

idx = searchsortedlast(spectrum.channels, ν)
spectrum.stokes[idx]

searchsortedlast returns 0 when the value you are searching for is smaller than the first value. On the other hand it returns the length of the array when it is larger than the final value. The former is out of bounds, while the latter is not. To be consistent I should check if idx == 0 and just return the first element in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants