Utilities

tom_targets.utils.export_targets(qs)

Exports all the specified targets into a csv file in folder csvTargetFiles NOTE: This saves locally. To avoid this, create file buffer.

Parameters

qs (QuerySet) – List of targets to export

Returns

String buffer of exported targets

Return type

StringIO

tom_targets.utils.import_targets(targets)

Imports a set of targets into the TOM and saves them to the database.

Parameters

targets (StringIO) – String buffer of targets

Returns

dictionary of successfully imported targets, as well errors

Return type

dict

tom_targets.utils.cone_search_filter(queryset, ra, dec, radius)

Executes cone search by annotating each target with separation distance from the specified RA/Dec. Formula is from Wikipedia: https://en.wikipedia.org/wiki/Angular_distance The result is converted to radians.

Cone search is preceded by a square search to reduce the search radius before annotating the queryset, in order to make the query faster.

Parameters
  • queryset (Target) – Queryset of Target objects

  • ra (float) – Right ascension of center of cone.

  • dec (float) – Declination of center of cone.

  • radius (float) – Radius of cone search in degrees.