Changeset 5144
- Timestamp:
- Sep 27, 2005, 7:43:49 AM (21 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 5 added
- 3 deleted
- 14 edited
-
doc/www/html/DVO/addstar.htm (modified) (1 diff)
-
doc/www/html/DVO/database.htm (added)
-
doc/www/html/DVO/extract.htm (added)
-
doc/www/html/DVO/navigate.htm (added)
-
doc/www/html/DVO/navigate.pro (added)
-
doc/www/html/DVO/photcodes.htm (added)
-
doc/www/html/DVO/relphot.htm (modified) (1 diff)
-
doc/www/html/Elixir-Tools/mosastro.htm (modified) (2 diffs)
-
doc/www/html/download.htm (modified) (1 diff)
-
etc/distributions/elixir-ohana-head.dst (modified) (1 diff)
-
src/addstar/doc/database.txt (deleted)
-
src/addstar/doc/description.txt (deleted)
-
src/addstar/doc/merge.txt (deleted)
-
src/addstar/include/addstar.h (modified) (1 diff)
-
src/addstar/src/ConfigInit.c (modified) (1 diff)
-
src/addstar/src/args.c (modified) (1 diff)
-
src/addstar/src/gstars.c (modified) (1 diff)
-
src/imregister/src/photcode.c (modified) (2 diffs)
-
src/libohana/src/LoadPhotcodes.c (modified) (4 diffs)
-
src/opihi/dvo/Makefile (modified) (1 diff)
-
src/opihi/dvo/cmpread.c (modified) (2 diffs)
-
src/opihi/include/dvo1.h (modified) (2 diffs)
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> 6 This program takes a photometry file, with astrometry, provided by 7 earlier routines and incorporates the stellar measurements into the 8 photometry database. This routine does NOT try to calibrate or check 9 the photometry, nor does it try to improve the coordinate 10 determinations or calculate chisquares for position or photometry - 11 those tasks are performed by other routines. 12 13 <p> 14 Addstar starts by loading in the photometry file and converting the 15 pixel coordinates to sky coordinates using the astrometry information 16 in the header of the file. It also gets the detection limits and 17 stores the image astrometry information. 18 19 <p> 20 Next, addstar determines which of all the previous images overlaps 21 with this image and also which of the catalog regions overlaps with 22 this image. 23 24 <p> 25 Addstar considers each catalog region in turn, and compares the 26 positions of stars in the catalog with stars in the image. If a 27 catalog star is detected, a new measurement is added to the catalog. 28 If a catalog star is not detected, but is in the field of view of this 29 image, the detection limit for this image is added to the list of 30 measurements as an upper limit. If the image contains a star which is 31 not already included in the catalog, the star is added to the catalog, 32 and all previous images are checked to see if they included this 33 location. If so, upper limits are added to the list of measurements. 34 35 <p> 36 To deal with blended images, we have taken the philosophy that all 37 measurements compatible with the coordinates of a given star should be 38 included in the list of measurements. This assumes that programs or people 39 downstream will figure out which is the "correct" measurement. To 40 this end, if a catalog star is consistent with multiple measurements, 41 they are all added to the catalog measurement and the measurements are 42 given a flag to say that there was blending in the catalog (ie, it is 43 probably the catalog star which is a blend). If multiple catalog 44 stars are consistent with the same image star, that measurement is 45 added to each catalog star, and given a flag to say that there was 46 blending on the image. 47 48 <p> 49 After all catalogs have been checked, updated, and written to disk, 50 the image is added to the database of images. 51 52 <p> 53 see <a href=database.html> DVO database </a> for discussion of the 54 database 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> 67 In the first form, addstar loads the photometry information for a 68 single image into the database. The file must be in one of the Elixir 69 cmp/smp/smf formats, and must have been astrometrized (eg, with 70 gastro, gastro2, and/or mosastro). The file must also be provided 71 with a valid photcode in the header (keyword PHOTCODE) or the photcode 72 must be supplied as an option to addstar (see below). The photcode 73 must be listed in the photcode table (see config variable 74 PHOTCODE_FILE). In the case that the image has been astrometrized 75 with mosastro (two-level mosaic astrometry), the corresponding mosaic 76 header unit must be supplied as an option (see below). 77 78 <p> 79 In the second form, addstar will load photometry from the specified 80 reference catalog, located in a known location, and will load it into 81 the database. Allowed catalog names are: <tt> USNO, GSC, 2MASS, 82 2MASS-ALLSKY, 2MASS-DR </tt>. Note that USNO corresponds to the 83 USNO-A catalog, 2MASS corresponds to the 2MASS-ALLSKY catalog. It is 84 necessary to have defined an appropriate photcode for the given 85 catalog. 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 94 When more than one photcode is allowed, one must be selected; there 95 are no defaults in that case. <em>It is advised that addstar -cat be 96 used with a restricted region of the sky; the default behavior will 97 load the reference catalog for the entire sky into the DB!</em> 98 99 <p> 100 In the third form, addstar will load data from the specified ASCII 101 text file with a fixed format. The file must contain lines with one 102 line per star. The first four columns must contain the values RA, 103 DEC, Magnitude, Magnitude error. The RA and DEC must be in J2000 104 decimal degrees. Blank lines are allowed, and lines may be commented 105 with the hash sign (#). The provided photometry must all be for a 106 single 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 135 addstar 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 141 of Ys, Ms, Ds to specify order. If only 2 digits are specified for 142 the year, numbers greater than 50 are assumed in the 1900s, less than 143 in 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 152 case the astrometric error listed in the header, along with 153 <tt>NSIGMA</tt> is used to define a match. Otherwise, defines a 154 radius in arcseconds. 155 156 <li> NSIGMA : number of astrometric error sigma to use for match 157 radius (see <tt>RADIUS</tt>). 158 159 <li> XOVERSCAN : used to define valid pixels in the image. subtracted 160 from image NAXIS1 value to define image box. 161 162 <li> YOVERSCAN : used to define valid pixels in the image. subtracted 163 from image NAXIS2 value to define image box. 164 165 <li> ADDSTAR_XMIN : this value, and the following three, are used to 166 define a region on the image where the photometry is considered 167 reliable. Stars outside this region are marked as having poor 168 measurements. 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 175 than 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 182 2MASS, 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, 189 MEF, SPLIT, MYSQL. SPLIT and MYSQL are currently unsupported. This 190 defines 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, 193 ELIXIR, PANSTARRS. 194 195 <li> PHOTCODE_FILE : location of the photcode file describing the 196 photometry system of interest. 197 198 <li> OBSERVATORY-LATITUDE : hard-wired observatory latitude. used for 199 precision airmass for skyprobe. <em> should be replaced with a more 200 sophisticated 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 205 header template 206 <li> CATALOG_TEMPLATE : deprecated, was used to supply a FITS 207 header 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 26 photometrically corrected flats (-grid option). 27 28 <h2> data exclusion </h2> 29 30 <p> relphot uses only a subset of the photometry data to calculate 31 Mcal and Mrel. In the first stage, calculation of the Mcal values, 32 relphot loads the photometry data from each relevant catalog and 33 creates an internal subset catalog with the function 34 <em>bcatalog</em>, excluding some of the irrelevant data. In 35 addition, it uses flags to mark some of the data as invalid for the 36 processing. 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 52 images can be flagged by setting bits of <b>image.code</b> 53 54 stars can be flagged by setting bits of <b>average.code</b> 55 56 measures can be flagged by setting bits of <b>measure.flag</b> 57 58 <b>image.code</b> 59 60 ID_IMAGE_NOCAL : ignore, irrelevant 61 ID_IMAGE_POOR : image measured bad 62 ID_IMAGE_SKIP : externally known bad 63 64 dMcal > VALUE FLAG_IMAGE_SCATTER <em>clean_images</em> 65 fabs(Mcal) > VALUE FLAG_IMAGE_ZEROPT <em>clean_images</em> 66 67 dMcal > VALUE FLAG_IMAGE_SCATTER <em>clean_mosaics</em> 68 fabs(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 74 Ngood < MEAS_TOOFEW <em>setMrel</em> 75 Ngood < MEAS_TOOFEW <em>clean_measures</em> 76 ChiSq > STAR_CHISQ <em>clean_stars</em> 77 dM > STAR_SCATTER <em>clean_stars</em> 78 79 average.code (STAR_BAD) is not saved by relphot: it is set by 80 clean_stars, clean_measures, and setMrel, but not setMrelOutput. 81 STAR_BAD should only be internal since it depends on the photcode, but 82 is not associated with a specific photcode in the data. Just in case, 83 it is reset to 0 in setMrelFinal. 84 85 <b>measure.flag</b> 86 87 X,Y out of range <em>setExclusions</em> 88 3 sigma clipping <em>clean_measures</em> 89 90 <h2> setting Mrel final value </h2> 91 92 setMrelFinal is used to set the final average.Mrel values. We do this 93 in 4 stages. In each stage, we set the Mrel values for stars which 94 have not already been set, based on the current exclusion settings. 95 At successive stages, we relax the exclusions, allowing the more 96 spurious objects to have a valid Mrel value to be set. In this loop, 97 we actually run setMrelOutput twice: once to get the approximate Mrel 98 value, then we flag the outlier measurements with clean_measure, 99 then we redetermine the Mrel values on this basis, and mark the stars 100 for exclusion from the next iteration. 101 102 <pre> 103 exclude 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 117 for all relphot runs, Mrel is re-calculated, and measures are marked 118 at least if they are outliers in mag or ccd area. 119 120 setMrel.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 130 imphotset allows you to set certain phot.image table entries. here 131 are the options: 132 133 imphotset [-photcode code] [-name foo] [-trange (start) (stop)] -flag and value 134 135 136 Here is a complete list of relphot configuration variable names, a 137 quick description, and reasonable values to start with: 138 139 <pre> 140 --- configuration variables used by relphot --- 141 MAG_LIM : float 142 ignore measurements fainter than this absolute magnitude 143 144 SIGMA_LIM : float 145 ignore measurements with magnitude error larger than this value 146 147 STAR_SCATTER : float 148 mark stars as bad if their scatter is larger than this value 149 150 IMAGE_SCATTER : float 151 mark images as bad if their scatter is larger than this value 152 153 IMAGE_OFFSET : float 154 mark images as bad if the absolute value of thie zero point offset 155 is larger than this number 156 157 STAR_CHISQ : float 158 mark stars as variable if their reduced chisq are larger than this value 159 160 STAR_TOOFEW : int 161 mark stars as bad if the have fewer than this number of valid measurements 162 163 IMAGE_TOOFEW : int 164 mark images as bad if the have fewer than this number of valid measurements 165 166 IMAGE_GOOD_FRACTION : float 167 mark images as bad if the have fewer than this fraction of valid measurements 168 169 IMAGE_CATALOG : string 170 name of the image catalog file 171 172 IMAGE_CATALOG_TEMPLATE : string 173 name of the template file to create the image catalog file 174 175 CATALOG_TEMPLATE : string 176 name of the template file to create the catalog file 177 178 GSCFILE : string 179 name of the GSC region table 180 181 CATDIR : string 182 directory where the database is stored 183 184 PHOTCODE_FILE : string 185 file containing photometry code information 186 187 ZERO_PT : float 188 default zero point for random data 189 190 RELPHOT_GRID_X : int 191 scale of mosaic correction grid 192 193 RELPHOT_GRID_Y : int 194 scale of mosaic correction grid 195 196 RELPHOT_GRID_BINNING : int 197 deprecated 198 199 CAMERA_CONFIG : string 200 name of the file containing descriptive information about the camera 201 202 --- sample ConfigFile entries with typical values --- 203 204 MAG_LIM 24.0 205 SIGMA_LIM 0.05 206 STAR_SCATTER 0.05 207 IMAGE_SCATTER 0.05 208 IMAGE_OFFSET 0.2 209 STAR_CHISQ 10.0 210 STAR_TOOFEW 3 211 IMAGE_TOOFEW 10 212 IMAGE_GOOD_FRACTION 213 IMAGE_CATALOG $CATDIR/Images.dat 214 IMAGE_CATALOG_TEMPLATE $REFSDIR/elixir/template.cat 215 CATALOG_TEMPLATE $REFSDIR/elixir/template.cat 216 GSCFILE $REFSDIR/gsc/GSCregions.tbl 217 CATDIR $CATDIR 218 PHOTCODE_FILE $CONFDIR/camera/$CAMERA.photcode 219 ZERO_PT 25.0 220 RELPHOT_GRID_X 4 221 RELPHOT_GRID_Y 8 222 RELPHOT_GRID_BINNING 512 223 CAMERA_CONFIG $CONFDIR/camera/$CAMERA.config 224 </pre> -
trunk/Ohana/doc/www/html/Elixir-Tools/mosastro.htm
r5135 r5144 157 157 values are <tt>GSC, USNO, 2MASS, PTOLEMY, STONE</tt>. 158 158 159 <li> USNO_CDROM : directory where USNO data is stored160 <li> STONE_DIR : location of the Stone et al referencedata161 <li> 2MASS_DIR : location of the 2MASS data162 <li> CATDIR : location of the ptolemy data163 <li> GSCDIR : location of the HST Guide Star Catalog164 <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) 165 165 166 166 note that 'ptolemy' refers to data using the DVO format. 2MASS data 167 must be in a DVO format database. 167 must be in a DVO format database. USNO and GSC are both loaded from 168 their idiosyncratic formats. 168 169 169 170 <li> RADIUS : matching radius in arcsec to select reference stars … … 178 179 systematic error limit. 179 180 </ul> 180 181 </pre>182 183 184 185 186 187 188 -
trunk/Ohana/doc/www/html/download.htm
r4835 r5144 40 40 41 41 <ul> 42 <li><a href=download/tarballs/elixir-ohana-head.tgz>elixir-ohana-head.tgz </a> 42 43 <li><a href=download/tarballs/elixir-ohana-1.3.tgz>elixir-ohana-1.3.tgz </a> 43 44 <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 10 10 USE elixir 11 11 USE gastro 12 USE gastro2 12 13 USE gcompare 13 14 USE gophot -
trunk/Ohana/src/addstar/include/addstar.h
r5014 r5144 74 74 int XMIN, XMAX, YMIN, YMAX; 75 75 int ACCEPT_ASTROM; 76 int TEXTMODE; 76 77 77 78 PhotCode *thiscode; -
trunk/Ohana/src/addstar/src/ConfigInit.c
r4826 r5144 35 35 36 36 ScanConfig (config, "IMAGE_CATALOG", "%s", 0, ImageCat); 37 ScanConfig (config, "IMAGE_CATALOG_TEMPLATE", "%s", 0, ImageTemplate);38 ScanConfig (config, "CATALOG_TEMPLATE", "%s", 0, CatTemplate);39 37 ScanConfig (config, "GSCFILE", "%s", 0, GSCFILE); 40 38 ScanConfig (config, "CATDIR", "%s", 0, CATDIR); -
trunk/Ohana/src/addstar/src/args.c
r4538 r5144 183 183 remove_argument (N, &argc, argv); 184 184 } 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 } 185 191 /* extra error messages */ 186 192 VERBOSE = FALSE; -
trunk/Ohana/src/addstar/src/gstars.c
r5014 r5144 166 166 extend = FALSE; 167 167 fits_scan (&header, "EXTEND", "%t", 1, &extend); 168 if (extend ) {168 if (extend && !TEXTMODE) { 169 169 Nbytes = fits_matrix_size (&header); 170 170 fseek (f, Nbytes, SEEK_CUR); 171 171 rdstars = rfits (f, &image[0].nstar); 172 if (rdstars == NULL) { 173 fprintf (stderr, "ERROR: failed to read fits table\n"); 174 exit (1); 175 } 172 176 } else { 173 177 /* allocate space for stars */ -
trunk/Ohana/src/imregister/src/photcode.c
r2803 r5144 1 1 # include "imregister.h" 2 static char *version = "photcode $Revision: 3. 1$";2 static char *version = "photcode $Revision: 3.2 $"; 3 3 4 4 int main (int argc, char **argv) { … … 61 61 } 62 62 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); 64 64 ccd = 0; 65 65 } -
trunk/Ohana/src/libohana/src/LoadPhotcodes.c
r4865 r5144 485 485 486 486 int Np; 487 short M;487 float M; 488 488 489 489 Np = photcodes[0].hashcode[measure[0].source]; … … 672 672 673 673 int i, Ns; 674 short Mave, Mref, Mcol, mc;674 float Mave, Mref, Mcol, mc; 675 675 double Mc; 676 676 … … 697 697 698 698 int Ns; 699 short Mave;699 float Mave; 700 700 701 701 Ns = photcodes[0].hashNsec[code[0].code]; … … 708 708 709 709 int Ns; 710 short dM;710 float dM; 711 711 712 712 Ns = photcodes[0].hashNsec[code[0].code]; -
trunk/Ohana/src/opihi/dvo/Makefile
r4833 r5144 28 28 $(SDIR)/ImageSelection.$(ARCH).o \ 29 29 $(SDIR)/LoadImages.$(ARCH).o \ 30 $(SDIR)/cmpRead.$(ARCH).o \ 30 31 $(SDIR)/aregion.$(ARCH).o \ 31 32 $(SDIR)/compare.$(ARCH).o \ -
trunk/Ohana/src/opihi/dvo/cmpread.c
r4689 r5144 1 1 # include "dvo1.h" 2 # define D_NSTARS 1000 3 # define BYTES_STAR 66 4 # define BLOCK 1000 2 3 /* add others as needed */ 4 enum {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}; 5 5 6 6 int cmpread (int argc, char **argv) { 7 7 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; 13 11 FILE *f; 14 char *buffer; 15 int Nfield, Nra, Ndec; 16 Vector *rvec, *dvec, *vec; 12 Vector *vec; 17 13 Header header; 18 14 Coords coords; 15 CMPstars *stars; 19 16 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"); 23 19 return (FALSE); 24 20 } 25 21 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]); 48 37 return (FALSE); 49 38 } 50 39 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]); 58 45 return (FALSE); 59 46 } 60 47 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"); 62 58 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]); 66 60 fits_free_header (&header); 67 61 return (FALSE); … … 69 63 fseek (f, header.size, SEEK_SET); 70 64 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); 88 70 } 89 71 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); 102 86 } 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); 143 88 } 144 89 fclose (f); 145 90 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); 146 139 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); 152 141 return (TRUE); 153 142 } 154 -
trunk/Ohana/src/opihi/include/dvo1.h
r4805 r5144 22 22 double RA0, RA1, DEC0, DEC1; 23 23 } RegionFile; 24 25 typedef 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; 24 39 25 40 /*** dvo prototypes ***/ … … 73 88 void sort_images PROTO((Image *image, int N)); 74 89 void sortave PROTO((Average *ave, int N)); 90 CMPstars *cmpReadFits (FILE *f, int *nstars); 91 CMPstars *cmpReadText (FILE *f, int *nstars); 75 92 76 93 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
