pyplate API

metadata Module

class pyplate.metadata.ArchiveMeta[source]

Plate archive metadata class.

assign_conf(conf)[source]

Assign and parse configuration.

get_logpagelist()[source]

Get list of logpage filenames

get_logpagemeta(filename=None)[source]

Get metadata for the specific logpage.

get_platelist()[source]

Get list of plate IDs based on WFPDB and CSV files

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 : a PlateMeta object

PlateMeta object that contains the plate metadata.

get_scanlist()[source]

Get list of filenames from CSV files

output_logpages_db()[source]

Write logpages to the database.

output_plates_db()[source]

Write plates to the database.

output_scans_db()[source]

Write scans to the database.

read_csv(csv_dir=None, fn_plate_csv=None, fn_scan_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_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.CSV_Dict(*args, **kwargs)[source]

Bases: collections.OrderedDict

Metadata CSV dictionary class.

class pyplate.metadata.LogpageMeta(*args, **kwargs)[source]

Bases: collections.OrderedDict

Logpage metadata class.

assign_conf(conf)[source]

Assign configuration.

parse_csv(val_list, csv_filename=None)[source]

Extract data from a CSV row.

parse_exif()[source]

Extract data from image EXIF.

class pyplate.metadata.PlateHeader(*args, **kwargs)[source]

Bases: astropy.io.fits.header.Header

Plate header class. Based on FITS header class from astropy.io.

assign_conf(conf)[source]

Assign configuration to the plate header.

assign_platemeta(platemeta)[source]

Assign plate metadata.

assign_values()[source]

Assign fixed keyword values (integers, floats and strings separately).

compute_values()[source]

Compute keyword values.

format()[source]

Format and reorder header cards.

classmethod from_fits(filename)[source]

Read header from FITS file.

classmethod from_hdrf(filename)[source]

Read header from the output file of header2011.

insert_wcs(wcshead)[source]

Insert WCS header cards.

output_to_file(filename)[source]

Output header to a text file.

output_to_fits(filename)[source]

Output header to FITS file.

populate()[source]

Populate header with blank cards.

rename_keywords()[source]

Rename keywords in the header.

reorder()[source]

Reorder header cards based on configuration.

rewrite()[source]

Rewrite header cards with proper formatting.

update_all()[source]

Do all header updates.

update_comments()[source]

Add/modify keyword comments based on configuration.

update_from_fits(filename)[source]

Update header with header values in a FITS file.

update_from_platemeta(platemeta=None)[source]

Update header with plate metadata.

update_values()[source]

Edit keyword values based on configuration.

class pyplate.metadata.PlateMeta(*args, **kwargs)[source]

Bases: collections.OrderedDict

Plate metadata class.

assign_conf(conf)[source]

Assign configuration.

compute_values()[source]

Compute UT time from sidereal time and precess coordinates from plate epoch to J2000.

copy()[source]
get_value(key, exp=0)[source]

Get PlateMeta value for SQL query

Parameters :

key : str

PlateMeta keyword to be fetched

Returns :

val

PlateMeta value corresponding to the keyword

parse_conf()[source]

Extract data from configuration file.

parse_csv(val_list, csv_filename=None)[source]

Extract data from a CSV row.

parse_header(header)[source]

Extract data from FITS header.

parse_maindata(maindata_entry)[source]

Extract data from the WFPDB maindata entry.

parse_notes(notes_entry)[source]

Extract data from the WFPDB notes entry.

parse_observer(observer_entry)[source]

Extract data from the WFPDB observer entry.

parse_quality(quality_entry)[source]

Extract data from the WFPDB quality entry.

printdata()[source]

Print keywords and their values.

pyplate.metadata.str_to_num(s)[source]

Convert string to int or float, if possible. Otherwise return the original string.

solve Module

class pyplate.solve.AstrometryNetIndex(*args)[source]

Astrometry.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.

create_index_year(year, max_scale=None, min_scale=None, sort_by='BTmag')[source]

Create Astrometry.net index for a given epoch.

download_tycho2(site=None)[source]

Download full Tycho-2 catalogue with vizquery.

Parameters :

site : str

A site name that vizquery recognizes

class pyplate.solve.SolveProcess(filename, archive_id=None)[source]

Plate solve process class

assign_conf(conf)[source]

Parse configuration and set class attributes.

assign_header(header)[source]

Assign FITS header with metadata.

calibrate_photometry()[source]

Calibrate extracted magnitudes.

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_process_start()[source]

Write process start to the database.

db_update_process(sky=None, sky_sigma=None, threshold=None, num_sources=None, solved=None, num_ucac4=None, num_tycho2=None, num_apass=None, color_term=None, bright_limit=None, faint_limit=None, mag_range=None, calibrated=None)[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_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_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)

finish()[source]

Finish plate process.

invert_plate()[source]

Invert FITS image and save the result (*_inverted.fits) in the scratch or work directory.

output_calibration_db()[source]

Write photometric calibration to the database.

output_color_db()[source]

Write photometric color term result to the database.

output_cterm_db()[source]

Write photometric color term data to the database.

output_rmse_db()[source]

Write photometric calibration errors to the database.

output_solution_db()[source]

Write plate solution to the database.

output_sources_csv(filename=None)[source]

Write source list with calibrated RA and Dec to an ASCII file.

output_sources_db()[source]

Write source list with calibrated RA and Dec to the database.

output_wcs_header()[source]

Write WCS header to an ASCII file.

process_source_coordinates()[source]

Combine coordinates from the global and recursive solutions. Calculate X, Y, and Z on the unit sphere.

setup()[source]

Set up plate solve process.

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, sip=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)

