Changeset 7693
- Timestamp:
- Jun 26, 2006, 9:43:18 AM (20 years ago)
- Location:
- trunk/Ohana/src/addstar
- Files:
-
- 1 added
- 5 edited
-
include/sedstar.h (modified) (1 diff)
-
src/SEDfit.c (added)
-
src/SEDops.c (modified) (1 diff)
-
src/SEDtableLoad.c (modified) (5 diffs)
-
src/args_sedstar.c (modified) (4 diffs)
-
src/sedstar.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/include/sedstar.h
r7690 r7693 1 2 typedef structu { 3 int Nfilter; 4 float *wavecode; 5 float *vegaToAB; 6 int *hashcode; 7 int codeP; 8 int codeM; 9 SEDtableRow **row; 10 int Nrow; 11 } SEDtable; 1 12 2 13 typedef struct { -
trunk/Ohana/src/addstar/src/SEDops.c
r7690 r7693 1 # include "addstar.h" 2 # include "sedstar.h" 1 3 2 4 // fit the data (with errors) to the given table row -
trunk/Ohana/src/addstar/src/SEDtableLoad.c
r7690 r7693 2 2 # include "sedstar.h" 3 3 4 SEDtable *SEDtableLoad (char *filename, int *nrow) { 4 // XXX where do the colorP and colorM codes come from? 5 SEDtable *SEDtableLoad (char *filename) { 5 6 6 7 FILE *f; 8 char line[1024], name[64]; 9 char colornameP[64], colornameM[64]; 10 int colorP, colorM; 11 int i, Nrow, NROW; 12 13 ALLOCATE (table, SEDtable, 1); 7 14 8 15 // load SED table … … 12 19 // XXX add error checks for header data 13 20 scan_line (f, line); 14 sscanf (line, "%*s %*s %d", & Nfilter);21 sscanf (line, "%*s %*s %d", &table[0].Nfilter); 15 22 16 23 // load SED table photcodes, generate the photcode hashtable 17 ALLOCATE ( hashcode, int, 0x10000);18 ALLOCATE ( wavecode, float,Nfilter);19 ALLOCATE ( vegaToAB, float,Nfilter);24 ALLOCATE (table[0].hashcode, int, 0x10000); 25 ALLOCATE (table[0].wavecode, float, table[0].Nfilter); 26 ALLOCATE (table[0].vegaToAB, float, table[0].Nfilter); 20 27 21 for (i = 0; i < 0x10000; i++) hashcode[i] = -1;22 for (i = 0; i < Nfilter; i++) {28 for (i = 0; i < 0x10000; i++) table[0].hashcode[i] = -1; 29 for (i = 0; i < table[0].Nfilter; i++) { 23 30 scan_line (f, line); 24 sscanf (line, "%*s %s %f %f", name, & wavecode[i], &vegaToAB[i]);31 sscanf (line, "%*s %s %f %f", name, &table[0].wavecode[i], &table[0].vegaToAB[i]); 25 32 code = GetPhotcodeCodebyName (name); 26 33 if (code == 0) goto code_missing; 27 hashcode[code] = i;34 table[0].hashcode[code] = i; 28 35 } 29 codeP = hashcode[colorP]; 30 codeM = hashcode[colorM]; 31 if ((codeP == -1) || (codeM == -1)) goto color_missing; 36 37 // define the selection color codes 38 sscanf (line, "# %s - %s", colornameP, colornameM); 39 colorP = GetPhotcodeCodebyName (colornameP); 40 colorM = GetPhotcodeCodebyName (colornameM); 41 table[0].codeP = table[0].hashcode[colorP]; 42 table[0].codeM = table[0].hashcode[colorM]; 43 if (table[0].codeP == -1) Shutdown ("missing positive color filter"); 44 if (table[0].codeM == -1) Shutdown ("missing positive color filter"); 32 45 33 46 // skip remaining header lines … … 37 50 scan_line (f, line); 38 51 39 // load the SED table data52 // load the SED raw table rows 40 53 Nrow = 0; 41 54 NROW = 100; … … 44 57 fparse (&SEDtableRaw[Nrow].Temp, 1, line); 45 58 fparse (&SEDtableRaw[Nrow].Av, 2, line); 46 ALLOCATE (SEDtableRaw[Nrow].mags, float, Nfilter);47 for (i = 0; i < Nfilter; i++) {59 ALLOCATE (SEDtableRaw[Nrow].mags, float, table[0].Nfilter); 60 for (i = 0; i < table[0].Nfilter; i++) { 48 61 fparse (&SEDtableRaw[Nrow].mags[i], i + 3, line); 49 62 } … … 54 67 55 68 // sort the SEDtable by the reference colors 56 SEDtable = sort_SEDtable (SEDtableRaw, Nrow); 69 table[0].row = sort_SEDtable (SEDtableRaw, Nrow); 70 table[0].Nrow = Nrow; 71 return (table); 72 } -
trunk/Ohana/src/addstar/src/args_sedstar.c
r7690 r7693 34 34 remove_argument (N, &argc, argv); 35 35 } 36 /* override any header PHOTCODE values */37 options.photcode = 0;38 if ((N = get_argument (argc, argv, "-p"))) {39 remove_argument (N, &argc, argv);40 options.photcode = GetPhotcodeCodebyName (argv[N]);41 remove_argument (N, &argc, argv);42 }43 36 44 options.timeref = 0;45 options.mosaic = FALSE;46 options.existing_regions = FALSE;47 options.skip_missed = FALSE;48 options.closest = FALSE;49 50 /* only add to existing objects */51 options.only_match = FALSE;52 if ((N = get_argument (argc, argv, "-only-match"))) {53 options.only_match = TRUE;54 remove_argument (N, &argc, argv);55 }56 /* replace measurement, don't duplicate (ref/cat only) */57 options.replace = FALSE;58 if ((N = get_argument (argc, argv, "-replace"))) {59 options.replace = TRUE;60 remove_argument (N, &argc, argv);61 }62 63 /* select quality flags */64 SELECT_2MASS_QUALITY = NULL;65 if ((N = get_argument (argc, argv, "-2massquality"))) {66 remove_argument (N, &argc, argv);67 SELECT_2MASS_QUALITY = strcreate (argv[N]);68 remove_argument (N, &argc, argv);69 }70 37 /* extra error messages */ 71 38 VERBOSE = FALSE; … … 76 43 77 44 /* other defaults */ 45 options.timeref = 0; 46 options.mosaic = FALSE; 47 options.existing_regions = FALSE; 48 options.skip_missed = FALSE; 49 options.closest = FALSE; 50 options.only_match = FALSE; 51 options.replace = FALSE; 78 52 options.nosort = FALSE; 79 53 options.update = FALSE; … … 87 61 DUMP = NULL; 88 62 89 if (argc != 1) {90 fprintf (stderr, "USAGE: load2mass\n");63 if (argc != 3) { 64 fprintf (stderr, "USAGE: sedstar (sedtable) (outcatalog) [-region Rmin Rmax Dmin Dmax]\n"); 91 65 exit (2); 92 66 } … … 97 71 98 72 fprintf (stderr, "USAGE\n"); 99 fprintf (stderr, " load2mass");100 fprintf (stderr, " add data from 2MASS catalog to fullsky\n\n");73 fprintf (stderr, " sedstar (SEDtable)"); 74 fprintf (stderr, " fit objects to stellar SEDs\n\n"); 101 75 102 76 fprintf (stderr, " optional flags:\n"); 103 fprintf (stderr, " -p (photcode) : specify photcode (override header)\n"); 104 fprintf (stderr, " -only-match : only add measurements to existing objects\n"); 105 fprintf (stderr, " -replace : replace time/photcode measurements (no duplication)\n"); 77 fprintf (stderr, " -region Rmin Rmax Dmin Dmax : sky region for analysis\n"); 106 78 fprintf (stderr, " -v : verbose mode\n"); 107 79 fprintf (stderr, " -help : this list\n"); -
trunk/Ohana/src/addstar/src/sedstar.c
r7690 r7693 7 7 SkyTable *sky, *sky2mass; 8 8 AddstarClientOptions options; 9 Catalog incatalog, outcatalog; 9 10 10 11 // need to construct these options with args_load2mass... … … 16 17 17 18 // select regions of interest 19 skylist = SkyListByPatch (sky, -1, &UserPatch); 18 20 19 21 // load the SED data table 20 sedtable = SEDtableLoad ( SEDfile, &Nsedtable);22 sedtable = SEDtableLoad (argv[1]); 21 23 24 for (i = 0; i < skylist[0].Nregions; i++) { 25 incatalog.filename = skylist[0].filename[i]; 26 load_pt_catalog (&incatalog, skylist[0].regions[i]); 27 28 // create output catalog filename 29 root = strstr (incatalog.filename, CATDIR); 30 if (root == NULL) Shutdown ("error with input catalog name"); 31 32 extension = incatalog.filename + strlen(CATDIR); 33 ALLOCATE (outcatalog.filename, char, strlen(argv[2]) + strlen(extension) + 2); 34 sprintf (outcatalog.filename, "%s/%s", argv[2], extension); 35 36 status = lock_catalog (outcatalog, LCK_XCLD); 37 if (status != 2) Shutdown ("error: output catalog exists"); 38 mkcatalog (region, catalog); /* fills in new header info */ 39 40 SEDfit (&outcatalog, &incatalog, sedtable); 41 42 wcatalog (outcatalog); 43 unlock_catalog (outcatalog); 44 free (outcatalog.filename); 45 } 22 46 23 47 exit (0);
Note:
See TracChangeset
for help on using the changeset viewer.
