Changeset 6675
- Timestamp:
- Mar 24, 2006, 3:19:05 PM (20 years ago)
- Location:
- trunk/Ohana/src/addstar
- Files:
-
- 3 added
- 5 edited
-
Makefile (modified) (2 diffs)
-
include/addstar.h (modified) (3 diffs)
-
src/ConfigInit.c (modified) (1 diff)
-
src/SkyTableFromTychoIndex.c (added)
-
src/gettycho.c (added)
-
src/getusno.c (modified) (5 diffs)
-
src/getusnob.c (added)
-
src/greference.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/Makefile
r6674 r6675 40 40 $(SRC)/get2mass_dr2.$(ARCH).o \ 41 41 $(SRC)/getgsc.$(ARCH).o \ 42 $(SRC)/gettycho.$(ARCH).o \ 42 43 $(SRC)/getusno.$(ARCH).o \ 44 $(SRC)/getusnob.$(ARCH).o \ 43 45 $(SRC)/gimages.$(ARCH).o \ 44 46 $(SRC)/greference.$(ARCH).o \ … … 58 60 $(SRC)/wcatalog.$(ARCH).o \ 59 61 $(SRC)/Shutdown.$(ARCH).o \ 62 $(SRC)/SkyTableFromTychoIndex.$(ARCH).o \ 60 63 $(SRC)/SkyRegionUtils.$(ARCH).o \ 61 64 $(SRC)/SkyListForStars.$(ARCH).o \ -
trunk/Ohana/src/addstar/include/addstar.h
r6674 r6675 44 44 char TWO_MASS_DIR_DR2[256]; 45 45 char GSCDIR[256]; 46 char CDROM[256]; 46 char USNO_A_DIR[256]; 47 char USNO_B_DIR[256]; 48 char TYCHO_DIR[256]; 47 49 char SubpixDatafile[256]; 48 50 char PASSWORD[80]; … … 110 112 float airmass PROTO((float secz_image, double ra, double dec, double st, double latitude)); 111 113 void SetAirmassQuality PROTO((int quality)); 114 SkyTable *SkyTableFromTychoIndex PROTO((char *filename, int VERBOSE)); 112 115 AddstarClientOptions args PROTO((int argc, char **argv, AddstarClientOptions options)); 113 116 void check_permissions PROTO((char *basefile)); … … 122 125 double get_subpix PROTO((double x, double y)); 123 126 Stars *getgsc PROTO((SkyRegion *patch, int *NSTARS)); 127 Stars *gettycho PROTO((SkyRegion *catstats, int photcode, double epoch, int *Nstars)); 124 128 Stars *getusno PROTO((SkyRegion *catstats, int photcode, int *Nstars)); 129 Stars *getusnob PROTO((SkyRegion *catstats, int photcode, double epoch, int *Nstars)); 125 130 Image *gimages PROTO((FITS_DB *db, Image *image, Coords *mosaic, int *Npimage)); 126 131 Stars *grefcat PROTO((char *Refcat, SkyRegion *catstats, int photcode, int *nstars)); -
trunk/Ohana/src/addstar/src/ConfigInit.c
r5585 r6675 52 52 ScanConfig (config, "2MASS_DIR_DR2", "%s", 0, TWO_MASS_DIR_DR2); 53 53 ScanConfig (config, "GSCDIR", "%s", 0, GSCDIR); 54 ScanConfig (config, "USNO_CDROM", "%s", 0, CDROM); 54 55 if (!ScanConfig (config, "USNO_A_DIR", "%s", 0, USNO_A_DIR)) { 56 ScanConfig (config, "USNO_CDROM", "%s", 0, USNO_A_DIR); 57 } 58 ScanConfig (config, "USNO_B_DIR", "%s", 0, USNO_B_DIR); 59 60 ScanConfig (config, "TYCHO_DIR", "%s", 0, TYCHO_DIR); 55 61 56 62 ScanConfig (config, "IMAGE_CATALOG", "%s", 0, ImageCat); -
trunk/Ohana/src/addstar/src/getusno.c
r5443 r6675 1 1 # include "addstar.h" 2 2 # define NZONE 24 3 # define NBYTE 4 4 # define NELEM 3 3 5 4 int SPDzone[] = { 5 0, 75, 450, 375, 1500, 1650, 300, 1425, 1725, 525, 1275, 225, 6 675, 150, 600, 1575, 750, 975, 900, 1050, 1125, 1200, 825, 1350}; 7 8 int USNOdisk[] = { 9 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10}; 10 11 Stars *getusno (SkyRegion *catstats, int photcode, int *Nstars) { 6 Stars *getusno (SkyRegion *catstats, int photcode, int *nstars) { 12 7 13 8 long int offset; 14 int i, bin, first, last, nitems, Nitems, Nbins ;9 int i, bin, first, last, nitems, Nitems, Nbins, Nstars; 15 10 float hours[100]; 16 11 int start[100], number[100], *buffer, *buf; 17 char filename[128] , c;12 char filename[128]; 18 13 FILE *f; 19 14 int iRA0, iRA1, iDEC0, iDEC1; 20 15 double dec; 21 int spd, spd_start, spd_end , disk;16 int spd, spd_start, spd_end; 22 17 int NUSNO, Nusno; 23 18 Stars *stars; … … 53 48 54 49 for (spd = spd_start; spd < spd_end; spd += 75) { 55 disk = -1;56 for (i = 0; i < NZONE; i++) {57 if (spd == SPDzone[i])58 disk = USNOdisk[i];59 }60 if (disk < 0) {61 fprintf (stderr, "ERROR: can't find cdrom for spd %d\n", spd);62 exit (1);63 }64 50 65 51 /* load accelerator file */ 66 sprintf (filename, "%s/zone%04d.acc", CDROM, spd);52 sprintf (filename, "%s/zone%04d.acc", USNO_A_DIR, spd); 67 53 if (VERBOSE) fprintf (stderr, "reading from %s\n", filename); 68 54 f = fopen (filename, "r"); 69 55 if (f == (FILE *) NULL) { 70 fprintf (stderr, "can't open file %s, is cdrom %d in drive?\n", filename, disk); 71 fprintf (stderr, "press return when ready to continue: "); 72 fscanf (stdin, "%c", &c); 73 fprintf (stderr, "trying again...\n"); 74 f = fopen (filename, "r"); 75 if (f == (FILE *) NULL) { 76 fprintf (stderr, "ERROR: can't open file %s, is cdrom %d in drive?\n", filename, disk); 77 exit (1); 78 } 56 fprintf (stderr, "ERROR: can't open accelerator file %s\n", filename); 57 exit (1); 79 58 } 80 59 for (i = 0; fscanf (f, "%f %d %d", &hours[i], &start[i], &number[i]) != EOF; i++); … … 94 73 95 74 /* open data file */ 96 sprintf (filename, "%s/zone%04d.cat", CDROM, spd);75 sprintf (filename, "%s/zone%04d.cat", USNO_A_DIR, spd); 97 76 if (VERBOSE) fprintf (stderr, "reading from %s\n", filename); 98 77 f = fopen (filename, "r"); … … 101 80 exit (1); 102 81 } 82 83 /** USNO-A consists of 3 x 4byte (int) records **/ 103 84 /* advance file pointer to first slice */ 104 offset = 3*sizeof(int)*(start[first] - 1);85 offset = NELEM*NBYTE*(start[first] - 1); 105 86 fseek (f, offset, SEEK_SET); 106 /* on each loop, load data from an RA slice of the catalog */ 87 88 /* sum the number of stars in data segment of interest */ 89 Nstars = 0; 107 90 for (bin = first; bin < last; bin++) { 108 Nitems = 3*number[bin]; 109 ALLOCATE (buffer, int, Nitems); 110 nitems = Fread (buffer, sizeof(int), Nitems, f, "int"); 111 if (nitems != Nitems) { 112 fprintf (stderr, "ERROR: failure reading data from file %s\n", filename); 113 exit (1); 91 Nstars += number[bin]; 92 } 93 Nitems = NELEM*Nstars; 94 /* number of blocks to read -- we need to use Fread for byte-swapping read */ 95 96 /* read stars from catalog */ 97 ALLOCATE (buffer, int, Nitems); 98 nitems = Fread (buffer, NBYTE, Nitems, f, "int"); 99 if (nitems != Nitems) { 100 fprintf (stderr, "ERROR: failure reading data from file %s\n", filename); 101 exit (1); 102 } 103 104 /* extract the data of interest from segment (in RA and DEC range) */ 105 buf = buffer; 106 for (i = 0; i < Nstars; i++, buf += NELEM) { 107 if (buf[0] < iRA0) continue; 108 if (buf[0] > iRA1) continue; 109 if (buf[1] < iDEC0) continue; 110 if (buf[1] > iDEC1) continue; 111 112 bzero (&stars[Nusno], sizeof(Stars)); 113 stars[Nusno].R = buf[0]/360000.0; 114 stars[Nusno].D = buf[1]/360000.0 - 90.0; 115 stars[Nusno].dM = NO_ERR; 116 stars[Nusno].t = 0; 117 stars[Nusno].found = -1; 118 119 /* one pass of addstar does either r or b */ 120 if (photcode == USNO_RED) { 121 stars[Nusno].code = USNO_RED; 122 stars[Nusno].M = fabs (0.1*(buf[2] - 1000*((int)(buf[2]/1000)))); 123 } 124 if (photcode == USNO_BLUE) { 125 stars[Nusno].code = USNO_BLUE; 126 stars[Nusno].M = fabs (0.1*((int)(buf[2] - 1000000*((int)(buf[2]/1000000))) / 1000)); 114 127 } 115 buf = buffer; 116 /* print out data from slice within RA and DEC range */ 117 for (i = 0; i < number[bin]; i++, buf+=3) { 118 if (buf[0] < iRA0) continue; 119 if (buf[0] > iRA1) continue; 120 if (buf[1] < iDEC0) continue; 121 if (buf[1] > iDEC1) continue; 122 123 bzero (&stars[Nusno], sizeof(Stars)); 124 stars[Nusno].R = buf[0]/360000.0; 125 stars[Nusno].D = buf[1]/360000.0 - 90.0; 126 stars[Nusno].dM = NO_ERR; 127 stars[Nusno].t = 0; 128 stars[Nusno].found = -1; 129 130 /* one pass of addstar does either r or b */ 131 if (photcode == USNO_RED) { 132 stars[Nusno].code = USNO_RED; 133 stars[Nusno].M = fabs (0.1*(buf[2] - 1000*((int)(buf[2]/1000)))); 134 } 135 if (photcode == USNO_BLUE) { 136 stars[Nusno].code = USNO_BLUE; 137 stars[Nusno].M = fabs (0.1*((int)(buf[2] - 1000000*((int)(buf[2]/1000000))) / 1000)); 138 } 139 Nusno ++; 140 CHECK_REALLOCATE (stars, Stars, NUSNO, Nusno, 5000); 141 } 142 free (buffer); 128 Nusno ++; 129 CHECK_REALLOCATE (stars, Stars, NUSNO, Nusno, 5000); 143 130 } 131 free (buffer); 144 132 fclose (f); 145 133 } 134 REALLOCATE (stars, Stars, Nusno); 146 135 147 * Nstars = Nusno;136 *nstars = Nusno; 148 137 if (VERBOSE) fprintf (stderr, "%d stars from USNO 1.0\n", Nusno); 149 138 return (stars); … … 151 140 152 141 142 143 144 /* these entries are legacy code incase you want to read from one of the USNO CDRoms 145 int SPDzone[] = {0, 75, 450, 375, 1500, 1650, 300, 1425, 1725, 525, 1275, 225, 675, 150, 600, 1575, 750, 975, 900, 1050, 1125, 1200, 825, 1350}; 146 int USNOdisk[] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10}; 147 148 disk = -1; 149 for (i = 0; i < NZONE; i++) { 150 if (spd == SPDzone[i]) 151 disk = USNOdisk[i]; 152 } 153 if (disk < 0) { 154 fprintf (stderr, "ERROR: can't find cdrom for spd %d\n", spd); 155 exit (1); 156 } 157 158 */ 159 -
trunk/Ohana/src/addstar/src/greference.c
r5443 r6675 17 17 if (!strcasecmp (Refcat, "USNO")) { 18 18 stars = getusno (region, photcode, &Nstars); 19 } 20 21 /* get stars from the USNO B catalog for the given region */ 22 if (!strcasecmp (Refcat, "USNOB")) { 23 stars = getusnob (region, photcode, 2000.0, &Nstars); 24 } 25 26 /* get stars from the USNO B catalog for the given region */ 27 if (!strcasecmp (Refcat, "TYCHO")) { 28 stars = gettycho (region, photcode, 2000.0, &Nstars); 19 29 } 20 30
Note:
See TracChangeset
for help on using the changeset viewer.
