Changeset 4805 for trunk/Ohana/src/relphot
- Timestamp:
- Aug 16, 2005, 6:41:16 PM (21 years ago)
- Location:
- trunk/Ohana/src/relphot
- Files:
-
- 5 edited
-
Makefile (modified) (1 diff)
-
include/relphot.h (modified) (2 diffs)
-
src/get_regions.c (modified) (1 diff)
-
src/misc.c (modified) (1 diff)
-
src/time.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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.
