Task Manager (photometry.TaskManager
)
A TaskManager which keeps track of which targets to process.
Code author: Rasmus Handberg <rasmush@phys.au.dk>
- class photometry.taskmanager.TaskManager(todo_file, cleanup=False, overwrite=False, cleanup_constraints=None, summary=None, summary_interval=200, load_into_memory=False, backup_interval=10000)[source]
A TaskManager which keeps track of which targets to process.
- __init__(todo_file, cleanup=False, overwrite=False, cleanup_constraints=None, summary=None, summary_interval=200, load_into_memory=False, backup_interval=10000)[source]
Initialize the TaskManager which keeps track of which targets to process.
- Parameters:
todo_file (string) – Path to the TODO-file.
cleanup (boolean, optional) – Perform cleanup/optimization of TODO-file before during initialization. Default=False.
overwrite (boolean, optional) – Restart calculation from the beginning, discarding any previous results. Default=False.
cleanup_constraints (dict, optional) – Dict of constraint for cleanup of the status of previous correction runs. If not specified, all bad results are cleaned up.
summary (string, optional) – Path to file where to periodically write a progress summary. The output file will be in JSON format. Default=None.
summary_interval (int, optional) – Interval at which summary file is updated. Setting this to 1 will mean writing the file after every tasks completes. Default=100.
- Raises:
FileNotFoundError – If TODO-file could not be found.
Code author: Rasmus Handberg <rasmush@phys.au.dk>
- backup()[source]
Save backup of todo-file to disk. This only has an effect when load_into_memory is enabled.
Code author: Rasmus Handberg <rasmush@phys.au.dk>
- get_number_tasks(**kwargs)[source]
Get number of tasks due to be processed.
- Parameters:
**kwarg – Keyword arguments are passed to
build_constraints()
.- Returns:
Number of tasks due to be processed.
- Return type:
int
- get_random_task()[source]
Get random task to be processed.
- Returns:
Dictionary of settings for task.
- Return type:
dict or None
- get_task(**kwargs)[source]
Get next task to be processed.
- Parameters:
**kwarg – Keyword arguments are passed to
build_constraints()
.- Returns:
Dictionary of settings for task.
- Return type:
dict or None
- save_result(result)[source]
Save results and diagnostics. This will update the TODO list.
- Parameters:
results (dict) – Dictionary of results and diagnostics.
- photometry.taskmanager.build_constraints(priority=None, starid=None, sector=None, cadence=None, camera=None, ccd=None, cbv_area=None, datasource=None, tmag_min=None, tmag_max=None, return_list=False)[source]
Build constraints for database query from given parameters.
For
tmag_min
andtmag_max
constraints, these limits are put on the primary target for all secondary targets. This means that a faint target will still be processed if it is in the TPF of a bright target. This is because this constraint is primarily used for processing bright targets separately since these require more memory.- Parameters:
priority (int, optional) – Only return task matching this priority.
starid (int, optional) – Only return tasks matching this starid.
sector (int, optional) – Only return tasks matching this Sector.
cadence (int, optional) – Only return tasks matching this cadence.
camera (int, optional) – Only return tasks matching this camera.
ccd (int, optional) – Only return tasks matching this CCD.
cbv_area (int, optional) – Only return tasks matching this CBV-AREA.
datasource (str, optional) – Only return tasks from this datasource. Choises are
'tpf'
and'ffi'
.tmag_min (float, optional) – Lower/bright limit on Tmag.
tmag_max (float, optional) – Upper/faint limit on Tmag.
- Returns:
- List of strings containing constraints for database. The constraints should be
joined with “AND” to have the desired effect.
- Return type:
list
Code author: Rasmus Handberg <rasmush@phys.au.dk>