sip : int

SIP distortion order (default 3)

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]

Plate solve process log class

close()[source]

Close log file.

open()[source]

Open log file.

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)

pyplate.solve.new_scampref()[source]

Create HDUList for SCAMP reference catalogue.

Returns :hdulist : an astropy.io.fits.HDUList object
pyplate.solve.run_solve_process(filename, conf_file=None, **kwargs)[source]

Run the source extraction and plate solving process.

Parameters :

filename : str

Filename of the digitised plate

database Module

class pyplate.database.PlateDB[source]

Plate database class.

assign_conf(conf)[source]

Assign and parse configuration.

close_connection()[source]

Close MySQL database connection.

execute_query(*args)[source]

Execute SQL query and reopen connection if connection has been lost.

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 : int

Logbook ID

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 : int

Logpage ID number

get_plate_epoch(plate_id)[source]

Get plate epoch from the database.

Parameters :

plate_id : int

Plate ID number

Returns :

result : float

Plate epoch as a 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 : int

Plate ID

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 : int

Plate ID

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 : tuple

A tuple containing scan ID and plate ID

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_process(process_id, sky=None, sky_sigma=None, threshold=None, num_sources=None, solved=None, num_ucac4=None, num_tycho2=None, num_apass=None, color_term=None, bright_limit=None, faint_limit=None, mag_range=None, calibrated=None)[source]

Update plate-solve process in the database.

write_logbook(logbookmeta)[source]

Write a logbook to the database.

write_logpage(logpagemeta)[source]

Write a single logpage 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_rmse(phot_rmse, process_id=None, scan_id=None, plate_id=None, archive_id=None)[source]

Write photometric calibration errors to the database.

write_plate(platemeta)[source]

Write plate entry to the database.

Parameters :

platemeta : PlateMeta

Plate metadata instance

Returns :

plate_id : int

Plate ID number

write_plate_logpage(platemeta)[source]

Write plate-logpage relations to the database.

Parameters :

platemeta : PlateMeta

Plate metadata instance

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 : PlateMeta

Plate metadata instance

Returns :

scan_id : int

Scan ID number

write_solution(solution, process_id=None, scan_id=None, plate_id=None, archive_id=None)[source]

Write plate solution to the database.

write_sources(sources, process_id=None, scan_id=None, plate_id=None, archive_id=None)[source]

Write source list with calibrated RA and Dec to the database.

pyplate.database.print_tables(use_drop=False)[source]

Print table creation SQL queries to standard output.

image Module

class pyplate.image.PlateConverter[source]

TIFF-to-FITS converter class

assign_conf(conf)[source]

Parse configuration and set class attributes.

batch_tiff2fits()[source]

Convert all TIFF images in the TIFF directory to FITS.

tiff2fits(filename, cut_wedge=None, wedge_height=None)[source]

Convert TIFF image to FITS.

Parameters :

filename : str

Filename of the TIFF image

cut_wedge : bool

If True, a wedge image is separated from below plate image

wedge_height : int

Height of the wedge in pixels

pipeline Module

class pyplate.pipeline.PlateImagePipeline(plate_converter=None)[source]

Plate processing pipeline class

assign_conf(conf)[source]

Parse configuration and set class attributes.

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

single_image(filename, plate_epoch=None)[source]

Process single plate image.

Parameters :

filename : str

Filename of the FITS image to be processed

plate_epoch : float

Plate epoch (decimal year)

worker()[source]

Take a filename from the queue and process the file.

pyplate.pipeline.run_pipeline(filenames, fn_conf)[source]

Run metadata processing and plate solving pipeline.

Parameters :

filenames : list

List of FITS files to be processed

conf_file : str

Full path to the configuration file

conf Module

pyplate.conf.read_conf(conf_file)[source]

Read configuration file.

Parameters :

conf_file : str

Configuration file path.

Returns :

conf : a ConfigParser object

Table Of Contents

Previous topic

Using pyplate

This Page