Targets of Opportunity (ToO) for SDSS-V
Project description
SDSS-V Targets of Opportunity
A package to load and cross-match targets of opportunity (ToO) for SDSS-V.
Overview
This package deals with all the aspects of loading and processing targets of opportunity. At a high level it:
- Reads one or multiple ToO input files.
- Loads new targets into
catalogdb.too_targetand updates the metadata of existing targets incatalogdb.too_metadata. - Cross-matches the new targets, assigning
catalogidsto new targets and populating thecatalogdb.catalog_to_too_targettable. - Assigns new
sdss_idto the newcatalogidentries. - Runs the
toocarton and updatestargetdb.target,targetdb.carton_to_target, andtargetdb.magnitudefor new ToOs. - Performs target validation.
- Generates a text file of active ToOs that can be synced to the observatories and is used by jaeger to replace targets on the fly when creating new configurations.
Datamodel
Target of opportunity files must be CSV or Parquet files with a table/dataframe that conforms to the following structure:
| Column | Type | Description |
|---|---|---|
| too_id | int64 | Unique identifier for the ToO target. [required] |
| program | string | The time-domain program that provided this target. |
| fiber_type | string | Type of fiber to be used to observe the target (APOGEE or BOSS). [required] |
| catalogid | int64 | catalogid for this target, if already matched. |
| sdss_id | int64 | sdss_id for this target, if already matched. |
| gaia_dr3_source_id | int64 | Unique identifier of the target in the Gaia DR3 catalog (source_id column). |
| twomass_pts_key | int32 | Unique identifier of the target in the 2MASS catalog (pts_key column). |
| sky_brightness_mode | string | The sky brightness mode. Either bright or dark. [required] |
| ra | float64 | The Right Ascension of the target in ICRS coordinates as decimal degrees. [required] |
| dec | float64 | The declination of the target in ICRS coordinates as decimal degrees. [required] |
| pmra | float32 | The proper motion in RA in mas/yr as a true angle (the cos(dec) factor must have been applied). |
| pmdec | float32 | The proper motion in Dec in mas/yr as a true angle. |
| epoch | float32 | The epoch of the ra/dec coordinates. Required when pmra/pmdec are defined. |
| parallax | float32 | The parallax in mas. |
| lambda_eff | float32 | The effective wavelength to calculate the atmospheric refraction correction for the target. |
| u_mag | float32 | Sloan u' magnitude of the target. |
| g_mag | float32 | Sloan g' magnitude of the target. |
| r_mag | float32 | Sloan r' magnitude of the target. |
| i_mag | float32 | Sloan i' magnitude of the target. |
| z_mag | float32 | Sloan z' magnitude of the target. |
| optical_prov | string | Source of the optical magnitudes. |
| gaia_bp_mag | float32 | Gaia BP magnitude of the target. |
| gaia_rp_mag | float32 | Gaia RP magnitude of the target. |
| gaia_g_mag | float32 | Gaia G magnitude of the target. |
| h_mag | float32 | H-band magnitude of the target. |
| delta_ra | float32 | Fixed RA offset as a true angle, in arcsec. |
| delta_dec | float32 | Fixed Dec offset, in arcsec. |
| can_offset | boolean | true if the ToO is allowed to be offset. Offseting will only occur if target violates magnitude limits. [required] |
| inertial | boolean | If true, the proper motions for this target will be ignored (equivalent to pmra = pmdec = 0.0). |
| n_exposures | int16 | The minimum number of exposures required for the ToO to be complete and not assigned anymore. [required] |
| priority | int16 | The relative prioriry of this target (10: highest, 1: lowest, 0: the target will be ignored) |
| active | boolean | true if the target is active and should be assigned to configurations if possible. [required] |
| observe_from_mjd | int32 | MJD from which the target is considered observable. Default to the current date. |
| observe_until_mjd | int32 | MJD at which the target should automatically be consider inactive. If empty, the target never expires. |
| observed | boolean | true if the target has been fully observed and should not be assigned again. [required] |
| added_on | date | Date when the target was last added or modified, with the format YYYY-MM-DD. [required] |
The input file(s) must contain all the columns defined above with the correct data formats.
At least one magnitude is required for target validation. If one of the Sloan magnitude is provided, all the ugriz values must be provided. A sample, valid ToO file can be found here.
The too_id must be unique across all targets of opportunity. The ingestion of new ToOs will fail if a ToO is found in the database with the same too_id.
MJDs are understood of the MJD on which the night ends. For example, a target with observe_from_mjd=60422 will attempt to observ the target from the night in which MJD 60421 crosses into 60422.
A file can be validated by using the validate_too_targets function, which will also fill nulls in some columns with default values.
from too import read_too_file, validate_too_targets
df = read_too_file('sample.csv')
validate_too_targets(df)
or via the CLI
too validate sample.csv
Note that too validate expects the schema of the input file to exactly match that of the ToO datamodel (for example, if the file contains a too_id column of type Int32 the validation will fail even if the values do not overflow int32). You can pass the flag --cast to cast the columns to the correct types. This will fail if the input dataframe cannot be coerced to the correct types. When too runs the entire pipeline, the input file is always cast, which can lead to some data precision loss.
To regenerate the table above, run
>>> from too.datamodel import datamodel_to_markdown
>>> datamodel_to_markdown()
| Column | Type | Description |
|---------------------|---------|--------------------------------------------------------------------------------------------------------|
| too_id | int64 | Unique identifier for the ToO target [required]. |
| fiber_type | string | Type of fiber to be used to observe the target [required]. |
...
Running too
Loading targets from a file
When a new ToO file with the format described in the previous section is available, it can be loaded into the database using the CLI command
too process <FILE>
See too process --help for more information on available options.
too process will perform the following tasks:
- Read and validate the input file(s).
- Establish a connection to the database using the command flags as modifiers. Without additional flags
toowill try to connect to the databasesdss5dbon localhost with usersdss. - Load new targets into the tables
catalogdb.too_targetandcatalogdb.too_metadata. - Update data in
too_metadatafor existing targets. - Cross-match the new targets, creating entries in
catalogdb.catalogandcatalogdb.catalog_to_too_target. - Run the
toocarton.
Dumping active ToOs
To create a Parquet file with a list of ToOs that are active (ready to be observed, not expired, and not completed), use
too dump-targets <FILE>
This command will create the Parquet file and add the bright neighbour and magnitude limit validation columns. The resulting file has the format required by jaeger to perform the replacement of science targets with ToOs.
Cronjob
Generally the ToO code runs daily at Utah as a cronjob. The cronjob file is located here and is expected to be run as the sdssunit user in the pipelines.sdss.org machine. It does:
- Run
too processagainst the entire list of ToO files generated by the time-domain team. - Run
too dump-targetsto generate the Parquet file with the active ToOs for each observatory. The new file is copied to sdsscore and independently committed by thesdsscorecronjob. Cronjobs at APO and LCO pull the changes before observing. - Run
too dump-sdss-idto generate CSV files with the "diff" new sdss_ids generated as part of the daily run. The CSVs are used to update thecatalogdb.sdss_id_flatandcatalogdb.sdss_id_flattables inoperationsandpipelines.
The crontab can be run as
00 13 * * * . $CRONTAB_DIR/git/too.sh 2> $CRONTAB_DIR/git/too.err 1> $CRONTAB_DIR/git/too.out
where $CRONTAB_DIR is the sdssunit directory for crontab scripts and too.sh is a symlink to the scripts/cronjob.sh file.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sdss_too-1.1.1.tar.gz.
File metadata
- Download URL: sdss_too-1.1.1.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06078305833f89916ed66a747208e0cc6165beaea3d85dae5717a13f95cb18ba
|
|
| MD5 |
ab8dfecc9055151263bf1b5f763fad47
|
|
| BLAKE2b-256 |
f36dc48cffab858b4eeb6968dc1ca2004792a802e979e702f2563a4b070c1e6d
|
Provenance
The following attestation bundles were made for sdss_too-1.1.1.tar.gz:
Publisher:
release.yml on sdss/too
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sdss_too-1.1.1.tar.gz -
Subject digest:
06078305833f89916ed66a747208e0cc6165beaea3d85dae5717a13f95cb18ba - Sigstore transparency entry: 843368263
- Sigstore integration time:
-
Permalink:
sdss/too@6f499dffda8a2105c7748eaea67cb6bf53fe0fae -
Branch / Tag:
refs/tags/1.1.1 - Owner: https://github.com/sdss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6f499dffda8a2105c7748eaea67cb6bf53fe0fae -
Trigger Event:
push
-
Statement type:
File details
Details for the file sdss_too-1.1.1-py3-none-any.whl.
File metadata
- Download URL: sdss_too-1.1.1-py3-none-any.whl
- Upload date:
- Size: 34.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de357717be48ccc1e89f36ce85b386657b4fc7bdd410a0328baf3a9d0b89d0e6
|
|
| MD5 |
658d16be1d6022fd1e322d36b58c770e
|
|
| BLAKE2b-256 |
a417667f6d7087614253d970a02d748ba839e9e57e9f7c749946f44b38dced7d
|
Provenance
The following attestation bundles were made for sdss_too-1.1.1-py3-none-any.whl:
Publisher:
release.yml on sdss/too
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sdss_too-1.1.1-py3-none-any.whl -
Subject digest:
de357717be48ccc1e89f36ce85b386657b4fc7bdd410a0328baf3a9d0b89d0e6 - Sigstore transparency entry: 843368264
- Sigstore integration time:
-
Permalink:
sdss/too@6f499dffda8a2105c7748eaea67cb6bf53fe0fae -
Branch / Tag:
refs/tags/1.1.1 - Owner: https://github.com/sdss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6f499dffda8a2105c7748eaea67cb6bf53fe0fae -
Trigger Event:
push
-
Statement type: