IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4805


Ignore:
Timestamp:
Aug 16, 2005, 6:41:16 PM (21 years ago)
Author:
eugene
Message:

cleaning include files, merging time/coord functions in libohana

Location:
trunk/Ohana/src
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/Makefile

    r4299 r4805  
    2828$(SRC)/check_permissions.$(ARCH).o \
    2929$(SRC)/ConfigInit.$(ARCH).o \
    30 $(SRC)/conversions.$(ARCH).o \
    3130$(SRC)/dump.$(ARCH).o \
    3231$(SRC)/edge_check.$(ARCH).o \
  • trunk/Ohana/src/addstar/include/addstar.h

    r4538 r4805  
    106106time_t TIMEREF;
    107107
    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 ***/
     109void       AddToCalibration       PROTO((Average *average, Measure *measure, Measure *new, int Nstar));
     110void       ConfigInit             PROTO((int *argc, char **argv));
     111void       FindCalibration        PROTO((Image *image));
     112int        FindDecBand            PROTO((double dec, double *DEC0, double *DEC1));
     113int        FindRegionByPoint      PROTO((GSCRegion *regions, double ra, double dec, GSCRegion *gsc, int Ngsc));
     114int        FindRegionDecBandStart PROTO((GSCRegion *region, int Nregion, double dec));
     115int        FindRegionDecBandStop  PROTO((GSCRegion *region, int Nregion, double dec));
     116FILE      *GetDB                  PROTO((int *state));
     117void       InitCalibration        PROTO(());
     118GSCRegion *LoadRegions            PROTO((int *nregions));
     119void       SaveCalibration        PROTO((float M, float dM, float Mr, float dMr, float Mc, float A, int N));
     120void       SetProtect             PROTO((int mode));
     121int        SetSignals             PROTO(());
     122int        Shutdown               PROTO((char *message, ...); )
     123void       TrapSignal             PROTO((int sig));
     124short      airmass                PROTO((short secz_image, double ra, double dec, double st, double latitude));
     125void       aregion                PROTO((GSCRegion *region, FILE *f, double ra, double dec));
     126int        args                   PROTO((int argc, char **argv));
     127void       check_permissions      PROTO((char *basefile));
     128int        dump_rawstars          PROTO((Stars *stars, int Nstars));
     129int        edge_check             PROTO((double *x1, double *y1, double *x2, double *y2));
     130void       find_matches           PROTO((GSCRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap));
     131void       find_matches_refstars  PROTO((GSCRegion *region, Stars **stars, int Nstars, Catalog *catalog));
     132Stars    **find_subset            PROTO((GSCRegion *region, Stars *stars, int Nstars, int *NSTARS));
     133int        gcatalog               PROTO((Catalog *catalog));
     134Stars     *get2mass               PROTO((GSCRegion *patch, int *NSTARS, int mode));
     135double     get_subpix             PROTO((double x, double y));
     136Stars     *getgsc                 PROTO((GSCRegion *patch, int *NSTARS));
     137Stars     *getusno                PROTO((GSCRegion *catstats, int *Nstars));
     138Image     *gimages                PROTO((Image *image, int *Npimage));
     139Stars     *grefcat                PROTO((char *Refcat, GSCRegion *catstats, int *nstars));
     140Stars     *grefstars              PROTO((char *file, int *Nstars));
     141GSCRegion *gregion_image          PROTO((Image *image, int *Nregions));
     142GSCRegion *gregion_match          PROTO((GSCRegion *regions, int *nregions));
     143GSCRegion *gregion_patch          PROTO((GSCRegion *patch, int *nregions));
     144void       gregion_star           PROTO((Stars *star, GSCRegion *region));
     145GSCRegion *gregion_stars          PROTO((Stars *stars, int Nstars, int *Nregion));
     146GSCRegion *gregions               PROTO((Image *image, int *Nregions));
     147Stars     *gstars                 PROTO((char *file, int *NSTARS, Image *image));
     148void       help                   PROTO(());
     149int        hms_to_deg             PROTO((double *h0, double *h1, double *d0, double *d1, char *string));
     150int        in_image               PROTO((double r, double d, Image *image));
     151int        load_pt_catalog        PROTO((Catalog *catalog, GSCRegion *region));  /*** choose new name ***/
     152void       load_subpix            PROTO(());
     153void       lock_image_db          PROTO(());
     154int        main                   PROTO((int argc, char **argv));
     155void       make_backup            PROTO((char *filename));
     156int        match_refstars         PROTO((Stars *stars, int Nstars));
     157void       mkcatalog              PROTO((GSCRegion *region, Catalog *catalog));
     158double     opening_angle          PROTO((double x1, double y1, double x2, double y2, double x3, double y3));
     159int        parse_time             PROTO((Header *header));
     160Stars     *rd_gsc                 PROTO((char *filename, int *nstars));
     161int        replace_match          PROTO((Average *average, Measure *measure, Stars *star));
     162Stars     *rfits                  PROTO((FILE *f, int *nstars));
     163Stars     *rtext                  PROTO((FILE *f, int *nstars));
     164void       save_pt_catalog        PROTO((Catalog *catalog));  /*** choose new name ***/
     165double     scat_subpix            PROTO((double x, double y));
     166time_t     short_date_to_sec      PROTO((char *date));
     167void       sort_lists             PROTO((float *X, float *Y, int *S, int N));
     168void       sort_regions           PROTO((GSCRegion *region, int N));
     169void       sort_stars             PROTO((Stars *stars, int N));
     170int        str_to_radec           PROTO((double *ra, double *dec, char *str1, char *str2));
     171void       unlock_image_db        PROTO((Image *image));
     172void       update_coords          PROTO((Average *average, Measure *measure, int *next));
     173void       wcatalog               PROTO((Catalog *catalog));
     174void       wimage                 PROTO((Image *image));
    115175
    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 
     176void       uppercase              PROTO((char *string));
     177void       fsort                  PROTO((float *X, int N));
     178void       fsort2                 PROTO((float *X, float *Y, int N));
    160179
    161180/**
     
    168187**/
    169188
    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  
    11# include "addstar.h"
     2
    23enum {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
    311
    412/***** convert [-]00:00:00 to 0.0000 ****/
     
    8694  return (TRUE);
    8795}
    88 
    89 # define FORMAT_DAYS    1
    90 # define FORMAT_HOURS   2
    91 # define FORMAT_MINUTES 3
    92 # define FORMAT_SECONDS 4
    93 # define FORMAT_JD      5
    94 # define FORMAT_DATE    6
    9596
    9697/**********/
  • trunk/Ohana/src/delstar/Makefile

    r4680 r4805  
    3838$(SRC)/find_matches.$(ARCH).o     \
    3939$(SRC)/parse_time.$(ARCH).o       \
    40 $(SRC)/convert.$(ARCH).o \
    4140$(SRC)/sort_lists.$(ARCH).o \
    4241$(SRC)/check_permissions.$(ARCH).o \
  • trunk/Ohana/src/delstar/include/delstar.h

    r4680 r4805  
    3030enum {MODE_IMAGENAME, MODE_IMAGEFILE, MODE_TIME, MODE_ORPHAN, MODE_MISSED};
    3131
    32 enum {TIME_NONE, TIME_JD, TIME_MJD, TIME_DATE, TIME_DAYS, TIME_HOURS, TIME_MINUTES, TIME_SECONDS};
    33 
    3432char DateKeyword[64], DateMode[64], UTKeyword[64], MJDKeyword[64], JDKeyword[64];
    3533
    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 ***/
     35void       ConfigInit             PROTO((int *argc, char **argv));
     36int        FindDecBand            PROTO((double dec, double *DEC0, double *DEC1));
     37int        FindRegionByPoint      PROTO((GSCRegion *region, double ra, double dec, GSCRegion *gsc, int Ngsc));
     38int        FindRegionDecBandStart PROTO((GSCRegion *region, int Nregion, double dec));
     39int        FindRegionDecBandStop  PROTO((GSCRegion *region, int Nregion, double dec));
     40FILE      *GetDB                  PROTO((int *state));
     41Image     *GetImages              PROTO((int *nimage));
     42GSCRegion *LoadRegions            PROTO((int *nregions));
     43int        SetImages              PROTO((Image *new, int Nnew));
     44void       SetProtect             PROTO((int mode));
     45int        SetSignals             PROTO(());
     46int        Shutdown               PROTO((char *format, ...));
     47void       TrapSignal             PROTO((int sig));
     48int        args                   PROTO((int *argc, char **argv));
     49void       check_permissions      PROTO((char *basefile));
     50void       delete_imagefile       PROTO((char *filename));
     51void       delete_imagename       PROTO((char *name));
     52void       delete_times           PROTO(());
     53int        dimages                PROTO((int *imlist, int Nimlist));
     54int        edge_check             PROTO((double *x1, double *y1, double *x2, double *y2));
     55Image     *find_images            PROTO((FILE *f, CatStats *catstats, int *Nimages));
     56int       *find_images_data       PROTO((Image *timage, int *nlist));
     57int       *find_images_name       PROTO((char *filename, int *nlist));
     58int       *find_images_time       PROTO((time_t start, time_t end, PhotCode *code, int *nlist));
     59void       find_matches           PROTO((Catalog *catalog, int photcode, int start, int end));
     60int        gcatalog               PROTO((Catalog *catalog));
     61Image     *gimages                PROTO((char *filename));
     62GSCRegion *gregion_image          PROTO((Image *image, int *Nregions));
     63GSCRegion *gregion_patch          PROTO((GSCRegion *patch, int *nregions));
     64Image     *gtimes                 PROTO((int *NIMAGE));
     65void       help                   PROTO(());
     66int        load_image_db          PROTO(());
     67void       lock_image_db          PROTO(());
     68void       match_images           PROTO((Catalog *catalog, Image *image, int Nimage));
     69double     opening_angle          PROTO((double x1, double y1, double x2, double y2, double x3, double y3));
     70int        parse_time             PROTO((Header *header));
     71int        save_image_db          PROTO(());
     72void       sort_lists             PROTO((float *X, float *Y, int *S, int N));
     73void       sort_regions           PROTO((GSCRegion *region, int N));
     74void       unlock_image_db        PROTO(());
     75void       usage                  PROTO(());
     76int        wcatalog               PROTO((Catalog *catalog));
  • trunk/Ohana/src/delstar/src/convert.c

    r4680 r4805  
    11# include "delstar.h"
    22 
     3enum {TIME_NONE, TIME_DATE, TIME_DAYS, TIME_HOURS, TIME_MINUTES, TIME_SECONDS, TIME_JD, TIME_MJD};
     4
    35/***** convert [-]00:00:00 to 0.0000 ****/
    46int dms_to_ddd (double *Value, char *string) {
     
    9597  p1 = line;
    9698  tmp = strtod (p1, &p2);
     99  mode = TIME_DATE;
    97100  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    }
    98113    if (*p2 == 'j') {
    99114      mode = TIME_JD;
     
    102117      mode = TIME_MJD;
    103118    }
    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;
    118119  }
    119120  return (mode);
     
    141142      ALLOCATE (tmpline, char, 64);
    142143      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]);
    145145      *second = date_to_sec (tmpline);
    146146      free (tmpline);
     
    155155  case 0:
    156156    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);
    157172  case TIME_JD:
    158173    jd = strtod (line, 0);
     
    162177    jd = strtod (line, 0);
    163178    *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);
    179179    return (TRUE);
    180180  }
     
    319319}
    320320
     321/***** short date in format yymmdd *****/
     322time_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
    321345/**********/
    322346int hms_to_deg (double *h0, double *h1, double *d0, double *d1, char *string) {
  • trunk/Ohana/src/libohana/Makefile

    r4744 r4805  
    3434$(SRC)/version.$(ARCH).o         \
    3535$(SRC)/string.$(ARCH).o          \
     36$(SRC)/time.$(ARCH).o            \
    3637$(SRC)/findexec.$(ARCH).o        \
    3738$(SRC)/glockfile.$(ARCH).o       \
  • trunk/Ohana/src/libohana/include/ohana.h

    r3903 r4805  
    9191extern double hypot();
    9292
    93 char *ohana_version ();
    94 
    9593/* 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);
     94int     stripwhite             PROTO((char *string));
     95int     strnumcmp              PROTO((char *str1, char *str2));
     96char   *strcreate              PROTO((char *string));
     97char   *strncreate             PROTO((char *string, int n));
     98int     scan_line              PROTO((FILE *f, char *line));
     99int     dparse                 PROTO((double *X, int NX, char *line));
     100int     fparse                 PROTO((float *X, int NX, char *line));
     101int     get_argument           PROTO((int argc, char **argv, char *arg));
     102int     remove_argument        PROTO((int N, int *argc, char **argv));
     103void    uppercase              PROTO((char *string));
    106104
    107105/* 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);
     106char   *pathname               PROTO((char *name));
     107char   *filebasename           PROTO((char *name));
     108char   *filerootname           PROTO((char *name));
     109char   *findexec               PROTO((int argc, char **argv));
     110int     mkdirhier              PROTO((char *path));
     111void    make_backup            PROTO((char *filename));
    114112
    115113/* 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);
     114FILE   *fsetlockfile           PROTO((char *filename, double timeout, int type, int *state));
     115int     fclearlockfile         PROTO((char *filename, FILE *f, int type, int *state));
    118116
    119117/* 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);
     118char   *SelectConfigFile       PROTO((int *argc, char **argv, char *progname));
     119char   *LoadConfigFile         PROTO((char *filename));
     120char   *ScanConfig             PROTO((char *config, char *field, char *mode, int N,...));
     121char   *expandline             PROTO((char *line, char *config));
     122char   *fileextname            PROTO((char *file));
     123char   *LoadRawConfigFile      PROTO((char *, int));
    126124
    127 /* in Fseek.c */
    128 int   Fseek (FILE *f, long offset, int whence);
     125/* others */
     126int     Fseek                  PROTO((FILE *f, long offset, int whence));
     127char   *ohana_version          PROTO(());
     128
     129/* in time.c */
     130enum {TIME_NONE, TIME_DATE, TIME_DAYS, TIME_HOURS, TIME_MINUTES, TIME_SECONDS, TIME_JD, TIME_MJD};
     131
     132int     chk_time               PROTO((char *line));
     133time_t  date_to_sec            PROTO((char *date));
     134int     dms_to_ddd             PROTO((double *Value, char *string));
     135time_t  jd_to_sec              PROTO((double jd));
     136char   *sec_to_date            PROTO((time_t second));
     137double  sec_to_jd              PROTO((time_t second));
     138int     str_to_dtime           PROTO((char *line, double *second));
     139int     str_to_time            PROTO((char *line, time_t *second));
     140double  sec_to_mjd             PROTO((time_t second));
     141time_t  mjd_to_sec             PROTO((double mjd));
     142int     hms_to_deg             PROTO((double *h0, double *h1, double *d0, double *d1, char *string));
    129143
    130144/*
  • trunk/Ohana/src/mosastro/include/mosastro.h

    r4772 r4805  
    128128char *FOCAL_PLANE;
    129129
    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 ***/
     131void       ChipToFP           PROTO((StarData *stars, int Nstars, Coords *coords));
     132void       ChipToSky          PROTO((StarData *stars, int Nstars, Coords *coords));
     133int        ClipOnFP           PROTO((double Nsigma));
     134void       ConfigInit         PROTO((int *argc, char **argv));
     135int        ConvertMatch       PROTO((MatchData *data, int size, int nitems));
     136void       FPtoChip           PROTO((StarData *stars, int Nstars, Coords *coords));
     137void       FPtoTP             PROTO((StarData *stars, int Nstars, Coords *coords));
     138void       FitChip            PROTO((StarData *raw, StarData *ref, int Nmatch, Coords *coords));
     139void       FitChipLinear      PROTO((StarData *raw, StarData *ref, int Nmatch, Coords *coords));
     140void       FitChipResid       PROTO((StarData *raw, StarData *ref, int Nmatch, Coords *coords));
     141void       FitChips           PROTO((int Norder));
     142void       FitGradients       PROTO((Gradients *grad));
     143void       GetConfig          PROTO((char *config, char *field, char *format, int N, void *ptr));
     144Gradients *GetGradients       PROTO(());
     145double     GetScatter         PROTO((int *Nscatter, double *DL, double *DM, int bright));
     146int        LoadStars          PROTO((int Nfile, char **file));
     147void       SaveResiduals      PROTO((FILE *f, Header *header));
     148void       SkyToTP            PROTO((StarData *stars, int Nstars, Coords *coords));
     149void       TPtoFP             PROTO((StarData *stars, int Nstars, Coords *coords));
     150void       TPtoSky            PROTO((StarData *stars, int Nstars, Coords *coords));
     151void       add_to_regions     PROTO((CatStats *area));
     152void       area_of_region     PROTO((CatStats *region));
     153void       args               PROTO((int *argc, char **argv));
     154int        deproject_raw      PROTO(());
     155int        deproject_stars    PROTO(());
     156int        dump_grads         PROTO((Gradients *grad, char *filename));
     157int        dump_match         PROTO(());
     158int        dump_rawstars      PROTO(());
     159int        dump_refcat        PROTO((StarData *refcat, int Nrefcat));
     160int        dump_stars         PROTO((FILE *f, StarData *stars, int Nstars));
     161int        fake_field         PROTO((double RA, double DEC));
     162void       field_combine      PROTO(());
     163void       field_stats        PROTO(());
     164int        find_dec_bands     PROTO((CatStats *area));
     165void       fit_add            PROTO((double x1, double y1, double x2, double y2));
     166void       fit_apply_coords   PROTO((Coords *coords));
     167void       fit_apply_grads    PROTO((Coords *distort, Coords *project, int term));
     168void       fit_correct_grads  PROTO((Gradients *in, Gradients *out, int term));
     169void       fit_eval           PROTO(());
     170void       fit_free           PROTO(());
     171void       fit_init           PROTO((int order));
     172int        gaussj             PROTO((double **a, int n, double **b, int m));
     173StarData  *gcatalog           PROTO((char *filename, int *Nstars));
     174StarData  *get2mass           PROTO((CatStats *catstats, int *NSTARS));
     175StarData  *getgsc             PROTO((CatStats *catstats, int *NSTARS));
     176StarData  *getptolemy         PROTO((CatStats *catstats, int *NSTARS));
     177StarData  *getstone           PROTO((CatStats *input, int *nstars));
     178StarData  *getusno            PROTO((CatStats *catstats, int *Nstars));
     179StarData  *gptolemy           PROTO((char *filename, int *NSTARS));
     180StarData  *greference         PROTO((int *Nrefcat));
     181CatStats  *gregions           PROTO((CatStats *patch, int *nregion));
     182int        init_chips         PROTO(());
     183int        init_field         PROTO(());
     184void       init_regions       PROTO(());
     185int        load_chips         PROTO((char *filename));
     186int        load_field         PROTO((char *filename));
     187int        load_ra_blocks     PROTO((int Ndec, CatStats *area));
     188int        match              PROTO((StarData *refcat, int Nrefcat));
     189Header    *mkheader           PROTO((int Nx, int Ny, int Nstars, Coords *coords));
     190Header    *mkmosaic           PROTO((int Nx, int Ny, int Nstars, Coords *coords));
     191int        mkpolyterm         PROTO((int n, int m));
     192int        mkvector           PROTO((int n, int m, int norder));
     193void       output             PROTO((char *ext, char *phu));
     194int        parse_GSC_line     PROTO((CatStats *tregion, char *line));
     195e_time     parse_time         PROTO((Header *header));
     196void       print_help         PROTO(());
     197int        project_ref        PROTO(());
     198int        project_refcat     PROTO((StarData *refcat, int Nrefcat));
     199int        project_stars      PROTO(());
     200int        rfits              PROTO((Chip *mychip));
     201int        rtext              PROTO((Chip *mychip));
     202void       set_catalog        PROTO((char *catdir));
     203int        sortthree          PROTO((double *X, double *Y, int *Z, int N));
     204void       uppercase          PROTO((char *string));
     205void       wchip              PROTO((char *filename, Chip *data));
     206void       wfits              PROTO((char *filename, SMPData *stars, int Nstars, Header *header));
     207void       wstars             PROTO((char *filename, SMPData *stars, int Nstars, Header *header));
  • trunk/Ohana/src/opihi/include/convert.h

    r4602 r4805  
    44# define CONVERT_H
    55
    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 ***/
    107time_t        TimeRef               PROTO((double time, time_t TimeReference, int TimeFormat));
    118double        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
    2310int           hh_hms                PROTO((double hh, int *hr, int *mn, double *sc));
    2411int           dd_dms                PROTO((double dd, int *dg, int *mn, double *sc));
     
    3320char         *meade_dec_to_str      PROTO((double deg));
    3421int           hstgsc_hms_to_deg     PROTO((double *h0, double *h1, double *d0, double *d1, char *string));
     22char         *strptime              PROTO((const char *s, const char *format, struct tm *tm));
    3523
    3624# endif
  • trunk/Ohana/src/opihi/include/dvo1.h

    r4689 r4805  
    2323} RegionFile;
    2424
    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 ***/
     26int           DetermineTypeCode     PROTO((Average *average, Measure *measure, int code));
     27double        DetermineTypefrac     PROTO((Average *average, Measure *measure, PhotCode *code));
     28double        ExtractAverages       PROTO((PhotCode *code, int mode, Average *average, SecFilt *secfilt, Measure *measure, int param));
     29double       *ExtractByDMag         PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param));
     30double       *ExtractDMag           PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist));
     31double       *ExtractMagnitudes     PROTO((PhotCode *code, int mode, Average *average, SecFilt *secfilt, Measure *measure, int *n));
     32double       *ExtractMeasures       PROTO((PhotCode *code, int mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param));
    4333double       *ExtractMeasuresByDMag PROTO((PhotCode **code, int *mode, int use_first, Average *average, SecFilt *secfilt, Measure *measure, int *nlist, int param));
    4434double       *ExtractMeasuresDMag   PROTO((PhotCode **code, int *mode, Average *average, SecFilt *secfilt, Measure *measure, int *nlist));
     35void          FreeImageSelection    PROTO(());
     36void          FreeImageSelection    PROTO(());
     37int           GetAverageParam       PROTO((char *parname));
     38void          GetAverageParamHelp   PROTO(());
     39int           GetMagMode            PROTO((char *string));
     40double        GetMeasure            PROTO((int param, Average *average, Measure *measure, double mag));
     41int           GetMeasureParam       PROTO((char *parname));
     42int           GetMeasureTypeCode    PROTO((Measure *measure));
     43int           GetPhotcodeInfo       PROTO((char *string, PhotCode **Code, int *Mode));
     44int           GetRegionSelection    PROTO(());
     45int           GetSelectionParam     PROTO(());
     46int           GetTimeSelection      PROTO((time_t *tz, time_t *te));
     47void          InitDVO               PROTO(());
     48int           InitPhotcodes         PROTO(());
     49Image        *LoadImages            PROTO((int *Nimage));
     50Image        *MatchImage            PROTO((unsigned int time, short int source));
    4551Image        *MatchImage            PROTO((unsigned int time, short int source));
    4652Coords       *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));
     53int           Quality               PROTO((Measure *measure, int IsDophot));
    6154int           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));
     55RegionFile   *SelectRegions         PROTO((char *RegionName, char *RegionList, int *nregions));
     56int           SetImageSelection     PROTO((int mode));
     57int           SetPhotSelections     PROTO((int *argc, char **argv, int Nparams));
     58int           SetRegionSelection    PROTO((int *argc, char **argv, char **RegionName, char **RegionList));
     59int           SetSelectionParam     PROTO((int param));
     60int           TestAverage           PROTO((PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure));
     61int           TestPhotSelections    PROTO((PhotCode **code, int *mode, int param));
     62void          aregion               PROTO((GSCRegion *region, FILE *f, double ra, double dec, char *path));
     63void          compare               PROTO((Catalog *catlog1, Catalog *catlog2, Vector *rvec,  Vector *dvec,  Vector *mvec, Vector *drvec, Vector *ddvec, Vector *dmvec, double radius));
     64void          cprecess              PROTO((Average *average, int Naverage, double in_epoch, double out_epoch));
     65RegionFile   *find_regions          PROTO((double Ra, double Dec, double radius, int *Nregions));
     66GSCRegion    *get_regions           PROTO((Image *image, int *Nregions));
     67void          image_subset          PROTO((Image *image, int Nimage, int **Subset, int *Nsubset, Graphdata *graph, int RegionSelect, unsigned long int tzero, double trange, int TimeSelect));
     68int           match_image           PROTO((Image *image, int Nimage, unsigned int T, short int S));
     69int           match_image_subset    PROTO((Image *image, int *subset, int Nsubset, unsigned int T, short int S));
    6770void          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);
     71RegionFile   *region_list           PROTO((char *filename, int *Nregions));
     72void          sort_image_subset     PROTO((Image *image, int *subset, int N));
     73void          sort_images           PROTO((Image *image, int N));
     74void          sortave               PROTO((Average *ave, int N));
    8075
    8176# endif
  • trunk/Ohana/src/opihi/lib.data/Makefile

    r4747 r4805  
    2121# general numerical functions (libdata) #####################
    2222srcs = \
    23 $(SDIR)/convert.$(ARCH).o               \
    2423$(SDIR)/sort.$(ARCH).o                  \
    2524$(SDIR)/fft.$(ARCH).o                   \
  • trunk/Ohana/src/opihi/lib.data/convert.c

    r4697 r4805  
    33# include <time.h>
    44
    5 char *strptime(const char *s, const char *format, struct tm *tm);
    6 
    7  
     5/** additional time / coordinate conversions not supplied by libohana **/
     6
    87int hh_hms (double hh, int *hr, int *mn, double *sc) {
    98
     
    111110}
    112111
    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 
    169112/***** convert 00:00:00 or 00:00 to 0 - 86400 ****/
    170113int hms_to_sec (char *string, time_t *second) {
     
    211154  if (*p) return (FALSE);
    212155  *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;
    242156  return (TRUE);
    243157}
     
    302216}
    303217
    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 
    536218/* convert UNIX time to a value referenced to the TimeReference in the given unit */
    537219double TimeValue (time_t time, time_t TimeReference, int TimeFormat) {
     
    599281
    600282/* 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  
    4141$(SRC)/plotstuff.$(ARCH).o       \
    4242$(SRC)/misc.$(ARCH).o            \
    43 $(SRC)/time.$(ARCH).o            \
    4443$(SRC)/reload_catalogs.$(ARCH).o \
    4544$(SRC)/free_catalogs.$(ARCH).o   \
  • trunk/Ohana/src/relphot/include/relphot.h

    r4796 r4805  
    8888
    8989int TimeSelect;
    90 unsigned int TSTART, TSTOP;
     90time_t TSTART, TSTOP;
    9191
    9292# ifdef GRID_V1
     
    9898# endif
    9999
    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 ***/
     101void          ConfigInit          PROTO((int *argc, char **argv));
     102int           Fseek               PROTO((FILE *f, long offset, int whence));
     103void          GetConfig           PROTO((char *config, char *field, char *format, int N, void *ptr));
     104char         *GetPhotnamebyCode   PROTO((PhotCodeData *photcodes, int code));
     105void          InterpolateGrid     PROTO((float *buffer, int Nx, int Ny, Coords *ccd, Coords *gcoords));
     106int          *SelectRefMosaic     PROTO((Mosaic **refmosaic, int *Nimage));
     107int           args                PROTO((int argc, char **argv));
     108int           bcatalog            PROTO((Catalog *subcatalog, Catalog *catalog, GSCRegion *fullregion));
     109void          clean_images        PROTO(());
     110void          clean_measures      PROTO((Catalog *catalog, int Ncatalog, int final));
     111void          clean_mosaics       PROTO(());
     112void          clean_stars         PROTO((Catalog *catalog, int Ncatalog));
     113int           corner_check        PROTO((double *x1, double *y1, double *x2, double *y2));
     114void          dumpGrid            PROTO(());
     115void          dump_grid           PROTO(());
     116int           edge_check          PROTO((double *x1, double *y1, double *x2, double *y2));
     117void          findImages          PROTO((Catalog *catalog, int Ncatalog));
     118int           findMosaics         PROTO((Catalog *catalog, int Ncatalog));
     119Image        *find_images         PROTO((GSCRegion *region, int Nregion, int *Nimages, int **LineNum));
     120GSCRegion    *find_regions        PROTO((Image *image, int Nimage, int *Nregions, GSCRegion *fullregion));
     121void          freeGridBins        PROTO((int Ncatalog));
     122void          freeImageBins       PROTO((int Ncatalog));
     123void          freeMosaicBins      PROTO((int Ncatalog));
     124void          free_catalogs       PROTO((Catalog *catalog, int Ncatalog));
     125int           gcatalog            PROTO((Catalog *catalog, int FINAL));
     126Coords       *getCoords           PROTO((int meas, int cat));
     127short         getMcal             PROTO((int meas, int cat));
     128short         getMgrid            PROTO((int meas, int cat));
     129short         getMmos             PROTO((int meas, int cat));
     130short         getMrel             PROTO((Catalog *catalog, int meas, int cat));
     131GSCRegion    *get_regions         PROTO((double minRa, double maxRa, double minDec, double maxDec, int *Nregions));
     132void          getfullregion       PROTO((Image *image, int Nimage, GSCRegion *fullregion));
     133Image        *getimage            PROTO((int N));
     134Image        *getimages           PROTO((int *N));
     135void          global_stats        PROTO((Catalog *catalog, int Ncatalog));
     136void          initGrid            PROTO((int dX, int dY));
     137void          initGridBins        PROTO((Catalog *catalog, int Ncatalog));
     138void          initImageBins       PROTO((Catalog *catalog, int Ncatalog));
     139void          initImages          PROTO((Image *input, int N));
     140void          initMosaicBins      PROTO((Catalog *catalog, int Ncatalog));
     141void          initMosaicGrid      PROTO((Image *image, int Nimage));
     142void          initMosaics         PROTO((Image *image, int Nimage));
     143void          initMrel            PROTO((Catalog *catalog, int Ncatalog));
     144void          initialize          PROTO((int argc, char **argv));
     145void          initstats           PROTO((char *mode));
     146int           liststats           PROTO((double *value, double *dvalue, int N, StatType *stats));
     147Catalog      *load_catalogs       PROTO((GSCRegion *region, int Nregion, GSCRegion *fullregion));
     148GSCRegion    *load_images         PROTO((char *seed, int *nregion, GSCRegion *fullregion));
     149int           main                PROTO((int argc, char **argv));
     150void          mark_images         PROTO((Image *image, int Nimage, Image *timage, int Ntimage));
     151void          matchImage          PROTO((Catalog *catalog, int meas, int cat));
     152void          matchMosaics        PROTO((Catalog *catalog, int meas, int cat));
     153GSCRegion    *name_region         PROTO((char *name, int *Nregions));
     154double        opening_angle       PROTO((double x1, double y1, double x2, double y2, double x3, double y3));
     155void          plot_chisq          PROTO((Catalog *catalog, int Ncatalog));
     156void          plot_defaults       PROTO((Graphdata *graphdata));
     157void          plot_grid           PROTO((Catalog *catalog));
     158void          plot_images         PROTO(());
     159void          plot_list           PROTO((Graphdata *graphdata, double *xlist, double *ylist, int N, char *label, char *file));
     160void          plot_mosaic_fields  PROTO((Catalog *catalog));
     161void          plot_mosaics        PROTO(());
     162void          plot_scatter        PROTO((Catalog *catalog, int Ncatalog));
     163void          plot_star_coords    PROTO((Catalog *catalog, int Ncatalog));
     164void          plot_stars          PROTO((Catalog *catalog, int Ncatalog));
     165void          reload_catalogs     PROTO((GSCRegion *region, int Nregion, GSCRegion *fullregion));
     166int           setExclusions       PROTO((Catalog *catalog, int Ncatalog));
     167void          setMcal             PROTO((Catalog *catalog, int Poor));
     168void          setMcalFinal        PROTO((Image *image, int Nimage));
     169int           setMcalOutput       PROTO((Catalog *catalog, int Ncatalog));
     170void          setMgrid            PROTO((Catalog *catalog));
     171int           setMmos             PROTO((Catalog *catalog, int Poor));
     172int           setMrel             PROTO((Catalog *catalog, int Ncatalog));
     173void          setMrelFinal        PROTO((Catalog *catalog));
     174int           setMrelOutput       PROTO((Catalog *catalog, int Ncatalog, int mark));
     175void          set_ZP              PROTO((double ZERO));
     176int           setrefcode          PROTO((Image *image, int Nimage));
     177void          skip_measurements   PROTO((Catalog *catalog, int pass));
     178void          sortA               PROTO((double *X, int N));
     179void          sortB               PROTO((double *X, double *Y, int N));
     180void          sortC               PROTO((double *X, double *Y, double *F1, double *F2, int N));
     181void          sortD               PROTO((double *X, double *Y, double *Z, int N));
     182StatType      statsImageM         PROTO((Catalog *catalog));
     183StatType      statsImageN         PROTO((Catalog *catalog));
     184StatType      statsImageX         PROTO((Catalog *catalog));
     185StatType      statsImagedM        PROTO((Catalog *catalog));
     186StatType      statsMosaicM        PROTO((Catalog *catalog));
     187StatType      statsMosaicN        PROTO((Catalog *catalog));
     188StatType      statsMosaicX        PROTO((Catalog *catalog));
     189StatType      statsMosaicdM       PROTO((Catalog *catalog));
     190StatType      statsStarN          PROTO((Catalog *catalog, int Ncatalog));
     191StatType      statsStarS          PROTO((Catalog *catalog, int Ncatalog));
     192StatType      statsStarX          PROTO((Catalog *catalog, int Ncatalog));
     193void          wcatalog            PROTO((Catalog *catalog));
     194void          wimages             PROTO(());
     195void          write_coords        PROTO((Header *header, Coords *coords));
  • trunk/Ohana/src/relphot/src/get_regions.c

    r4796 r4805  
    166166 
    167167}
    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  
    182182}
    183183
     184/* fseek with timeout - 0.5 sec */
     185int 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  
    11# include "relphot.h"
     2
     3enum {TIME_NONE, TIME_DATE, TIME_DAYS, TIME_HOURS, TIME_MINUTES, TIME_SECONDS, TIME_JD, TIME_MJD};
    24
    35/***** convert [-]00:00:00 to 0.0000 ****/
     
    8688}
    8789
    88 # define FORMAT_DAYS    1
    89 # define FORMAT_HOURS   2
    90 # define FORMAT_MINUTES 3
    91 # define FORMAT_SECONDS 4
    92 # define FORMAT_JD      5
    93 # define FORMAT_DATE    6
    94 
    9590/**********/
    9691int chk_time (char *line) {
     
    10297  p1 = line;
    10398  tmp = strtod (p1, &p2);
     99  mode = TIME_DATE;
    104100  if (p2 == p1 + strlen (p1) - 1) {
    105101    if (*p2 == 'd') {
    106       mode = FORMAT_DAYS;
     102      mode = TIME_DAYS;
    107103    }
    108104    if (*p2 == 'h') {
    109       mode = FORMAT_HOURS;
     105      mode = TIME_HOURS;
    110106    }
    111107    if (*p2 == 'm') {
    112       mode = FORMAT_MINUTES;
     108      mode = TIME_MINUTES;
    113109    }
    114110    if (*p2 == 's') {
    115       mode = FORMAT_SECONDS;
     111      mode = TIME_SECONDS;
    116112    }
    117113    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    }
    122119  }
    123120  return (mode);
     
    125122
    126123/**********/
    127 int str_to_time (char *line, unsigned int *second) {
    128  
     124int str_to_time (char *line, time_t *second) {
     125 
     126  char *tmpline;
     127  struct tm *gmt;
    129128  struct timeval now;
    130129  double jd;
     130  time_t tsec;
    131131
    132132  if (!strcasecmp (line, "NOW")) {
     
    136136  }
    137137   
    138   if (!strcasecmp (line, "TODAY")) {
     138  if (!strncasecmp (line, "TODAY", 5)) {
    139139    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    }
    142152  }
    143153   
     
    145155  case 0:
    146156    return (FALSE);
    147   case FORMAT_DAYS:
     157  case TIME_DATE:
     158    *second = date_to_sec (line);
     159    return (TRUE);
     160  case TIME_DAYS:
    148161    *second = strtod (line, 0) * 86400.0;
    149162    return (TRUE);
    150   case FORMAT_HOURS:
     163  case TIME_HOURS:
    151164    *second = strtod (line, 0) * 3600.0;
    152165    return (TRUE);
    153   case FORMAT_MINUTES:
     166  case TIME_MINUTES:
    154167    *second = strtod (line, 0) * 60.0;
    155168    return (TRUE);
    156   case FORMAT_SECONDS:
     169  case TIME_SECONDS:
    157170    *second = strtod (line, 0);
    158171    return (TRUE);
    159   case FORMAT_JD:
     172  case TIME_JD:
    160173    jd = strtod (line, 0);
    161174    *second = jd_to_sec (jd);
    162175    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);
    165179    return (TRUE);
    166180  }
    167181  return (FALSE);
    168182}
     183
    169184
    170185/**********/
     
    173188  switch (chk_time (line)) {
    174189  case 0:
    175   case FORMAT_JD:
    176   case FORMAT_DATE:
     190  case TIME_JD:
     191  case TIME_MJD:
     192  case TIME_DATE:
    177193    return (FALSE);
    178   case FORMAT_DAYS:
     194  case TIME_DAYS:
    179195    *second = strtod (line, 0) * 86400.0;
    180196    return (TRUE);
    181   case FORMAT_HOURS:
     197  case TIME_HOURS:
    182198    *second = strtod (line, 0) * 3600.0;
    183199    return (TRUE);
    184   case FORMAT_MINUTES:
     200  case TIME_MINUTES:
    185201    *second = strtod (line, 0) * 60.0;
    186202    return (TRUE);
    187   case FORMAT_SECONDS:
     203  case TIME_SECONDS:
    188204    *second = strtod (line, 0);
    189205    return (TRUE);
     
    193209
    194210/**********/
    195 double sec_to_jd (unsigned long second) {
     211double sec_to_jd (time_t second) {
    196212
    197213  double jd;
     
    202218
    203219/**********/
    204 unsigned long int jd_to_sec (double jd) {
    205 
    206   unsigned long int second;
     220time_t jd_to_sec (double jd) {
     221
     222  time_t second;
    207223
    208224  second = (jd - 2440587.5)*86400;
     
    211227
    212228/**********/
    213 char *sec_to_date (unsigned long second) {
     229double sec_to_mjd (time_t second) {
     230
     231  double mjd;
     232 
     233  mjd = second/86400.0 + 40587.0;
     234  return (mjd);
     235}
     236
     237/**********/
     238time_t mjd_to_sec (double mjd) {
     239
     240  time_t second;
     241
     242  second = (mjd - 40587.0)*86400;
     243  return (second);
     244}
     245
     246/**********/
     247char *sec_to_date (time_t second) {
    214248 
    215249  struct tm *gmt;
     
    218252  ALLOCATE (line, char, 64);
    219253  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);
    221255  return (line);
    222256
     
    224258
    225259/***** date in format yyyy/mm/dd,hh:mm:ss *****/
    226 unsigned long date_to_sec (char *date) {
    227  
    228   unsigned long second;
     260time_t date_to_sec (char *date) {
     261 
     262  time_t second;
    229263  double tmp, jd;
    230264  struct tm now;
     
    283317}
    284318
     319/***** short date in format yymmdd *****/
     320time_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/**********/
     344int 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}
    285383
    286384/* times may be in forms as:
    287    20040200450s (N seconds since 1970.0)
     385 * 20040200450s (N seconds since 1970.0)
    288386   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.