IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5144


Ignore:
Timestamp:
Sep 27, 2005, 7:43:49 AM (21 years ago)
Author:
eugene
Message:

minor cleanups, web edits

Location:
trunk/Ohana
Files:
5 added
3 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/doc/www/html/DVO/addstar.htm

    r4726 r5144  
     1<meta name=file  content=addstar>
     2<meta name=title content=addstar>
     3<meta name=page  content=addstar>
     4
     5<p>
     6This program takes a photometry file, with astrometry, provided by
     7earlier routines and incorporates the stellar measurements into the
     8photometry database.  This routine does NOT try to calibrate or check
     9the photometry, nor does it try to improve the coordinate
     10determinations or calculate chisquares for position or photometry -
     11those tasks are performed by other routines.
     12
     13<p>
     14Addstar starts by loading in the photometry file and converting the
     15pixel coordinates to sky coordinates using the astrometry information
     16in the header of the file.  It also gets the detection limits and
     17stores the image astrometry information.
     18
     19<p>
     20Next, addstar determines which of all the previous images overlaps
     21with this image and also which of the catalog regions overlaps with
     22this image.
     23
     24<p>
     25Addstar considers each catalog region in turn, and compares the
     26positions of stars in the catalog with stars in the image.  If a
     27catalog star is detected, a new measurement is added to the catalog.
     28If a catalog star is not detected, but is in the field of view of this
     29image, the detection limit for this image is added to the list of
     30measurements as an upper limit.  If the image contains a star which is
     31not already included in the catalog, the star is added to the catalog,
     32and all previous images are checked to see if they included this
     33location.  If so, upper limits are added to the list of measurements.
     34
     35<p>
     36To deal with blended images, we have taken the philosophy that all
     37measurements compatible with the coordinates of a given star should be
     38included in the list of measurements.  This assumes that programs or people
     39downstream will figure out which is the "correct" measurement.  To
     40this end, if a catalog star is consistent with multiple measurements,
     41they are all added to the catalog measurement and the measurements are
     42given a flag to say that there was blending in the catalog (ie, it is
     43probably the catalog star which is a blend).  If multiple catalog
     44stars are consistent with the same image star, that measurement is
     45added to each catalog star, and given a flag to say that there was
     46blending on the image.
     47
     48<p>
     49After all catalogs have been checked, updated, and written to disk,
     50the image is added to the database of images.
     51
     52<p>
     53see <a href=database.html> DVO database </a> for discussion of the
     54database storage format.   
     55
     56<hr>
     57
     58<h2> Usage </h2>
     59
     60<pre>
     61 addstar (filename)
     62 addstar -cat (catalog)
     63 addstar -ref (filename)
     64</pre>
     65
     66<p>
     67In the first form, addstar loads the photometry information for a
     68single image into the database.  The file must be in one of the Elixir
     69cmp/smp/smf formats, and must have been astrometrized (eg, with
     70gastro, gastro2, and/or mosastro).  The file must also be provided
     71with a valid photcode in the header (keyword PHOTCODE) or the photcode
     72must be supplied as an option to addstar (see below).  The photcode
     73must be listed in the photcode table (see config variable
     74PHOTCODE_FILE).  In the case that the image has been astrometrized
     75with mosastro (two-level mosaic astrometry), the corresponding mosaic
     76header unit must be supplied as an option (see below). 
     77
     78<p>
     79In the second form, addstar will load photometry from the specified
     80reference catalog, located in a known location, and will load it into
     81the database.  Allowed catalog names are: <tt> USNO, GSC, 2MASS,
     822MASS-ALLSKY, 2MASS-DR </tt>.  Note that USNO corresponds to the
     83USNO-A catalog, 2MASS corresponds to the 2MASS-ALLSKY catalog.  It is
     84necessary to have defined an appropriate photcode for the given
     85catalog.  The following photcodes are expected to exist:
     86
     87<table>
     88<tr><th> catalog </th><th> allowed photcodes         </th></tr>
     89<tr><td> GSC     </td><td> GSC_M                     </th></tr>
     90<tr><td> USNO    </td><td> USNO_RED, USNO_BLUE       </th></tr>
     91<tr><td> 2MASS*  </td><td> 2MASS_J, 2MASS_H, 2MASS_K </th></tr>
     92</table>
     93
     94When more than one photcode is allowed, one must be selected; there
     95are no defaults in that case. <em>It is advised that addstar -cat be
     96used with a restricted region of the sky; the default behavior will
     97load the reference catalog for the entire sky into the DB!</em>
     98
     99<p>
     100In the third form, addstar will load data from the specified ASCII
     101text file with a fixed format.  The file must contain lines with one
     102line per star.  The first four columns must contain the values RA,
     103DEC, Magnitude, Magnitude error.  The RA and DEC must be in J2000
     104decimal degrees.  Blank lines are allowed, and lines may be commented
     105with the hash sign (#).  The provided photometry must all be for a
     106single photcode, which must be provided as a command-line option.
     107
     108<h2> Additional Options </h2>
     109
     110<pre>
     111  -region ra ra dec dec           : only add data in specified region (-ref mode only)
     112  -p (photcode)                   : specify photcode (override header)
     113  -time (YYYY/MM/DD,HH:MM:SS)     : specify date/time (override header)
     114  -mosaic (filename)              : identify associated mosaic frame for chip image
     115  -fits                           : input file is FITS table, not TEXT table
     116  -existing-regions               : only add measurements to existing catalog files
     117  -only-match                     : only add measurements to existing objects
     118  -missed                         : skipped 'missed' entries
     119  -replace                        : replace time/photcode measurements (no duplication)
     120  -image                          : only insert image data
     121  -cal                            : perform zero-point calibration
     122  -skyprobe                       : specify skyprobe mode
     123  -2massquality                   : define 2MASS quality flags to keep
     124  -accept                         : accept bad astrometry from header
     125  -force                          : force read of database with inconsistent info
     126  -v                              : verbose mode
     127  -dump (mode)                    : output test data
     128  -help                           : print this list
     129  -h                              : print this list
     130</pre>
     131
     132
     133<h2> Elixir Configuration Data </h2>
     134
     135addstar uses the following Elixir configuration variables:
     136
     137<ul>
     138<li> EXPTIME-KEYWORD  : header keyword defining exposure time
     139<li> DATE-KEYWORD  : header keyword defining the date
     140<li> DATE-MODE  : mode for header date information: use a combination
     141of Ys, Ms, Ds to specify order.  If only 2 digits are specified for
     142the year, numbers greater than 50 are assumed in the 1900s, less than
     143in the 2000s.  eg YYYY/MM/DD
     144<li> UT-KEYWORD  : header keyword defining UT
     145<li> MJD-KEYWORD  : header keyword defining MJD
     146<li> JD-KEYWORD  : header keyword defining JD
     147<li> AIRMASS-KEYWORD
     148<li> CCDNUM-KEYWORD
     149<li> ST-KEYWORD
     150
     151<li> RADIUS : radius for matches; may have the value "header", in which
     152case the astrometric error listed in the header, along with
     153<tt>NSIGMA</tt> is used to define a match.  Otherwise, defines a
     154radius in arcseconds.
     155
     156<li> NSIGMA : number of astrometric error sigma to use for match
     157radius (see <tt>RADIUS</tt>).
     158
     159<li> XOVERSCAN : used to define valid pixels in the image. subtracted
     160from image NAXIS1 value to define image box.
     161
     162<li> YOVERSCAN : used to define valid pixels in the image. subtracted
     163from image NAXIS2 value to define image box.
     164
     165<li> ADDSTAR_XMIN : this value, and the following three, are used to
     166define a region on the image where the photometry is considered
     167reliable.  Stars outside this region are marked as having poor
     168measurements.
     169
     170<li> ADDSTAR_XMAX : see <tt>ADDSTAR_XMIN</tt>
     171<li> ADDSTAR_YMIN : see <tt>ADDSTAR_XMIN</tt>
     172<li> ADDSTAR_YMAX : see <tt>ADDSTAR_XMIN</tt>
     173
     174<li> MIN_SN_FSTAT : only include objects in the DB with S/N greater
     175than this value.
     176
     177<li> GSCDIR        : location of the HST Guide Star Catalog
     178<li> USNO_CDROM    : location of the USNO-A data
     179<li> 2MASS_DIR_AS  : location of the 2MASS allsky data
     180<li> 2MASS_DIR_DR2 : location of the 2MASS DR2 data
     181
     1822MASS, USNO, and GSC are all loaded from their idiosyncratic formats.
     183
     184<li> GSCFILE  : location of the GSC layout file (for GSC and ptolemy)
     185<li> CATDIR  : location of the ptolemy data
     186<li> IMAGE_CATALOG : location of the image database table
     187
     188<li> CATMODE : storage mode for the database.  may be one of RAW,
     189MEF, SPLIT, MYSQL.  SPLIT and MYSQL are currently unsupported.  This
     190defines the output format for new tables; the input format is auto-detected.
     191
     192<li> CATFORMAT : data format for the database.  may be one of LONEOS,
     193ELIXIR, PANSTARRS.
     194
     195<li> PHOTCODE_FILE : location of the photcode file describing the
     196photometry system of interest.
     197
     198<li> OBSERVATORY-LATITUDE : hard-wired observatory latitude.  used for
     199precision airmass for skyprobe.  <em> should be replaced with a more
     200sophisticated approach</em>
     201
     202<li> SUBPIX_DATAFILE : table for subpixel structure corrections (skyprobe)
     203
     204<li> IMAGE_CATALOG_TEMPLATE : deprecated, was used to supply a FITS
     205header template
     206<li> CATALOG_TEMPLATE : deprecated, was used to supply a FITS
     207header template
     208</ul>
  • trunk/Ohana/doc/www/html/DVO/relphot.htm

    r4726 r5144  
     1
     2<h2> relphot outline </h2>
     3
     4<ul>
     5<li> load data
     6     <ul>
     7     <li> images: match photcode and time range, reset flags
     8     <li> measure: select subset matching restritions on:
     9          photcode, time, dM, Minst, Mag, dophot == 1
     10     </ul>
     11<li> iterate to find Mcal, image.flags:
     12<li> write out modified Mcal values to image table
     13<li> write out modified Mcal values to measure table
     14<li> write out modified Mrel values to average table
     15</ul>
     16
     17<h2> relphot overview </h2>
     18
     19<p> relphot has two primary purposes:<br>
     20<ul>
     21<li> calculate <b>Mcal</b> for images / measures
     22<li> calculate <b>Mrel</b> for stars
     23</ul>
     24
     25<p> relphot can also be used to determine the mosaic grid used to generate
     26photometrically corrected flats (-grid option).
     27
     28<h2> data exclusion </h2>
     29
     30<p> relphot uses only a subset of the photometry data to calculate
     31Mcal and Mrel.  In the first stage, calculation of the Mcal values,
     32relphot loads the photometry data from each relevant catalog and
     33creates an internal subset catalog with the function
     34<em>bcatalog</em>, excluding some of the irrelevant data.  In
     35addition, it uses flags to mark some of the data as invalid for the
     36processing.
     37
     38<b> bcatalog exclusions </b>
     39<ul>
     40<li> measure.photcode not equivalent to requested photcode
     41<li> measure.dophot != 1
     42<li> measure.Mcat > MAG_LIM
     43<li> measure.dM > SIGMA_LIM
     44<li> measure.Minst out of range (ImagMin - ImagMax) [optional]
     45<li> measure.t out of range (TSTART, TSTOP)
     46</ul>
     47
     48<b> flagged data </b>
     49
     50<b> flagged image data </b>
     51
     52images can be flagged by setting bits of <b>image.code</b>
     53
     54stars can be flagged by setting bits of <b>average.code</b>
     55
     56measures can be flagged by setting bits of <b>measure.flag</b>
     57
     58<b>image.code</b>
     59
     60ID_IMAGE_NOCAL : ignore, irrelevant
     61ID_IMAGE_POOR  : image measured bad
     62ID_IMAGE_SKIP  : externally known bad
     63
     64dMcal > VALUE       FLAG_IMAGE_SCATTER <em>clean_images</em>
     65fabs(Mcal) > VALUE  FLAG_IMAGE_ZEROPT  <em>clean_images</em>
     66
     67dMcal > VALUE       FLAG_IMAGE_SCATTER <em>clean_mosaics</em>
     68fabs(Mcal) > VALUE  FLAG_IMAGE_ZEROPT  <em>clean_mosaics</em>
     69
     70<em> mark_images </em> does not seem to do anything useful?
     71
     72<b>average.code</b>
     73
     74Ngood < MEAS_TOOFEW                     <em>setMrel</em>
     75Ngood < MEAS_TOOFEW                     <em>clean_measures</em>
     76ChiSq > STAR_CHISQ                      <em>clean_stars</em>
     77dM    > STAR_SCATTER                    <em>clean_stars</em>
     78
     79average.code (STAR_BAD) is not saved by relphot: it is set by
     80clean_stars, clean_measures, and setMrel, but not setMrelOutput.
     81STAR_BAD should only be internal since it depends on the photcode, but
     82is not associated with a specific photcode in the data.  Just in case,
     83it is reset to 0 in setMrelFinal.
     84
     85<b>measure.flag</b>
     86
     87X,Y out of range                        <em>setExclusions</em>
     883 sigma clipping                        <em>clean_measures</em>
     89
     90<h2> setting Mrel final value </h2>
     91
     92setMrelFinal is used to set the final average.Mrel values.  We do this
     93in 4 stages.  In each stage, we set the Mrel values for stars which
     94have not already been set, based on the current exclusion settings.
     95At successive stages, we relax the exclusions, allowing the more
     96spurious objects to have a valid Mrel value to be set.  In this loop,
     97we actually run setMrelOutput twice: once to get the approximate Mrel
     98value, then we flag the outlier measurements with clean_measure,
     99then we redetermine the Mrel values on this basis, and mark the stars
     100for exclusion from the next iteration. 
     101
     102<pre>
     103exclude on
     104 photcode       0 1 2 3
     105 time range     0 1 2 3
     106 MEAS_POOR      0 1 2 3
     107 MEAS_TOOFEW    0 1 2 3
     108 dophot == 10   0 1 2
     109 inst mag       0 1 2
     110 dophot != 1,2  0 1 
     111 ID_IMAGE_POOR  0 1
     112 ID_IMAGE_SKIP  0 1
     113 dophot != 1    0
     114 measure.dM     0
     115</pre>
     116
     117for all relphot runs, Mrel is re-calculated, and measures are marked
     118at least if they are outliers in mag or ccd area.
     119
     120setMrel.output needs to do a few things differently from setMrel:
     121<ul>
     122<li> set measure.Mcal (skipped in setMrel.basic)
     123<li> set average.Mrel if N < TOO_FEW (not STAR_BAD) (optional!)
     124<li> use MAX (stats.error, stats.sigma) (optionally)
     125<li> allow STAR_BAD?
     126</ul>
     127
     128<h2> imphotset </h2>
     129
     130imphotset allows you to set certain phot.image table entries.  here
     131are the options:
     132
     133imphotset [-photcode code] [-name foo] [-trange (start) (stop)] -flag and value
     134
     135
     136Here is a complete list of relphot configuration variable names, a
     137quick description, and reasonable values to start with:
     138
     139<pre>
     140--- configuration variables used by relphot ---
     141MAG_LIM : float
     142  ignore measurements fainter than this absolute magnitude
     143
     144SIGMA_LIM : float
     145  ignore measurements with magnitude error larger than this value
     146
     147STAR_SCATTER : float
     148  mark stars as bad if their scatter is larger than this value
     149
     150IMAGE_SCATTER : float
     151  mark images as bad if their scatter is larger than this value
     152
     153IMAGE_OFFSET : float
     154  mark images as bad if the absolute value of thie zero point offset
     155  is larger than this number
     156
     157STAR_CHISQ : float
     158  mark stars as variable if their reduced chisq are larger than this value
     159
     160STAR_TOOFEW : int
     161  mark stars as bad if the have fewer than this number of valid measurements
     162
     163IMAGE_TOOFEW : int
     164  mark images as bad if the have fewer than this number of valid measurements
     165
     166IMAGE_GOOD_FRACTION : float
     167  mark images as bad if the have fewer than this fraction of valid measurements 
     168
     169IMAGE_CATALOG : string
     170  name of the image catalog file
     171
     172IMAGE_CATALOG_TEMPLATE : string
     173  name of the template file to create the image catalog file
     174
     175CATALOG_TEMPLATE : string
     176  name of the template file to create the catalog file
     177
     178GSCFILE : string
     179  name of the GSC region table
     180
     181CATDIR : string
     182  directory where the database is stored
     183
     184PHOTCODE_FILE : string
     185  file containing photometry code information
     186
     187ZERO_PT : float
     188  default zero point for random data
     189
     190RELPHOT_GRID_X : int
     191  scale of mosaic correction grid
     192
     193RELPHOT_GRID_Y : int
     194  scale of mosaic correction grid
     195
     196RELPHOT_GRID_BINNING : int
     197  deprecated
     198
     199CAMERA_CONFIG : string
     200  name of the file containing descriptive information about the camera
     201
     202--- sample ConfigFile entries with typical values ---
     203
     204MAG_LIM                  24.0
     205SIGMA_LIM                 0.05
     206STAR_SCATTER              0.05
     207IMAGE_SCATTER             0.05
     208IMAGE_OFFSET              0.2
     209STAR_CHISQ               10.0
     210STAR_TOOFEW               3
     211IMAGE_TOOFEW             10
     212IMAGE_GOOD_FRACTION     
     213IMAGE_CATALOG            $CATDIR/Images.dat
     214IMAGE_CATALOG_TEMPLATE   $REFSDIR/elixir/template.cat
     215CATALOG_TEMPLATE         $REFSDIR/elixir/template.cat
     216GSCFILE                  $REFSDIR/gsc/GSCregions.tbl
     217CATDIR                   $CATDIR
     218PHOTCODE_FILE            $CONFDIR/camera/$CAMERA.photcode
     219ZERO_PT                  25.0
     220RELPHOT_GRID_X           4
     221RELPHOT_GRID_Y           8
     222RELPHOT_GRID_BINNING     512
     223CAMERA_CONFIG            $CONFDIR/camera/$CAMERA.config
     224</pre>
  • trunk/Ohana/doc/www/html/Elixir-Tools/mosastro.htm

    r5135 r5144  
    157157values are <tt>GSC, USNO, 2MASS, PTOLEMY, STONE</tt>. 
    158158
    159 <li> USNO_CDROM  : directory where USNO data is stored
    160 <li> STONE_DIR  : location of the Stone et al reference data
    161 <li> 2MASS_DIR  : location of the 2MASS data
    162 <li> CATDIR  : location of the ptolemy data
    163 <li> GSCDIR  : location of the HST Guide Star Catalog
    164 <li> GSCFILE  : location of the GSC layout file (for GSC and ptolemy)
     159<li> GSCDIR      : location of the HST Guide Star Catalog
     160<li> USNO_CDROM  : location of the USNO-A data
     161<li> STONE_DIR   : location of the Stone et al reference data
     162<li> 2MASS_DIR   : location of the 2MASS data
     163<li> CATDIR      : location of the ptolemy data
     164<li> GSCFILE     : location of the GSC layout file (for GSC and ptolemy)
    165165
    166166note that 'ptolemy' refers to data using the DVO format.  2MASS data
    167 must be in a DVO format database.
     167must be in a DVO format database.  USNO and GSC are both loaded from
     168their idiosyncratic formats. 
    168169
    169170<li> RADIUS  : matching radius in arcsec to select reference stars
     
    178179systematic error limit.
    179180</ul>
    180  
    181 </pre>
    182 
    183 
    184 
    185 
    186 
    187 
    188 
  • trunk/Ohana/doc/www/html/download.htm

    r4835 r5144  
    4040
    4141<ul>
     42<li><a href=download/tarballs/elixir-ohana-head.tgz>elixir-ohana-head.tgz </a>
    4243<li><a href=download/tarballs/elixir-ohana-1.3.tgz>elixir-ohana-1.3.tgz </a>
    4344<li><a href=download/tarballs/elixir-ohana-1.2.tgz>elixir-ohana-1.2.tgz </a>
  • trunk/Ohana/etc/distributions/elixir-ohana-head.dst

    r4739 r5144  
    1010 USE elixir
    1111 USE gastro
     12 USE gastro2
    1213 USE gcompare
    1314 USE gophot
  • trunk/Ohana/src/addstar/include/addstar.h

    r5014 r5144  
    7474int    XMIN, XMAX, YMIN, YMAX;
    7575int    ACCEPT_ASTROM;
     76int    TEXTMODE;
    7677
    7778PhotCode *thiscode;
  • trunk/Ohana/src/addstar/src/ConfigInit.c

    r4826 r5144  
    3535
    3636  ScanConfig (config, "IMAGE_CATALOG",          "%s",  0, ImageCat);
    37   ScanConfig (config, "IMAGE_CATALOG_TEMPLATE", "%s",  0, ImageTemplate);
    38   ScanConfig (config, "CATALOG_TEMPLATE",       "%s",  0, CatTemplate);
    3937  ScanConfig (config, "GSCFILE",                "%s",  0, GSCFILE);
    4038  ScanConfig (config, "CATDIR",                 "%s",  0, CATDIR);
  • trunk/Ohana/src/addstar/src/args.c

    r4538 r5144  
    183183    remove_argument (N, &argc, argv);
    184184  }
     185  /* force read of image database with mismatched NSTARS & size */
     186  TEXTMODE = FALSE;
     187  if ((N = get_argument (argc, argv, "-textmode"))) {
     188    TEXTMODE = TRUE;
     189    remove_argument (N, &argc, argv);
     190  }
    185191  /* extra error messages */
    186192  VERBOSE = FALSE;
  • trunk/Ohana/src/addstar/src/gstars.c

    r5014 r5144  
    166166  extend = FALSE;
    167167  fits_scan (&header, "EXTEND",  "%t", 1, &extend);
    168   if (extend) {
     168  if (extend && !TEXTMODE) {
    169169    Nbytes = fits_matrix_size (&header);
    170170    fseek (f, Nbytes, SEEK_CUR);
    171171    rdstars = rfits (f, &image[0].nstar);
     172    if (rdstars == NULL) {
     173      fprintf (stderr, "ERROR: failed to read fits table\n");
     174      exit (1);
     175    }
    172176  } else {
    173177    /* allocate space for stars */
  • trunk/Ohana/src/imregister/src/photcode.c

    r2803 r5144  
    11# include "imregister.h"
    2 static char *version = "photcode $Revision: 3.1 $";
     2static char *version = "photcode $Revision: 3.2 $";
    33
    44int main (int argc, char **argv) {
     
    6161  }
    6262  if (ccd == -1) {
    63     fprintf (stderr, "warning: ccd %s not found in camera config file\n", ID);
     63    fprintf (stderr, "warning: ccd %s not found in camera config file\n", ccd);
    6464    ccd = 0;
    6565  }
  • trunk/Ohana/src/libohana/src/LoadPhotcodes.c

    r4865 r5144  
    485485
    486486  int Np;
    487   short M;
     487  float M;
    488488
    489489  Np = photcodes[0].hashcode[measure[0].source];
     
    672672
    673673  int i, Ns;
    674   short Mave, Mref, Mcol, mc;
     674  float Mave, Mref, Mcol, mc;
    675675  double Mc;
    676676
     
    697697
    698698  int Ns;
    699   short Mave;
     699  float Mave;
    700700
    701701  Ns = photcodes[0].hashNsec[code[0].code];
     
    708708
    709709  int Ns;
    710   short dM;
     710  float dM;
    711711
    712712  Ns = photcodes[0].hashNsec[code[0].code];
  • trunk/Ohana/src/opihi/dvo/Makefile

    r4833 r5144  
    2828$(SDIR)/ImageSelection.$(ARCH).o        \
    2929$(SDIR)/LoadImages.$(ARCH).o            \
     30$(SDIR)/cmpRead.$(ARCH).o               \
    3031$(SDIR)/aregion.$(ARCH).o               \
    3132$(SDIR)/compare.$(ARCH).o               \
  • trunk/Ohana/src/opihi/dvo/cmpread.c

    r4689 r5144  
    11# include "dvo1.h"
    2 # define D_NSTARS 1000
    3 # define BYTES_STAR 66
    4 # define BLOCK 1000
     2
     3/* add others as needed */
     4enum {F_NONE, F_RA, F_DEC, F_X, F_Y, F_MAG, F_DMAG, F_TYPE, F_SKY, F_FX, F_FY, F_APMAG, F_GALMAG};
    55
    66int cmpread (int argc, char **argv) {
    77 
    8   int i, nstar, Nin, Nextra;
    9   int doneread, done, Nskip, Nbytes, nbytes, Ninstar, RAnDEC;
    10   char *c, *c2, *name, *file;
    11   float *R, *D, *V;
    12   double tR, tD, tmp, X, Y;
     8  int i, field, extend, Nbytes, Nstars;
     9  double tR, tD;
     10  float value;
    1311  FILE *f;
    14   char *buffer;
    15   int Nfield, Nra, Ndec;
    16   Vector *rvec, *dvec, *vec;
     12  Vector *vec;
    1713  Header header;
    1814  Coords coords;
     15  CMPstars *stars;
    1916
    20   if ((argc != 4) && (argc != 6)) {
    21     fprintf (stderr, "USAGE: cmpread name Nfield <filename>\n");
    22     fprintf (stderr, "USAGE: cmpread ra N dec N <filename>\n");
     17  if (argc != 3) {
     18    fprintf (stderr, "USAGE: cmpread field <filename>\n");
    2319    return (FALSE);
    2420  }
    2521
    26   R = D = V = NULL;
    27   file = NULL;
    28   name = NULL;
    29   Nfield = Nra = Ndec = 0;
    30   RAnDEC = FALSE;
    31 
    32   if (argc == 4) {
    33     name = strcreate (argv[1]);
    34     Nfield = atof (argv[2]);
    35     file = strcreate (argv[3]);
    36     RAnDEC = FALSE;
    37   } else {
    38     Nra  = atof (argv[2]);
    39     Ndec = atof (argv[4]);
    40     file = strcreate (argv[5]);
    41     RAnDEC = TRUE;
    42   }   
    43 
    44   if (!fits_read_header (file, &header)) {
    45     fprintf (stderr, "ERROR: can't read header for %s\n", file);
    46     free (file);
    47     if (!RAnDEC) free (name);
     22  field = F_NONE;
     23  if (!strcasecmp (argv[1], "ra"))   field = F_RA;
     24  if (!strcasecmp (argv[1], "dec"))  field = F_DEC;
     25  if (!strcasecmp (argv[1], "mag"))  field = F_MAG;
     26  if (!strcasecmp (argv[1], "dmag")) field = F_DMAG;
     27  if (!strcasecmp (argv[1], "x"))    field = F_X;
     28  if (!strcasecmp (argv[1], "y"))    field = F_Y;
     29  if (!strcasecmp (argv[1], "type")) field = F_TYPE;
     30  if (!strcasecmp (argv[1], "sky"))  field = F_SKY;
     31  if (!strcasecmp (argv[1], "fx"))   field = F_FX;
     32  if (!strcasecmp (argv[1], "fy"))   field = F_FY;
     33  if (!strcasecmp (argv[1], "apmag"))  field = F_APMAG;
     34  if (!strcasecmp (argv[1], "galmag"))  field = F_GALMAG;
     35  if (field == F_NONE) {
     36    fprintf (stderr, "invalid cmp field: %s\n", argv[1]);
    4837    return (FALSE);
    4938  }
    5039
    51   /* find expected number of stars */
    52   fits_scan (&header, "NSTARS", "%d", 1, &nstar);
    53   if (nstar == 0) {
    54     fprintf (stderr, "ERROR: can't get NSTARS from header\n");
    55     free (file);
    56     if (!RAnDEC) free (name);
    57     fits_free_header (&header);
     40  if ((vec = SelectVector (argv[1],  ANYVECTOR, TRUE)) == NULL) return (FALSE);
     41
     42  /* load FITS header */
     43  if (!fits_read_header (argv[2], &header)) {
     44    fprintf (stderr, "ERROR: can't read header for %s\n", argv[2]);
    5845    return (FALSE);
    5946  }
    6047
    61   f = fopen (file, "r");
     48  if ((field == F_RA) || (field == F_DEC)) {
     49    if (!GetCoords (&coords, &header)) {
     50      fprintf (stderr, "can't get WCS info from header\n");
     51      fits_free_header (&header);
     52      return (FALSE);
     53    }
     54  }
     55
     56  /* re-open file to load data */
     57  f = fopen (argv[2], "r");
    6258  if (f == NULL) {
    63     fprintf (stderr, "ERROR: can't read data from %s\n", file);
    64     free (file);
    65     if (!RAnDEC) free (name);
     59    fprintf (stderr, "ERROR: can't read data from %s\n", argv[2]);
    6660    fits_free_header (&header);
    6761    return (FALSE);
     
    6963  fseek (f, header.size, SEEK_SET);
    7064
    71   if (RAnDEC) {
    72     if ((rvec = SelectVector ("ra",  ANYVECTOR, TRUE)) == NULL) return (FALSE);
    73     if ((dvec = SelectVector ("dec",  ANYVECTOR, TRUE)) == NULL) return (FALSE);
    74     REALLOCATE (rvec[0].elements, float, nstar);
    75     REALLOCATE (dvec[0].elements, float, nstar);
    76     R = rvec[0].elements;
    77     D = dvec[0].elements;
    78     rvec[0].Nelements = dvec[0].Nelements = nstar;
    79     if (!GetCoords (&coords, &header)) {
    80       fprintf (stderr, "can't get WCS info from header\n");
    81       return (FALSE);
    82     }
    83   } else {
    84     if ((vec = SelectVector (name, ANYVECTOR, TRUE)) == NULL) return (FALSE);
    85     REALLOCATE (vec[0].elements, float, nstar);
    86     V = vec[0].elements;
    87     vec[0].Nelements = nstar;
     65  /* find expected number of stars */
     66  if (!fits_scan (&header, "NSTARS", "%d", 1, &Nstars)) {
     67    fprintf (stderr, "ERROR: can't get NSTARS from header\n");
     68    fits_free_header (&header);
     69    return (FALSE);
    8870  }
    8971
    90   /* load in stars by blocks of 1000 */
    91   Nin = 0;
    92   ALLOCATE (buffer, char, (BLOCK*BYTES_STAR) + 1);
    93   buffer[BLOCK*BYTES_STAR] = 0;
    94   Nextra = 0;
    95   doneread = FALSE;
    96   while (!doneread) {
    97     Nbytes = BYTES_STAR * BLOCK - Nextra;
    98     nbytes = fread (&buffer[Nextra], 1, Nbytes, f);
    99     if (nbytes == 0) {
    100       doneread = TRUE;
    101       continue;
     72  /* read from FITS table or from text table */
     73  extend = FALSE;
     74  fits_scan (&header, "EXTEND",  "%t", 1, &extend);
     75  if (extend) {
     76    fprintf (stderr, "reading from FITS cmp file %s\n", argv[2]);
     77    Nbytes = fits_matrix_size (&header);
     78    fseek (f, Nbytes, SEEK_CUR);
     79    stars = cmpReadFits (f, &Nstars);
     80  } else {
     81    /* allocate space for stars */
     82    fprintf (stderr, "reading from TEXT cmp file %s\n", argv[2]);
     83    if (!fits_scan (&header, "NSTARS", "%d", 1, &Nstars)) {
     84      fprintf (stderr, "ERROR: failed to find NSTARS\n");
     85      exit (1);
    10286    }
    103     nbytes += Nextra;
    104     /* check line-by-line integrity */
    105     c = buffer;
    106     done = FALSE;
    107     while ((c < buffer + nbytes) && (!done)) {
    108       for (c2 = c; *c2 == '\n'; c2++);
    109       if (c2 > c) { /* extra return chars */
    110         memmove (c, c2, (int)(buffer + nbytes - c2));
    111         Nskip = c2 - c;
    112         nbytes -= Nskip;
    113         bzero (buffer + nbytes, Nskip);
    114       }
    115       c2 = strchr (c, '\n');
    116       if (c2 == (char *) NULL) {
    117         done = TRUE;   
    118         continue;
    119       }
    120       c2++;
    121       if ((c2 - c) != BYTES_STAR) { /* bad line, delete it */
    122         memmove (c, c2, (int)(buffer + nbytes - c2));
    123         Nskip = c2 - c;
    124         nbytes -= Nskip;
    125         bzero (buffer + nbytes, Nskip);
    126       } else {
    127         c = c2;
    128       }
    129     }
    130     Ninstar = nbytes / BYTES_STAR;
    131     Nextra = nbytes % BYTES_STAR;
    132     for (i = 0; i < Ninstar; i++, Nin++) {
    133       if (RAnDEC) {
    134         dparse (&X, Nra,  &buffer[i*BYTES_STAR]);
    135         dparse (&Y, Ndec, &buffer[i*BYTES_STAR]);
    136         XY_to_RD (&tR, &tD, X, Y, &coords);
    137         R[Nin] = tR; D[Nin] = tD;
    138       } else {
    139         dparse (&tmp, Nfield, &buffer[i*BYTES_STAR]);
    140         V[Nin] = tmp;
    141       }
    142     }
     87    stars = cmpReadText (f, &Nstars);
    14388  }
    14489  fclose (f);
    14590
     91  REALLOCATE (vec[0].elements, float, Nstars);
     92  vec[0].Nelements = Nstars;
     93  bzero (vec[0].elements, Nstars*sizeof(float));
     94
     95  for (i = 0; i < Nstars; i++) {
     96    switch (field) {
     97      case F_RA:
     98        XY_to_RD (&tR, &tD, stars[i].X, stars[i].Y, &coords);
     99        value = tR;
     100        break;
     101      case F_DEC:
     102        XY_to_RD (&tR, &tD, stars[i].X, stars[i].Y, &coords);
     103        value = tD;
     104        break;
     105      case F_X:
     106        value = stars[i].X;
     107        break;
     108      case F_Y:
     109        value = stars[i].Y;
     110        break;
     111      case F_MAG:
     112        value = stars[i].M;
     113        break;
     114      case F_APMAG:
     115        value = stars[i].Map;
     116        break;
     117      case F_GALMAG:
     118        value = stars[i].Mgal;
     119        break;
     120      case F_DMAG:
     121        value = stars[i].dM;
     122        break;
     123      case F_TYPE:
     124        value = stars[i].dophot;
     125        break;
     126      case F_SKY:
     127        value = stars[i].sky;
     128        break;
     129      case F_FX:
     130        value = stars[i].fx;
     131        break;
     132      case F_FY:
     133        value = stars[i].fy;
     134        break;
     135    }
     136    vec[0].elements[i] = value;
     137  }     
     138  free (stars);
    146139  fits_free_header (&header);
    147   free (buffer);
    148   free (file);
    149   if (!RAnDEC) free (name);
    150 
    151   fprintf (stderr, "loaded %d objects\n", Nin);
     140  fprintf (stderr, "loaded %d objects\n", Nstars);
    152141  return (TRUE);
    153142}
    154 
  • trunk/Ohana/src/opihi/include/dvo1.h

    r4805 r5144  
    2222  double RA0, RA1, DEC0, DEC1;
    2323} RegionFile;
     24
     25typedef struct {
     26  double X;
     27  double Y;
     28  double R;
     29  double D;
     30  double M, dM;
     31  char   dophot;
     32  double sky;
     33  double fx, fy, df;
     34  double Mgal, Map;
     35  int found;
     36  short int code;
     37  e_time t;
     38} CMPstars;
    2439
    2540/*** dvo prototypes ***/
     
    7388void          sort_images           PROTO((Image *image, int N));
    7489void          sortave               PROTO((Average *ave, int N));
     90CMPstars *cmpReadFits (FILE *f, int *nstars);
     91CMPstars *cmpReadText (FILE *f, int *nstars);
    7592
    7693# endif
Note: See TracChangeset for help on using the changeset viewer.