AstroDb - EranOfek/AstroPack GitHub Wiki

Description

Class Hierarchy: Base -> Component -> AstroDb

The AstroDb class is a container for storing and manipulating database objects for various missions and observatories (currently, only LAST functionality is coded). This class inherits from Component.

Additional help is available using:

help AstroDb

% to see this file
open +manuals.AstroDb
AstroDb.help

% while a list of properties and methods is available by typing AstroDb followed by <tab>, or using
methods(AstroDb)

Class properties

This class inherits from Component that inherits from Base. Additional properties for this class are:

  • Query - a DbQuery object
  • Tables - the list of existing tables
  • Telescope - a telescope name

Constructor

The AstroDb constructor can be used to generate empty database objects:

ADB = db.AstroDb;

Static methods

see AstroDb. unitTest - unitTest for the class

% test the class
db.AstroDb.unitTest

Methods

The methods normally employed by a user are listed below. For all the internal methods see the AstroDb.m file.

  • createImageTable - Create or update definitions of database image tables of various types (RAW, PROC, COADD)
  • createCatalogTable - Create or update definitions of database catalog table
  • insert - Add records to the database. Possible inputs are: AstroImage, AstroHeader, AstroCatalog objects, FITS file lists, data directory + FITS file name template
  • updateByTupleID - Update DB table column values for the specified tuple numbers
  • coneSearch - Make a coordinate search (from RA, Dec and Radius) in a DB table (image, catalog) combined with other user-supplied constraints

Examples:

% create a DB object with the default parameters:
A = db.AstroDb; 
% create a DB object with some more user-defined parameters:
A = db.AstroDb('Host', '10.23.1.1', 'DatabaseName', 'last_operational', 'UserName', 'myuser', 'Password', 'mypwd', 'Port', 5432);
% view the list of existing tables:
A.Tables
% re-create the raw_images table (existing data will be lost):
A.createImageTable('raw_images','Drop',1);
% Add to the DB metadata from RAW level images contained in the /home/sasha/Raw2/ directory according to the internal template:
TupleIDs = A.insert('LAST*raw*Ima*fits','DataDir','/home/sasha/Raw2/','Table','raw_images');
% Add to the DB metadata from RAW level images contained in a vector of AstroImages (AI):
TupleIDs = A.insert(AI,'Table','raw_images');
% Add to the DB metadata from PROC level images contained in the /home/sasha/Obs2/ directory according to the template:
TupleIDs = A.insert('LAST*proc*Ima*fits','DataDir','/home/sasha/Obs2/','Table','proc_images');
% Same, but do not insert the records which already exist in the table:
TupleIDs = A.insert('LAST*proc*Ima*fits','DataDir','/home/sasha/Obs2/','Table','proc_images','Force',0);
% Add to the DB metadata from COADD level images contained in the /home/sasha/Obs2/ directory according to the template:
TupleIDs = A.insert('LAST*coadd*Ima*fits','DataDir','/home/sasha/Obs2/','Table','coadd_images');
% Add to the DB metadata from COADD level images contained in a vector of AstroHeaders (AH):
TupleIDs = A.insert(AH,'Table','coadd_images'); 
% Same, but also put out the processed file names:
TupleIDs = A.insert('LAST*coadd*Ima*fits','DataDir','/home/sasha/Obs2/','Table','coadd_images','Verbose',1);
% Add to the DB source data from COADD level catalogs in the /home/sasha/Obs2/ directory according to the template:
TupleIDs = A.insert('LAST*coadd*Cat*fits','DataDir','/home/sasha/Obs2/','Type','cat','Table','src_catalog');
% Add to the DB source data from COADD level catalogs contained in a vector of AstroCatalogs (AC):
TupleIDs = A.insert(AC,'Type','cat','Table','src_catalog');
% Change 'ra' to 218 in tuples with ids from 2 to 10 in the 'proc_images' table
A.updateByTupleID([2:10],'ra',218,'Table','proc_images')
% Change 'procstat' to 'seeing 0.5' for tuples listed in the vector Tuples)
A.updateByTupleID(Tuples,'procstat','seeing 0.5','Table','raw_images')

The output vector TupleIDs contains unique database identificators of the newly made records. If a user attempts to insert the same record twice and the 'Force' keyword is false, the corresponding output TupleID will be negative (equal to the negated identificator of the already existing record). If the 'Force' keyword is true (the default), the record will be inserted and the procversion column value advanced by 1.

% create a DB object with the default parameters:
A = db.AstroDb; 
% Search 'coadd_images' table for images with centers not further than 600 arcsec from (RA,Dec) = (34.5,-4.3) deg J2000
% producing a record with ra and dec columns only
Res = A.coneSearch('coadd_images',34.5,-4.3,600);
% Search 'src_catalog' table for sources with centers not further than 5 arcmin from (RA,Dec) = (220,51) deg J2000 AND S/N > 10
% producing a record with all the columns existing in the DB table
Res = A.coneSearch('src_catalog',220,51,5,'DistUnit','arcmin','AND','sn>10','Columns','*');
⚠️ **GitHub.com Fallback** ⚠️