NAME:
  sc_pstar

 PURPOSE:
  Search a star catalog for an isolated star near a given position.

 DESCRIPTION:
  Search a star catalog for a reference star that is within a given
  arc (RADIUS) from a point in the sky and has no brighter stars nearby within
  a given distance (SUB_RADIUS).

 CATEGORY:
  Database
 CALLING SEQUENCE:
  sc_pstar,cra,cdec,radius,id,ra,dec,dra,ddec,mag,odra,oddec
 
 INPUTS:
  cra    - ra of search location  (radians, string)
  cdec   - dec of search location  (radians, string)
  radius - maximum disance from cra/cdec to look  (degrees)

 OPTIONAL INPUT PARAMETERS:

 KEYWORD INPUT PARAMETERS:
  MAG_MIN    - lower bound of star magnitude to return (default= 12.0)
  MAG_MAX    - upper bound of star magnitude to return (default= -3.0)
  SCLASS     - Spectral classification, as a regexp (default=all types)
                   (eg. [ab]0 for a0 and b0 class)
  DBNAME     - Name of DB to access (default='obs')
  TBLNAME    - Name of table to query in the DB (default='ppm_catalog')
  SUB_RADIUS - region around reference star where no brighter star is
                 allowed (arcsec, default=300 arcsec).
  SILENT     - Flag, if set will suppress printed output

 OUTPUTS: Returns a suitable reference star
  id   - name of star
  ra   - ra  (radians)
  dec  - dec  (radians)
  dra  - ra proper motion
  ddec - dec proper motion
  mag  - magnitude of star
  odra - ra corrected for proper motion to date program is run
  oddec - dec corrected for proper motion to date program is run
  
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
  2002/02/19, Writen by David Tucker
  2012/04/03, MWB, added SILENT, changed units on radius and sub_radius,
                 added string input option on ra,dec, added printed output
  2015/09/13, MWB, output variables now exist if search fails.  Test on the
                 result (id != '') to know if you can use.