TakeTwilightFlatsLSSTCam¶
- class lsst.ts.externalscripts.maintel.TakeTwilightFlatsLSSTCam(index)¶
Bases:
BaseTakeTwilightFlats
Specialized script for taking Twilight flats with LSSTCam.
Attributes Summary
Get the checkpoints at which to pause and stop.
Get the group ID (a
str
), or "" if not set.Get the block ID (a
str
), or "" if not set.Get the current state.
Get the name of the current
state
.state.Methods Summary
amain
(**kwargs)Run the script from the command line.
Verify that camera is in a feasible state to execute the script.
assert_state
(action, states)Assert that the current state is in
states
and the script is not exiting.Confirm sun's elevation is safe for taking twilight flats.
checkpoint
([name])Await this at any "nice" point your script can be paused or stopped.
cleanup
()Perform final cleanup, if any.
close
([exception, cancel_start])Shut down, clean up resources and set done_task done.
Shut down pending tasks.
configure
(config)Configure script components including camera.
Handle creating the camera object and waiting remote to start.
Method to configure the catalog.
Handle creating the ATCS object and waiting remote to start.
do_configure
(data)Configure the currently loaded script.
do_resume
(data)Resume the currently paused script.
do_run
(data)Run the script and quit.
do_setCheckpoints
(data)Set or clear the checkpoints at which to pause and stop.
do_setGroupId
(data)Set or clear the group_id attribute.
do_setLogLevel
(data)Set logging level.
do_stop
(data)Stop the script.
Abstract method to get the instrument configuration.
Get instrument filter configuration.
Get instrument name.
get_new_exptime
(sky_counts, exp_time)Calculate exposure time for next image.
Get obs id from camera obs id server.
Return a jsonschema to validate configuration, as a
dict
.Abstract method to get the median sky counts from the last image.
Returns the AZ of the target area of the sky that's an azimuth
distance_from_sun
away from the Sun, givenelevation
, and at a giventime
.Returns the RADEC of the target area of the sky that's an azimuth
distance_from_sun
away from the Sun, givenelevation
, and at a giventime
.get_twilight_flat_sky_coords
(target[, radius])Query the "Deep blank field catalogue : J/MNRAS/427/679" in Vizier.
make_from_cmd_line
(**kwargs)Make a script from command-line arguments.
Return the group ID supplemented with a new subgroup.
Context manager to publish appropriate checkpoints with program and reason.
Output the logLevel event.
run
()Override base script run to encapsulate execution with appropriate checkpoints.
Run the block of tasks to take PTC flats sequence.
Save test case to the LFA.
set_metadata
(metadata)Set script metadata, including estimated duration.
set_state
([state, reason, keep_old_reason, ...])Set the script state.
slew_azel_and_setup_instrument
(az, el)Abstract method to set the instrument.
start
()Finish construction.
Additional work after
start
before fully started.Take the sequence of twilight flats twilight flats.
test_case_step
([comment])Context manager to handle test case steps.
track_radec_and_setup_instrument
(ra, dec)Method to set the instrument filter and slew to desired field.
Attributes Documentation
- camera¶
- catalog¶
- checkpoints¶
Get the checkpoints at which to pause and stop.
Returns
self.evt_checkpoints.data
which has these fields:pause
: checkpoints at which to pause, a regular expressionstop
: checkpoints at which to stop, a regular expression
- consdb¶
- domain¶
- state¶
Get the current state.
Returns
self.evt_state.data
, which has these fields:
- tcs¶
Methods Documentation
- async classmethod amain(**kwargs: Any) None ¶
Run the script from the command line.
- Parameters:
- kwargs
Keyword arguments for the script constructor. Must not include
index
. Ignored (other than testing forindex
) if the command specifies--schema
.
- Raises:
- RuntimeError
If
kwargs
includesindex
.
Notes
The final return code will be:
0 if final state is
lsst.ts.idl.enums.Script.ScriptState.DONE
orlsst.ts.idl.enums.Script.ScriptState.STOPPED
.1 if final state is anything else, or if script.done_task is an exception (which would be raised by the script’s cleanup code).
Issues a RuntimeWarning if script.done_task is an exception and the final script state is anything other than Failed. This should never happen.
- assert_state(action: str, states: Sequence[ScriptState]) None ¶
Assert that the current state is in
states
and the script is not exiting.
- assert_sun_location()¶
Confirm sun’s elevation is safe for taking twilight flats.
- async checkpoint(name: str = '') None ¶
Await this at any “nice” point your script can be paused or stopped.
- Parameters:
- name
str
, optional Name of checkpoint; “” if it has no name.
- name
- Raises:
- async cleanup() None ¶
Perform final cleanup, if any.
This method is called as the script state is exiting, unless the script had not yet started to run, or the script process is aborted by SIGTERM or SIGKILL.
- async close(exception: Exception | None = None, cancel_start: bool = True) None ¶
Shut down, clean up resources and set done_task done.
May be called multiple times. The first call closes the Controller; subsequent calls wait until the Controller is closed.
Subclasses should override
close_tasks
instead ofclose
, unless you have a good reason to do otherwise.- Parameters:
- exception
Exception
, optional The exception that caused stopping, if any, in which case the
self.done_task
exception is set to this value. SpecifyNone
for a normal exit, in which case theself.done_task
result is set toNone
.- cancel_start
bool
, optional Cancel the start task? Leave this true unless calling this from the start task.
- exception
Notes
Removes the SAL log handler, calls
close_tasks
to stop all background tasks, pauses briefly to allow final SAL messages to be sent, then closes the dds domain.
- async close_tasks() None ¶
Shut down pending tasks. Called by
close
.Perform all cleanup other than disabling logging to SAL and closing the dds domain.
- async configure(config: SimpleNamespace)¶
Configure script components including camera.
- Parameters:
- config
types.SimpleNamespace
Script configuration, as defined by
schema
.
- config
- configure_catalog()¶
Method to configure the catalog.
- async do_configure(data: BaseMsgType) None ¶
Configure the currently loaded script.
- Parameters:
- data
cmd_configure.DataType
Configuration.
- data
- Raises:
- base.ExpectedError
If
self.state.state
is notlsst.ts.idl.enums.Script.ScriptState.UNCONFIGURED
.
Notes
This method does the following:
Parse the
config
field as yaml-encodeddict
and validate it (including setting default values).Call
configure
.Set the pause and stop checkpoints.
Set the log level if
data.logLevel != 0
.Call
set_metadata
.Output the metadata event.
Change the script state to
lsst.ts.idl.enums.Script.ScriptState.CONFIGURED
.
- async do_resume(data: BaseMsgType) None ¶
Resume the currently paused script.
- Parameters:
- data
cmd_resume.DataType
Ignored.
- data
- Raises:
- base.ExpectedError
If
self.state.state
is notlsst.ts.idl.enums.Script.ScriptState.PAUSED
.
- async do_run(data: BaseMsgType) None ¶
Run the script and quit.
The script must have been configured and the group ID set.
- Parameters:
- data
cmd_run.DataType
Ignored.
- data
- Raises:
- base.ExpectedError
If
self.state.state
is notlsst.ts.idl.enums.Script.ScriptState.CONFIGURED
. Ifself.group_id
is blank.
- async do_setCheckpoints(data: BaseMsgType) None ¶
Set or clear the checkpoints at which to pause and stop.
This command is deprecated. Please set the checkpoints using the
configure
command.- Parameters:
- data
cmd_setCheckpoints.DataType
Names of checkpoints for pausing and stopping, each a single regular expression; “” for no checkpoints, “.*” for all.
- data
- Raises:
- base.ExpectedError
If
self.state.state
is not one of:lsst.ts.idl.enums.Script.ScriptState.UNCONFIGURED
lsst.ts.idl.enums.Script.ScriptState.CONFIGURED
lsst.ts.idl.enums.Script.ScriptState.RUNNING
lsst.ts.idl.enums.Script.ScriptState.PAUSED
- async do_setGroupId(data: BaseMsgType) None ¶
Set or clear the group_id attribute.
The script must be in the Configured state. This command may be called multiple times. It is typically called when the script reaches the top position on the script queue.
- Parameters:
- data
cmd_setGroupId.DataType
Group ID, or “” to clear the group ID.
- data
- Raises:
- base.ExpectedError
If
state.state
is notlsst.ts.idl.enums.Script.ScriptState.CONFIGURED
.
- async do_setLogLevel(data: BaseMsgType) None ¶
Set logging level.
- Parameters:
- data
cmd_setLogLevel.DataType
Logging level.
- data
- async do_stop(data: BaseMsgType) None ¶
Stop the script.
- Parameters:
- data
cmd_stop.DataType
Ignored.
- data
Notes
This is a no-op if the script is already exiting. This does not wait for _exit to run.
- get_instrument_configuration() dict ¶
Abstract method to get the instrument configuration.
- Returns:
- dict
Dictionary with instrument configuration.
- get_instrument_filter() str ¶
Get instrument filter configuration.
- Returns:
- instrument_filter:
string
- instrument_filter:
- get_new_exptime(sky_counts, exp_time)¶
Calculate exposure time for next image.
- Parameters:
- sky_countsfloat
Counts in electrons of previous flat.
- exp_timefloat
Exposure time of previous flat
- Returns:
- float
Calculated new exposure time.
- async get_obs_id() str | None ¶
Get obs id from camera obs id server.
- Returns:
str
or NoneId generated from camera server.
- classmethod get_schema()¶
Return a jsonschema to validate configuration, as a
dict
.Please provide default values for all fields for which defaults make sense. This makes the script easier to use.
If your script has no configuration then return
None
, in which case theconfig
field of theconfigure
command must be an empty string.
- async get_sky_counts() float ¶
Abstract method to get the median sky counts from the last image.
- Returns:
- float
Sky counts in electrons.
- get_target_az()¶
Returns the AZ of the target area of the sky that’s an azimuth
distance_from_sun
away from the Sun, givenelevation
, and at a giventime
.- Returns:
- target_azfloat, (-180, 180)
The target azimuth in degrees
- get_target_radec()¶
Returns the RADEC of the target area of the sky that’s an azimuth
distance_from_sun
away from the Sun, givenelevation
, and at a giventime
.- Returns:
- target_radec
target ra dec
- async get_twilight_flat_sky_coords(target, radius=5)¶
Query the “Deep blank field catalogue : J/MNRAS/427/679” in Vizier.
- Parameters:
- targetastropy.coordinates.SkyCoord
Sky coordinates near the field
- radiusfloat
Search radius in degrees.
- Returns:
- raastropy.coordinates.SkyCoord
Right ascension of the twilight flats
- decastropy.coordinates.SkyCoord
Declination of the twilight flats
- classmethod make_from_cmd_line(**kwargs: Any) lsst.ts.salobj.base_script.BaseScript | None ¶
Make a script from command-line arguments.
Return None if
--schema
specified.- Parameters:
- kwargs
Keyword arguments for the script constructor. Must not include
index
.
- Raises:
- RuntimeError
If
kwargs
includesindex
.
- next_supplemented_group_id() str ¶
Return the group ID supplemented with a new subgroup.
The returned string has this format: f”{self.group_id}#{subgroup_id}”, where
subgroup_id
is an integer that starts at 1 and is incremented for every call to this method.- Raises:
- RuntimeError
If there is no group ID.
- program_reason()¶
Context manager to publish appropriate checkpoints with program and reason.
- async run()¶
Override base script run to encapsulate execution with appropriate checkpoints.
- async run_block()¶
Run the block of tasks to take PTC flats sequence.
- set_metadata(metadata: BaseMsgType) None ¶
Set script metadata, including estimated duration.
- async set_state(state: lsst.ts.xml.enums.Script.ScriptState | int | None = None, reason: str | None = None, keep_old_reason: bool = False, force_output: bool = False) None ¶
Set the script state.
- Parameters:
- state
ScriptState
orint
, optional New state, or None if no change
- reason
str
, optional Reason for state change.
None
for no new reason.- keep_old_reason
bool
If true, keep old reason; append the
reason
argument after “;” if it is is a non-empty string. If false replace withreason
, or “” ifreason
isNone
.- force_output
bool
, optional If true the output even if not changed.
- state
Notes
The lastCheckpoint field is set from self.last_checkpoint, and the numCheckpoints field is set from self.num_checkpoints.
- async slew_azel_and_setup_instrument(az, el)¶
Abstract method to set the instrument. Change the filter and slew and track target.
- Parameters:
- azfloat
Azimuth of target field.
- elfloat
Elevation of target field.
- async start_phase2() None ¶
Additional work after
start
before fully started.Used by BaseCsc to transition to handle the initial state.
- async take_twilight_flats()¶
Take the sequence of twilight flats twilight flats.
- async track_radec_and_setup_instrument(ra, dec)¶
Method to set the instrument filter and slew to desired field.
- Parameters:
- rafloat
RA of target field.
- decfloat
Dec of target field.