Changeset 4805
- Timestamp:
- Aug 16, 2005, 6:41:16 PM (21 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 18 edited
-
addstar/Makefile (modified) (1 diff)
-
addstar/include/addstar.h (modified) (2 diffs)
-
addstar/src/conversions.c (modified) (2 diffs)
-
delstar/Makefile (modified) (1 diff)
-
delstar/include/delstar.h (modified) (1 diff)
-
delstar/src/convert.c (modified) (7 diffs)
-
libohana/Makefile (modified) (1 diff)
-
libohana/include/ohana.h (modified) (1 diff)
-
mosastro/include/mosastro.h (modified) (1 diff)
-
opihi/include/convert.h (modified) (2 diffs)
-
opihi/include/dvo1.h (modified) (1 diff)
-
opihi/lib.data/Makefile (modified) (1 diff)
-
opihi/lib.data/convert.c (modified) (5 diffs)
-
relphot/Makefile (modified) (1 diff)
-
relphot/include/relphot.h (modified) (2 diffs)
-
relphot/src/get_regions.c (modified) (1 diff)
-
relphot/src/misc.c (modified) (1 diff)
-
relphot/src/time.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/Makefile
r4299 r4805 28 28 $(SRC)/check_permissions.$(ARCH).o \ 29 29 $(SRC)/ConfigInit.$(ARCH).o \ 30 $(SRC)/conversions.$(ARCH).o \31 30 $(SRC)/dump.$(ARCH).o \ 32 31 $(SRC)/edge_check.$(ARCH).o \ -
trunk/Ohana/src/addstar/include/addstar.h
r4538 r4805 106 106 time_t TIMEREF; 107 107 108 int main (int argc, char **argv); 109 int Shutdown (char *message, ...); 110 void TrapSignal (int sig); 111 int SetSignals (); 112 void help (); 113 int args (int argc, char **argv); 114 void SetProtect (int mode); 108 /*** addstar prototypes ***/ 109 void AddToCalibration PROTO((Average *average, Measure *measure, Measure *new, int Nstar)); 110 void ConfigInit PROTO((int *argc, char **argv)); 111 void FindCalibration PROTO((Image *image)); 112 int FindDecBand PROTO((double dec, double *DEC0, double *DEC1)); 113 int FindRegionByPoint PROTO((GSCRegion *regions, double ra, double dec, GSCRegion *gsc, int Ngsc)); 114 int FindRegionDecBandStart PROTO((GSCRegion *region, int Nregion, double dec)); 115 int FindRegionDecBandStop PROTO((GSCRegion *region, int Nregion, double dec)); 116 FILE *GetDB PROTO((int *state)); 117 void InitCalibration PROTO(()); 118 GSCRegion *LoadRegions PROTO((int *nregions)); 119 void SaveCalibration PROTO((float M, float dM, float Mr, float dMr, float Mc, float A, int N)); 120 void SetProtect PROTO((int mode)); 121 int SetSignals PROTO(()); 122 int Shutdown PROTO((char *message, ...); ) 123 void TrapSignal PROTO((int sig)); 124 short airmass PROTO((short secz_image, double ra, double dec, double st, double latitude)); 125 void aregion PROTO((GSCRegion *region, FILE *f, double ra, double dec)); 126 int args PROTO((int argc, char **argv)); 127 void check_permissions PROTO((char *basefile)); 128 int dump_rawstars PROTO((Stars *stars, int Nstars)); 129 int edge_check PROTO((double *x1, double *y1, double *x2, double *y2)); 130 void find_matches PROTO((GSCRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap)); 131 void find_matches_refstars PROTO((GSCRegion *region, Stars **stars, int Nstars, Catalog *catalog)); 132 Stars **find_subset PROTO((GSCRegion *region, Stars *stars, int Nstars, int *NSTARS)); 133 int gcatalog PROTO((Catalog *catalog)); 134 Stars *get2mass PROTO((GSCRegion *patch, int *NSTARS, int mode)); 135 double get_subpix PROTO((double x, double y)); 136 Stars *getgsc PROTO((GSCRegion *patch, int *NSTARS)); 137 Stars *getusno PROTO((GSCRegion *catstats, int *Nstars)); 138 Image *gimages PROTO((Image *image, int *Npimage)); 139 Stars *grefcat PROTO((char *Refcat, GSCRegion *catstats, int *nstars)); 140 Stars *grefstars PROTO((char *file, int *Nstars)); 141 GSCRegion *gregion_image PROTO((Image *image, int *Nregions)); 142 GSCRegion *gregion_match PROTO((GSCRegion *regions, int *nregions)); 143 GSCRegion *gregion_patch PROTO((GSCRegion *patch, int *nregions)); 144 void gregion_star PROTO((Stars *star, GSCRegion *region)); 145 GSCRegion *gregion_stars PROTO((Stars *stars, int Nstars, int *Nregion)); 146 GSCRegion *gregions PROTO((Image *image, int *Nregions)); 147 Stars *gstars PROTO((char *file, int *NSTARS, Image *image)); 148 void help PROTO(()); 149 int hms_to_deg PROTO((double *h0, double *h1, double *d0, double *d1, char *string)); 150 int in_image PROTO((double r, double d, Image *image)); 151 int load_pt_catalog PROTO((Catalog *catalog, GSCRegion *region)); /*** choose new name ***/ 152 void load_subpix PROTO(()); 153 void lock_image_db PROTO(()); 154 int main PROTO((int argc, char **argv)); 155 void make_backup PROTO((char *filename)); 156 int match_refstars PROTO((Stars *stars, int Nstars)); 157 void mkcatalog PROTO((GSCRegion *region, Catalog *catalog)); 158 double opening_angle PROTO((double x1, double y1, double x2, double y2, double x3, double y3)); 159 int parse_time PROTO((Header *header)); 160 Stars *rd_gsc PROTO((char *filename, int *nstars)); 161 int replace_match PROTO((Average *average, Measure *measure, Stars *star)); 162 Stars *rfits PROTO((FILE *f, int *nstars)); 163 Stars *rtext PROTO((FILE *f, int *nstars)); 164 void save_pt_catalog PROTO((Catalog *catalog)); /*** choose new name ***/ 165 double scat_subpix PROTO((double x, double y)); 166 time_t short_date_to_sec PROTO((char *date)); 167 void sort_lists PROTO((float *X, float *Y, int *S, int N)); 168 void sort_regions PROTO((GSCRegion *region, int N)); 169 void sort_stars PROTO((Stars *stars, int N)); 170 int str_to_radec PROTO((double *ra, double *dec, char *str1, char *str2)); 171 void unlock_image_db PROTO((Image *image)); 172 void update_coords PROTO((Average *average, Measure *measure, int *next)); 173 void wcatalog PROTO((Catalog *catalog)); 174 void wimage PROTO((Image *image)); 115 175 116 int gcatalog (Catalog *catalog); 117 void gregion_star (Stars *star, GSCRegion *region); 118 GSCRegion *gregion_image (Image *image, int *Nregions); 119 int edge_check (double *x1, double *y1, double *x2, double *y2); 120 double opening_angle (double x1, double y1, double x2, double y2, double x3, double y3); 121 Stars *gstars (char *file, int *NSTARS, Image *image); 122 int in_image (double r, double d, Image *image); 123 void wcatalog (Catalog *catalog); 124 void ConfigInit (int *argc, char **argv); 125 void aregion (GSCRegion *region, FILE *f, double ra, double dec); 126 short airmass (short secz_image, double ra, double dec, double st, double latitude); 127 void InitCalibration (); 128 void FindCalibration (Image *image); 129 double get_subpix (double x, double y); 130 void load_subpix (); 131 double scat_subpix (double x, double y); 132 void mkcatalog (GSCRegion *region, Catalog *catalog); 133 Stars *grefstars (char *file, int *Nstars); 134 Stars **find_subset (GSCRegion *region, Stars *stars, int Nstars, int *NSTARS); 135 int match_refstars (Stars *stars, int Nstars); 136 int parse_time (Header *header); 137 138 void check_permissions (char *basefile); 139 void make_backup (char *filename); 140 void uppercase (char *string); 141 142 void sort_lists (float *X, float *Y, int *S, int N); 143 void fsort (float *X, int N); 144 void fsort2 (float *X, float *Y, int N); 145 void sort_stars (Stars *stars, int N); 146 void sort_regions (GSCRegion *region, int N); 147 148 char *sec_to_date (time_t second); 149 double sec_to_jd (time_t second); 150 int chk_time (char *line); 151 int dms_to_ddd (double *Value, char *string); 152 int hms_to_deg (double *h0, double *h1, double *d0, double *d1, char *string); 153 int str_to_dtime (char *line, double *second); 154 int str_to_radec (double *ra, double *dec, char *str1, char *str2); 155 int str_to_time (char *line, time_t *second); 156 time_t jd_to_sec (double jd); 157 time_t date_to_sec (char *date); 158 time_t short_date_to_sec (char *date); 159 176 void uppercase PROTO((char *string)); 177 void fsort PROTO((float *X, int N)); 178 void fsort2 PROTO((float *X, float *Y, int N)); 160 179 161 180 /** … … 168 187 **/ 169 188 170 Stars *get2mass (GSCRegion *patch, int *NSTARS, int mode);171 GSCRegion *gregion_stars (Stars *stars, int Nstars, int *Nregion);172 Stars *grefstars (char *file, int *Nstars);173 GSCRegion *LoadRegions (int *nregions);174 int FindRegionByPoint (GSCRegion *regions, double ra, double dec, GSCRegion *gsc, int Ngsc);175 int FindRegionDecBandStart (GSCRegion *region, int Nregion, double dec);176 int FindRegionDecBandStop (GSCRegion *region, int Nregion, double dec);177 int FindDecBand (double dec, double *DEC0, double *DEC1);178 179 int hms_to_deg (double *h0, double *h1, double *d0, double *d1, char *string);180 void find_matches_refstars (GSCRegion *region, Stars **stars, int Nstars, Catalog *catalog);181 Stars *gstars (char *file, int *NSTARS, Image *image);182 void find_matches (GSCRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap);183 Stars *getusno (GSCRegion *catstats, int *Nstars);184 Stars *rd_gsc (char *filename, int *nstars);185 Stars *getgsc (GSCRegion *patch, int *NSTARS);186 Stars *grefcat (char *Refcat, GSCRegion *catstats, int *nstars);187 void load_subpix ();188 double get_subpix (double x, double y);189 double scat_subpix (double x, double y);190 void help ();191 int args (int argc, char **argv);192 void InitCalibration ();193 void SaveCalibration (float M, float dM, float Mr, float dMr, float Mc, float A, int N);194 void AddToCalibration (Average *average, Measure *measure, Measure *new, int Nstar);195 void FindCalibration (Image *image);196 int load_pt_catalog (Catalog *catalog, GSCRegion *region); /*** choose new name ***/197 void save_pt_catalog (Catalog *catalog); /*** choose new name ***/198 void wcatalog (Catalog *catalog);199 GSCRegion *gregions (Image *image, int *Nregions);200 int gcatalog (Catalog *catalog);201 GSCRegion *gregion_image (Image *image, int *Nregions);202 void update_coords (Average *average, Measure *measure, int *next);203 int replace_match (Average *average, Measure *measure, Stars *star);204 FILE *GetDB (int *state);205 void lock_image_db ();206 void unlock_image_db (Image *image);207 void wimage (Image *image);208 Image *gimages (Image *image, int *Npimage);209 double opening_angle (double x1, double y1, double x2, double y2, double x3, double y3);210 int edge_check (double *x1, double *y1, double *x2, double *y2);211 GSCRegion *gregion_match (GSCRegion *regions, int *nregions);212 GSCRegion *gregion_patch (GSCRegion *patch, int *nregions);213 int dump_rawstars (Stars *stars, int Nstars);214 Stars *rfits (FILE *f, int *nstars);215 Stars *rtext (FILE *f, int *nstars);216 -
trunk/Ohana/src/addstar/src/conversions.c
r3376 r4805 1 1 # include "addstar.h" 2 2 3 enum {TIME_NONE, TIME_DATE, TIME_HOURS, TIME_DAYS, TIME_JD, TIME_MJD, TIME_SEC}; 4 5 # define FORMAT_DAYS 1 6 # define FORMAT_HOURS 2 7 # define FORMAT_MINUTES 3 8 # define FORMAT_SECONDS 4 9 # define FORMAT_JD 5 10 # define FORMAT_DATE 6 3 11 4 12 /***** convert [-]00:00:00 to 0.0000 ****/ … … 86 94 return (TRUE); 87 95 } 88 89 # define FORMAT_DAYS 190 # define FORMAT_HOURS 291 # define FORMAT_MINUTES 392 # define FORMAT_SECONDS 493 # define FORMAT_JD 594 # define FORMAT_DATE 695 96 96 97 /**********/ -
trunk/Ohana/src/delstar/Makefile
r4680 r4805 38 38 $(SRC)/find_matches.$(ARCH).o \ 39 39 $(SRC)/parse_time.$(ARCH).o \ 40 $(SRC)/convert.$(ARCH).o \41 40 $(SRC)/sort_lists.$(ARCH).o \ 42 41 $(SRC)/check_permissions.$(ARCH).o \ -
trunk/Ohana/src/delstar/include/delstar.h
r4680 r4805 30 30 enum {MODE_IMAGENAME, MODE_IMAGEFILE, MODE_TIME, MODE_ORPHAN, MODE_MISSED}; 31 31 32 enum {TIME_NONE, TIME_JD, TIME_MJD, TIME_DATE, TIME_DAYS, TIME_HOURS, TIME_MINUTES, TIME_SECONDS};33 34 32 char DateKeyword[64], DateMode[64], UTKeyword[64], MJDKeyword[64], JDKeyword[64]; 35 33 36 /*** conversion functions ***/ 37 FILE *GetDB PROTO((int *state)); 38 Image *GetImages PROTO((int *nimage)); 39 GSCRegion *LoadRegions PROTO((int *nregions)); 40 Image *find_images PROTO((FILE *f, CatStats *catstats, int *Nimages)); 41 int *find_images_data PROTO((Image *timage, int *nlist)); 42 int *find_images_name PROTO((char *filename, int *nlist)); 43 int *find_images_time PROTO((time_t start, time_t end, PhotCode *code, int *nlist)); 44 Image *gimages PROTO((char *filename)); 45 GSCRegion *gregion_image PROTO((Image *image, int *Nregions)); 46 GSCRegion *gregion_patch PROTO((GSCRegion *patch, int *nregions)); 47 Image *gtimes PROTO((int *NIMAGE)); 48 char *sec_to_date PROTO((time_t second)); 49 void ConfigInit PROTO((int *argc, char **argv)); 50 int FindDecBand PROTO((double dec, double *DEC0, double *DEC1)); 51 int FindRegionByPoint PROTO((GSCRegion *region, double ra, double dec, GSCRegion *gsc, int Ngsc)); 52 int FindRegionDecBandStart PROTO((GSCRegion *region, int Nregion, double dec)); 53 int FindRegionDecBandStop PROTO((GSCRegion *region, int Nregion, double dec)); 54 int SetImages PROTO((Image *new, int Nnew)); 55 void SetProtect PROTO((int mode)); 56 int SetSignals PROTO(()); 57 int Shutdown PROTO((char *format, ...)); 58 void TrapSignal PROTO((int sig)); 59 int args PROTO((int *argc, char **argv)); 60 void check_permissions PROTO((char *basefile)); 61 int chk_time PROTO((char *line)); 62 time_t date_to_sec PROTO((char *date)); 63 void delete_imagefile PROTO((char *filename)); 64 void delete_imagename PROTO((char *name)); 65 void delete_times PROTO(()); 66 int dimages PROTO((int *imlist, int Nimlist)); 67 int dms_to_ddd PROTO((double *Value, char *string)); 68 int edge_check PROTO((double *x1, double *y1, double *x2, double *y2)); 69 void find_matches PROTO((Catalog *catalog, int photcode, int start, int end)); 70 int gcatalog PROTO((Catalog *catalog)); 71 void help PROTO(()); 72 int hms_to_deg PROTO((double *h0, double *h1, double *d0, double *d1, char *string)); 73 time_t jd_to_sec PROTO((double jd)); 74 int load_image_db PROTO(()); 75 void lock_image_db PROTO(()); 76 void match_images PROTO((Catalog *catalog, Image *image, int Nimage)); 77 time_t mjd_to_sec PROTO((double mjd)); 78 double opening_angle PROTO((double x1, double y1, double x2, double y2, double x3, double y3)); 79 int parse_time PROTO((Header *header)); 80 int save_image_db PROTO(()); 81 double sec_to_jd PROTO((time_t second)); 82 double sec_to_mjd PROTO((time_t second)); 83 void sort_lists PROTO((float *X, float *Y, int *S, int N)); 84 void sort_regions PROTO((GSCRegion *region, int N)); 85 int str_to_dtime PROTO((char *line, double *second)); 86 int str_to_radec PROTO((double *ra, double *dec, char *str1, char *str2)); 87 int str_to_time PROTO((char *line, time_t *second)); 88 void unlock_image_db PROTO(()); 89 void usage PROTO(()); 90 int wcatalog PROTO((Catalog *catalog)); 34 /*** delstar prototypes ***/ 35 void ConfigInit PROTO((int *argc, char **argv)); 36 int FindDecBand PROTO((double dec, double *DEC0, double *DEC1)); 37 int FindRegionByPoint PROTO((GSCRegion *region, double ra, double dec, GSCRegion *gsc, int Ngsc)); 38 int FindRegionDecBandStart PROTO((GSCRegion *region, int Nregion, double dec)); 39 int FindRegionDecBandStop PROTO((GSCRegion *region, int Nregion, double dec)); 40 FILE *GetDB PROTO((int *state)); 41 Image *GetImages PROTO((int *nimage)); 42 GSCRegion *LoadRegions PROTO((int *nregions)); 43 int SetImages PROTO((Image *new, int Nnew)); 44 void SetProtect PROTO((int mode)); 45 int SetSignals PROTO(()); 46 int Shutdown PROTO((char *format, ...)); 47 void TrapSignal PROTO((int sig)); 48 int args PROTO((int *argc, char **argv)); 49 void check_permissions PROTO((char *basefile)); 50 void delete_imagefile PROTO((char *filename)); 51 void delete_imagename PROTO((char *name)); 52 void delete_times PROTO(()); 53 int dimages PROTO((int *imlist, int Nimlist)); 54 int edge_check PROTO((double *x1, double *y1, double *x2, double *y2)); 55 Image *find_images PROTO((FILE *f, CatStats *catstats, int *Nimages)); 56 int *find_images_data PROTO((Image *timage, int *nlist)); 57 int *find_images_name PROTO((char *filename, int *nlist)); 58 int *find_images_time PROTO((time_t start, time_t end, PhotCode *code, int *nlist)); 59 void find_matches PROTO((Catalog *catalog, int photcode, int start, int end)); 60 int gcatalog PROTO((Catalog *catalog)); 61 Image *gimages PROTO((char *filename)); 62 GSCRegion *gregion_image PROTO((Image *image, int *Nregions)); 63 GSCRegion *gregion_patch PROTO((GSCRegion *patch, int *nregions)); 64 Image *gtimes PROTO((int *NIMAGE)); 65 void help PROTO(()); 66 int load_image_db PROTO(()); 67 void lock_image_db PROTO(()); 68 void match_images PROTO((Catalog *catalog, Image *image, int Nimage)); 69 double opening_angle PROTO((double x1, double y1, double x2, double y2, double x3, double y3)); 70 int parse_time PROTO((Header *header)); 71 int save_image_db PROTO(()); 72 void sort_lists PROTO((float *X, float *Y, int *S, int N)); 73 void sort_regions PROTO((GSCRegion *region, int N)); 74 void unlock_image_db PROTO(()); 75 void usage PROTO(()); 76 int wcatalog PROTO((Catalog *catalog)); -
trunk/Ohana/src/delstar/src/convert.c
r4680 r4805 1 1 # include "delstar.h" 2 2 3 enum {TIME_NONE, TIME_DATE, TIME_DAYS, TIME_HOURS, TIME_MINUTES, TIME_SECONDS, TIME_JD, TIME_MJD}; 4 3 5 /***** convert [-]00:00:00 to 0.0000 ****/ 4 6 int dms_to_ddd (double *Value, char *string) { … … 95 97 p1 = line; 96 98 tmp = strtod (p1, &p2); 99 mode = TIME_DATE; 97 100 if (p2 == p1 + strlen (p1) - 1) { 101 if (*p2 == 'd') { 102 mode = TIME_DAYS; 103 } 104 if (*p2 == 'h') { 105 mode = TIME_HOURS; 106 } 107 if (*p2 == 'm') { 108 mode = TIME_MINUTES; 109 } 110 if (*p2 == 's') { 111 mode = TIME_SECONDS; 112 } 98 113 if (*p2 == 'j') { 99 114 mode = TIME_JD; … … 102 117 mode = TIME_MJD; 103 118 } 104 if (*p2 == 'd') {105 mode = TIME_DAYS;106 }107 if (*p2 == 'h') {108 mode = TIME_HOURS;109 }110 if (*p2 == 'm') {111 mode = TIME_MINUTES;112 }113 if (*p2 == 's') {114 mode = TIME_SECONDS;115 }116 } else {117 mode = TIME_DATE;118 119 } 119 120 return (mode); … … 141 142 ALLOCATE (tmpline, char, 64); 142 143 gmt = gmtime (&tsec); 143 sprintf (tmpline, "%04d/%02d/%02d,%s", 144 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, &line[6]); 144 sprintf (tmpline, "%04d/%02d/%02d,%s", 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, &line[6]); 145 145 *second = date_to_sec (tmpline); 146 146 free (tmpline); … … 155 155 case 0: 156 156 return (FALSE); 157 case TIME_DATE: 158 *second = date_to_sec (line); 159 return (TRUE); 160 case TIME_DAYS: 161 *second = strtod (line, 0) * 86400.0; 162 return (TRUE); 163 case TIME_HOURS: 164 *second = strtod (line, 0) * 3600.0; 165 return (TRUE); 166 case TIME_MINUTES: 167 *second = strtod (line, 0) * 60.0; 168 return (TRUE); 169 case TIME_SECONDS: 170 *second = strtod (line, 0); 171 return (TRUE); 157 172 case TIME_JD: 158 173 jd = strtod (line, 0); … … 162 177 jd = strtod (line, 0); 163 178 *second = mjd_to_sec (jd); 164 return (TRUE);165 case TIME_DATE:166 *second = date_to_sec (line);167 return (TRUE);168 case TIME_DAYS:169 *second = strtod (line, 0) * 86400.0;170 return (TRUE);171 case TIME_HOURS:172 *second = strtod (line, 0) * 3600.0;173 return (TRUE);174 case TIME_MINUTES:175 *second = strtod (line, 0) * 60.0;176 return (TRUE);177 case TIME_SECONDS:178 *second = strtod (line, 0);179 179 return (TRUE); 180 180 } … … 319 319 } 320 320 321 /***** short date in format yymmdd *****/ 322 time_t short_date_to_sec (char *date) { 323 324 time_t second; 325 double jd; 326 struct tm now; 327 328 bzero (&now, sizeof(now)); 329 330 sscanf (date, "%2d%2d%2d", &now.tm_year, &now.tm_mon, &now.tm_mday); 331 332 if (now.tm_year > 51) now.tm_year += 0; 333 if (now.tm_year < 50) now.tm_year += 100; 334 now.tm_mon --; /* tm_mon runs from 0 - 11 */ 335 336 jd = now.tm_mday - 32075 + (int)(1461*(1900 + now.tm_year + 4800 + (int)(((now.tm_mon+1)-14)/12))/4) 337 + (int)(367*((now.tm_mon+1) - 2 - (int)(((now.tm_mon+1) - 14)/12)*12)/12) 338 - (int)(3*(int)((1900 + now.tm_year + 4900 + (int)(((now.tm_mon+1) - 14)/12))/100)/4) - 0.5; 339 340 second = (jd - 2440587.5)*86400 + 3600.0*now.tm_hour + now.tm_min*60.0 + now.tm_sec; 341 342 return (second); 343 } 344 321 345 /**********/ 322 346 int hms_to_deg (double *h0, double *h1, double *d0, double *d1, char *string) { -
trunk/Ohana/src/libohana/Makefile
r4744 r4805 34 34 $(SRC)/version.$(ARCH).o \ 35 35 $(SRC)/string.$(ARCH).o \ 36 $(SRC)/time.$(ARCH).o \ 36 37 $(SRC)/findexec.$(ARCH).o \ 37 38 $(SRC)/glockfile.$(ARCH).o \ -
trunk/Ohana/src/libohana/include/ohana.h
r3903 r4805 91 91 extern double hypot(); 92 92 93 char *ohana_version ();94 95 93 /* in string.c */ 96 int stripwhite (char *string);97 int strnumcmp (char *str1, char *str2);98 char *strcreate (char *string);99 char *strncreate (char *string, int n);100 int scan_line (FILE *f, char *line);101 int dparse (double *X, int NX, char *line);102 int fparse (float *X, int NX, char *line);103 int get_argument (int argc, char **argv, char *arg);104 int remove_argument (int N, int *argc, char **argv);105 void uppercase (char *string);94 int stripwhite PROTO((char *string)); 95 int strnumcmp PROTO((char *str1, char *str2)); 96 char *strcreate PROTO((char *string)); 97 char *strncreate PROTO((char *string, int n)); 98 int scan_line PROTO((FILE *f, char *line)); 99 int dparse PROTO((double *X, int NX, char *line)); 100 int fparse PROTO((float *X, int NX, char *line)); 101 int get_argument PROTO((int argc, char **argv, char *arg)); 102 int remove_argument PROTO((int N, int *argc, char **argv)); 103 void uppercase PROTO((char *string)); 106 104 107 105 /* in findexec.c */ 108 char *pathname (char *name);109 char *filebasename (char *name);110 char *filerootname (char *name);111 char *findexec (int argc, char **argv);112 int mkdirhier (char *path);113 void make_backup (char *filename);106 char *pathname PROTO((char *name)); 107 char *filebasename PROTO((char *name)); 108 char *filerootname PROTO((char *name)); 109 char *findexec PROTO((int argc, char **argv)); 110 int mkdirhier PROTO((char *path)); 111 void make_backup PROTO((char *filename)); 114 112 115 113 /* in glockfile.c */ 116 FILE *fsetlockfile (char *filename, double timeout, int type, int *state);117 int fclearlockfile (char *filename, FILE *f, int type, int *state);114 FILE *fsetlockfile PROTO((char *filename, double timeout, int type, int *state)); 115 int fclearlockfile PROTO((char *filename, FILE *f, int type, int *state)); 118 116 119 117 /* in config.c */ 120 char *SelectConfigFile (int *argc, char **argv, char *progname);121 char *LoadConfigFile (char *filename);122 char *ScanConfig (char *config, char *field, char *mode, int N,...);123 char *expandline (char *line, char *config);124 char *fileextname (char *file);125 char *LoadRawConfigFile (char *, int);118 char *SelectConfigFile PROTO((int *argc, char **argv, char *progname)); 119 char *LoadConfigFile PROTO((char *filename)); 120 char *ScanConfig PROTO((char *config, char *field, char *mode, int N,...)); 121 char *expandline PROTO((char *line, char *config)); 122 char *fileextname PROTO((char *file)); 123 char *LoadRawConfigFile PROTO((char *, int)); 126 124 127 /* in Fseek.c */ 128 int Fseek (FILE *f, long offset, int whence); 125 /* others */ 126 int Fseek PROTO((FILE *f, long offset, int whence)); 127 char *ohana_version PROTO(()); 128 129 /* in time.c */ 130 enum {TIME_NONE, TIME_DATE, TIME_DAYS, TIME_HOURS, TIME_MINUTES, TIME_SECONDS, TIME_JD, TIME_MJD}; 131 132 int chk_time PROTO((char *line)); 133 time_t date_to_sec PROTO((char *date)); 134 int dms_to_ddd PROTO((double *Value, char *string)); 135 time_t jd_to_sec PROTO((double jd)); 136 char *sec_to_date PROTO((time_t second)); 137 double sec_to_jd PROTO((time_t second)); 138 int str_to_dtime PROTO((char *line, double *second)); 139 int str_to_time PROTO((char *line, time_t *second)); 140 double sec_to_mjd PROTO((time_t second)); 141 time_t mjd_to_sec PROTO((double mjd)); 142 int hms_to_deg PROTO((double *h0, double *h1, double *d0, double *d1, char *string)); 129 143 130 144 /* -
trunk/Ohana/src/mosastro/include/mosastro.h
r4772 r4805 128 128 char *FOCAL_PLANE; 129 129 130 CatStats *gregions (CatStats *patch, int *nregion); 131 Gradients *GetGradients (); 132 Header *mkheader (int Nx, int Ny, int Nstars, Coords *coords); 133 Header *mkmosaic (int Nx, int Ny, int Nstars, Coords *coords); 134 StarData *getusno (CatStats *catstats, int *Nstars); 135 StarData *getgsc (CatStats *catstats, int *NSTARS); 136 StarData *get2mass (CatStats *catstats, int *NSTARS); 137 StarData *getptolemy (CatStats *catstats, int *NSTARS); 138 StarData *greference (int *Nrefcat); 139 StarData *gcatalog (char *filename, int *Nstars); 140 StarData *gptolemy (char *filename, int *NSTARS); 141 double GetScatter (int *Nscatter, double *DL, double *DM, int bright); 142 int find_dec_bands (CatStats *area); 143 int load_ra_blocks (int Ndec, CatStats *area); 144 int parse_GSC_line (CatStats *tregion, char *line); 145 int fake_field (double RA, double DEC); 146 int LoadStars (int Nfile, char **file); 147 int project_refcat (StarData *refcat, int Nrefcat); 148 int deproject_stars (); 149 int project_stars (); 150 int deproject_raw (); 151 int project_ref (); 152 int init_field (); 153 int load_field (char *filename); 154 int init_chips (); 155 int load_chips (char *filename); 156 int dump_stars (FILE *f, StarData *stars, int Nstars); 157 int dump_grads (Gradients *grad, char *filename); 158 int dump_match (); 159 int dump_rawstars (); 160 int dump_refcat (StarData *refcat, int Nrefcat); 161 int match (StarData *refcat, int Nrefcat); 162 int mkvector (int n, int m, int norder); 163 int ClipOnFP (double Nsigma); 164 void GetConfig (char *config, char *field, char *format, int N, void *ptr); 165 void init_regions (); 166 void add_to_regions (CatStats *area); 167 void area_of_region (CatStats *region); 168 void set_catalog (char *catdir); 169 void FitChipLinear (StarData *raw, StarData *ref, int Nmatch, Coords *coords); 170 void FitChipResid (StarData *raw, StarData *ref, int Nmatch, Coords *coords); 171 void ConfigInit (int *argc, char **argv); 172 void print_help (); 173 void args (int *argc, char **argv); 174 void field_stats (); 175 void field_combine (); 176 void fit_apply_grads (Coords *distort, Coords *project, int term); 177 void fit_apply_coords (Coords *coords); 178 void fit_eval (); 179 void fit_add (double x1, double y1, double x2, double y2); 180 void fit_init (int order); 181 void fit_correct_grads (Gradients *in, Gradients *out, int term); 182 void fit_free (); 183 void output (char *ext, char *phu); 184 void FitGradients (Gradients *grad); 185 void uppercase (char *string); 186 e_time parse_time (Header *header); 187 int sortthree (double *X, double *Y, int *Z, int N); 188 StarData *getstone (CatStats *input, int *nstars); 189 void ChipToSky (StarData *stars, int Nstars, Coords *coords); 190 void ChipToFP (StarData *stars, int Nstars, Coords *coords); 191 void FPtoTP (StarData *stars, int Nstars, Coords *coords); 192 void TPtoSky (StarData *stars, int Nstars, Coords *coords); 193 void SkyToTP (StarData *stars, int Nstars, Coords *coords); 194 void TPtoFP (StarData *stars, int Nstars, Coords *coords); 195 void FPtoChip (StarData *stars, int Nstars, Coords *coords); 196 int gaussj (double **a, int n, double **b, int m); 197 void FitChips (int Norder); 198 void FitChip (StarData *raw, StarData *ref, int Nmatch, Coords *coords); 199 int mkpolyterm (int n, int m); 200 void wchip (char *filename, Chip *data); 201 void wstars (char *filename, SMPData *stars, int Nstars, Header *header); 202 int rfits (Chip *mychip); 203 int rtext (Chip *mychip); 204 void wfits (char *filename, SMPData *stars, int Nstars, Header *header); 205 int ConvertMatch (MatchData *data, int size, int nitems); 206 void SaveResiduals (FILE *f, Header *header); 130 /*** mosastro prototypes ***/ 131 void ChipToFP PROTO((StarData *stars, int Nstars, Coords *coords)); 132 void ChipToSky PROTO((StarData *stars, int Nstars, Coords *coords)); 133 int ClipOnFP PROTO((double Nsigma)); 134 void ConfigInit PROTO((int *argc, char **argv)); 135 int ConvertMatch PROTO((MatchData *data, int size, int nitems)); 136 void FPtoChip PROTO((StarData *stars, int Nstars, Coords *coords)); 137 void FPtoTP PROTO((StarData *stars, int Nstars, Coords *coords)); 138 void FitChip PROTO((StarData *raw, StarData *ref, int Nmatch, Coords *coords)); 139 void FitChipLinear PROTO((StarData *raw, StarData *ref, int Nmatch, Coords *coords)); 140 void FitChipResid PROTO((StarData *raw, StarData *ref, int Nmatch, Coords *coords)); 141 void FitChips PROTO((int Norder)); 142 void FitGradients PROTO((Gradients *grad)); 143 void GetConfig PROTO((char *config, char *field, char *format, int N, void *ptr)); 144 Gradients *GetGradients PROTO(()); 145 double GetScatter PROTO((int *Nscatter, double *DL, double *DM, int bright)); 146 int LoadStars PROTO((int Nfile, char **file)); 147 void SaveResiduals PROTO((FILE *f, Header *header)); 148 void SkyToTP PROTO((StarData *stars, int Nstars, Coords *coords)); 149 void TPtoFP PROTO((StarData *stars, int Nstars, Coords *coords)); 150 void TPtoSky PROTO((StarData *stars, int Nstars, Coords *coords)); 151 void add_to_regions PROTO((CatStats *area)); 152 void area_of_region PROTO((CatStats *region)); 153 void args PROTO((int *argc, char **argv)); 154 int deproject_raw PROTO(()); 155 int deproject_stars PROTO(()); 156 int dump_grads PROTO((Gradients *grad, char *filename)); 157 int dump_match PROTO(()); 158 int dump_rawstars PROTO(()); 159 int dump_refcat PROTO((StarData *refcat, int Nrefcat)); 160 int dump_stars PROTO((FILE *f, StarData *stars, int Nstars)); 161 int fake_field PROTO((double RA, double DEC)); 162 void field_combine PROTO(()); 163 void field_stats PROTO(()); 164 int find_dec_bands PROTO((CatStats *area)); 165 void fit_add PROTO((double x1, double y1, double x2, double y2)); 166 void fit_apply_coords PROTO((Coords *coords)); 167 void fit_apply_grads PROTO((Coords *distort, Coords *project, int term)); 168 void fit_correct_grads PROTO((Gradients *in, Gradients *out, int term)); 169 void fit_eval PROTO(()); 170 void fit_free PROTO(()); 171 void fit_init PROTO((int order)); 172 int gaussj PROTO((double **a, int n, double **b, int m)); 173 StarData *gcatalog PROTO((char *filename, int *Nstars)); 174 StarData *get2mass PROTO((CatStats *catstats, int *NSTARS)); 175 StarData *getgsc PROTO((CatStats *catstats, int *NSTARS)); 176 StarData *getptolemy PROTO((CatStats *catstats, int *NSTARS)); 177 StarData *getstone PROTO((CatStats *input, int *nstars)); 178 StarData *getusno PROTO((CatStats *catstats, int *Nstars)); 179 StarData *gptolemy PROTO((char *filename, int *NSTARS)); 180 StarData *greference PROTO((int *Nrefcat)); 181 CatStats *gregions PROTO((CatStats *patch, int *nregion)); 182 int init_chips PROTO(()); 183 int init_field PROTO(()); 184 void init_regions PROTO(()); 185 int load_chips PROTO((char *filename)); 186 int load_field PROTO((char *filename)); 187 int load_ra_blocks PROTO((int Ndec, CatStats *area)); 188 int match PROTO((StarData *refcat, int Nrefcat)); 189 Header *mkheader PROTO((int Nx, int Ny, int Nstars, Coords *coords)); 190 Header *mkmosaic PROTO((int Nx, int Ny, int Nstars, Coords *coords)); 191 int mkpolyterm PROTO((int n, int m)); 192 int mkvector PROTO((int n, int m, int norder)); 193 void output PROTO((char *ext, char *phu)); 194 int parse_GSC_line PROTO((CatStats *tregion, char *line)); 195 e_time parse_time PROTO((Header *header)); 196 void print_help PROTO(()); 197 int project_ref PROTO(()); 198 int project_refcat PROTO((StarData *refcat, int Nrefcat)); 199 int project_stars PROTO(()); 200 int rfits PROTO((Chip *mychip)); 201 int rtext PROTO((Chip *mychip)); 202 void set_catalog PROTO((char *catdir)); 203 int sortthree PROTO((double *X, double *Y, int *Z, int N)); 204 void uppercase PROTO((char *string)); 205 void wchip PROTO((char *filename, Chip *data)); 206 void wfits PROTO((char *filename, SMPData *stars, int Nstars, Header *header)); 207 void wstars PROTO((char *filename, SMPData *stars, int Nstars, Header *header)); -
trunk/Ohana/src/opihi/include/convert.h
r4602 r4805 4 4 # define CONVERT_H 5 5 6 /*** values for time formats */ 7 enum {TIME_NONE, TIME_JD, TIME_MJD, TIME_DATE, TIME_DAYS, TIME_HOURS, TIME_MINUTES, TIME_SECONDS}; 8 9 /*** conversion functions ***/ 6 /*** time/coord conversion functions not supplied by libohana ***/ 10 7 time_t TimeRef PROTO((double time, time_t TimeReference, int TimeFormat)); 11 8 double TimeValue PROTO((time_t time, time_t TimeReference, int TimeFormat)); 12 int chk_time PROTO((char *line)); 13 time_t date_to_sec PROTO((char *date)); 14 int dms_to_ddd PROTO((double *Value, char *string)); 15 time_t jd_to_sec PROTO((double jd)); 16 time_t mjd_to_sec PROTO((double mjd)); 17 char *sec_to_date PROTO((time_t second)); 18 double sec_to_jd PROTO((time_t second)); 19 double sec_to_mjd PROTO((time_t second)); 20 int str_to_dtime PROTO((char *line, double *second)); 21 int str_to_radec PROTO((double *ra, double *dec, char *str1, char *str2)); 22 int str_to_time PROTO((char *line, time_t *second)); 9 23 10 int hh_hms PROTO((double hh, int *hr, int *mn, double *sc)); 24 11 int dd_dms PROTO((double dd, int *dg, int *mn, double *sc)); … … 33 20 char *meade_dec_to_str PROTO((double deg)); 34 21 int hstgsc_hms_to_deg PROTO((double *h0, double *h1, double *d0, double *d1, char *string)); 22 char *strptime PROTO((const char *s, const char *format, struct tm *tm)); 35 23 36 24 # endif -
trunk/Ohana/src/opihi/include/dvo1.h
r4689 r4805 23 23 } RegionFile; 24 24 25 /* aregion, region_list, match_image, LoadImages */ 26 RegionFile *find_regions PROTO((double Ra, double Dec, double radius, int *Nregions)); 27 GSCRegion *get_regions PROTO((Image *image, int *Nregions)); 28 void aregion PROTO((GSCRegion *region, FILE *f, double ra, double dec, char *path)); 29 RegionFile *region_list PROTO((char *filename, int *Nregions)); 30 int match_image PROTO((Image *image, int Nimage, unsigned int T, short int S)); 31 Image *LoadImages PROTO((int *Nimage)); 32 void image_subset PROTO((Image *image, int Nimage, int **Subset, int *Nsubset, Graphdata *graph, int RegionSelect, unsigned long int tzero, double trange, int TimeSelect)); 33 void sort_images PROTO((Image *image, int N)); 34 void sortave PROTO((Average *ave, int N)); 35 void cprecess PROTO((Average *average, int Naverage, double in_epoch, double out_epoch)); 36 void compare PROTO((Catalog *catlog1, Catalog *catlog2, Vector *rvec, Vector *dvec, Vector *mvec, Vector *drvec, Vector *ddvec, Vector *dmvec, double radius)); 37 38 /*** photometry functions ***/ 39 double *ExtractByDMag PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param)); 40 double *ExtractDMag PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist)); 41 double *ExtractMagnitudes PROTO((PhotCode *code, int mode, Average *average, SecFilt *secfilt, Measure *measure, int *n)); 42 double *ExtractMeasures PROTO((PhotCode *code, int mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param)); 25 /*** dvo prototypes ***/ 26 int DetermineTypeCode PROTO((Average *average, Measure *measure, int code)); 27 double DetermineTypefrac PROTO((Average *average, Measure *measure, PhotCode *code)); 28 double ExtractAverages PROTO((PhotCode *code, int mode, Average *average, SecFilt *secfilt, Measure *measure, int param)); 29 double *ExtractByDMag PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param)); 30 double *ExtractDMag PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist)); 31 double *ExtractMagnitudes PROTO((PhotCode *code, int mode, Average *average, SecFilt *secfilt, Measure *measure, int *n)); 32 double *ExtractMeasures PROTO((PhotCode *code, int mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param)); 43 33 double *ExtractMeasuresByDMag PROTO((PhotCode **code, int *mode, int use_first, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param)); 44 34 double *ExtractMeasuresDMag PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist)); 35 void FreeImageSelection PROTO(()); 36 void FreeImageSelection PROTO(()); 37 int GetAverageParam PROTO((char *parname)); 38 void GetAverageParamHelp PROTO(()); 39 int GetMagMode PROTO((char *string)); 40 double GetMeasure PROTO((int param, Average *average, Measure *measure, double mag)); 41 int GetMeasureParam PROTO((char *parname)); 42 int GetMeasureTypeCode PROTO((Measure *measure)); 43 int GetPhotcodeInfo PROTO((char *string, PhotCode **Code, int *Mode)); 44 int GetRegionSelection PROTO(()); 45 int GetSelectionParam PROTO(()); 46 int GetTimeSelection PROTO((time_t *tz, time_t *te)); 47 void InitDVO PROTO(()); 48 int InitPhotcodes PROTO(()); 49 Image *LoadImages PROTO((int *Nimage)); 50 Image *MatchImage PROTO((unsigned int time, short int source)); 45 51 Image *MatchImage PROTO((unsigned int time, short int source)); 46 52 Coords *MatchMosaic PROTO((unsigned int time, short int source)); 47 int DetermineTypeCode PROTO((Average *average, Measure *measure, int code)); 48 double DetermineTypefrac PROTO((Average *average, Measure *measure, PhotCode *code)); 49 double ExtractAverages PROTO((PhotCode *code, int mode, Average *average, SecFilt *secfilt, Measure *measure, int param)); 50 void FreeImageSelection PROTO(()); 51 int GetAverageParam PROTO((char *parname)); 52 void GetAverageParamHelp PROTO(()); 53 int GetMagMode PROTO((char *string)); 54 double GetMeasure PROTO((int param, Average *average, Measure *measure, double mag)); 55 int GetMeasureParam PROTO((char *parname)); 56 int GetMeasureTypeCode PROTO((Measure *measure)); 57 int GetPhotcodeInfo PROTO((char *string, PhotCode **Code, int *Mode)); 58 int GetSelectionParam PROTO(()); 59 int InitPhotcodes PROTO(()); 60 int Quality PROTO((Measure *measure, int IsDophot)); 53 int Quality PROTO((Measure *measure, int IsDophot)); 61 54 int SelectMags PROTO((int Nphot, int Tphot, int Ns, Average *average, Measure *measure, SecFilt *secfilt, int UL)); 62 int SetImageSelection PROTO((int mode)); 63 int SetPhotSelections PROTO((int *argc, char **argv, int Nparams)); 64 int SetSelectionParam PROTO((int param)); 65 int TestAverage PROTO((PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure)); 66 int TestPhotSelections PROTO((PhotCode **code, int *mode, int param)); 55 RegionFile *SelectRegions PROTO((char *RegionName, char *RegionList, int *nregions)); 56 int SetImageSelection PROTO((int mode)); 57 int SetPhotSelections PROTO((int *argc, char **argv, int Nparams)); 58 int SetRegionSelection PROTO((int *argc, char **argv, char **RegionName, char **RegionList)); 59 int SetSelectionParam PROTO((int param)); 60 int TestAverage PROTO((PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure)); 61 int TestPhotSelections PROTO((PhotCode **code, int *mode, int param)); 62 void aregion PROTO((GSCRegion *region, FILE *f, double ra, double dec, char *path)); 63 void compare PROTO((Catalog *catlog1, Catalog *catlog2, Vector *rvec, Vector *dvec, Vector *mvec, Vector *drvec, Vector *ddvec, Vector *dmvec, double radius)); 64 void cprecess PROTO((Average *average, int Naverage, double in_epoch, double out_epoch)); 65 RegionFile *find_regions PROTO((double Ra, double Dec, double radius, int *Nregions)); 66 GSCRegion *get_regions PROTO((Image *image, int *Nregions)); 67 void image_subset PROTO((Image *image, int Nimage, int **Subset, int *Nsubset, Graphdata *graph, int RegionSelect, unsigned long int tzero, double trange, int TimeSelect)); 68 int match_image PROTO((Image *image, int Nimage, unsigned int T, short int S)); 69 int match_image_subset PROTO((Image *image, int *subset, int Nsubset, unsigned int T, short int S)); 67 70 void print_value PROTO((FILE *f, double value, short int ival)); 68 69 RegionFile *SelectRegions PROTO((char *RegionName, char *RegionList, int *nregions)); 70 71 void InitDVO (); 72 73 void FreeImageSelection (); 74 Image *MatchImage (unsigned int time, short int source); 75 int GetRegionSelection (); 76 int SetRegionSelection (int *argc, char **argv, char **RegionName, char **RegionList); 77 void sort_image_subset (Image *image, int *subset, int N); 78 int match_image_subset (Image *image, int *subset, int Nsubset, unsigned int T, short int S); 79 int GetTimeSelection (time_t *tz, time_t *te); 71 RegionFile *region_list PROTO((char *filename, int *Nregions)); 72 void sort_image_subset PROTO((Image *image, int *subset, int N)); 73 void sort_images PROTO((Image *image, int N)); 74 void sortave PROTO((Average *ave, int N)); 80 75 81 76 # endif -
trunk/Ohana/src/opihi/lib.data/Makefile
r4747 r4805 21 21 # general numerical functions (libdata) ##################### 22 22 srcs = \ 23 $(SDIR)/convert.$(ARCH).o \24 23 $(SDIR)/sort.$(ARCH).o \ 25 24 $(SDIR)/fft.$(ARCH).o \ -
trunk/Ohana/src/opihi/lib.data/convert.c
r4697 r4805 3 3 # include <time.h> 4 4 5 char *strptime(const char *s, const char *format, struct tm *tm); 6 7 5 /** additional time / coordinate conversions not supplied by libohana **/ 6 8 7 int hh_hms (double hh, int *hr, int *mn, double *sc) { 9 8 … … 111 110 } 112 111 113 /***** convert [-]00:00:00 to 0.0000 ****/114 int dms_to_ddd (double *Value, char *string) {115 116 int valid, neg, status;117 double tmp, value;118 char *p1, *p2, *px;119 120 valid = FALSE;121 neg = FALSE;122 stripwhite (string);123 p1 = string;124 px = string + strlen(string);125 126 if (string[0] == '-') {127 valid = TRUE;128 neg = TRUE;129 p1 = &string[1];130 }131 if (string[0] == '+') {132 valid = TRUE;133 neg = FALSE;134 p1 = &string[1];135 }136 if (isdigit(string[0])) {137 valid = TRUE;138 p1 = &string[0];139 }140 if (!valid) { return (FALSE); }141 142 status = 1;143 tmp = strtod (p1, &p2);144 if (p2 == p1) return (FALSE); /* entry not a number: +fred */145 value = tmp;146 if (p2 == px) goto escape; /* entry only number: +1.0 */147 p1 = p2 + 1;148 149 tmp = strtod (p1, &p2);150 if (p2 == p1) goto escape; /* entry not a number: +1:fred */151 status = 2;152 value += tmp / 60.0;153 if (p2 == px) goto escape; /* entry only number: +1:1 */154 p1 = p2 + 1;155 156 tmp = strtod (p1, &p2);157 if (p2 == p1) goto escape; /* entry not a number: +1:1:fred */158 value += tmp / 3600.0;159 160 escape:161 if (neg) {162 value *= -1;163 }164 *Value = value;165 166 return (status);167 }168 169 112 /***** convert 00:00:00 or 00:00 to 0 - 86400 ****/ 170 113 int hms_to_sec (char *string, time_t *second) { … … 211 154 if (*p) return (FALSE); 212 155 *second = time.tm_wday*86400 + time.tm_hour*3600 + time.tm_min*60 + time.tm_sec; 213 return (TRUE);214 }215 216 /**********/217 int str_to_radec (double *ra, double *dec, char *str1, char *str2) {218 219 double Ra, Dec;220 221 *ra = *dec = 0;222 switch (dms_to_ddd (&Ra, str1)) {223 case 0:224 fprintf (stderr, "syntax error in RA\n");225 return (FALSE);226 case 1:227 break;228 case 2:229 Ra = Ra * 15;230 break;231 }232 switch (dms_to_ddd (&Dec, str2)) {233 case 0:234 fprintf (stderr, "syntax error in DEC\n");235 return (FALSE);236 case 1:237 case 2:238 break;239 }240 *ra = Ra;241 *dec = Dec;242 156 return (TRUE); 243 157 } … … 302 216 } 303 217 304 /**********/305 int chk_time (char *line) {306 307 char *p1, *p2;308 double tmp;309 int mode;310 311 p1 = line;312 tmp = strtod (p1, &p2);313 mode = TIME_DATE;314 if (p2 == p1 + strlen (p1) - 1) {315 if (*p2 == 'j') {316 mode = TIME_JD;317 }318 if (*p2 == 'J') {319 mode = TIME_MJD;320 }321 if (*p2 == 'd') {322 mode = TIME_DAYS;323 }324 if (*p2 == 'h') {325 mode = TIME_HOURS;326 }327 if (*p2 == 'm') {328 mode = TIME_MINUTES;329 }330 if (*p2 == 's') {331 mode = TIME_SECONDS;332 }333 }334 return (mode);335 }336 337 /**********/338 int str_to_time (char *line, time_t *second) {339 340 char *tmpline;341 struct tm *gmt;342 struct timeval now;343 double jd;344 time_t tsec;345 346 if (!strcasecmp (line, "NOW")) {347 gettimeofday (&now, (struct timezone *) NULL);348 *second = now.tv_sec;349 return (TRUE);350 }351 352 if (!strncasecmp (line, "TODAY", 5)) {353 gettimeofday (&now, (struct timezone *) NULL);354 if (line[5]) { /* line has extra data (ie, hh:mm:ss) */355 tsec = now.tv_sec;356 ALLOCATE (tmpline, char, 64);357 gmt = gmtime (&tsec);358 sprintf (tmpline, "%04d/%02d/%02d,%s",359 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, &line[6]);360 *second = date_to_sec (tmpline);361 free (tmpline);362 return (TRUE);363 } else {364 *second = 86400 * ((int)(now.tv_sec / 86400));365 return (TRUE);366 }367 }368 369 switch (chk_time (line)) {370 case 0:371 return (FALSE);372 case TIME_JD:373 jd = strtod (line, 0);374 *second = jd_to_sec (jd);375 return (TRUE);376 case TIME_MJD:377 jd = strtod (line, 0);378 *second = mjd_to_sec (jd);379 return (TRUE);380 case TIME_DATE:381 *second = date_to_sec (line);382 return (TRUE);383 case TIME_DAYS:384 *second = strtod (line, 0) * 86400.0;385 return (TRUE);386 case TIME_HOURS:387 *second = strtod (line, 0) * 3600.0;388 return (TRUE);389 case TIME_MINUTES:390 *second = strtod (line, 0) * 60.0;391 return (TRUE);392 case TIME_SECONDS:393 *second = strtod (line, 0);394 return (TRUE);395 }396 return (FALSE);397 }398 399 400 /**********/401 int str_to_dtime (char *line, double *second) {402 403 switch (chk_time (line)) {404 case 0:405 case TIME_JD:406 case TIME_MJD:407 case TIME_DATE:408 return (FALSE);409 case TIME_DAYS:410 *second = strtod (line, 0) * 86400.0;411 return (TRUE);412 case TIME_HOURS:413 *second = strtod (line, 0) * 3600.0;414 return (TRUE);415 case TIME_MINUTES:416 *second = strtod (line, 0) * 60.0;417 return (TRUE);418 case TIME_SECONDS:419 *second = strtod (line, 0);420 return (TRUE);421 }422 return (FALSE);423 }424 425 /**********/426 double sec_to_jd (time_t second) {427 428 double jd;429 430 jd = second/86400.0 + 2440587.5;431 return (jd);432 }433 434 /**********/435 time_t jd_to_sec (double jd) {436 437 time_t second;438 439 second = (jd - 2440587.5)*86400;440 return (second);441 }442 443 /**********/444 double sec_to_mjd (time_t second) {445 446 double mjd;447 448 mjd = second/86400.0 + 40587.0;449 return (mjd);450 }451 452 /**********/453 time_t mjd_to_sec (double mjd) {454 455 time_t second;456 457 second = (mjd - 40587.0)*86400;458 return (second);459 }460 461 /**********/462 char *sec_to_date (time_t second) {463 464 struct tm *gmt;465 char *line;466 467 ALLOCATE (line, char, 64);468 gmt = gmtime (&second);469 sprintf (line, "%04d/%02d/%02d,%02d:%02d:%02d",470 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday,471 gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);472 return (line);473 474 }475 476 /***** date in format yyyy/mm/dd,hh:mm:ss *****/477 time_t date_to_sec (char *date) {478 479 time_t second;480 double tmp, jd;481 struct tm now;482 char *p1, *p2, *px;483 484 p1 = date;485 px = date + strlen(date);486 bzero (&now, sizeof(now));487 488 tmp = strtod (p1, &p2);489 if (p2 == p1) goto escape;490 now.tm_year = tmp;491 if (now.tm_year > 1000) now.tm_year -= 1900;492 if (now.tm_year < 50) now.tm_year += 100;493 if (p2 == px) goto escape;494 p1 = p2 + 1;495 496 tmp = strtod (p1, &p2);497 if (p2 == p1) goto escape;498 now.tm_mon = tmp - 1; /* mon runs from 0 - 11 */499 if (p2 == px) goto escape;500 p1 = p2 + 1;501 502 tmp = strtod (p1, &p2);503 if (p2 == p1) goto escape;504 now.tm_mday = tmp;505 if (p2 == px) goto escape;506 p1 = p2 + 1;507 508 tmp = strtod (p1, &p2);509 if (p2 == p1) goto escape;510 p1 = p2 + 1;511 now.tm_hour = tmp;512 if (p2 == px) goto escape;513 514 tmp = strtod (p1, &p2);515 if (p2 == p1) goto escape;516 now.tm_min = tmp;517 if (p2 == px) goto escape;518 p1 = p2 + 1;519 520 tmp = strtod (p1, &p2);521 if (p2 == p1) goto escape;522 now.tm_sec = tmp;523 if (p2 == px) goto escape;524 p1 = p2 + 1;525 526 escape:527 jd = now.tm_mday - 32075 + (int)(1461*(1900 + now.tm_year + 4800 + (int)(((now.tm_mon+1)-14)/12))/4)528 + (int)(367*((now.tm_mon+1) - 2 - (int)(((now.tm_mon+1) - 14)/12)*12)/12)529 - (int)(3*(int)((1900 + now.tm_year + 4900 + (int)(((now.tm_mon+1) - 14)/12))/100)/4) - 0.5;530 531 second = (jd - 2440587.5)*86400 + 3600.0*now.tm_hour + now.tm_min*60.0 + now.tm_sec;532 533 return (second);534 }535 536 218 /* convert UNIX time to a value referenced to the TimeReference in the given unit */ 537 219 double TimeValue (time_t time, time_t TimeReference, int TimeFormat) { … … 599 281 600 282 /* times may be in forms as: 601 20040200450s (N seconds since 1970.0) 602 2440900.232j (julian date) 603 99/02/23,03:22:18 (date string) 604 (separators may be anything except space, +, -) 605 99:02:15:12:23:30 606 99:02:15:12h23m30s 607 */ 283 * 20040200450s (N seconds since 1970.0) 284 * 2440900.232j (julian date) 285 * 99/02/23,03:22:18 (date string) 286 * (separators may be anything except space, +, -) 287 * 99:02:15:12:23:30 288 * 99:02:15:12h23m30s 289 */ 290 -
trunk/Ohana/src/relphot/Makefile
r2833 r4805 41 41 $(SRC)/plotstuff.$(ARCH).o \ 42 42 $(SRC)/misc.$(ARCH).o \ 43 $(SRC)/time.$(ARCH).o \44 43 $(SRC)/reload_catalogs.$(ARCH).o \ 45 44 $(SRC)/free_catalogs.$(ARCH).o \ -
trunk/Ohana/src/relphot/include/relphot.h
r4796 r4805 88 88 89 89 int TimeSelect; 90 unsigned int TSTART, TSTOP;90 time_t TSTART, TSTOP; 91 91 92 92 # ifdef GRID_V1 … … 98 98 # endif 99 99 100 /***** prototypes ****/ 101 int main (int argc, char **argv); 102 Catalog *load_catalogs (GSCRegion *region, int Nregion, GSCRegion *fullregion); 103 GSCRegion *load_images (char *seed, int *nregion, GSCRegion *fullregion); 104 GSCRegion *name_region (char *name, int *Nregions); 105 GSCRegion *find_regions (Image *image, int Nimage, int *Nregions, GSCRegion *fullregion); 106 GSCRegion *get_regions (double minRa, double maxRa, double minDec, double maxDec, int *Nregions); 107 Image *find_images (GSCRegion *region, int Nregion, int *Nimages, int **LineNum); 108 double opening_angle (double x1, double y1, double x2, double y2, double x3, double y3); 109 int edge_check (double *x1, double *y1, double *x2, double *y2); 110 int corner_check (double *x1, double *y1, double *x2, double *y2); 111 int hms_to_deg (double *h0, double *h1, double *d0, double *d1, char *string); 112 int bcatalog (Catalog *subcatalog, Catalog *catalog, GSCRegion *fullregion); 113 int findMosaics (Catalog *catalog, int Ncatalog); 114 int setMmos (Catalog *catalog, int Poor); 115 int setMrel (Catalog *catalog, int Ncatalog); 116 int setrefcode (Image *image, int Nimage); 117 int args (int argc, char **argv); 118 short getMgrid (int meas, int cat); 119 short getMcal (int meas, int cat); 120 short getMmos (int meas, int cat); 121 short getMrel (Catalog *catalog, int meas, int cat); 122 void initGrid (int dX, int dY); 123 void initGridBins (Catalog *catalog, int Ncatalog); 124 void initMosaics (Image *image, int Nimage); 125 void initMosaicGrid (Image *image, int Nimage); 126 void initMosaicBins (Catalog *catalog, int Ncatalog); 127 void initMrel (Catalog *catalog, int Ncatalog); 128 void initialize (int argc, char **argv); 129 void ConfigInit (int *argc, char **argv); 130 void mark_images (Image *image, int Nimage, Image *timage, int Ntimage); 131 void setMgrid (Catalog *catalog); 132 void dumpGrid (); 133 void initImages (Image *input, int N); 134 void initImageBins (Catalog *catalog, int Ncatalog); 135 void findImages (Catalog *catalog, int Ncatalog); 136 void matchImage (Catalog *catalog, int meas, int cat); 137 void matchMosaics (Catalog *catalog, int meas, int cat); 138 void setMcal (Catalog *catalog, int Poor); 139 void clean_images (); 140 void clean_stars (Catalog *catalog, int Ncatalog); 141 void reload_catalogs (GSCRegion *region, int Nregion, GSCRegion *fullregion); 142 void free_catalogs (Catalog *catalog, int Ncatalog); 143 void set_ZP (double ZERO); 144 char *GetPhotnamebyCode (PhotCodeData *photcodes, int code); 145 StatType statsStarS (Catalog *catalog, int Ncatalog); 146 StatType statsStarX (Catalog *catalog, int Ncatalog); 147 StatType statsStarN (Catalog *catalog, int Ncatalog); 148 StatType statsImageN (Catalog *catalog); 149 StatType statsImageX (Catalog *catalog); 150 StatType statsImageM (Catalog *catalog); 151 void plot_scatter (Catalog *catalog, int Ncatalog); 152 void plot_defaults (Graphdata *graphdata); 153 void plot_list (Graphdata *graphdata, double *xlist, double *ylist, int N, char *label, char *file); 154 void plot_stars (Catalog *catalog, int Ncatalog); 155 void plot_chisq (Catalog *catalog, int Ncatalog); 156 void plot_star_coords (Catalog *catalog, int Ncatalog); 157 void plot_grid (Catalog *catalog); 158 void dump_grid (); 159 int *SelectRefMosaic (Mosaic **refmosaic, int *Nimage); 160 Image *getimage (int N); 161 void InterpolateGrid (float *buffer, int Nx, int Ny, Coords *ccd, Coords *gcoords); 162 void plot_mosaic_fields (Catalog *catalog); 163 void plot_mosaics (); 164 void plot_images (); 165 void wimages (); 166 void clean_mosaics (); 167 void freeMosaicBins (int Ncatalog); 168 void freeGridBins (int Ncatalog); 169 void clean_measures (Catalog *catalog, int Ncatalog, int final); 170 void global_stats (Catalog *catalog, int Ncatalog); 171 StatType statsImagedM (Catalog *catalog); 172 StatType statsMosaicdM (Catalog *catalog); 173 StatType statsMosaicM (Catalog *catalog); 174 StatType statsMosaicN (Catalog *catalog); 175 StatType statsMosaicX (Catalog *catalog); 176 Coords *getCoords (int meas, int cat); 177 int setExclusions (Catalog *catalog, int Ncatalog); 178 void freeImageBins (int Ncatalog); 179 void sortA (double *X, int N); 180 void sortB (double *X, double *Y, int N); 181 void sortC (double *X, double *Y, double *F1, double *F2, int N); 182 void sortD (double *X, double *Y, double *Z, int N); 183 void initstats (char *mode); 184 int liststats (double *value, double *dvalue, int N, StatType *stats); 185 186 int dms_to_ddd (double *Value, char *string); 187 int str_to_radec (double *ra, double *dec, char *str1, char *str2); 188 int chk_time (char *line); 189 double sec_to_jd (unsigned long second); 190 unsigned long int jd_to_sec (double jd); 191 char *sec_to_date (unsigned long second); 192 unsigned long date_to_sec (char *date); 193 194 int str_to_time (char *line, unsigned int *second); 195 int str_to_dtime (char *line, double *second); 196 int Fseek (FILE *f, long offset, int whence); 197 void GetConfig (char *config, char *field, char *format, int N, void *ptr); 198 void skip_measurements (Catalog *catalog, int pass); 199 Image *getimages (int *N); 200 201 void setMrelFinal (Catalog *catalog); 202 void skip_measurements (Catalog *catalog, int pass); 203 GSCRegion *get_regions (double minRa, double maxRa, double minDec, double maxDec, int *Nregions); 204 int hms_to_deg (double *h0, double *h1, double *d0, double *d1, char *string); 205 GSCRegion *find_regions (Image *image, int Nimage, int *Nregions, GSCRegion *fullregion); 206 void getfullregion (Image *image, int Nimage, GSCRegion *fullregion); 207 void setMcalFinal (Image *image, int Nimage); 208 int gcatalog (Catalog *catalog, int FINAL); 209 void write_coords (Header *header, Coords *coords); 210 void wcatalog (Catalog *catalog); 211 int setMrelOutput (Catalog *catalog, int Ncatalog, int mark); 212 int setMcalOutput (Catalog *catalog, int Ncatalog); 100 /*** relphot prototypes ***/ 101 void ConfigInit PROTO((int *argc, char **argv)); 102 int Fseek PROTO((FILE *f, long offset, int whence)); 103 void GetConfig PROTO((char *config, char *field, char *format, int N, void *ptr)); 104 char *GetPhotnamebyCode PROTO((PhotCodeData *photcodes, int code)); 105 void InterpolateGrid PROTO((float *buffer, int Nx, int Ny, Coords *ccd, Coords *gcoords)); 106 int *SelectRefMosaic PROTO((Mosaic **refmosaic, int *Nimage)); 107 int args PROTO((int argc, char **argv)); 108 int bcatalog PROTO((Catalog *subcatalog, Catalog *catalog, GSCRegion *fullregion)); 109 void clean_images PROTO(()); 110 void clean_measures PROTO((Catalog *catalog, int Ncatalog, int final)); 111 void clean_mosaics PROTO(()); 112 void clean_stars PROTO((Catalog *catalog, int Ncatalog)); 113 int corner_check PROTO((double *x1, double *y1, double *x2, double *y2)); 114 void dumpGrid PROTO(()); 115 void dump_grid PROTO(()); 116 int edge_check PROTO((double *x1, double *y1, double *x2, double *y2)); 117 void findImages PROTO((Catalog *catalog, int Ncatalog)); 118 int findMosaics PROTO((Catalog *catalog, int Ncatalog)); 119 Image *find_images PROTO((GSCRegion *region, int Nregion, int *Nimages, int **LineNum)); 120 GSCRegion *find_regions PROTO((Image *image, int Nimage, int *Nregions, GSCRegion *fullregion)); 121 void freeGridBins PROTO((int Ncatalog)); 122 void freeImageBins PROTO((int Ncatalog)); 123 void freeMosaicBins PROTO((int Ncatalog)); 124 void free_catalogs PROTO((Catalog *catalog, int Ncatalog)); 125 int gcatalog PROTO((Catalog *catalog, int FINAL)); 126 Coords *getCoords PROTO((int meas, int cat)); 127 short getMcal PROTO((int meas, int cat)); 128 short getMgrid PROTO((int meas, int cat)); 129 short getMmos PROTO((int meas, int cat)); 130 short getMrel PROTO((Catalog *catalog, int meas, int cat)); 131 GSCRegion *get_regions PROTO((double minRa, double maxRa, double minDec, double maxDec, int *Nregions)); 132 void getfullregion PROTO((Image *image, int Nimage, GSCRegion *fullregion)); 133 Image *getimage PROTO((int N)); 134 Image *getimages PROTO((int *N)); 135 void global_stats PROTO((Catalog *catalog, int Ncatalog)); 136 void initGrid PROTO((int dX, int dY)); 137 void initGridBins PROTO((Catalog *catalog, int Ncatalog)); 138 void initImageBins PROTO((Catalog *catalog, int Ncatalog)); 139 void initImages PROTO((Image *input, int N)); 140 void initMosaicBins PROTO((Catalog *catalog, int Ncatalog)); 141 void initMosaicGrid PROTO((Image *image, int Nimage)); 142 void initMosaics PROTO((Image *image, int Nimage)); 143 void initMrel PROTO((Catalog *catalog, int Ncatalog)); 144 void initialize PROTO((int argc, char **argv)); 145 void initstats PROTO((char *mode)); 146 int liststats PROTO((double *value, double *dvalue, int N, StatType *stats)); 147 Catalog *load_catalogs PROTO((GSCRegion *region, int Nregion, GSCRegion *fullregion)); 148 GSCRegion *load_images PROTO((char *seed, int *nregion, GSCRegion *fullregion)); 149 int main PROTO((int argc, char **argv)); 150 void mark_images PROTO((Image *image, int Nimage, Image *timage, int Ntimage)); 151 void matchImage PROTO((Catalog *catalog, int meas, int cat)); 152 void matchMosaics PROTO((Catalog *catalog, int meas, int cat)); 153 GSCRegion *name_region PROTO((char *name, int *Nregions)); 154 double opening_angle PROTO((double x1, double y1, double x2, double y2, double x3, double y3)); 155 void plot_chisq PROTO((Catalog *catalog, int Ncatalog)); 156 void plot_defaults PROTO((Graphdata *graphdata)); 157 void plot_grid PROTO((Catalog *catalog)); 158 void plot_images PROTO(()); 159 void plot_list PROTO((Graphdata *graphdata, double *xlist, double *ylist, int N, char *label, char *file)); 160 void plot_mosaic_fields PROTO((Catalog *catalog)); 161 void plot_mosaics PROTO(()); 162 void plot_scatter PROTO((Catalog *catalog, int Ncatalog)); 163 void plot_star_coords PROTO((Catalog *catalog, int Ncatalog)); 164 void plot_stars PROTO((Catalog *catalog, int Ncatalog)); 165 void reload_catalogs PROTO((GSCRegion *region, int Nregion, GSCRegion *fullregion)); 166 int setExclusions PROTO((Catalog *catalog, int Ncatalog)); 167 void setMcal PROTO((Catalog *catalog, int Poor)); 168 void setMcalFinal PROTO((Image *image, int Nimage)); 169 int setMcalOutput PROTO((Catalog *catalog, int Ncatalog)); 170 void setMgrid PROTO((Catalog *catalog)); 171 int setMmos PROTO((Catalog *catalog, int Poor)); 172 int setMrel PROTO((Catalog *catalog, int Ncatalog)); 173 void setMrelFinal PROTO((Catalog *catalog)); 174 int setMrelOutput PROTO((Catalog *catalog, int Ncatalog, int mark)); 175 void set_ZP PROTO((double ZERO)); 176 int setrefcode PROTO((Image *image, int Nimage)); 177 void skip_measurements PROTO((Catalog *catalog, int pass)); 178 void sortA PROTO((double *X, int N)); 179 void sortB PROTO((double *X, double *Y, int N)); 180 void sortC PROTO((double *X, double *Y, double *F1, double *F2, int N)); 181 void sortD PROTO((double *X, double *Y, double *Z, int N)); 182 StatType statsImageM PROTO((Catalog *catalog)); 183 StatType statsImageN PROTO((Catalog *catalog)); 184 StatType statsImageX PROTO((Catalog *catalog)); 185 StatType statsImagedM PROTO((Catalog *catalog)); 186 StatType statsMosaicM PROTO((Catalog *catalog)); 187 StatType statsMosaicN PROTO((Catalog *catalog)); 188 StatType statsMosaicX PROTO((Catalog *catalog)); 189 StatType statsMosaicdM PROTO((Catalog *catalog)); 190 StatType statsStarN PROTO((Catalog *catalog, int Ncatalog)); 191 StatType statsStarS PROTO((Catalog *catalog, int Ncatalog)); 192 StatType statsStarX PROTO((Catalog *catalog, int Ncatalog)); 193 void wcatalog PROTO((Catalog *catalog)); 194 void wimages PROTO(()); 195 void write_coords PROTO((Header *header, Coords *coords)); -
trunk/Ohana/src/relphot/src/get_regions.c
r4796 r4805 166 166 167 167 } 168 169 /**********/170 int hms_to_deg (double *h0, double *h1, double *d0, double *d1, char *string) {171 172 int flag_d0, flag_d1, flag_h0, flag_h1;173 double tmp;174 175 *d0 = *h0 = *d1 = *h1 = 0;176 177 flag_h0 = dparse (h0, 1, string);178 flag_h1 = dparse (h1, 4, string);179 flag_d0 = dparse (d0, 7, string);180 flag_d1 = dparse (d1, 9, string);181 *h0 *= flag_h0;182 *h1 *= flag_h1;183 *d0 *= flag_d0;184 *d1 *= flag_d1;185 186 dparse (&tmp, 2, string);187 *h0 += tmp/60.0;188 dparse (&tmp, 3, string);189 *h0 += tmp/3600.0;190 191 dparse (&tmp, 5, string);192 *h1 += tmp/60.0;193 dparse (&tmp, 6, string);194 *h1 += tmp/3600.0;195 196 dparse (&tmp, 8, string);197 *d0 += tmp/60.0;198 199 dparse (&tmp, 10, string);200 *d1 += tmp/60.0;201 202 *h0 *= 15*flag_h0;203 *h1 *= 15*flag_h1;204 *d0 *= flag_d0;205 *d1 *= flag_d1;206 207 return (TRUE);208 } -
trunk/Ohana/src/relphot/src/misc.c
r4796 r4805 182 182 } 183 183 184 /* fseek with timeout - 0.5 sec */ 185 int Fseek (FILE *f, long offset, int whence) { 186 187 int status; 188 189 status = fseek (f, offset, whence); 190 if (status == -1) { 191 int k; 192 /* fprintf (stderr, "problem seeking position: %d\n", errno); */ 193 for (k = 0; (k < 10) && ((status = fseek (f, 0, SEEK_SET)) == -1); k++) usleep (50000); 194 if (status == -1) { 195 /* fprintf (stderr, "ERROR: serious problem seeking position: %d\n", errno); */ 196 /* clear lock at this point? */ 197 return (0); 198 } 199 } 200 return (1); 201 } -
trunk/Ohana/src/relphot/src/time.c
r4796 r4805 1 1 # include "relphot.h" 2 3 enum {TIME_NONE, TIME_DATE, TIME_DAYS, TIME_HOURS, TIME_MINUTES, TIME_SECONDS, TIME_JD, TIME_MJD}; 2 4 3 5 /***** convert [-]00:00:00 to 0.0000 ****/ … … 86 88 } 87 89 88 # define FORMAT_DAYS 189 # define FORMAT_HOURS 290 # define FORMAT_MINUTES 391 # define FORMAT_SECONDS 492 # define FORMAT_JD 593 # define FORMAT_DATE 694 95 90 /**********/ 96 91 int chk_time (char *line) { … … 102 97 p1 = line; 103 98 tmp = strtod (p1, &p2); 99 mode = TIME_DATE; 104 100 if (p2 == p1 + strlen (p1) - 1) { 105 101 if (*p2 == 'd') { 106 mode = FORMAT_DAYS;102 mode = TIME_DAYS; 107 103 } 108 104 if (*p2 == 'h') { 109 mode = FORMAT_HOURS;105 mode = TIME_HOURS; 110 106 } 111 107 if (*p2 == 'm') { 112 mode = FORMAT_MINUTES;108 mode = TIME_MINUTES; 113 109 } 114 110 if (*p2 == 's') { 115 mode = FORMAT_SECONDS;111 mode = TIME_SECONDS; 116 112 } 117 113 if (*p2 == 'j') { 118 mode = FORMAT_JD; 119 } 120 } else { 121 mode = FORMAT_DATE; 114 mode = TIME_JD; 115 } 116 if (*p2 == 'J') { 117 mode = TIME_MJD; 118 } 122 119 } 123 120 return (mode); … … 125 122 126 123 /**********/ 127 int str_to_time (char *line, unsigned int *second) { 128 124 int str_to_time (char *line, time_t *second) { 125 126 char *tmpline; 127 struct tm *gmt; 129 128 struct timeval now; 130 129 double jd; 130 time_t tsec; 131 131 132 132 if (!strcasecmp (line, "NOW")) { … … 136 136 } 137 137 138 if (!str casecmp (line, "TODAY")) {138 if (!strncasecmp (line, "TODAY", 5)) { 139 139 gettimeofday (&now, (struct timezone *) NULL); 140 *second = 86400 * ((int)(now.tv_sec / 86400)); 141 return (TRUE); 140 if (line[5]) { /* line has extra data (ie, hh:mm:ss) */ 141 tsec = now.tv_sec; 142 ALLOCATE (tmpline, char, 64); 143 gmt = gmtime (&tsec); 144 sprintf (tmpline, "%04d/%02d/%02d,%s", 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, &line[6]); 145 *second = date_to_sec (tmpline); 146 free (tmpline); 147 return (TRUE); 148 } else { 149 *second = 86400 * ((int)(now.tv_sec / 86400)); 150 return (TRUE); 151 } 142 152 } 143 153 … … 145 155 case 0: 146 156 return (FALSE); 147 case FORMAT_DAYS: 157 case TIME_DATE: 158 *second = date_to_sec (line); 159 return (TRUE); 160 case TIME_DAYS: 148 161 *second = strtod (line, 0) * 86400.0; 149 162 return (TRUE); 150 case FORMAT_HOURS:163 case TIME_HOURS: 151 164 *second = strtod (line, 0) * 3600.0; 152 165 return (TRUE); 153 case FORMAT_MINUTES:166 case TIME_MINUTES: 154 167 *second = strtod (line, 0) * 60.0; 155 168 return (TRUE); 156 case FORMAT_SECONDS:169 case TIME_SECONDS: 157 170 *second = strtod (line, 0); 158 171 return (TRUE); 159 case FORMAT_JD:172 case TIME_JD: 160 173 jd = strtod (line, 0); 161 174 *second = jd_to_sec (jd); 162 175 return (TRUE); 163 case FORMAT_DATE: 164 *second = date_to_sec (line); 176 case TIME_MJD: 177 jd = strtod (line, 0); 178 *second = mjd_to_sec (jd); 165 179 return (TRUE); 166 180 } 167 181 return (FALSE); 168 182 } 183 169 184 170 185 /**********/ … … 173 188 switch (chk_time (line)) { 174 189 case 0: 175 case FORMAT_JD: 176 case FORMAT_DATE: 190 case TIME_JD: 191 case TIME_MJD: 192 case TIME_DATE: 177 193 return (FALSE); 178 case FORMAT_DAYS:194 case TIME_DAYS: 179 195 *second = strtod (line, 0) * 86400.0; 180 196 return (TRUE); 181 case FORMAT_HOURS:197 case TIME_HOURS: 182 198 *second = strtod (line, 0) * 3600.0; 183 199 return (TRUE); 184 case FORMAT_MINUTES:200 case TIME_MINUTES: 185 201 *second = strtod (line, 0) * 60.0; 186 202 return (TRUE); 187 case FORMAT_SECONDS:203 case TIME_SECONDS: 188 204 *second = strtod (line, 0); 189 205 return (TRUE); … … 193 209 194 210 /**********/ 195 double sec_to_jd ( unsigned longsecond) {211 double sec_to_jd (time_t second) { 196 212 197 213 double jd; … … 202 218 203 219 /**********/ 204 unsigned long int jd_to_sec (double jd) {205 206 unsigned long int second;220 time_t jd_to_sec (double jd) { 221 222 time_t second; 207 223 208 224 second = (jd - 2440587.5)*86400; … … 211 227 212 228 /**********/ 213 char *sec_to_date (unsigned long second) { 229 double sec_to_mjd (time_t second) { 230 231 double mjd; 232 233 mjd = second/86400.0 + 40587.0; 234 return (mjd); 235 } 236 237 /**********/ 238 time_t mjd_to_sec (double mjd) { 239 240 time_t second; 241 242 second = (mjd - 40587.0)*86400; 243 return (second); 244 } 245 246 /**********/ 247 char *sec_to_date (time_t second) { 214 248 215 249 struct tm *gmt; … … 218 252 ALLOCATE (line, char, 64); 219 253 gmt = gmtime (&second); 220 sprintf (line, "% 4d/%02d/%02d,%02d:%02d:%02d", 1900+gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);254 sprintf (line, "%04d/%02d/%02d,%02d:%02d:%02d", 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 221 255 return (line); 222 256 … … 224 258 225 259 /***** date in format yyyy/mm/dd,hh:mm:ss *****/ 226 unsigned longdate_to_sec (char *date) {227 228 unsigned longsecond;260 time_t date_to_sec (char *date) { 261 262 time_t second; 229 263 double tmp, jd; 230 264 struct tm now; … … 283 317 } 284 318 319 /***** short date in format yymmdd *****/ 320 time_t short_date_to_sec (char *date) { 321 322 time_t second; 323 double jd; 324 struct tm now; 325 326 bzero (&now, sizeof(now)); 327 328 sscanf (date, "%2d%2d%2d", &now.tm_year, &now.tm_mon, &now.tm_mday); 329 330 if (now.tm_year > 51) now.tm_year += 0; 331 if (now.tm_year < 50) now.tm_year += 100; 332 now.tm_mon --; /* tm_mon runs from 0 - 11 */ 333 334 jd = now.tm_mday - 32075 + (int)(1461*(1900 + now.tm_year + 4800 + (int)(((now.tm_mon+1)-14)/12))/4) 335 + (int)(367*((now.tm_mon+1) - 2 - (int)(((now.tm_mon+1) - 14)/12)*12)/12) 336 - (int)(3*(int)((1900 + now.tm_year + 4900 + (int)(((now.tm_mon+1) - 14)/12))/100)/4) - 0.5; 337 338 second = (jd - 2440587.5)*86400 + 3600.0*now.tm_hour + now.tm_min*60.0 + now.tm_sec; 339 340 return (second); 341 } 342 343 /**********/ 344 int hms_to_deg (double *h0, double *h1, double *d0, double *d1, char *string) { 345 346 int flag_d0, flag_d1, flag_h0, flag_h1; 347 double tmp; 348 349 *d0 = *h0 = *d1 = *h1 = 0; 350 351 flag_h0 = dparse (h0, 1, string); 352 flag_h1 = dparse (h1, 4, string); 353 flag_d0 = dparse (d0, 7, string); 354 flag_d1 = dparse (d1, 9, string); 355 *h0 *= flag_h0; 356 *h1 *= flag_h1; 357 *d0 *= flag_d0; 358 *d1 *= flag_d1; 359 360 dparse (&tmp, 2, string); 361 *h0 += tmp/60.0; 362 dparse (&tmp, 3, string); 363 *h0 += tmp/3600.0; 364 365 dparse (&tmp, 5, string); 366 *h1 += tmp/60.0; 367 dparse (&tmp, 6, string); 368 *h1 += tmp/3600.0; 369 370 dparse (&tmp, 8, string); 371 *d0 += tmp/60.0; 372 373 dparse (&tmp, 10, string); 374 *d1 += tmp/60.0; 375 376 *h0 *= 15*flag_h0; 377 *h1 *= 15*flag_h1; 378 *d0 *= flag_d0; 379 *d1 *= flag_d1; 380 381 return (TRUE); 382 } 285 383 286 384 /* times may be in forms as: 287 20040200450s (N seconds since 1970.0)385 * 20040200450s (N seconds since 1970.0) 288 386 2440900.232j (julian date) 289 99/02/23,03:22:18 (date string) 290 (separators may be anything except space, +, -) 291 99:02:15:12:23:30 292 99:02:15:12h23m30s 293 */ 294 295 296 /* fseek with timeout - 0.5 sec */ 297 int Fseek (FILE *f, long offset, int whence) { 298 299 int status; 300 301 status = fseek (f, offset, whence); 302 if (status == -1) { 303 int k; 304 /* fprintf (stderr, "problem seeking position: %d\n", errno); */ 305 for (k = 0; (k < 10) && ((status = fseek (f, 0, SEEK_SET)) == -1); k++) usleep (50000); 306 if (status == -1) { 307 /* fprintf (stderr, "ERROR: serious problem seeking position: %d\n", errno); */ 308 /* clear lock at this point? */ 309 return (0); 310 } 311 } 312 return (1); 313 } 387 * 99/02/23,03:22:18 (date string) 388 * (separators may be anything except space, +, -) 389 * 99:02:15:12:23:30 390 * 99:02:15:12h23m30s 391 */
Note:
See TracChangeset
for help on using the changeset viewer.
