-
Notifications
You must be signed in to change notification settings - Fork 2
Create phase_down.py #232
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
base: master
Are you sure you want to change the base?
Create phase_down.py #232
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #!/usr/bin/env python | ||
| # | ||
| # Reset the delay adjustments and CBF F-engine gains to zero. | ||
|
|
||
| import time | ||
|
|
||
| import numpy as np | ||
| import katpoint | ||
| from katcorelib.observe import (standard_script_options, verify_and_connect, | ||
| collect_targets, start_session, user_logger, | ||
| SessionSDP) | ||
|
|
||
| class NoTargetsUpError(Exception): | ||
| """No targets are above the horizon at the start of the observation.""" | ||
|
|
||
| # Set up standard script options | ||
| usage = "%prog" | ||
| description = 'Reset all the delays and phases to default.' | ||
| parser = standard_script_options(usage, description) | ||
| # Add experiment-specific options | ||
|
|
||
| # Set default value for any option (both standard and experiment-specific options) | ||
| parser.set_defaults(observer='comm_test', nd_params='off', project_id='COMMTEST', | ||
| description='Phase-up observation that sets the F-engine weights') | ||
| # Parse the command line | ||
| opts, args = parser.parse_args() | ||
|
|
||
| # Set of targets with flux models | ||
| J1934 = 'PKS 1934-63 | J1939-6342, radec, 19:39:25.03, -63:42:45.7, (200.0 12000.0 -11.11 7.777 -1.231)' | ||
| J0408 = 'PKS 0408-65 | J0408-6545, radec, 4:08:20.38, -65:45:09.1, (800.0 8400.0 -3.708 3.807 -0.7202)' | ||
| J1331 = '3C286 | J1331+3030, radec, 13:31:08.29, +30:30:33.0,(800.0 43200.0 0.956 0.584 -0.1644)' | ||
|
|
||
| observation_sources = katpoint.Catalogue(antenna=kat.sources.antenna) | ||
| observation_sources.add(J1934) | ||
| observation_sources.add(J0408) | ||
| observation_sources.add(J1331) | ||
|
|
||
| if len(observation_sources.filter(el_limit_deg=opts.horizon)) == 0: | ||
| raise NoTargetsUpError("No targets are currently visible - please re-run the script later") | ||
|
|
||
| with verify_and_connect(opts) as kat: | ||
| with start_session(kat, **vars(opts)) as session: | ||
| session.standard_setup(**vars(opts)) | ||
| session.cbf.correlator.req.capture_start() | ||
| channels = 32768 if session.product.endswith('32k') else 4096 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this check is used in other scripts, but it isn't very robust. E.g. for a user product like @ludwigschwardt, please confirm that is the correct way to use the SessionCBFStream object.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed. My best suggestions would be to look at # Default F-engine gain as a function of number of channels
DEFAULT_GAIN = {4096: 200, 32768: 4000}
def set_fengine_gain(session, gain):
"""Set F-engine gain to *gain* if positive, or automatic default if 0."""
if session.kat.dry_run:
gain = -1
# Obtain default gain based on channel count if none specified
if gain == 0:
num_channels = session.cbf.fengine.sensor.n_chans.get_value()
gain = DEFAULT_GAIN.get(num_channels, -1)
if gain > 0:
user_logger.info("Setting F-engine gains to %d" % (gain,))
for inp in session.cbf.fengine.inputs:
session.cbf.fengine.req.gain(inp, gain) |
||
| if channels == 4096: | ||
| default_gain = 200 | ||
| elif channels == 32768: | ||
| default_gain = 4000 | ||
| user_logger.info("Resetting F-engine gains to %g", default_gain) | ||
| for inp in session.cbf.fengine.inputs: | ||
| session.cbf.fengine.req.gain(inp, default_gain) | ||
| user_logger.info("Resetting delay adjustments to zero") | ||
| session.cbf.req.adjust_all_delays() | ||
|
|
||
| track_duration = 24 | ||
| for target in [observation_sources.sort('el').targets[-1]]: | ||
| user_logger.info("Initiating %g-second track on target '%s' to validate reset", | ||
| track_duration, target.name) | ||
| session.track(target, duration=track_duration, announce=False) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
katobject hasn't been assigned yet. Looks like this block needs to move down, after line 41.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As below, I would suggest to follow
calibrate_delays.pyas a template. We have removed these explicit sources in the code and replaced them with thethree_calib.csvfile in the instruction set. The whole catalogue construction also moves down to afterverify_and_connectas @ajoubertza suggests. I also pick only a single source as opposed to looping through a list containing one source.