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

Negative numbers in -ra and -dec confuse argparse #63

Open
JSKenyon opened this issue Mar 6, 2024 · 2 comments
Open

Negative numbers in -ra and -dec confuse argparse #63

JSKenyon opened this issue Mar 6, 2024 · 2 comments

Comments

@JSKenyon
Copy link

JSKenyon commented Mar 6, 2024

While simulating a MeerKAT observation of a calibrator at a negative declination, simms claims that -dec did not receive the correct number of arguments. The same is true from the example command given in the readme i.e.

simms -T kat-7 -t casa -l test_casa -dec -30d0m0s -ra 0h0m0s -st 1 -dt 60 -f0 1.4GHz -nc 4 -df 10MHz Simms/observatories/KAT7_ANTENNAS

will fail with

Traceback (most recent call last):
  File "/usr/lib/python3.10/argparse.py", line 1878, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python3.10/argparse.py", line 2091, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib/python3.10/argparse.py", line 2021, in consume_optional
    arg_count = match_argument(action, selected_patterns)
  File "/usr/lib/python3.10/argparse.py", line 2186, in _match_argument
    raise ArgumentError(action, msg)
argparse.ArgumentError: argument -dec/--dec: expected one argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jonathan/venvs/qcenv/bin/simms", line 8, in <module>
    sys.exit(main())
  File "/home/jonathan/venvs/qcenv/lib/python3.10/site-packages/simms/core.py", line 459, in main
    args = parser.parse_args()
  File "/usr/lib/python3.10/argparse.py", line 1845, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python3.10/argparse.py", line 1881, in parse_known_args
    self.error(str(err))
  File "/home/jonathan/venvs/qcenv/lib/python3.10/site-packages/simms/core.py", line 37, in error
    raise ParserError(message or "Not enough Arguments")
simms.core.ParserError: argument -dec/--dec: expected one argument
@JSKenyon
Copy link
Author

JSKenyon commented Mar 6, 2024

The workaround is to specify them as follows -dec=-30d0m0s. Note that string quoting the quantity doesn't seem to fix the problem (surprisingly).

@bennahugo
Copy link
Contributor

Yea it looks like an argparse specific issue, not quite sure how to fix this one or if there is another escape you should be using. It is already set to accept strings.
https://github.com/ratt-ru/simms/blob/968599de10524917479fdd10d941b13394984d42/simms/core.py#L310C1-L317C6

The other workaround I should mention is to just use j2000 strings using the -dir argument. I don't think I'm going to bother fixing - will just leave this open so that it is documented. A worked example is:

simms -dir "J2000,19h39m25.02671s,-63d42m45.6255s" -T meerkat -dt 2 -st 0.5 -nc 512 -f0 856MHz -df 1.671875MHz -pl XX XY YX YY -n mk64.0.1hr.2s.856.1.67Mhz.512chan.1939-6342.cross.ms

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