PyPlate API¶
metadata module¶
-
class
pyplate.metadata.Archive[source]¶ Bases:
objectPlate archive metadata class.
-
get_platemeta(plate_id=None, wfpdb_id=None, filename=None)[source]¶ Get metadata for the specific plate (or scan).
Source files are parsed in the following order: WFPDB maindata, WFPDB quality, WFPDB observer, WFPDB notes, plate CSV, scan CSV, configuration file.
Parameters: - plate_id (str) – Plate ID used in metadata files.
- filename (str) – Name of the plate scan file.
Returns: platemeta –
Plateobject that contains the plate metadata.Return type: a
Plateobject
-
read_csv(csv_dir=None, fn_plate_csv=None, fn_scan_csv=None, fn_preview_csv=None, fn_logbook_csv=None, fn_logpage_csv=None)[source]¶ Read CSV files.
Parameters: - csv_dir (str) – Path to the directory with CSV files.
- fn_plate_csv (str) – Name of the plate metadata CSV file.
- fn_scan_csv (str) – Name of the scan metadata CSV file.
- fn_preview_csv (str) – Name of the preview metadata CSV file.
- fn_logbook_csv (str) – Name of the logbook CSV file.
- fn_logpage_csv (str) – Name of the logpage CSV file.
-
read_wfpdb(wfpdb_dir=None, fn_maindata=None, fn_quality=None, fn_notes=None, fn_observer=None)[source]¶ Read WFPDB data files.
Parameters: - wfpdb_dir (str) – Path to the directory with WFPDB files.
- fn_maindata (str) – Name of the WFPDB maindata file.
- fn_quality (str) – Name of the WFPDB quality file.
- fn_notes (str) – Name of the WFPDB notes file.
- fn_observer (str) – Name of the WFPDB observer file.
-
-
class
pyplate.metadata.ArchiveMeta[source]¶ Bases:
pyplate.metadata.Archive
-
class
pyplate.metadata.CSV_Dict(*args, **kwargs)[source]¶ Bases:
collections.OrderedDictMetadata CSV dictionary class.
-
class
pyplate.metadata.Logbook(*args, **kwargs)[source]¶ Bases:
collections.OrderedDictLogbook metadata class.
-
class
pyplate.metadata.LogbookMeta(*args, **kwargs)[source]¶ Bases:
pyplate.metadata.Logbook
-
class
pyplate.metadata.Logpage(*args, **kwargs)[source]¶ Bases:
collections.OrderedDictLogpage metadata class.
-
class
pyplate.metadata.LogpageMeta(*args, **kwargs)[source]¶ Bases:
pyplate.metadata.Logpage
-
class
pyplate.metadata.Plate(*args, **kwargs)[source]¶ Bases:
collections.OrderedDictPlate metadata class.
-
calculate()¶ Compute UT time from sidereal time and precess coordinates from plate epoch to J2000.
-
compute_values()[source]¶ Compute UT time from sidereal time and precess coordinates from plate epoch to J2000.
-
-
class
pyplate.metadata.PlateHeader(*args, **kwargs)[source]¶ Bases:
astropy.io.fits.header.HeaderPlate header class. Based on FITS header class from astropy.io.
-
class
pyplate.metadata.PlateMeta(*args, **kwargs)[source]¶ Bases:
pyplate.metadata.Plate
-
class
pyplate.metadata.Preview(*args, **kwargs)[source]¶ Bases:
collections.OrderedDictPreview image metadata class.
-
class
pyplate.metadata.PreviewMeta(*args, **kwargs)[source]¶ Bases:
pyplate.metadata.Preview
solve module¶
-
class
pyplate.solve.AstrometryNetIndex(*args)[source]¶ Bases:
objectAstrometry.net index class
-
create_index_loop(start_year, end_year, step, max_scale=None, min_scale=None, sort_by='BTmag')[source]¶ Create Astrometry.net indexes for a set of epochs.
-
-
class
pyplate.solve.SolveProcess(filename, archive_id=None)[source]¶ Bases:
objectPlate solve process class
-
db_process_end(completed=None)[source]¶ Write process end to the database.
Parameters: completed (int) – A boolean value specifying whether the process was completed
-
db_update_process(**kwargs)[source]¶ Update process in the database.
Parameters: - num_sources (int) – Number of extracted sources
- solved (int) – A boolean value specifying whether plate was solved successfully with Astrometry.net
-
extract_sources(threshold_sigma=None, use_filter=None, filter_path=None, use_psf=None, psf_threshold_sigma=None, psf_model_sigma=None, circular_film=None)[source]¶ Extract sources from a FITS file.
Parameters: - threshold_sigma (float) – SExtractor threshold in sigmas (default 4.0)
- use_filter (bool) – Use SExtractor filter for source detection (default False)
- filter_path (string) – Path to SExtractor filter file
- use_psf (bool) – Use PSF for bright stars (default False)
- psf_threshold_sigma (float) – SExtractor threshold in sigmas for using PSF (default 20.0)
- psf_model_sigma (float) – SExtractor threshold in sigmas for PSF model stars (default 20.0)
- circular_film (bool) – Assume circular film (default False)
-
get_reference_catalogs()[source]¶ Get reference catalogs for astrometric and photometric calibration.
-
improve_photometry_recursive(max_recursion_depth=None)[source]¶ Improve photometric calibration recursively in sub-fields.
-
invert_plate()[source]¶ Invert FITS image and save the result (*_inverted.fits) in the scratch or work directory.
-
process_source_coordinates()[source]¶ Combine coordinates from the global and recursive solutions. Calculate X, Y, and Z on the unit sphere.
-
solve_plate(plate_epoch=None, sip=None, skip_bright=None)[source]¶ Solve astrometry in a FITS file.
Parameters: - plate_epoch (float) – Epoch of plate in decimal years (default 1950.0)
- sip (int) – SIP distortion order (default 3)
- skip_bright (int) – Number of brightest stars to skip when solving with Astrometry.net (default 10).
-
solve_recursive(plate_epoch=None, distort=None, skip_bright=None, max_recursion_depth=None, force_recursion_depth=None)[source]¶ Solve astrometry in a FITS file.
Parameters: - plate_epoch (float) – Epoch of plate in decimal years (default 1950.0)
- distort (int) – SCAMP distortion order (default 1)
- skip_bright (int) – Number of brightest stars to skip when solving with Astrometry.net (default 10).
- max_recursion_depth (int) – Maximum recursion depth (default 5)
- force_recursion_depth (int) – Force recursion depth if enough stars (default 0)
-
-
class
pyplate.solve.SolveProcessLog(file_path)[source]¶ Bases:
objectPlate solve process log class
-
to_db(level, message, event=None)[source]¶ Write a log message to the database.
Parameters: - level (int) – Log level (1 = error, 2 = warning, 3 = info, 4 = debug, 5 = trace)
- message (str) – Message to be written to the log file
- event (int) – Event code (default None)
-
write(message, timestamp=True, double_newline=True, level=None, event=None)[source]¶ Write a message to the log file and optionally to the database.
Parameters: - message (str) – Message to be written to the log file
- timestamp (bool) – Write timestamp with the message (default True)
- double_newline (bool) – Add two newline characters after the message (default True)
-
database module¶
-
class
pyplate.database.PlateDB[source]¶ Bases:
objectPlate database class.
-
executemany_query(*args)[source]¶ Execute SQL query with mutliple data rows and reopen connection if connection has been lost.
-
get_logbook_id(logbook_num, archive_id)[source]¶ Get logbook ID from the database by archive ID and logbook number.
Parameters: - logbook_num (str) – Logbook number (unique within the specified archive)
- archive_id (int) – Archive ID
Returns: logbook_id – Logbook ID
Return type: int
-
get_logpage_id(filename, archive_id)[source]¶ Get logpage ID from the database.
Parameters: - filename (str) – Filename of the logpage
- archive_id (int) – Archive ID number
Returns: result – Logpage ID number
Return type: int
-
get_plate_epoch(plate_id)[source]¶ Get plate epoch from the database.
Parameters: plate_id (int) – Plate ID number Returns: result – Plate epoch as a float Return type: float
-
get_plate_id(plate_num, archive_id)[source]¶ Get plate ID from the database by archive ID and plate number.
Parameters: - plate_num (str) – Plate number
- archive_id (int) – Archive ID
Returns: plate_id – Plate ID
Return type: int
-
get_plate_id_wfpdb(wfpdb_id)[source]¶ Get plate ID from the database by WFPDB ID.
Parameters: wfpdb_id (str) – WFPDB ID Returns: plate_id – Plate ID Return type: int
-
get_scan_id(filename, archive_id)[source]¶ Get scan ID and plate ID from the database.
Parameters: - filename (str) – Filename of the scan
- archive_id (int) – Archive ID number
Returns: result – A tuple containing scan ID and plate ID
Return type: tuple
-
open_connection(host=None, user=None, passwd=None, dbname=None)[source]¶ Open MySQL database connection.
Parameters: - host (str) – MySQL database host name
- user (str) – MySQL database user name
- passwd (str) – MySQL database password
- dbname (str) – MySQL database name
-
update_scan(platemeta, filecols=False)[source]¶ Update scan entry in the database.
Parameters: - platemeta (Plate) – Plate metadata instance
- filecols (bool) – If True, only specific file-related columns are updated
-
write_astrom_sub(astrom_sub, process_id=None, scan_id=None, plate_id=None, archive_id=None)[source]¶ Write astrometric sub-field calibration to the database.
-
write_phot_calib(phot_calib, process_id=None, scan_id=None, plate_id=None, archive_id=None)[source]¶ Write photometric calibration to the database.
-
write_phot_color(phot_color, process_id=None, scan_id=None, plate_id=None, archive_id=None)[source]¶ Write photometric color term result to the database.
-
write_phot_cterm(phot_cterm, process_id=None, scan_id=None, plate_id=None, archive_id=None)[source]¶ Write photometric color term data to the database.
-
write_phot_sub(phot_sub, process_id=None, scan_id=None, plate_id=None, archive_id=None)[source]¶ Write photometric sub-field calibration to the database.
-
write_plate(platemeta)[source]¶ Write plate entry to the database.
Parameters: platemeta (Plate) – Plate metadata instance Returns: plate_id – Plate ID number Return type: int
-
write_plate_logpage(platemeta)[source]¶ Write plate-logpage relations to the database.
Parameters: platemeta (Plate) – Plate metadata instance
-
write_preview(previewmeta)[source]¶ Write preview image entry to the database.
Parameters: previewmeta (Preview) – Preview metadata instance Returns: preview_id – Preview ID number Return type: int
-
write_process_end(process_id, completed=None, duration=None)[source]¶ Write plate-solve process end to the database.
-
write_process_start(scan_id=None, plate_id=None, archive_id=None, filename=None, use_psf=None)[source]¶ Write plate-solve process to the database.
-
write_processlog(level, message, event=None, process_id=None, scan_id=None, plate_id=None, archive_id=None)[source]¶ Write plate solve process log message to the database.
-
write_scan(platemeta)[source]¶ Write scan entry to the database.
Parameters: platemeta (Plate) – Plate metadata instance Returns: scan_id – Scan ID number Return type: int
-
image module¶
pipeline module¶
-
class
pyplate.pipeline.PlatePipeline(plate_converter=None)[source]¶ Bases:
objectPlate processing pipeline class
-
parallel_run(filenames, processes=None, process_max_tasks=None, wait_start=None)[source]¶ Run plate image processes in parallel.
Parameters: - filenames (list) – List of filenames to process
- processes (int) – Number of parallel processes
- process_max_tasks (int) – Number of images processed after which the worker process is renewed
- wait_start (float) – Number of seconds to wait before starting another worker process at the beginning
-