Changeset 9645
- Timestamp:
- Oct 18, 2006, 5:03:42 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroLoadRefstars.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroLoadRefstars.c
r9627 r9645 2 2 // int mkstemp(char *template); 3 3 # define ELIXIR_MODE 1 4 # define PIPE_MODE 05 4 6 5 psArray *psastroLoadRefstars (pmConfig *config) { … … 8 7 int fd; 9 8 bool status; 10 char tempLine[256]; 9 char *catformat = NULL; 10 char *getstarLine = NULL; 11 11 12 12 // select the DVO database? … … 24 24 char *CATDIR = psMetadataLookupStr(NULL, recipe, "DVO.CATDIR"); 25 25 if (CATDIR == NULL) { 26 psLogMsg ("psastro", 2, "warning: missing DVO.CATDIR, using HOME/.ptolemyrc definition\n");26 psLogMsg ("psastro", 2, "warning: missing DVO.CATDIR, using ~/.ptolemyrc definition\n"); 27 27 } 28 28 29 // XXX need to add a padding area30 29 // issue the following command: 31 30 // getstar -region RAmin RAmax DECmin DECmax … … 34 33 sprintf (tempFile, "/tmp/psastro.XXXXXX"); 35 34 if ((fd = mkstemp (tempFile)) == -1) { 36 fprintf (stderr, "error creating temp output file\n");35 psError(PSASTRO_ERR_REFSTARS, true, "error creating temp output file\n"); 37 36 return NULL; 38 37 } … … 42 41 43 42 // use fork to add timeout capability 44 // use cfitsio |filename format to avoid tempFile 45 # if ELIXIR_MODE 43 if (ELIXIR_MODE) { 44 psStringAppend (&catformat, "-D CATFORMAT elixir "); 45 } else { 46 psStringAppend (&catformat, "-D CATFORMAT panstarrs "); 47 } 48 46 49 if (CATDIR) { 47 sprintf (tempLine, "getstar -D CATDIR %s -D CATFORMAT elixir -D CATMODE mef -maglim %f -region %f %f %f %f -o %s", CATDIR, MAGmax, RAmin, DECmin, RAmax, DECmax, tempFile); 48 } else { 49 sprintf (tempLine, "getstar -D CATFORMAT elixir -D CATMODE mef -maglim %f -region %f %f %f %f -o %s", MAGmax, RAmin, DECmin, RAmax, DECmax, tempFile); 50 } 51 # else 52 if (CATDIR) { 53 sprintf (tempLine, "getstar -D CATDIR %s -D CATFORMAT panstarrs -D CATMODE mef -maglim %f -region %f %f %f %f -o %s", CATDIR, MAGmax, RAmin, DECmin, RAmax, DECmax, tempFile); 54 } else { 55 sprintf (tempLine, "getstar -D CATFORMAT panstarrs -D CATMODE mef -maglim %f -region %f %f %f %f -o %s", MAGmax, RAmin, DECmin, RAmax, DECmax, tempFile); 56 } 57 # endif 50 psStringAppend (&catformat, "-D CATDIR %s ", CATDIR); 51 } 58 52 59 psTrace ("psastro", 3, "%s\n", tempLine); 60 status = system (tempLine); 53 psStringAppend (&getstarLine, "getstar %s -D CATMODE mef -maglim %f -region %f %f %f %f -o %s", catformat, MAGmax, RAmin, DECmin, RAmax, DECmax, tempFile); 54 psTrace ("psastro", 3, "%s\n", getstarLine); 55 56 // XXX use psPipe: catch stderr, stdout, allow for Nsec timeout... 57 status = system (getstarLine); 61 58 if (status) { 62 fprintf (stderr, "error loading reference data\n");59 psError(PSASTRO_ERR_REFSTARS, true, "error loading reference data\n"); 63 60 return NULL; 64 61 } 62 psFree (getstarLine); 63 psFree (catformat); 65 64 66 65 psLogMsg ("psastro", 3, "ran getstar : %f sec\n", psTimerMark ("psastro")); … … 69 68 psFits *fits = psFitsOpen (tempFile, "r"); 70 69 71 # if ELIXIR_MODE72 psFitsMoveExtName (fits, "DVO_AVERAGE_ELIXIR");73 # else74 psFitsMoveExtName (fits, "DVO_AVERAGE_PANSTARRS");75 # endif70 if (ELIXIR_MODE) { 71 psFitsMoveExtName (fits, "DVO_AVERAGE_ELIXIR"); 72 } else { 73 psFitsMoveExtName (fits, "DVO_AVERAGE_PANSTARRS"); 74 } 76 75 77 76 psTimerStart ("psastro"); … … 92 91 93 92 // DVO tables are stored in degrees 94 # if ELIXIR_MODE 95 ref->sky->r = RAD_DEG*psMetadataLookupF32 (&status, row, "RA");96 ref->sky->d = RAD_DEG*psMetadataLookupF32 (&status, row, "DEC");97 ref->Mag = 0.001*psMetadataLookupS32 (&status, row, "MAG"); // XXX ELIXIR uses millimags, PANSTARRS usesmags98 # else99 ref->sky->r = RAD_DEG*psMetadataLookupF64 (&status, row, "RA");100 ref->sky->d = RAD_DEG*psMetadataLookupF64 (&status, row, "DEC");101 ref->Mag = psMetadataLookupF32 (&status, row, "MAG"); 102 # endif 93 if (ELIXIR_MODE) { 94 ref->sky->r = RAD_DEG*psMetadataLookupF32 (&status, row, "RA"); 95 ref->sky->d = RAD_DEG*psMetadataLookupF32 (&status, row, "DEC"); 96 ref->Mag = 0.001*psMetadataLookupS32 (&status, row, "MAG"); // ELIXIR uses millimags 97 } else { 98 ref->sky->r = RAD_DEG*psMetadataLookupF64 (&status, row, "RA"); 99 ref->sky->d = RAD_DEG*psMetadataLookupF64 (&status, row, "DEC"); 100 ref->Mag = psMetadataLookupF32 (&status, row, "MAG"); // PANSTARRS uses mags 101 } 103 102 104 103 psArrayAdd (refs, 100, ref); … … 114 113 return refs; 115 114 } 116 117 // XXX this function needs clarifiction of the getstar output format
Note:
See TracChangeset
for help on using the changeset viewer.
