IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19681


Ignore:
Timestamp:
Sep 23, 2008, 10:05:34 AM (18 years ago)
Author:
eugene
Message:

cleanup skycalc build, license info, prototypes; add sunmoon function

Location:
trunk/Ohana/src/skycalc
Files:
4 added
12 edited

Legend:

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

    r12842 r19681  
    1 default: skycalc
     1default: install
    22help:
    3         @echo "make options: (default)"
     3        @echo "make options: install libskycalc all programs clean dist"
    44
    55include ../../Makefile.System
     
    1313
    1414# programs may add their own internal requirements here
    15 FULL_CFLAGS   = $(BASE_CFLAGS)
     15FULL_CFLAGS   = $(BASE_CFLAGS) -fPIC
    1616FULL_CPPFLAGS = $(BASE_CPPFLAGS)
    17 FULL_LDFLAGS  = $(BASE_LDFLAGS)
     17FULL_LDFLAGS  = $(BASE_LDFLAGS) -lskycalc -lohana
    1818
    19 skycalc: $(DESTLIB)/libskycalc.a
    2019install: $(DESTINC)/skycalc.h $(DESTLIB)/libskycalc.a
     20libskycalc: $(DESTLIB)/libskycalc.a $(DESTLIB)/libskycalc.$(DLLTYPE)
    2121
    22 all: moondata dusktime sundata
     22all: libskycalc dusktime moondata sundata
     23programs: all
    2324
    24 OBJ =   $(SRC)/time.$(ARCH).o           $(SRC)/geometry.$(ARCH).o \
    25         $(SRC)/astro.$(ARCH).o          $(SRC)/sun.$(ARCH).o \
    26         $(SRC)/moon.$(ARCH).o
     25INCS = $(DESTINC)/skycalc.h
    2726
    28 $(OBJ): $(INC)/skycalc.h $(INC)/skycalc_internal.h
     27MYINCS = $(INCS) $(INC)/skycalc_internal.h
    2928
    30 $(LIB)/libskycalc.$(ARCH).a: $(OBJ)
    31         @if [ ! -d $(LIB) ]; then mkdir -p $(LIB); fi
    32         rm -f $(LIB)/libskycalc.$(ARCH).a
    33         ar rcv $(LIB)/libskycalc.$(ARCH).a $(OBJ)
    34         $(RANLIB) $(LIB)/libskycalc.$(ARCH).a
     29OBJS =  \
     30$(SRC)/time.$(ARCH).o     \
     31$(SRC)/geometry.$(ARCH).o \
     32$(SRC)/astro.$(ARCH).o    \
     33$(SRC)/sun.$(ARCH).o      \
     34$(SRC)/moon.$(ARCH).o
    3535
    36 $(DESTLIB)/libskycalc.a: $(LIB)/libskycalc.$(ARCH).a
    37         @if [ ! -d $(DESTLIB) ]; then mkdir -p $(DESTLIB); fi
    38         rm -f  $(DESTLIB)/libskycalc.a
    39         cp $(LIB)/libskycalc.$(ARCH).a $(DESTLIB)/libskycalc.a
     36$(OBJS): $(MYINCS)
    4037
    41 $(DESTINC)/skycalc.h: $(INC)/skycalc.h
    42         @if [ ! -d $(DESTINC) ]; then mkdir -p $(DESTINC); fi
    43         rm -f $(DESTINC)/skycalc.h
    44         cp $(INC)/skycalc.h $(DESTINC)/
     38$(LIB)/libskycalc.$(ARCH).a: $(OBJS)
     39$(LIB)/libskycalc.$(ARCH).$(DLLTYPE): $(OBJS)
    4540
    46 test:
    47         $(CC) $(CCFLAGS) -g -o skylib $(SRC)/skylib.c -lskycalc -lm
     41$(DESTLIB)/libskycalc.a:  $(LIB)/libskycalc.$(ARCH).a
     42$(DESTLIB)/libskycalc.$(DLLTYPE): $(LIB)/libskycalc.$(ARCH).$(DLLTYPE)
    4843
    49 dusktime: skycalc
    50         @if [ ! -d $(BIN) ]; then mkdir -p $(BIN); fi
    51         @if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN); fi
    52         $(CC) $(CCFLAGS) -g -o $(BIN)/dusktime.$(ARCH) $(SRC)/dusktime.c -lskycalc -lm -lohana
    53         cp $(BIN)/dusktime.$(ARCH) $(DESTBIN)/dusktime
     44dusktime : $(BIN)/dusktime.$(ARCH)
     45moondata : $(BIN)/moondata.$(ARCH)
     46sundata  : $(BIN)/sundata.$(ARCH)
     47sunmoon  : $(BIN)/sunmoon.$(ARCH)
    5448
    55 moondata: skycalc
    56         @if [ ! -d $(BIN) ]; then mkdir -p $(BIN); fi
    57         @if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN); fi
    58         $(CC) $(CCFLAGS) -g -o $(BIN)/moondata.$(ARCH) $(SRC)/moondata.c -lskycalc -lm -lohana
    59         cp $(BIN)/moondata.$(ARCH) $(DESTBIN)/moondata
     49DUSKTIME = $(SRC)/dusktime.$(ARCH).o
     50MOONDATA = $(SRC)/moondata.$(ARCH).o
     51SUNDATA  = $(SRC)/sundata.$(ARCH).o
     52SUNMOON  = $(SRC)/sunmoon.$(ARCH).o
    6053
    61 sundata: skycalc
    62         @if [ ! -d $(BIN) ]; then mkdir -p $(BIN); fi
    63         @if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN); fi
    64         $(CC) $(CCFLAGS) -g -o $(BIN)/sundata.$(ARCH) $(SRC)/sundata.c -lskycalc -lm -lohana
    65         cp $(BIN)/sundata.$(ARCH) $(DESTBIN)/sundata
     54$(DUSKTIME) : $(MYINCS)
     55$(MOONDATA) : $(MYINCS)
     56$(SUNDATA)  : $(MYINCS)
     57$(SUNMOON)  : $(MYINCS)
    6658
    67 clean: 
    68         rm -f `find . -name "*.o"`
    69         rm -f `find . -name "*.a"`
    70         rm -f `find . -name "*~"`
    71         rm -f `find . -name "#*"`
     59$(BIN)/dusktime.$(ARCH) : $(DUSKTIME)
     60$(BIN)/moondata.$(ARCH) : $(MOONDATA)
     61$(BIN)/sundata.$(ARCH)  : $(SUNDATA)
     62$(BIN)/sunmoon.$(ARCH)  : $(SUNMOON)
    7263
    73 .SUFFIXES: .$(ARCH).o
     64INSTALL = dusktime moondata sundata sunmoon
    7465
    75 .c.$(ARCH).o:
    76         $(CC) $(CFLAGS) -c $<
     66# dependancy rules for binary code #########################
     67$(INSTALL): % : $(BIN)/%.$(ARCH)
    7768
     69%.clean :
     70        rm -f $(BIN)/$*.$(ARCH)
     71
     72%.install:
     73        make $(DESTBIN)/$*
     74
     75install:
     76        for i in $(INSTALL); do make $$i.install || exit; done
  • trunk/Ohana/src/skycalc/include/skycalc.h

    r2496 r19681  
     1
     2/* This is the header file for the Ohana version of 'libskycalc'.  This library is based on the
     3 * code provided to the community by John Thorstensen.  See the discussion in the README file
     4 * and in the file doc/Thorstensen.txt
     5 */
    16
    27/* header for skycalc library function calls */
  • trunk/Ohana/src/skycalc/include/skycalc_internal.h

    r3263 r19681  
     1/* header for use by the skycalc library files and stand-alone programs, not needed for external calls */
    12
    2 /* header for use by the skycalc library files, not needed for external calls */
    3 
    4 # include <skycalc.h>
    53# include <stdio.h>
    64# include <math.h>
    7 # include <ctype.h>
    8 # include <stdarg.h>
    9 # include <string.h>
     5# include <stdlib.h>
    106# include <time.h>
    11 
    12 /* a couple of the system-dependent magic numbers are defined here */
    13 
    14 #define SYS_CLOCK_OK 1    /* 1 means ANSI-standard time libraries do work,
    15    2 means they don't.  This is used by compiler switches in file 5 and
    16    the main program.  */
    17 
    18 #define LOG_FILES_OK 1  /* 1 means that log files are enabled.
    19                         Any other value means they're not.  */
    20 
    21 #define MAX_OBJECTS 500
    22 #define MINSHORT -32767   /* min, max short integers and double precision */
    23 #define MAXSHORT 32767
    24 #define MAXDOUBLE 1.0e38
    25 #define MINDOUBLE -1.0e38
    26 #define BUFSIZE 150
     7# include <skycalc.h>
    278
    289/* some (not all) physical, mathematical, and astronomical constants
     
    4425#define  PLANET_TOL        3.          /* flag if nearer than 3 degrees
    4526                                                to a major planet ... */
    46 #define  KZEN              0.172       /* zenith extinction, mag, for use
    47                                      in lunar sky brightness calculations. */
    48 #define FIRSTJD            2415387.  /* 1901 Jan 1 -- calendrical limit */
    49 #define LASTJD             2488070.  /* 2099 Dec 31 */
    5027
    51 /* MAGIC NUMBERS which might depend on how accurately double-
    52    precision floating point is handled on your machine ... */
     28# define dCOS(A)   ((double) cos ((double)RAD_DEG*A))
     29# define dSIN(A)   ((double) sin ((double)RAD_DEG*A))
    5330
    54 #define  EARTH_DIFF        0.05            /* used in numerical
    55    differentiation to find earth velocity -- this value gives
    56    about 8 digits of numerical accuracy on the VAX, but is
    57    about 3 orders of magnitude larger than the value where roundoff
    58    errors become apparent. */
     31/** prototypes of private functions used by the library **/
    5932
    60 #define  MIDN_TOL          0.00001         /* this is no longer
    61    used -- it was formerly
    62    how close (in days) a julian date has to be to midnight
    63    before a warning flag is printed for the reader.  VAX
    64    double precision renders a Julian date considerably
    65    more accurately than this.  The day and date are now based
    66    on the same rounding of the julian date, so they should
    67    always agree. */
     33/* in time.c */
     34int    SC_get_sys_date (struct SC_date_time *date);
     35double SC_date_to_jd (struct SC_date_time date);
     36void   SC_jd_to_date (double jdin, struct SC_date_time *date);
     37double SC_lst (double jd, double longit);
     38double SC_adj_time (double x);
    6839
    69 /** prototypes **/
    70 int    get_sys_date (struct SC_date_time *date);
    71 double date_to_jd (struct SC_date_time date);
    72 void   jd_to_date (double jdin, struct SC_date_time *date);
    73 double lst (double jd, double longit);
    74 double adj_time (double x);
    75 void   xyz_cel (double x, double y, double z, double *r, double *d);
    76 double atan_circ (double x, double y);
    77 double altit (double dec, double ha, double lat, double *az);
    78 double ha_alt (double dec, double lat, double alt);
    79 void   min_max_alt (double lat, double dec, double *min, double *max);
    80 double circulo (double x);
    81 void   precrot (double rorig, double dorig, double orig_epoch, double final_epoch, double *rf, double *df);
    82 void   geocent (double geolong, double geolat, double height, double *x_geo, double *y_geo, double *z_geo);
    83 void   eclrot(double jd, double *x, double *y, double *z);
    84 double etcorr (double jd);
    85 void   set_zenith (struct SC_date_time date, double lat, double longit, double epoch, double *ra, double *dec);
    86 void   lpsun (double jd, double *ra, double *dec);
    87 double jd_sun_alt (double alt, double jdguess, double lat, double longit);
    88 void   accumoon (double jd, double geolat, double lst, double elevsea,
    89        double *geora, double *geodec, double *geodist,
    90        double *topora, double *topodec, double *topodist);
    91 double jd_moon_alt (double alt, double jdguess, double lat, double longit, double elevsea);
     40/* in geometry.c */
     41void   SC_xyz_cel (double x, double y, double z, double *r, double *d);
     42double SC_atan_circ (double x, double y);
     43double SC_altit (double dec, double ha, double lat, double *az);
     44double SC_ha_alt (double dec, double lat, double alt);
     45void   SC_min_max_alt (double lat, double dec, double *min, double *max);
     46double SC_circulo (double x);
    9247
    93 double sunset_tonight (struct SC_date_time date, double lat, double longit, double elev);
    94 double sunrise_tonight (struct SC_date_time date, double lat, double longit, double elev);
     48/* in astro.c */
     49void   SC_precrot (double rorig, double dorig, double orig_epoch, double final_epoch, double *rf, double *df);
     50void   SC_geocent (double geolong, double geolat, double height, double *x_geo, double *y_geo, double *z_geo);
     51void   SC_eclrot(double jd, double *x, double *y, double *z);
     52double SC_etcorr (double jd);
     53void   SC_set_zenith (struct SC_date_time date, double lat, double longit, double epoch, double *ra, double *dec);
    9554
    96 int dms_to_ddd (double *Value, char *string);
    97 int str_to_radec (double *ra, double *dec, char *str1, char *str2);
    98 int chk_time (char *line);
    99 double sec_to_jd (time_t second);
    100 time_t jd_to_sec (double jd);
    101 char *sec_to_date (time_t second);
    102 time_t date_to_sec (char *date);
    103 int str_to_time (char *line, time_t *second);
    104 int str_to_dtime (char *line, double *second);
     55/* in sun.c */
     56void   SC_lpsun (double jd, double *ra, double *dec);
     57double SC_jd_sun_alt (double alt, double jdguess, double lat, double longit);
     58double SC_sunset_tonight (struct SC_date_time date, double lat, double longit, double elev);
     59double SC_sunrise_tonight (struct SC_date_time date, double lat, double longit, double elev);
     60
     61/* in moon.c */
     62void   SC_lpmoon(double jd, double lat, double sid, double* ra, double* dec, double* dist);
     63void   SC_accumoon (double jd, double geolat, double lst, double elevsea, double *geora, double *geodec, double *geodist, double *topora, double *topodec, double *topodist);
     64double SC_jd_moon_alt (double alt, double jdguess, double lat, double longit, double elevsea);
     65double SC_moonset_tonight (struct SC_date_time date, double lat, double longit, double elevsea, double elev);
     66double SC_moonrise_tonight (struct SC_date_time date, double lat, double longit, double elevsea, double elev);
     67
     68// are these defined in here or in libohana?
     69// int dms_to_ddd (double *Value, char *string);
     70// int str_to_radec (double *ra, double *dec, char *str1, char *str2);
     71// int chk_time (char *line);
     72// double sec_to_jd (time_t second);
     73// time_t jd_to_sec (double jd);
     74// char *sec_to_date (time_t second);
     75// time_t date_to_sec (char *date);
     76// int str_to_time (char *line, time_t *second);
     77// int str_to_dtime (char *line, double *second);
  • trunk/Ohana/src/skycalc/src/astro.c

    r2496 r19681  
    99   system. Angles in degrees, epochs in years */
    1010
    11 void precrot (double rorig, double dorig, double orig_epoch, double final_epoch, double *rf, double *df) {
     11void SC_precrot (double rorig, double dorig, double orig_epoch, double final_epoch, double *rf, double *df) {
    1212 
    1313  double ti, tf, zeta, z, theta;  /* all as per  Taff */
     
    7272  /* convert back to spherical polar coords */
    7373
    74   xyz_cel(fin_x, fin_y, fin_z, rf, df);
     74  SC_xyz_cel(fin_x, fin_y, fin_z, rf, df);
    7575
    7676}
     
    8383   p. K11 */
    8484
    85 void geocent (double geolong, double geolat, double height, double *x_geo, double *y_geo, double *z_geo) {
     85void SC_geocent (double geolong, double geolat, double height, double *x_geo, double *y_geo, double *z_geo) {
    8686
    8787  double denom, C_geo, S_geo;
     
    103103/* rotates ecliptic rectangular coords x, y, z to
    104104   equatorial (all assumed of date.) */
    105 void eclrot(double jd, double *x, double *y, double *z) {
     105void SC_eclrot(double jd, double *x, double *y, double *z) {
    106106
    107107  double incl;
     
    139139     usually rather smaller. */
    140140
    141 double etcorr (double jd) {
     141double SC_etcorr (double jd) {
    142142
    143143  double jd1900 = 2415019.5;
     
    173173
    174174/* sets RA and DEC at zenith as defined by given time and date  */
    175 void set_zenith (struct SC_date_time date, double lat, double longit, double epoch, double *ra, double *dec)
     175void SC_set_zenith (struct SC_date_time date, double lat, double longit, double epoch, double *ra, double *dec)
    176176{
    177177  double jd, current_epoch;
    178178
    179   jd = date_to_jd (date);
     179  jd = SC_date_to_jd (date);
    180180
    181181  if (jd < 0.) return;  /* nonexistent time. */
    182182
    183   *ra = lst (jd, longit);
     183  *ra = SC_lst (jd, longit);
    184184
    185185  *dec = lat;
     
    187187  current_epoch = 2000. + (jd - J2000) / 365.25;
    188188
    189   precrot (*ra,*dec,current_epoch,epoch,ra,dec);
     189  SC_precrot (*ra,*dec,current_epoch,epoch,ra,dec);
    190190
    191191}
  • trunk/Ohana/src/skycalc/src/dusktime.c

    r3263 r19681  
    1 # include <stdio.h>
    2 # include <math.h>
    31# include <skycalc_internal.h>
     2# include <ohana.h>
    43# define VERBOSE 0
    54
    6 void set_site (double *longit, double *lat, double *elevsea, double *elev) {
     5// XXX is this set for MKO??
     6void SC_set_site (double *longit, double *lat, double *elevsea, double *elev) {
    77
    88  *longit = 10.36478; /*  W longitude in decimal hours */                     
     
    2626  }
    2727
    28   if (!str_to_time (argv[1], &tzero)) {
     28  if (!ohana_str_to_time (argv[1], &tzero)) {
    2929    fprintf (stderr, "syntax error\n");
    3030    exit (1);
     
    4040  if (VERBOSE) fprintf (stderr, "%4d/%02d/%02d %02d:%02d:%02f\n", date.y, date.mo, date.d, date.h, date.mn, date.s);
    4141
    42   set_site (&longit, &lat, &elevsea, &elev);
     42  SC_set_site (&longit, &lat, &elevsea, &elev);
    4343
    44   jdnow  = date_to_jd (date);
    45   jdset  = sunset_tonight (date, lat, longit, elev);
    46   jdrise = sunrise_tonight (date, lat, longit, elev);
     44  jdnow  = SC_date_to_jd (date);
     45  jdset  = SC_sunset_tonight (date, lat, longit, elev);
     46  jdrise = SC_sunrise_tonight (date, lat, longit, elev);
    4747
    4848
  • trunk/Ohana/src/skycalc/src/geometry.c

    r2496 r19681  
    22
    33/* converts a coordinate triplet back to a standard ra and dec */
    4 void xyz_cel (double x, double y, double z, double *r, double *d) {
     4void SC_xyz_cel (double x, double y, double z, double *r, double *d) {
    55
    66   /* converts a coordinate triplet back to a standard ra and dec */
     
    4848}
    4949
    50 /* returns radian angle 0 to 2pi for coords x, y -- get that quadrant right !! */
    51 double atan_circ (double x, double y) {
     50/* returns radian angle 0 to 2pi for coords x, y -- get that quadrant nright !! */
     51/* XXX : reimplements atan2() */
     52double SC_atan_circ (double x, double y) {
    5253 
    5354  double theta;
     
    6667/* returns altitude(degr) for dec, ha, lat (decimal degr, hr, degr);
    6768    also computes and returns azimuth through pointer argument. */
    68 double altit (double dec, double ha, double lat, double *az) {
     69double SC_altit (double dec, double ha, double lat, double *az) {
    6970
    7071  double x,y,z;
     
    7677  y =  sin(dec)*cos(lat) - cos(dec)*cos(ha)*sin(lat); /* due N comp. */
    7778  z =  -1. * cos(dec)*sin(ha); /* due east comp. */
    78   *az = atan_circ(y,z) * DEG_IN_RADIAN;
     79  *az = SC_atan_circ(y,z) * DEG_IN_RADIAN;
    7980  return(x);
    8081}
     
    8384   If object is never at this altitude, signals with special
    8485   return values 1000 (always higher) and -1000 (always lower). */
    85 double ha_alt (double dec, double lat, double alt) {
     86double SC_ha_alt (double dec, double lat, double alt) {
    8687
    8788  double x,coalt,min,max;
    8889 
    89   min_max_alt(lat,dec,&min,&max);
     90  SC_min_max_alt(lat,dec,&min,&max);
    9091  if(alt < min)
    9192    return(1000.);  /* flag value - always higher than asked */
     
    104105
    105106/* computes minimum and maximum altitude for a given dec and latitude. */
    106 void min_max_alt (double lat, double dec, double *min, double *max) {
     107void SC_min_max_alt (double lat, double dec, double *min, double *max) {
    107108
    108109  double x;
     
    124125
    125126/* force domain to be 0 - 360 degrees */
    126 double circulo (double x) {
     127double SC_circulo (double x) {
    127128 
    128129  /* fails for negative angles! */
  • trunk/Ohana/src/skycalc/src/moon.c

    r2496 r19681  
    11# include <skycalc_internal.h>
    22
    3 void lpmoon(double jd, double lat, double sid,
     3void SC_lpmoon(double jd, double lat, double sid,
    44       double* ra, double* dec, double* dist) {
    55
     
    6868    n = z / topo_dist;
    6969
    70     alpha = atan_circ(l,m);
     70    alpha = SC_atan_circ(l,m);
    7171    delta = asin(n);
    7272
     
    8383   pub. Willman-Bell.  Includes all the terms given there. */
    8484
    85 void accumoon (jd,geolat,lst,elevsea,geora,geodec,geodist,topora,topodec,topodist)
     85void SC_accumoon (jd,geolat,lst,elevsea,geora,geodec,geodist,topora,topodec,topodist)
    8686     double jd,geolat,lst,elevsea;
    8787     double *geora,*geodec,*geodist,*topora,*topodec,*topodist;
     
    9393  double x_geo, y_geo, z_geo;  /* geocentric position of *observer* */
    9494
    95   jd = jd + etcorr(jd)/SEC_IN_DAY;   /* approximate correction to ephemeris time */
     95  jd = jd + SC_etcorr(jd)/SEC_IN_DAY;   /* approximate correction to ephemeris time */
    9696  T = (jd - 2415020.) / 36525.;   /* this based around 1900 ... */
    9797  Tsq = T * T;
     
    111111    + 0.0000022*Tcb;
    112112
    113   Lpr = circulo(Lpr);
    114   Mpr = circulo(Mpr);
    115   M = circulo(M);
    116   D = circulo(D);
    117   F = circulo(F);
    118   Om = circulo(Om);
     113  Lpr = SC_circulo(Lpr);
     114  Mpr = SC_circulo(Mpr);
     115  M = SC_circulo(M);
     116  D = SC_circulo(D);
     117  F = SC_circulo(F);
     118  Om = SC_circulo(Om);
    119119
    120120
     
    292292  m = sin(lambda) * cos(beta);
    293293  n = sin(beta);
    294   eclrot(jd,&l,&m,&n);
     294  SC_eclrot(jd,&l,&m,&n);
    295295
    296296  dist = 1/sin((pie)/DEG_IN_RADIAN);
     
    299299  z = n * dist;
    300300
    301   *geora = atan_circ(l,m) * HRS_IN_RADIAN;
     301  *geora = SC_atan_circ(l,m) * HRS_IN_RADIAN;
    302302  *geodec = asin(n) * DEG_IN_RADIAN;
    303303  *geodist = dist;
    304304
    305   geocent (lst, geolat, elevsea, &x_geo, &y_geo, &z_geo);
     305  SC_geocent (lst, geolat, elevsea, &x_geo, &y_geo, &z_geo);
    306306
    307307  x = x - x_geo;  /* topocentric correction using elliptical earth fig. */
     
    315315  n = z / (*topodist);
    316316
    317   *topora = atan_circ(l,m) * HRS_IN_RADIAN;
     317  *topora = SC_atan_circ(l,m) * HRS_IN_RADIAN;
    318318  *topodec = asin(n) * DEG_IN_RADIAN;
    319319
     
    326326   you can replace calls to 'accumoon' with 'lpmoon' and remove
    327327   the 'elevsea' argument. */
    328 double jd_moon_alt (double alt, double jdguess, double lat, double longit, double elevsea) {
     328double SC_jd_moon_alt (double alt, double jdguess, double lat, double longit, double elevsea) {
    329329
    330330  double jdout;
     
    335335  /* first guess */
    336336
    337   sid=lst(jdguess,longit);
    338   accumoon(jdguess,lat,sid,elevsea,&geora,&geodec,&geodist,
     337  sid=SC_lst(jdguess,longit);
     338  SC_accumoon(jdguess,lat,sid,elevsea,&geora,&geodec,&geodist,
    339339           &ra,&dec,&dist);
    340   ha = lst(jdguess,longit) - ra;
    341   alt2 = altit(dec,ha,lat,&az);
     340  ha = SC_lst(jdguess,longit) - ra;
     341  alt2 = SC_altit(dec,ha,lat,&az);
    342342  jdguess = jdguess + del;
    343   sid = lst(jdguess,longit);
    344   accumoon(jdguess,lat,sid,elevsea,&geora,&geodec,&geodist,
     343  sid = SC_lst(jdguess,longit);
     344  SC_accumoon(jdguess,lat,sid,elevsea,&geora,&geodec,&geodist,
    345345           &ra,&dec,&dist);
    346   alt3 = altit(dec,(sid - ra),lat,&az);
     346  alt3 = SC_altit(dec,(sid - ra),lat,&az);
    347347  err = alt3 - alt;
    348348  deriv = (alt3 - alt2) / del;
    349349  while((fabs(err) > 0.1) && (i < 10)) {
    350350    jdguess = jdguess - err/deriv;
    351     sid=lst(jdguess,longit);
    352     accumoon(jdguess,lat,sid,elevsea,&geora,&geodec,&geodist,
     351    sid=SC_lst(jdguess,longit);
     352    SC_accumoon(jdguess,lat,sid,elevsea,&geora,&geodec,&geodist,
    353353             &ra,&dec,&dist);
    354     alt3 = altit(dec,(sid - ra),lat,&az);
     354    alt3 = SC_altit(dec,(sid - ra),lat,&az);
    355355    err = alt3 - alt;
    356356    i++;
     
    362362
    363363/* Given site position, return Moonset for closest midnight */
    364 double moonset_tonight (struct SC_date_time date, double lat, double longit, double elevsea, double elev) {
     364double SC_moonset_tonight (struct SC_date_time date, double lat, double longit, double elevsea, double elev) {
    365365
    366366  double jd, jdmid, stmid;
     
    376376
    377377  /* find offset in hours from longit to greenwich */
    378   jd = date_to_jd (date);  /* true jd now */
    379   lst0 = lst (jd, 0.0);    /* lst at long = 0 */
    380   lst1 = lst (jd, longit); /* local lst now */
     378  jd = SC_date_to_jd (date);  /* true jd now */
     379  lst0 = SC_lst (jd, 0.0);    /* lst at long = 0 */
     380  lst1 = SC_lst (jd, longit); /* local lst now */
    381381  dt = lst0 - lst1;
    382382  if (dt < 0) dt += 24;
     
    389389       
    390390  /* find jd for local midnight, select the *closest* midnight */
    391   jdmid = date_to_jd (date_midnight) - dt / 24.0;
     391  jdmid = SC_date_to_jd (date_midnight) - dt / 24.0;
    392392  djd = jd - jdmid;
    393393  if (djd < -0.5) jdmid -= 1.0;
    394394  if (djd >  0.5) jdmid += 1.0;
    395   stmid = lst (jdmid,longit);
    396 
    397   accumoon (jdmid,lat,stmid,elevsea,&geora,&geodec,&geodist,&ramoon,&decmoon,&distmoon);
    398 
    399   min_max_alt (lat,decmoon,&min_alt,&max_alt);  /* rough check -- occurs? */
     395  stmid = SC_lst (jdmid,longit);
     396
     397  SC_accumoon (jdmid,lat,stmid,elevsea,&geora,&geodec,&geodist,&ramoon,&decmoon,&distmoon);
     398
     399  SC_min_max_alt (lat,decmoon,&min_alt,&max_alt);  /* rough check -- occurs? */
    400400  if (max_alt < -(0.83+horiz)) return (-1);
    401401  if (min_alt > -(0.83+horiz)) return (-1);
     
    403403  /* compute moonrise and set if they're likely to occur */
    404404
    405   hamoonset = ha_alt(decmoon,lat,-(0.83+horiz)); /* rough approx. */
    406 
    407   tmoonset = adj_time(ramoon+hamoonset-stmid);
     405  hamoonset = SC_ha_alt(decmoon,lat,-(0.83+horiz)); /* rough approx. */
     406
     407  tmoonset = SC_adj_time(ramoon+hamoonset-stmid);
    408408  jdmoonset = jdmid + tmoonset / 24.;
    409   jdmoonset = jd_moon_alt(-(0.83+horiz),jdmoonset,lat,longit,elevsea);
     409  jdmoonset = SC_jd_moon_alt(-(0.83+horiz),jdmoonset,lat,longit,elevsea);
    410410
    411411  return (jdmoonset);
     
    414414
    415415/* Given site position, return Moonrise for closest midnight */
    416 double moonrise_tonight (struct SC_date_time date, double lat, double longit, double elevsea, double elev) {
     416double SC_moonrise_tonight (struct SC_date_time date, double lat, double longit, double elevsea, double elev) {
    417417
    418418  double jd, jdmid, stmid;
     
    428428
    429429  /* find offset in hours from longit to greenwich */
    430   jd = date_to_jd (date);  /* true jd now */
    431   lst0 = lst (jd, 0.0);    /* lst at long = 0 */
    432   lst1 = lst (jd, longit); /* local lst now */
     430  jd = SC_date_to_jd (date);  /* true jd now */
     431  lst0 = SC_lst (jd, 0.0);    /* lst at long = 0 */
     432  lst1 = SC_lst (jd, longit); /* local lst now */
    433433  dt = lst0 - lst1;
    434434  if (dt < 0) dt += 24;
     
    441441       
    442442  /* find jd for local midnight, select the *closest* midnight */
    443   jdmid = date_to_jd (date_midnight) - dt / 24.0;
     443  jdmid = SC_date_to_jd (date_midnight) - dt / 24.0;
    444444  djd = jd - jdmid;
    445445  if (djd < -0.5) jdmid -= 1.0;
    446446  if (djd >  0.5) jdmid += 1.0;
    447   stmid = lst (jdmid,longit);
    448 
    449   accumoon (jdmid,lat,stmid,elevsea,&geora,&geodec,&geodist,&ramoon,&decmoon,&distmoon);
    450 
    451   min_max_alt (lat,decmoon,&min_alt,&max_alt);  /* rough check -- occurs? */
     447  stmid = SC_lst (jdmid,longit);
     448
     449  SC_accumoon (jdmid,lat,stmid,elevsea,&geora,&geodec,&geodist,&ramoon,&decmoon,&distmoon);
     450
     451  SC_min_max_alt (lat,decmoon,&min_alt,&max_alt);  /* rough check -- occurs? */
    452452  if (max_alt < -(0.83+horiz)) return (-1);
    453453  if (min_alt > -(0.83+horiz)) return (-1);
     
    455455  /* compute moonrise and set if they're likely to occur */
    456456
    457   hamoonset = ha_alt(decmoon,lat,-(0.83+horiz)); /* rough approx. */
    458 
    459   tmoonrise = adj_time(ramoon-hamoonset-stmid);
     457  hamoonset = SC_ha_alt(decmoon,lat,-(0.83+horiz)); /* rough approx. */
     458
     459  tmoonrise = SC_adj_time(ramoon-hamoonset-stmid);
    460460  jdmoonrise = jdmid + tmoonrise / 24.;
    461   jdmoonrise = jd_moon_alt(-(0.83+horiz),jdmoonrise,lat,longit,elevsea);
     461  jdmoonrise = SC_jd_moon_alt(-(0.83+horiz),jdmoonrise,lat,longit,elevsea);
    462462
    463463  return (jdmoonrise);
  • trunk/Ohana/src/skycalc/src/moondata.c

    r3263 r19681  
    1 # include <stdio.h>
    2 # include <math.h>
    31# include <skycalc_internal.h>
     2# include <ohana.h>
     3# define VERBOSE 0
    44
    5 # define DEG_RAD 57.295779513082322
    6 # define RAD_DEG  0.017453292519943
    7 
    8 double atof();
    9 
    10 void set_site (double *longit, double *lat, double *elevsea, double *elev) {
     5void SC_set_site (double *longit, double *lat, double *elevsea, double *elev) {
    116
    127  *longit = 10.36478; /*  W longitude in decimal hours */                     
     
    3631  DECo = atof (argv[3]);
    3732
    38   if (!str_to_time (argv[1], &tzero)) {
     33  if (!ohana_str_to_time (argv[1], &tzero)) {
    3934    fprintf (stderr, "syntax error\n");
    4035    exit (1);
     
    5247  */
    5348
    54   set_site (&longit, &lat, &elevsea, &elev);
    55   jdnow  = date_to_jd (date);
     49  SC_set_site (&longit, &lat, &elevsea, &elev);
     50  jdnow  = SC_date_to_jd (date);
    5651  /* Calcualte local sidereal time */
    57   sid = lst(jdnow, longit);
    58   lpsun (jdnow, &Rsun, &Dsun);
     52  sid = SC_lst(jdnow, longit);
     53  SC_lpsun (jdnow, &Rsun, &Dsun);
    5954
    60   accumoon(jdnow,lat,sid,elevsea,&geora,&geodec,&geodist,&ra,&dec,&dist);
     55  SC_accumoon(jdnow,lat,sid,elevsea,&geora,&geodec,&geodist,&ra,&dec,&dist);
    6156
    6257  /*  fprintf (stdout, "moon @ %f %f\n", 15*ra, dec); */
  • trunk/Ohana/src/skycalc/src/skylib.c

    r2496 r19681  
    2020  double jd;
    2121
    22   set_site (&longit, &lat, &elevsea, &elev);
    23   get_sys_date (&date);
     22  SC_set_site (&longit, &lat, &elevsea, &elev);
     23  SC_get_sys_date (&date);
    2424
    25   jd = sunset_tonight (date, lat, longit, elev);
     25  jd = SC_sunset_tonight (date, lat, longit, elev);
    2626  fprintf (stderr, "Sunset (%5.0f m horizon): %f\n", elev, jd);
    27   jd_to_date (jd, &tmpdate);
     27  SC_jd_to_date (jd, &tmpdate);
    2828  fprintf (stderr, "%4d/%02d/%02d %02d:%02d:%02f\n", tmpdate.y, tmpdate.mo, tmpdate.d, tmpdate.h, tmpdate.mn, tmpdate.s);
    2929
    30   jd = sunrise_tonight (date, lat, longit, elev);
     30  jd = SC_sunrise_tonight (date, lat, longit, elev);
    3131  fprintf (stderr, "Sunrise (%5.0f m horizon): %f\n", elev, jd);
    32   jd_to_date (jd, &tmpdate);
     32  SC_jd_to_date (jd, &tmpdate);
    3333  fprintf (stderr, "%4d/%02d/%02d %02d:%02d:%02f\n", tmpdate.y, tmpdate.mo, tmpdate.d, tmpdate.h, tmpdate.mn, tmpdate.s);
    3434 
    3535
    36   jd = moonset_tonight (date, lat, longit, elevsea, elev);
     36  jd = SC_moonset_tonight (date, lat, longit, elevsea, elev);
    3737  fprintf (stderr, "Moonset (%5.0f m horizon): %f\n", elev, jd);
    38   jd_to_date (jd, &tmpdate);
     38  SC_jd_to_date (jd, &tmpdate);
    3939  fprintf (stderr, "%4d/%02d/%02d %02d:%02d:%02f\n", tmpdate.y, tmpdate.mo, tmpdate.d, tmpdate.h, tmpdate.mn, tmpdate.s);
    4040
    41   jd = moonrise_tonight (date, lat, longit, elevsea, elev);
     41  jd = SC_moonrise_tonight (date, lat, longit, elevsea, elev);
    4242  fprintf (stderr, "Moonrise (%5.0f m horizon): %f\n", elev, jd);
    43   jd_to_date (jd, &tmpdate);
     43  SC_jd_to_date (jd, &tmpdate);
    4444  fprintf (stderr, "%4d/%02d/%02d %02d:%02d:%02f\n", tmpdate.y, tmpdate.mo, tmpdate.d, tmpdate.h, tmpdate.mn, tmpdate.s);
    4545
  • trunk/Ohana/src/skycalc/src/sun.c

    r2496 r19681  
    33/* Low precision formulae for the sun, from Almanac p. C24 (1990) */
    44/* ra and dec are returned as decimal hours and decimal degrees. */
    5 void lpsun (double jd, double *ra, double *dec) {
     5void SC_lpsun (double jd, double *ra, double *dec) {
    66
    77  double n, L, g, lambda,epsilon,alpha,delta,x,y,z;
     
    1717  z = sin(epsilon)*sin(lambda);
    1818
    19   *ra = (atan_circ(x,y))*HRS_IN_RADIAN;
     19  *ra = (SC_atan_circ(x,y))*HRS_IN_RADIAN;
    2020  *dec = (asin(z))*DEG_IN_RADIAN;
    2121}
     
    2424   altitude, given jdguess as a starting point. Uses
    2525   low-precision sun, which is plenty good enough. */
    26 double jd_sun_alt (double alt, double jdguess, double lat, double longit) {
     26double SC_jd_sun_alt (double alt, double jdguess, double lat, double longit) {
    2727
    2828  double jdout;
     
    3333  /* first guess */
    3434 
    35   lpsun (jdguess, &ra, &dec);
    36   ha = lst (jdguess,longit) - ra;
    37   alt2 = altit (dec,ha,lat,&az);
     35  SC_lpsun (jdguess, &ra, &dec);
     36  ha = SC_lst (jdguess,longit) - ra;
     37  alt2 = SC_altit (dec,ha,lat,&az);
    3838  jdguess = jdguess + del;
    39   lpsun (jdguess,&ra,&dec);
    40   alt3 = altit(dec,(lst(jdguess,longit) - ra),lat,&az);
     39  SC_lpsun (jdguess,&ra,&dec);
     40  alt3 = SC_altit(dec,(SC_lst(jdguess,longit) - ra),lat,&az);
    4141  err = alt3 - alt;
    4242  deriv = (alt3 - alt2) / del;
    4343  while((fabs(err) > 0.1) && (i < 10)) {
    4444    jdguess = jdguess - err/deriv;
    45     lpsun(jdguess,&ra,&dec);
    46     alt3 = altit(dec,(lst(jdguess,longit) - ra),lat,&az);
     45    SC_lpsun(jdguess,&ra,&dec);
     46    alt3 = SC_altit(dec,(SC_lst(jdguess,longit) - ra),lat,&az);
    4747    err = alt3 - alt;
    4848    i++;
     
    5656/* Given site position, prints Sun info for the given night.
    5757/* dates are all in UT now */
    58 double sunset_tonight (struct SC_date_time date, double lat, double longit, double elev) {
     58double SC_sunset_tonight (struct SC_date_time date, double lat, double longit, double elev) {
    5959
    6060  double jd, jdmid0, jdmid, stmid;
     
    6868
    6969  /* find offset in hours from longit to greenwich */
    70   jd = date_to_jd (date);  /* true jd now */
    71   lst0 = lst (jd, 0.0);    /* lst at long = 0 */
    72   lst1 = lst (jd, longit); /* local lst now */
     70  jd = SC_date_to_jd (date);  /* true jd now */
     71  lst0 = SC_lst (jd, 0.0);    /* lst at long = 0 */
     72  lst1 = SC_lst (jd, longit); /* local lst now */
    7373  dt = lst0 - lst1;
    7474  if (dt < 0) dt += 24;
     
    8181       
    8282  /* find jd for local midnight, select the *closest* midnight */
    83   jdmid0 = date_to_jd (date_midnight);
     83  jdmid0 = SC_date_to_jd (date_midnight);
    8484  jdmid = jdmid0 + dt / 24.0;
    8585  djd = jd - jdmid;
    8686  if (djd < -0.5) jdmid -= 1.0;
    8787  if (djd >  0.5) jdmid += 1.0;
    88   stmid = lst (jdmid,longit);
     88  stmid = SC_lst (jdmid,longit);
    8989
    9090  /* sunset / sunrise hour angle */
    91   lpsun (jdmid, &rasun, &decsun);
    92   hasunset = ha_alt (decsun, lat, -(0.83+horiz));
     91  SC_lpsun (jdmid, &rasun, &decsun);
     92  hasunset = SC_ha_alt (decsun, lat, -(0.83+horiz));
    9393  if(hasunset > 900.) {  /* flag for never sets */
    9494    return (-1);
     
    9999
    100100  /* find sunset time */
    101   jdsunset = jdmid + adj_time(rasun+hasunset-stmid)/24.;
    102   jdsunset = jd_sun_alt (-(0.83+horiz),jdsunset,lat,longit);
     101  jdsunset = jdmid + SC_adj_time(rasun+hasunset-stmid)/24.;
     102  jdsunset = SC_jd_sun_alt (-(0.83+horiz),jdsunset,lat,longit);
    103103
    104104  return (jdsunset);
     
    108108/* Given site position, prints Sun info for the given night.
    109109/* dates are all in UT now */
    110 double sunrise_tonight (struct SC_date_time date, double lat, double longit, double elev) {
     110double SC_sunrise_tonight (struct SC_date_time date, double lat, double longit, double elev) {
    111111
    112112  double jd, jdmid, stmid;
     
    120120
    121121  /* find offset in hours from longit to greenwich */
    122   jd = date_to_jd (date);  /* true jd now */
    123   lst0 = lst (jd, 0.0);    /* lst at long = 0 */
    124   lst1 = lst (jd, longit); /* local lst now */
     122  jd = SC_date_to_jd (date);  /* true jd now */
     123  lst0 = SC_lst (jd, 0.0);    /* lst at long = 0 */
     124  lst1 = SC_lst (jd, longit); /* local lst now */
    125125  dt = lst0 - lst1;
    126126  if (dt < 0) dt += 24;
     
    133133       
    134134  /* find jd for local midnight, select the *closest* midnight */
    135   jdmid = date_to_jd (date_midnight) - dt / 24.0;
     135  jdmid = SC_date_to_jd (date_midnight) - dt / 24.0;
    136136  djd = jd - jdmid;
    137137  if (djd < -0.5) jdmid -= 1.0;
    138138  if (djd >  0.5) jdmid += 1.0;
    139   stmid = lst (jdmid,longit);
     139  stmid = SC_lst (jdmid,longit);
    140140
    141141  /* sunset / sunrise hour angle */
    142   lpsun (jdmid, &rasun, &decsun);
    143   hasunset = ha_alt (decsun, lat, -(0.83+horiz));
     142  SC_lpsun (jdmid, &rasun, &decsun);
     143  hasunset = SC_ha_alt (decsun, lat, -(0.83+horiz));
    144144  if(hasunset > 900.) {  /* flag for never sets */
    145145    return (-1);
     
    151151
    152152  /* find sunrise time */
    153   jdsunrise = jdmid + adj_time(rasun-hasunset-stmid)/24.;
    154   jdsunrise = jd_sun_alt(-(0.83+horiz),jdsunrise,lat,longit);
     153  jdsunrise = jdmid + SC_adj_time(rasun-hasunset-stmid)/24.;
     154  jdsunrise = SC_jd_sun_alt(-(0.83+horiz),jdsunrise,lat,longit);
    155155
    156156  return (jdsunrise);
  • trunk/Ohana/src/skycalc/src/sundata.c

    r3263 r19681  
    1 # include <stdio.h>
    2 # include <math.h>
    31# include <skycalc_internal.h>
     2# include <ohana.h>
    43
    5 # define DEG_RAD 57.295779513082322
    6 # define RAD_DEG  0.017453292519943
    7 # define dCOS(A)   ((double) cos ((double)RAD_DEG*A))
    8 # define dSIN(A)   ((double) sin ((double)RAD_DEG*A))
    9 
    10 double atof();
    11 
    12 void set_site (double *longit, double *lat, double *elevsea, double *elev) {
     4void SC_set_site (double *longit, double *lat, double *elevsea, double *elev) {
    135
    146  *longit = 10.36478; /*  W longitude in decimal hours */                     
     
    3830  DECo = atof (argv[3]);
    3931
    40   if (!str_to_time (argv[1], &tzero)) {
     32  if (!ohana_str_to_time (argv[1], &tzero)) {
    4133    fprintf (stderr, "syntax error\n");
    4234    exit (1);
     
    5446  */
    5547
    56   set_site (&longit, &lat, &elevsea, &elev);
    57   jdnow  = date_to_jd (date);
     48  SC_set_site (&longit, &lat, &elevsea, &elev);
     49  jdnow  = SC_date_to_jd (date);
    5850
    59   /* Calcualte local sidereal time */
    60   sid = lst(jdnow, longit);
    61   lpsun (jdnow, &Rsun, &Dsun);
     51  /* Calculate local sidereal time */
     52  sid = SC_lst(jdnow, longit);
     53  SC_lpsun (jdnow, &Rsun, &Dsun);
    6254
    6355  /* dot product of unit vectors of (RAo,DECo) & (Rsun,Dsun) */
  • trunk/Ohana/src/skycalc/src/time.c

    r2496 r19681  
    22
    33/* fill date structure with current date & time (UT) */
    4 int get_sys_date (struct SC_date_time *date) {
     4int SC_get_sys_date (struct SC_date_time *date) {
    55
    66  time_t t;
     
    2525
    2626/* convert a UT date to JD ( 1900 -- 2100?) */
    27 double date_to_jd (struct SC_date_time date) {
     27double SC_date_to_jd (struct SC_date_time date) {
    2828 
    29   short yr1=0, mo1=1;
    30   long jdzpt = 1720982, jdint, inter;
    31   double jd,jdfrac;
     29  short yr1=0;
     30  short mo1=1;
     31  long jdzpt = 1720982;
     32  long jdint, inter;
     33  double jd, jdfrac;
    3234 
    3335  if ((date.y <= 1900) | (date.y >= 2100)) return (0.0);
     
    5355
    5456/* convert JD to a UT date & time */
    55 void jd_to_date (double jdin, struct SC_date_time *date) {
     57/* XXX can we drop this and use the unix time functions? */
     58void SC_jd_to_date (double jdin, struct SC_date_time *date) {
    5659 
    5760#define IGREG 2299161
     
    104107   p.359, 1982.  On workstations, accuracy (numerical only!)
    105108   is about a millisecond in the 1990s. */
    106 double lst (double jd, double longit) {
     109double SC_lst (double jd, double longit) {
    107110 
    108111  double t, ut, jdmid, jdint, jdfrac, sid_g, sid;
     
    132135
    133136/* force time domain to be -12h and 12h  */
    134 double adj_time (double x) {
     137double SC_adj_time (double x) {
    135138 
    136139  /* ridiculously inefficient - use modulo and fractions.. */
Note: See TracChangeset for help on using the changeset viewer.