Changeset 34772 for branches/czw_branch/20120906/Ohana/src/opihi
- Timestamp:
- Dec 6, 2012, 6:32:19 PM (14 years ago)
- Location:
- branches/czw_branch/20120906/Ohana
- Files:
-
- 2 deleted
- 43 edited
- 9 copied
-
. (modified) (1 prop)
-
src/opihi (modified) (1 prop)
-
src/opihi/cmd.astro (modified) (1 prop)
-
src/opihi/cmd.astro/cgrid.c (modified) (1 diff)
-
src/opihi/cmd.astro/cplot.c (modified) (3 diffs)
-
src/opihi/cmd.astro/czplot.c (modified) (1 diff)
-
src/opihi/cmd.data (modified) (1 prop)
-
src/opihi/cmd.data/Makefile (modified) (1 diff)
-
src/opihi/cmd.data/box.c (modified) (1 diff)
-
src/opihi/cmd.data/dbconnect.c (modified) (1 diff)
-
src/opihi/cmd.data/dbselect.c (modified) (1 diff)
-
src/opihi/cmd.data/grid.c (modified) (1 diff)
-
src/opihi/cmd.data/imspline_apply.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/imspline_apply.c )
-
src/opihi/cmd.data/imspline_construct.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/imspline_construct.c )
-
src/opihi/cmd.data/init.c (modified) (2 diffs)
-
src/opihi/cmd.data/plot.c (modified) (4 diffs)
-
src/opihi/cmd.data/read_vectors.c (modified) (9 diffs)
-
src/opihi/cmd.data/reindex.c (modified) (5 diffs)
-
src/opihi/cmd.data/spline.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/spline.c )
-
src/opihi/cmd.data/spline_apply.c (deleted)
-
src/opihi/cmd.data/spline_commands.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/spline_commands.c )
-
src/opihi/cmd.data/spline_construct.c (deleted)
-
src/opihi/cmd.data/subset.c (modified) (1 diff)
-
src/opihi/cmd.data/write_vectors.c (modified) (1 diff)
-
src/opihi/cmd.data/zplot.c (modified) (10 diffs)
-
src/opihi/doc/pantasks.controller.txt (copied) (copied from trunk/Ohana/src/opihi/doc/pantasks.controller.txt )
-
src/opihi/dvo/Makefile (modified) (1 diff)
-
src/opihi/dvo/avextract.c (modified) (2 diffs)
-
src/opihi/dvo/avmatch.c (modified) (2 diffs)
-
src/opihi/dvo/dvo_host_utils.c (modified) (4 diffs)
-
src/opihi/dvo/fitcolors.c (modified) (1 diff)
-
src/opihi/dvo/images.c (modified) (1 diff)
-
src/opihi/dvo/imbox.c (modified) (1 diff)
-
src/opihi/dvo/imdense.c (modified) (1 diff)
-
src/opihi/dvo/imstats.c (modified) (1 diff)
-
src/opihi/dvo/init.c (modified) (2 diffs)
-
src/opihi/dvo/lcurve.c (modified) (1 diff)
-
src/opihi/dvo/mextract.c (modified) (4 diffs)
-
src/opihi/dvo/mmatch.c (copied) (copied from trunk/Ohana/src/opihi/dvo/mmatch.c ) (1 diff)
-
src/opihi/dvo/procks.c (modified) (2 diffs)
-
src/opihi/dvo/remote.c (modified) (2 diffs)
-
src/opihi/dvo/showtile.c (modified) (1 diff)
-
src/opihi/dvo/simage.c (modified) (1 diff)
-
src/opihi/dvo/skycat.c (modified) (1 diff)
-
src/opihi/dvo/test (copied) (copied from trunk/Ohana/src/opihi/dvo/test )
-
src/opihi/dvo/test/mmatch.sh (copied) (copied from trunk/Ohana/src/opihi/dvo/test/mmatch.sh )
-
src/opihi/include/data.h (modified) (2 diffs)
-
src/opihi/include/display.h (modified) (1 diff)
-
src/opihi/include/dvoshell.h (modified) (1 diff)
-
src/opihi/lib.data/Makefile (modified) (1 diff)
-
src/opihi/lib.data/PlotVectors.c (modified) (4 diffs)
-
src/opihi/lib.data/SplineOps.c (copied) (copied from trunk/Ohana/src/opihi/lib.data/SplineOps.c )
-
src/opihi/lib.data/spline.c (modified) (3 diffs)
-
src/opihi/lib.shell/VectorIO.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20120906/Ohana
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20120905/Ohana (added) merged: 34423-34428,34468,34490,34494-34495,34508,34517-34526,34529,34562-34563,34569,34572-34573,34575,34616-34619
- Property svn:mergeinfo changed
-
branches/czw_branch/20120906/Ohana/src/opihi
- Property svn:mergeinfo deleted
-
branches/czw_branch/20120906/Ohana/src/opihi/cmd.astro
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.astro (added) merged: 34428,34468,34490,34521,34569,34575,34618,34654,34735,34747
- Property svn:mergeinfo changed
-
branches/czw_branch/20120906/Ohana/src/opihi/cmd.astro/cgrid.c
r30611 r34772 279 279 graphmode.ptype = 100; /* connect a pair */ 280 280 graphmode.etype = 0; 281 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);281 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 282 282 283 283 free (Xvec.elements.Ptr); -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.astro/cplot.c
r21153 r34772 3 3 int cplot (int argc, char **argv) { 4 4 5 double ra_prev = 0; 5 6 int i, kapa, Npts, status, leftside; 6 7 opihi_flt *x, *y, *r, *d, Rmin, Rmax, Rmid; … … 41 42 Npts = 0; 42 43 for (i = 0; i < Xvec.Nelements; i++, r++, d++) { 43 *r= ohana_normalize_angle (*r);44 while ( *r < Rmin) *r+= 360.0;45 while ( *r > Rmax) *r-= 360.0;44 double ra = ohana_normalize_angle (*r); 45 while (ra < Rmin) ra += 360.0; 46 while (ra > Rmax) ra -= 360.0; 46 47 47 48 // for pair-by-pair connections, check on second point if we straddle the back midline 48 if ((graphmode.ptype == 100) && (i % 2)) { 49 leftside = (r[-1] < Rmid); // if first of the pair is left, second must be as well 50 if ( leftside && (r[0] > Rmid + 90)) { r[0] -= 360.0; } 51 if (!leftside && (r[0] < Rmid - 90)) { r[0] += 360.0; } 49 if (graphmode.ptype == 100) { 50 if (i % 2) { 51 leftside = (ra_prev < Rmid); // if first of the pair is left, second must be as well 52 if ( leftside && (ra > Rmid + 90)) { ra -= 360.0; } 53 if (!leftside && (ra < Rmid - 90)) { ra += 360.0; } 54 } else { 55 ra_prev = ra; 56 } 52 57 } 53 status = RD_to_XY (x, y, *r, *d, &graphmode.coords);58 status = RD_to_XY (x, y, ra, *d, &graphmode.coords); 54 59 55 60 // if we fail on one of the points, drop the corresponding pair … … 78 83 79 84 graphmode.etype = 0; 80 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);85 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 81 86 82 87 free (Xvec.elements.Ptr); -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.astro/czplot.c
r31667 r34772 76 76 graphmode.size = -1; /* point size determined by Zvec */ 77 77 graphmode.etype = 0; 78 PlotVectorTriplet (kapa, &Xvec, &Yvec, &Zvec, &graphmode);78 PlotVectorTriplet (kapa, &Xvec, &Yvec, &Zvec, NULL, &graphmode); 79 79 80 80 free (Xvec.elements.Flt); -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data
- Property svn:mergeinfo set to
-
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/Makefile
r33662 r34772 114 114 $(SRC)/shift.$(ARCH).o \ 115 115 $(SRC)/sort.$(ARCH).o \ 116 $(SRC)/spline_apply.$(ARCH).o \ 117 $(SRC)/spline_construct.$(ARCH).o \ 116 $(SRC)/spline.$(ARCH).o \ 117 $(SRC)/spline_commands.$(ARCH).o \ 118 $(SRC)/imspline_apply.$(ARCH).o \ 119 $(SRC)/imspline_construct.$(ARCH).o \ 118 120 $(SRC)/imstats.$(ARCH).o \ 119 121 $(SRC)/style.$(ARCH).o \ -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/box.c
r27790 r34772 149 149 usage: 150 150 gprint (GP_ERR, "USAGE: box [-ticks NNNN] [-axis NNNN] [-labels NNNN]\n"); 151 152 gprint (GP_ERR, " additional options:\n"); 153 gprint (GP_ERR, " -fn (font) (size) : set font used for box\n"); 154 gprint (GP_ERR, " -lw (weight) : set box line weight\n"); 155 gprint (GP_ERR, " -c (color) : set box color\n"); 156 gprint (GP_ERR, " \n"); 157 gprint (GP_ERR, " for the descriptions below:\n"); 158 gprint (GP_ERR, " -x refers to the bottom x-axis, \n"); 159 gprint (GP_ERR, " -y refers to the left y-axis, \n"); 160 gprint (GP_ERR, " +x refers to the top x-axis, \n"); 161 gprint (GP_ERR, " +y refers to the right y-axis, \n"); 162 gprint (GP_ERR, " \n"); 163 gprint (GP_ERR, " -ticks [NNNN] : turn on (1), off (0), or use default for ticks\n"); 164 gprint (GP_ERR, " -labels [NNNN] : turn on (1), off (0), or use default for label\n"); 165 gprint (GP_ERR, " -axis [NNNN] : turn on (1), off (0), or use default for axis\n"); 166 gprint (GP_ERR, " the order for the NNNN values in the above options is: -x, -y, +x, +y\n"); 167 gprint (GP_ERR, " \n"); 168 gprint (GP_ERR, " -tickpad : set the spacing between the ticks and the tick text \n"); 169 gprint (GP_ERR, " \n"); 170 gprint (GP_ERR, " the following set the spacing between the label and the given axis:\n"); 171 gprint (GP_ERR, " -labelpadx, -labelpady, +labelpadx, +labelpady\n"); 172 gprint (GP_ERR, " \n"); 173 gprint (GP_ERR, " -pad : set the spacing between the plot section boundary and the axes\n"); 174 gprint (GP_ERR, " alternatively, set each axis independently with:\n"); 175 gprint (GP_ERR, " -xpad, -ypad, +xpad, +ypad\n"); 176 151 177 return (FALSE); 152 178 } -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/dbconnect.c
r27435 r34772 33 33 password[i] = 0; 34 34 # endif 35 36 // XXX do I need to call mysql_library_init()? 35 37 36 38 mysql_init (&mysql); -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/dbselect.c
r20936 r34772 61 61 ALLOCATE (vec, Vector *, Ncols); 62 62 for (i = 0; i < Ncols; i++) { 63 if ((vec[i] = SelectVector (fields[i].name, ANYVECTOR, TRUE)) == NULL) { 64 gprint (GP_ERR, "trouble creating vector named %s\n", fields[i].name); 63 char *name = fields[i].name ? fields[i].name : fields[i].org_name; 64 if ((vec[i] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) { 65 gprint (GP_ERR, "trouble creating vector named %s\n", name); 65 66 free (query); 66 67 free (vec); -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/grid.c
r26258 r34772 178 178 graphmode.ptype = 100; /* connect a pair */ 179 179 graphmode.etype = 0; 180 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);180 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 181 181 182 182 free (Xvec.elements.Flt); -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/init.c
r33662 r34772 102 102 int shift PROTO((int, char **)); 103 103 int sort_vectors PROTO((int, char **)); 104 int spline_apply_cmd PROTO((int, char **)); 105 int spline_construct_cmd PROTO((int, char **)); 104 int spline_command PROTO((int, char **)); 105 int imspline_apply PROTO((int, char **)); 106 int imspline_construct PROTO((int, char **)); 106 107 int stats PROTO((int, char **)); 107 108 int imstats PROTO((int, char **)); … … 254 255 {1, "shift", shift, "shift data in an image"}, 255 256 {1, "sort", sort_vectors, "sort list of vectors"}, 256 {1, "spline.apply", spline_apply_cmd, "apply spline fit to generate an image"}, 257 {1, "spline.const", spline_construct_cmd, "create spline 2nd deriv. terms"}, 257 {1, "spline", spline_command, "shift data in an image"}, 258 {1, "imspline.apply", imspline_apply, "apply spline fit to generate an image"}, 259 {1, "imspline.const", imspline_construct, "create spline 2nd deriv. terms"}, 258 260 {1, "stats", imstats, "statistics on a portion of an image"}, 259 261 {1, "style", style, "set the style for graph plots"}, -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/plot.c
r32346 r34772 3 3 int plot (int argc, char **argv) { 4 4 5 int kapa, N, Npts; 5 char *out; 6 int kapa, N, Npts, valid, size, i; 6 7 Graphdata graphmode; 7 8 Vector *xvec, *yvec, *dxmvec, *dxpvec, *dymvec, *dypvec; … … 32 33 } 33 34 34 if (argc != 3) { 35 valid = (argc == 3); 36 valid |= (argc > 4) && !strcmp (argv[3], "where"); 37 if (!valid) { 35 38 gprint (GP_ERR, "USAGE: plot <x> <y> [style]\n"); 39 gprint (GP_ERR, " OR: plot <x> <y> [style] where (condition)\n"); 36 40 return (FALSE); 41 } 42 43 // tvec is used for logical test (truth vector) 44 Vector *tvec = NULL; 45 char *mask = NULL; 46 if (argc > 4) { 47 out = dvomath (argc - 4, &argv[4], &size, 1); 48 if (out == NULL) { 49 print_error (); 50 return FALSE; 51 } 52 if ((tvec = SelectVector (out, OLDVECTOR, TRUE)) == NULL) { 53 gprint (GP_ERR, " invalid logic result\n"); 54 DeleteNamedVector (out); 55 free (out); 56 return (FALSE); 57 } 37 58 } 38 59 … … 53 74 return (FALSE); 54 75 } 76 if (tvec && tvec[0].Nelements != yvec[0].Nelements) { 77 gprint (GP_ERR, "logic test vector not the same length as data vectors\n"); 78 return (FALSE); 79 } 55 80 if (dypvec && (dypvec->Nelements != xvec->Nelements)) goto mismatch; 56 81 if (dymvec && (dymvec->Nelements != xvec->Nelements)) goto mismatch; … … 59 84 60 85 Npts = xvec[0].Nelements; 61 if (Npts == 0) return (TRUE); 86 if (Npts == 0) { 87 if (tvec) DeleteVector (tvec); 88 return (TRUE); 89 } 90 91 if (tvec) { 92 Npts = 0; 93 ALLOCATE (mask, char, tvec->Nelements); 94 for (i = 0; i < tvec->Nelements; i++) { 95 mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0); 96 if (!mask[i]) Npts ++; 97 } 98 if (Npts == 0) { 99 DeleteVector (tvec); 100 free (mask); 101 return TRUE; 102 } 103 } 62 104 63 105 if (!KapaPrepPlot (kapa, Npts, &graphmode)) return (FALSE); 64 106 65 PlotVectorSingle (kapa, xvec, "x");66 PlotVectorSingle (kapa, yvec, "y");107 PlotVectorSingle (kapa, xvec, mask, "x"); 108 PlotVectorSingle (kapa, yvec, mask, "y"); 67 109 if (graphmode.etype & 0x01) { 68 PlotVectorSingle (kapa, dymvec, "dym");69 PlotVectorSingle (kapa, dypvec, "dyp");110 PlotVectorSingle (kapa, dymvec, mask, "dym"); 111 PlotVectorSingle (kapa, dypvec, mask, "dyp"); 70 112 } 71 113 if (graphmode.etype & 0x02) { 72 PlotVectorSingle (kapa, dxmvec, "dxm"); 73 PlotVectorSingle (kapa, dxpvec, "dxp"); 114 PlotVectorSingle (kapa, dxmvec, mask, "dxm"); 115 PlotVectorSingle (kapa, dxpvec, mask, "dxp"); 116 } 117 118 if (tvec) { 119 free (mask); 120 DeleteVector (tvec); 74 121 } 75 122 return (TRUE); -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/read_vectors.c
r33662 r34772 22 22 23 23 // vector types 24 enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME };24 enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME, COLTYPE_CHAR}; 25 25 26 26 int read_vectors (int argc, char **argv) { … … 30 30 int i, j, Nskip, Narg, Nvec, *col, IsCSV, VERBOSE; 31 31 int Nbytes, Nstart, NELEM, Nelem, nread, *coltype; 32 char *colstr, *c0, *c1, * buffer, *extname;32 char *colstr, *c0, *c1, *extname; 33 33 Vector **vec; 34 35 char *buffer = NULL; 34 36 35 37 /* auto-sense table type */ … … 101 103 if (!strcasecmp(ptr, "float")) { coltype[i] = COLTYPE_FLT; } 102 104 if (!strcasecmp(ptr, "int")) { coltype[i] = COLTYPE_INT; } 105 if (!strcasecmp(ptr, "char")) { coltype[i] = COLTYPE_CHAR; } 103 106 if (!strcasecmp(ptr, "time")) { coltype[i] = COLTYPE_TIME; } 104 107 if (!coltype[i]) goto bad_colname; … … 143 146 NELEM = 1000; 144 147 for (i = 0; i < Nvec; i++) { 145 if ( coltype[i] == COLTYPE_INT) {148 if ((coltype[i] == COLTYPE_INT) || (coltype[i] == COLTYPE_CHAR)) { 146 149 ResetVector (vec[i], OPIHI_INT, NELEM); 147 150 } else { … … 154 157 bzero (buffer, 0x10001); 155 158 for (i = 0; i < Nskip; i++) { 156 scan_line (f, buffer); 159 if (scan_line_maxlen (f, buffer, 0x10000) == EOF) { 160 gprint (GP_ERR, "problem reading file %s\n", filename); 161 free (vec); 162 free (col); 163 return FALSE; 164 } 157 165 } 158 166 … … 178 186 while (bufferStatus) { 179 187 c1 = strchr (c0, '\n'); // find the end of this current line 188 if (!c1) { 189 c1 = strchr (c0, '\r'); // try \r for non-UNIX files (what do we do about a Mac? \n\r?) 190 } 180 191 if (c1 == (char *) NULL) { 181 192 Nstart = strlen (c0); … … 195 206 for (i = 0; i < Nvec; i++) { 196 207 int ivalue; 208 char cvalue; 197 209 double dvalue; 198 210 time_t tvalue; … … 203 215 readStatus = IsCSV ? iparse_csv (&ivalue, col[i], c0) : iparse (&ivalue, col[i], c0); 204 216 vec[i][0].elements.Int[Nelem] = readStatus ? ivalue : 0; 217 break; 218 case COLTYPE_CHAR: 219 readStatus = IsCSV ? charparse_csv (&cvalue, col[i], c0) : charparse (&cvalue, col[i], c0); 220 vec[i][0].elements.Int[Nelem] = readStatus ? cvalue : 0; 205 221 break; 206 222 case COLTYPE_FLT: … … 254 270 free (vec); 255 271 free (col); 256 free (buffer);272 if (buffer) free (buffer); 257 273 return (TRUE); 258 274 -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/reindex.c
r33662 r34772 5 5 int reindex (int argc, char **argv) { 6 6 7 int i, N pts, Nmax;7 int i, Nmax, N; 8 8 Vector *ivec, *ovec, *xvec; 9 9 10 10 ivec = ovec = xvec = NULL; 11 Npts = 0; 11 int Npts = 0; 12 13 int KEEP_UNMATCH = FALSE; 14 if ((N = get_argument (argc, argv, "-keep-unmatched"))) { 15 remove_argument (N, &argc, argv); 16 KEEP_UNMATCH = TRUE; 17 } 12 18 13 19 if (argc != 6) goto usage; … … 22 28 23 29 // ovec matches ivec in type and xvec in size (xvec need not have all ivec elements, and may have duplicates 30 int NPTS = xvec[0].Nelements; 24 31 ResetVector (ovec, ivec->type, xvec[0].Nelements); 25 32 … … 31 38 opihi_int *vx = xvec[0].elements.Int; 32 39 for (Npts = i = 0; i < xvec[0].Nelements; i++, vx++) { 33 if (*vx == -1) continue; 34 if (*vx < 0) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i); 40 if (Npts >= NPTS) { 41 NPTS += 2000; 42 REALLOCATE (ovec[0].elements.Flt, opihi_flt, NPTS); 43 } 44 if (*vx < 0) { 45 if (KEEP_UNMATCH) { 46 ovec[0].elements.Flt[Npts] = NAN; 47 Npts++; 48 } 49 continue; 50 } 35 51 if (*vx > Nmax) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i); 36 52 ovec[0].elements.Flt[Npts] = vi[*vx]; … … 42 58 opihi_int *vx = xvec[0].elements.Int; 43 59 for (Npts = i = 0; i < xvec[0].Nelements; i++, vx++) { 44 if (*vx == -1) continue; 45 if (*vx < 0) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i); 60 if (Npts >= NPTS) { 61 NPTS += 2000; 62 REALLOCATE (ovec[0].elements.Int, opihi_int, NPTS); 63 } 64 if (*vx < 0) { 65 if (KEEP_UNMATCH) { 66 ovec[0].elements.Flt[Npts] = -1; 67 Npts++; 68 } 69 continue; 70 } 46 71 if (*vx > Nmax) ESCAPE("unexpected value in index: %d (%d)\n", *vx, i); 47 72 ovec[0].elements.Int[Npts] = vi[*vx]; … … 60 85 usage: 61 86 gprint (GP_ERR, "USAGE: reindex (out) = (in) using (index)\n"); 62 gprint (GP_ERR, " creates a new vectors (out) from (in) based on sequence in (index)\n"); 87 gprint (GP_ERR, " Creates a new vector (out) from (in) based on sequence in (index)\n"); 88 gprint (GP_ERR, " output[i] = input[index[i]]\n"); 89 gprint (GP_ERR, " If -keep-unmatched is provided, elements of index with negative values will be set to NaN / -1,\n"); 90 gprint (GP_ERR, " otherwise they will be skipped in the output.\n"); 91 gprint (GP_ERR, " The output vector has the type of the input vector and the length of the index (if -keep-unmatched).\n"); 92 gprint (GP_ERR, " The index vector may have duplicates\n"); 63 93 return (FALSE); 64 94 } -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/subset.c
r30610 r34772 13 13 Npts = 0; 14 14 15 if (argc < 6) { 16 gprint (GP_ERR, "SYNTAX: subset vec = vec [if/where] (logic expression)\n"); 17 return (FALSE); 18 } 19 15 20 valid = TRUE; 16 valid &= (argc >= 6);17 21 valid &= !strcmp(argv[2], "="); 18 22 valid &= !strcmp(argv[4], "if") || !strcmp (argv[4], "where"); -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/write_vectors.c
r33963 r34772 99 99 } 100 100 101 /* open file for out uput */101 /* open file for output */ 102 102 if (append) { 103 103 f = fopen (argv[1], "a"); -
branches/czw_branch/20120906/Ohana/src/opihi/cmd.data/zplot.c
r31667 r34772 3 3 int zplot (int argc, char **argv) { 4 4 5 int i, kapa; 5 char *outname = NULL; 6 int i, kapa, valid, size; 6 7 opihi_flt *out; 7 8 double min, range; … … 11 12 if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE); 12 13 13 if (argc != 6) { 14 valid = (argc == 6); 15 valid |= (argc > 7) && !strcmp (argv[6], "where"); 16 if (!valid) { 14 17 gprint (GP_ERR, "USAGE: zplot <x> <y> <z> min max\n"); 18 gprint (GP_ERR, " OR: zplot <x> <y> <z> min max where (condition)\n"); 15 19 return (FALSE); 16 20 } … … 18 22 min = atof(argv[4]); 19 23 range = atof(argv[5]) - min; 24 25 // tvec is used for logical test (truth vector) 26 Vector *tvec = NULL; 27 char *mask = NULL; 28 if (argc > 7) { 29 outname = dvomath (argc - 7, &argv[7], &size, 1); 30 if (outname == NULL) { 31 print_error (); 32 return FALSE; 33 } 34 if ((tvec = SelectVector (outname, OLDVECTOR, TRUE)) == NULL) { 35 gprint (GP_ERR, " invalid logic result\n"); 36 DeleteNamedVector (outname); 37 free (outname); 38 return (FALSE); 39 } 40 } 20 41 21 42 /* find vectors */ … … 29 50 if (xvec[0].Nelements != zvec[0].Nelements) { 30 51 gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[3]); 52 return (FALSE); 53 } 54 if (tvec && tvec[0].Nelements != yvec[0].Nelements) { 55 gprint (GP_ERR, "logic test vector not the same length as data vectors\n"); 31 56 return (FALSE); 32 57 } … … 46 71 } 47 72 73 if (tvec) { 74 ALLOCATE (mask, char, tvec->Nelements); 75 for (i = 0; i < tvec->Nelements; i++) { 76 mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0); 77 } 78 } 79 48 80 /* point size determined by Zvec */ 49 81 graphmode.style = 2; /* plot points */ 50 82 graphmode.size = -1; /* point size determined by Zvec */ 51 83 graphmode.etype = 0; /* no errorbars */ 52 PlotVectorTriplet (kapa, xvec, yvec, &Zvec, &graphmode);84 PlotVectorTriplet (kapa, xvec, yvec, &Zvec, mask, &graphmode); 53 85 54 86 free (Zvec.elements.Ptr); 87 if (mask) free (mask); 88 DeleteNamedVector (outname); 55 89 56 90 return (TRUE); … … 60 94 int zcplot (int argc, char **argv) { 61 95 62 int i, kapa; 96 char *outname = NULL; 97 int i, kapa, valid, size; 63 98 opihi_flt *out; 64 99 double min, range; … … 68 103 if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE); 69 104 70 if (argc != 6) { 71 gprint (GP_ERR, "USAGE: zplot <x> <y> <z> min max\n"); 105 valid = (argc == 6); 106 valid |= (argc > 7) && !strcmp (argv[6], "where"); 107 if (!valid) { 108 gprint (GP_ERR, "USAGE: zcplot <x> <y> <z> min max\n"); 109 gprint (GP_ERR, " OR: zcplot <x> <y> <z> min max where (condition)\n"); 72 110 return (FALSE); 73 111 } … … 75 113 min = atof(argv[4]); 76 114 range = atof(argv[5]) - min; 115 116 // tvec is used for logical test (truth vector) 117 Vector *tvec = NULL; 118 char *mask = NULL; 119 if (argc > 7) { 120 outname = dvomath (argc - 7, &argv[7], &size, 1); 121 if (outname == NULL) { 122 print_error (); 123 return FALSE; 124 } 125 if ((tvec = SelectVector (outname, OLDVECTOR, TRUE)) == NULL) { 126 gprint (GP_ERR, " invalid logic result\n"); 127 DeleteNamedVector (outname); 128 free (outname); 129 return (FALSE); 130 } 131 } 77 132 78 133 /* find vectors */ … … 86 141 if (xvec[0].Nelements != zvec[0].Nelements) { 87 142 gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[3]); 143 return (FALSE); 144 } 145 if (tvec && tvec[0].Nelements != yvec[0].Nelements) { 146 gprint (GP_ERR, "logic test vector not the same length as data vectors\n"); 88 147 return (FALSE); 89 148 } … … 103 162 } 104 163 164 if (tvec) { 165 ALLOCATE (mask, char, tvec->Nelements); 166 for (i = 0; i < tvec->Nelements; i++) { 167 mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0); 168 } 169 } 170 105 171 /* point size determined by Zvec */ 106 172 graphmode.style = 2; /* plot points */ 107 173 graphmode.color = -1; /* point color determined by Zvec */ 108 174 graphmode.etype = 0; /* no errorbars */ 109 PlotVectorTriplet (kapa, xvec, yvec, &Zvec, &graphmode);175 PlotVectorTriplet (kapa, xvec, yvec, &Zvec, mask, &graphmode); 110 176 111 177 free (Zvec.elements.Ptr); 178 if (mask) free (mask); 179 DeleteNamedVector (outname); 112 180 113 181 return (TRUE); -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/Makefile
r33662 r34772 67 67 $(SRC)/lightcurve.$(ARCH).o \ 68 68 $(SRC)/mextract.$(ARCH).o \ 69 $(SRC)/mmatch.$(ARCH).o \ 69 70 $(SRC)/mmextract.$(ARCH).o \ 70 71 $(SRC)/objectcoverage.$(ARCH).o \ -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/avextract.c
r34405 r34772 137 137 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results 138 138 if (PARALLEL && !HOST_ID) { 139 int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE);139 int status = HostTableParallelOps (argc, argv, RESULT_FILE, TRUE, 0, VERBOSE); 140 140 141 141 dbFreeFields (fields, Nfields); … … 325 325 gprint (GP_ERR, " <photcode>:nphot : number of measurements used for average magnitude in this photcode\n"); 326 326 327 // gprint (GP_ERR, " <photcode>:ap : catalog aperture magnitude for photcode\n"); 328 // gprint (GP_ERR, " <photcode>:aper : catalog aperture magnitude for photcode\n"); 329 // gprint (GP_ERR, " <photcode>:aveerr : average error (stdev)\n"); 330 // gprint (GP_ERR, " <photcode>:aperinst : aperture flux\n"); 331 // gprint (GP_ERR, " <photcode>:aper_inst : aperture flux\n"); 332 333 gprint (GP_ERR, " <photcode>:kron : kron flux\n"); 334 // gprint (GP_ERR, " <photcode>:kronerr : kron error\n"); 335 gprint (GP_ERR, " <photcode>:photflags : photometry flags for measurements\n"); 336 gprint (GP_ERR, " <photcode>:flags : photometry flags for measurements\n"); 337 gprint (GP_ERR, " <photcode>:stdev : standard deviation of measurements\n"); 338 gprint (GP_ERR, " <photcode>:20 : 20 percentile psf mag\n"); 339 gprint (GP_ERR, " <photcode>:80 : 80 percentile psf mag\n"); 340 gprint (GP_ERR, " <photcode>:ucdist : distance to ubercalibrated exposure (in exposure overlaps)\n"); 341 gprint (GP_ERR, " <photcode>:stackDetectID : PSPS ID for stack detection\n"); 342 gprint (GP_ERR, " <photcode>:fluxpsf : psf flux\n"); 343 gprint (GP_ERR, " <photcode>:fluxpsferr : psf flux error\n"); 344 gprint (GP_ERR, " <photcode>:fluxkron : kron flux\n"); 345 gprint (GP_ERR, " <photcode>:fluxkronerr : kron flux error\n"); 346 327 347 // gprint (GP_ERR, " type : dophot type (unused)\n"); 328 348 // gprint (GP_ERR, " typefrac : dophot type fraction (unused)\n"); -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/avmatch.c
r34405 r34772 95 95 96 96 // I need to pass the RA & DEC vectors to the remote clients... 97 int status = HostTableParallelOps (argc, argv, RESULT_FILE, RAvec->Nelements, VERBOSE);97 int status = HostTableParallelOps (argc, argv, RESULT_FILE, TRUE, RAvec->Nelements, VERBOSE); 98 98 if (vec) free (vec); 99 99 … … 203 203 Npts = j; 204 204 205 if (Ncat == -1) continue; 206 if (Ncat == -2) continue; 205 if (Ncat == -1) continue; // this point is not in this catalog file 206 if (Ncat == -2) continue; // no matches to this point 207 207 208 208 m = catalog.average[Ncat].measureOffset; -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/dvo_host_utils.c
r34260 r34772 79 79 } 80 80 81 // bundle the arguments into a command and pass to dvo_client. this implementation 82 // expects there to be a result file from the clients, and to load this into vectors in 83 // the main shell. 'Nelements' is a temp hack : for most commands, the result vectors are 84 // concatenated, but for avmatch, the vectors are merged by index into a pre-known 85 // length. this is probably not a solution to a general problem.. 86 int HostTableParallelOps (int argc, char **argv, char *ResultFile, int Nelements, int VERBOSE) { 81 // bundle the arguments into a command and pass to dvo_client. 82 83 // the normal ending step expects there to be a result file from the clients, and to load 84 // this into vectors in the main shell. 'Nelements' is a temp hack : for most commands, 85 // the result vectors are concatenated, but for avmatch, the vectors are merged by index 86 // into a pre-known length. this is probably not a solution to a general problem.. 87 88 // an alternative ending step ignores the result files and instead saves the names into 89 // the list 'result:n' for the user to access as desired 90 int HostTableParallelOps (int argc, char **argv, char *ResultFile, int ReadVectors, int Nelements, int VERBOSE) { 87 91 88 92 int i; … … 153 157 } 154 158 159 // create the result file list 160 char name[256]; 161 snprintf (name, 256, "RESULT_FILE:n"); 162 set_int_variable (name, table->Nhosts); 163 snprintf (name, 256, "RESULT_DATA:n"); 164 set_int_variable (name, table->Nhosts); 165 snprintf (name, 256, "RESULT_STATUS:n"); 166 set_int_variable (name, table->Nhosts); 167 155 168 // load fields from file 156 169 int Nvec = 0; 157 170 Vector **vec = NULL; 158 171 for (i = 0; i < table->Nhosts; i++) { 172 173 snprintf (name, 256, "RESULT_FILE:%d", i); 174 set_str_variable (name, table->hosts[i].results); 175 176 // DATA : 0 (unread), 1 (read) 177 snprintf (name, 256, "RESULT_DATA:%d", i); 178 set_int_variable (name, 0); 179 180 // STATUS : 0 (normal exit), -1 (crash), N (failure exit status) 181 snprintf (name, 256, "RESULT_STATUS:%d", i); 182 set_int_variable (name, table->hosts[i].status); 183 159 184 if (table->hosts[i].status) continue; 185 186 if (ReadVectors) { 187 int Ninvec = 0; 188 Vector **invec = ReadVectorTableFITS (table->hosts[i].results, "RESULT", &Ninvec); 189 if (!invec) { 190 // failed to read the file, now what? 191 gprint (GP_ERR, "failed to read remote result file : %s\n", table->hosts[i].results); 192 free (table->hosts[i].results); 193 table->hosts[i].results = NULL; 194 continue; 195 } 196 free (table->hosts[i].results); 197 table->hosts[i].results = NULL; 198 set_int_variable (name, 1); // result file has been read 199 200 if (Nelements == 0) { 201 vec = MergeVectors (vec, &Nvec, invec, Ninvec); 202 if (vec != invec) { 203 FreeVectorArray (invec, Ninvec); 204 } 205 } else { 206 vec = MergeVectorsByIndex (vec, &Nvec, invec, Ninvec, Nelements); 207 FreeVectorArray (invec, Ninvec); 208 } 209 } 210 } 211 212 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 213 if (ResultFile) { 214 int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nvec, FALSE, NULL); 215 if (!status) { 216 gprint (GP_ERR, "failed to write result file %s\n", ResultFile); 217 return FALSE; 218 } 219 } 220 221 for (i = 0; i < Nvec; i++) { 222 AssignVector (vec[i], vec[i]->name, ANYVECTOR, TRUE); 223 } 224 free (vec); 225 226 free (table); 227 return TRUE; 228 } 229 230 // re-gather the remote results files: this can be used in case one of the clients failed, 231 // and has since been re-run 232 int HostTableReloadResults (char *uniquer, int VERBOSE) { 233 234 int i; 235 236 // load the list of hosts 237 SkyTable *sky = GetSkyTable(); 238 if (!sky) { 239 gprint (GP_ERR, "failed to load sky table for database\n"); 240 return FALSE; 241 } 242 243 char *CATDIR = GetCATDIR (); 244 if (!CATDIR) { 245 gprint (GP_ERR, "failed to get CATDIR for database\n"); 246 return FALSE; 247 } 248 249 HostTable *table = HostTableLoad (CATDIR, sky->hosts); 250 if (!table) { 251 gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR); 252 return FALSE; 253 } 254 255 // load fields from file 256 int Nvec = 0; 257 Vector **vec = NULL; 258 for (i = 0; i < table->Nhosts; i++) { 259 // ensure that the paths are absolute path names 260 char *tmppath = abspath (table->hosts[i].pathname, DVO_MAX_PATH); 261 free (table->hosts[i].pathname); 262 table->hosts[i].pathname = tmppath; 263 264 // need to save the results filename with the uniquer 265 // XXX a bit of a waste (but only 1024 * 60 bytes or so 266 ALLOCATE (table->hosts[i].results, char, DVO_MAX_PATH); 267 snprintf (table->hosts[i].results, DVO_MAX_PATH, "%s/dvo.results.%s.fits", table->hosts[i].pathname, uniquer); 160 268 161 269 int Ninvec = 0; … … 171 279 table->hosts[i].results = NULL; 172 280 173 if (Nelements == 0) { 174 vec = MergeVectors (vec, &Nvec, invec, Ninvec); 175 if (vec != invec) { 176 FreeVectorArray (invec, Ninvec); 177 } 178 } else { 179 vec = MergeVectorsByIndex (vec, &Nvec, invec, Ninvec, Nelements); 281 // fprintf (stderr, "%s : %d\n", table->hosts[i].pathname, invec[0]->Nelements); 282 283 vec = MergeVectors (vec, &Nvec, invec, Ninvec); 284 if (vec != invec) { 180 285 FreeVectorArray (invec, Ninvec); 181 }182 }183 184 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere)185 if (ResultFile) {186 int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nvec, FALSE, NULL);187 if (!status) {188 gprint (GP_ERR, "failed to write result file %s\n", ResultFile);189 return FALSE;190 286 } 191 287 } … … 199 295 return TRUE; 200 296 } 201 202 // re-gather the remote results files: this can be used in case one of the clients failed,203 // and has since been re-run204 int HostTableReloadResults (char *uniquer, int VERBOSE) {205 206 int i;207 208 // load the list of hosts209 SkyTable *sky = GetSkyTable();210 if (!sky) {211 gprint (GP_ERR, "failed to load sky table for database\n");212 return FALSE;213 }214 215 char *CATDIR = GetCATDIR ();216 if (!CATDIR) {217 gprint (GP_ERR, "failed to get CATDIR for database\n");218 return FALSE;219 }220 221 HostTable *table = HostTableLoad (CATDIR, sky->hosts);222 if (!table) {223 gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);224 return FALSE;225 }226 227 // load fields from file228 int Nvec = 0;229 Vector **vec = NULL;230 for (i = 0; i < table->Nhosts; i++) {231 // ensure that the paths are absolute path names232 char *tmppath = abspath (table->hosts[i].pathname, DVO_MAX_PATH);233 free (table->hosts[i].pathname);234 table->hosts[i].pathname = tmppath;235 236 // need to save the results filename with the uniquer237 // XXX a bit of a waste (but only 1024 * 60 bytes or so238 ALLOCATE (table->hosts[i].results, char, DVO_MAX_PATH);239 snprintf (table->hosts[i].results, DVO_MAX_PATH, "%s/dvo.results.%s.fits", table->hosts[i].pathname, uniquer);240 241 int Ninvec = 0;242 Vector **invec = ReadVectorTableFITS (table->hosts[i].results, "RESULT", &Ninvec);243 if (!invec) {244 // failed to read the file, now what?245 gprint (GP_ERR, "failed to read remote result file : %s\n", table->hosts[i].results);246 free (table->hosts[i].results);247 table->hosts[i].results = NULL;248 continue;249 }250 free (table->hosts[i].results);251 table->hosts[i].results = NULL;252 253 // fprintf (stderr, "%s : %d\n", table->hosts[i].pathname, invec[0]->Nelements);254 255 vec = MergeVectors (vec, &Nvec, invec, Ninvec);256 if (vec != invec) {257 FreeVectorArray (invec, Ninvec);258 }259 }260 261 for (i = 0; i < Nvec; i++) {262 AssignVector (vec[i], vec[i]->name, ANYVECTOR, TRUE);263 }264 free (vec);265 266 free (table);267 return TRUE;268 } -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/fitcolors.c
r28241 r34772 311 311 KapaBox (kapa, &graphdata); 312 312 313 PlotVectorPair (kapa, xvec, yvec, &graphdata);313 PlotVectorPair (kapa, xvec, yvec, NULL, &graphdata); 314 314 315 315 for (i = 0; i < 11; i++) { -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/images.c
r34088 r34772 350 350 graphmode.ptype = 100; /* connect pairs of points */ 351 351 graphmode.etype = 0; 352 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);352 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 353 353 } 354 354 -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/imbox.c
r27435 r34772 123 123 graphmode.ptype = 100; /* connect pairs of points */ 124 124 graphmode.etype = 0; 125 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);125 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 126 126 } 127 127 -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/imdense.c
r31635 r34772 65 65 graphmode.style = 2; /* points */ 66 66 graphmode.etype = 0; 67 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);67 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 68 68 } 69 69 -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/imstats.c
r31635 r34772 54 54 graphmode.style = 2; 55 55 graphmode.etype = 0; 56 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);56 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 57 57 58 58 free (Xvec.elements.Flt); -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/init.c
r33662 r34772 42 42 int lightcurve PROTO((int, char **)); 43 43 int mextract PROTO((int, char **)); 44 int mmatch PROTO((int, char **)); 44 45 int mmextract PROTO((int, char **)); 45 46 int objectcoverage PROTO((int, char **)); … … 97 98 {1, "lightcurve", lightcurve, "extract lightcurve for a star"}, 98 99 {1, "mextract", mextract, "extract measure data values"}, 100 {1, "mmatch", mmatch, "extract measure data values matched to RA,DEC points"}, 99 101 {1, "mmextract", mmextract, "extract joined measurements"}, 100 102 {1, "objectcoverage", objectcoverage, "plot catalog boundaries"}, -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/lcurve.c
r34088 r34772 160 160 PlotVectorPairErrors (kapa, &Xvec, &Yvec, &dYvec, &graphmode); 161 161 } else { 162 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);162 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 163 163 } 164 164 -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/mextract.c
r34260 r34772 108 108 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results 109 109 if (PARALLEL && !HOST_ID) { 110 int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE);110 int status = HostTableParallelOps (argc, argv, RESULT_FILE, TRUE, 0, VERBOSE); 111 111 112 112 dbFreeFields (fields, Nfields); … … 313 313 gprint (GP_ERR, " Npos : number of measurments used for astrometry\n"); 314 314 315 gprint (GP_ERR, " objflags : object flags\n"); 316 gprint (GP_ERR, " photflags : detection flags from image analysis\n"); 317 gprint (GP_ERR, " dbflags : detection flags from database analysis\n"); 315 gprint (GP_ERR, " objflags : object flags [alias: obj_flags]\n"); 316 gprint (GP_ERR, " secflags : average photometry flags [aliases: obj_phot_flags, sec_flags, secfilt_flags]\n"); 317 gprint (GP_ERR, " photflags : detection flags from image analysis [alias: phot_flags]\n"); 318 gprint (GP_ERR, " dbflags : detection flags from database analysis [alias: db_flags]\n"); 318 319 319 320 gprint (GP_ERR, " obj_flags : object flags\n"); … … 321 322 gprint (GP_ERR, " db_flags : detection flags from database analysis\n"); 322 323 324 gprint (GP_ERR, " airmass : airmass of detection\n"); 325 gprint (GP_ERR, " meas_airmass : airmass of exposure\n"); 326 gprint (GP_ERR, " alt : altitude of detection\n"); 327 gprint (GP_ERR, " az : azimuth of detection\n"); 328 gprint (GP_ERR, " exptime : exposure time [s]\n"); 329 gprint (GP_ERR, " photcode : photcode \n"); 330 gprint (GP_ERR, " photcode:equiv : equivalent average photcode \n"); 331 gprint (GP_ERR, " photcode:c : zero point of photcode \n"); 332 gprint (GP_ERR, " photcode:klam : airmass slope of photcode \n"); 333 gprint (GP_ERR, " time : time of exposure [Seconds since Jan 1, 1970/\n"); 334 gprint (GP_ERR, " fwhm : fwhm (average) of fitted PSF [pixels]\n"); 335 gprint (GP_ERR, " fwhm_maj : fwhm (major axis) of fitted PSF [pixels]\n"); 336 gprint (GP_ERR, " fwhm_min : fwhm (minor axis) of fitted PSF [pixels]\n"); 337 gprint (GP_ERR, " theta : position angle of fitted PSF\n"); 338 gprint (GP_ERR, " posangle : position angle of detector at measurement [degrees]\n"); 339 gprint (GP_ERR, " platescale : plate scale of detector at measurement [arcsec/pixel] (negative = sky parity)\n"); 340 341 gprint (GP_ERR, " Mxx : second moment in X [pixels^2]\n"); 342 gprint (GP_ERR, " Mxy : second moment cross term [pixels^2]\n"); 343 gprint (GP_ERR, " Myy : second moment in Y [pixels^2]\n"); 344 345 gprint (GP_ERR, " xccd : ccd x position\n"); 346 gprint (GP_ERR, " yccd : ccd y position\n"); 347 gprint (GP_ERR, " xoff : ccd x correction\n"); 348 gprint (GP_ERR, " yoff : ccd y correction\n"); 349 gprint (GP_ERR, " xccd:err : ccd x position error\n"); 350 gprint (GP_ERR, " yccd:err : ccd y position error\n"); 351 352 gprint (GP_ERR, " pos_sys_err : systematic position error\n"); 353 354 gprint (GP_ERR, " xmosaic : mosaic x position\n"); 355 gprint (GP_ERR, " ymosaic : mosaic y position\n"); 356 357 gprint (GP_ERR, " xchip : chip x position (= ccd position)\n"); 358 gprint (GP_ERR, " ychip : chip y position (= ccd position)\n"); 359 gprint (GP_ERR, " xfpa : fpa x position (= mosaic position)\n"); 360 gprint (GP_ERR, " yfpa : fpa y position (= mosaic position)\n"); 361 362 gprint (GP_ERR, " detID : ID of detection (unique on source image)\n"); 363 gprint (GP_ERR, " objID : object ID (32 bit, unique in catalog)\n"); 364 gprint (GP_ERR, " catID : catalog ID (32 bit)\n"); 365 gprint (GP_ERR, " imageID : ID of source image (32 bit)\n"); 366 gprint (GP_ERR, " externID : externID of source image (32 bit)\n"); 367 368 gprint (GP_ERR, " psf_qf : PSF quality factor (psf-weighted mask fraction)\n"); 369 gprint (GP_ERR, " psf_qf_perfect : PSF quality factor, perfect mask version (psf-weighted mask fraction)\n"); 370 371 gprint (GP_ERR, " psf_chisq : PSF fit chi square\n"); 372 gprint (GP_ERR, " psf_ndof : PSF number of degrees of freedom\n"); 373 gprint (GP_ERR, " psf_npix : PSF number of pixels\n"); 374 375 gprint (GP_ERR, " cr_nsigma : Nsigma deviation towards cosmic ray\n"); 376 gprint (GP_ERR, " ext_nsigma : Nsigma deviation towards extended source\n"); 377 378 gprint (GP_ERR, " sky : sky model flux at measurement location\n"); 379 gprint (GP_ERR, " sky_err : sky model stdev at measurement location\n"); 380 381 gprint (GP_ERR, " Mcal_offset : difference wrt nominal zero point (clouds are positive)\n"); 382 gprint (GP_ERR, " flat : flat-field correction (measure.Mcal - image.Mcal)\n"); 383 384 gprint (GP_ERR, " center_offset : distance to image center\n"); 385 gprint (GP_ERR, " flux : PSF flux\n"); 386 gprint (GP_ERR, " flux_err : PSF flux error\n"); 387 gprint (GP_ERR, " flux_psf : PSF flux\n"); 388 gprint (GP_ERR, " flux_psf_err : PSF flux error\n"); 389 gprint (GP_ERR, " flux_kron : KRON flux\n"); 390 gprint (GP_ERR, " flux_kron_err : KRON flux error\n"); 391 392 gprint (GP_ERR, " --- the following fields are selected by giving a photcode with the attached ending\n"); 323 393 gprint (GP_ERR, " <photcode>:ave : average magnitude for photcode (or equivalent)\n"); 324 394 gprint (GP_ERR, " <photcode>:ref : reference magnitude system for photcode (or equivalent)\n"); … … 335 405 gprint (GP_ERR, " <photcode>:ncode : number of measurements in photcode\n"); 336 406 gprint (GP_ERR, " <photcode>:nphot : number of measurements used for average magnitude\n"); 337 gprint (GP_ERR, " airmass : airmass of detection\n"); 338 gprint (GP_ERR, " alt : altitude of detection\n"); 339 gprint (GP_ERR, " az : azimuth of detection\n"); 340 gprint (GP_ERR, " exptime : exposure time [s]\n"); 341 gprint (GP_ERR, " photcode : photcode \n"); 342 gprint (GP_ERR, " photcode:equiv : equivalent average photcode \n"); 343 gprint (GP_ERR, " time : time of exposure [Seconds since Jan 1, 1970/\n"); 344 gprint (GP_ERR, " fwhm : fwhm (average) of fitted PSF [pixels]\n"); 345 gprint (GP_ERR, " fwhm_maj : fwhm (major axis) of fitted PSF [pixels]\n"); 346 gprint (GP_ERR, " fwhm_min : fwhm (minor axis) of fitted PSF [pixels]\n"); 347 gprint (GP_ERR, " theta : position angle of fitted PSF\n"); 348 gprint (GP_ERR, " posangle : position angle of detector at measurement [degrees]\n"); 349 gprint (GP_ERR, " platescale : plate scale of detector at measurement [arcsec/pixel] \n"); 350 351 gprint (GP_ERR, " psf_qf : PSF quality factor (psf-weighted mask fraction)\n"); 352 gprint (GP_ERR, " psf_chisq : PSF fit chi square\n"); 353 gprint (GP_ERR, " psf_ndof : PSF number of degrees of freedom\n"); 354 gprint (GP_ERR, " psf_npix : PSF number of pixels\n"); 355 356 gprint (GP_ERR, " cr_nsigma : Nsigma deviation towards cosmic ray\n"); 357 gprint (GP_ERR, " ext_nsigma : Nsigma deviation towards extended source\n"); 358 359 gprint (GP_ERR, " Mxx : second moment in X [pixels^2]\n"); 360 gprint (GP_ERR, " Mxy : second moment cross term [pixels^2]\n"); 361 gprint (GP_ERR, " Myy : second moment in Y [pixels^2]\n"); 362 363 gprint (GP_ERR, " xccd : ccd x position\n"); 364 gprint (GP_ERR, " yccd : ccd y position\n"); 365 gprint (GP_ERR, " xccd:err : ccd x position error\n"); 366 gprint (GP_ERR, " yccd:err : ccd y position error\n"); 367 gprint (GP_ERR, " xmosaic : mosaic x position\n"); 368 gprint (GP_ERR, " ymosaic : mosaic y position\n"); 369 gprint (GP_ERR, " xchip : chip x position (= ccd position)\n"); 370 gprint (GP_ERR, " ychip : chip y position (= ccd position)\n"); 371 gprint (GP_ERR, " xfpa : fpa x position (= mosaic position)\n"); 372 gprint (GP_ERR, " yfpa : fpa y position (= mosaic position)\n"); 373 374 gprint (GP_ERR, " detID : ID of detection (unique on source image)\n"); 375 gprint (GP_ERR, " objID : object ID (32 bit, unique in catalog)\n"); 376 gprint (GP_ERR, " catID : catalog ID (32 bit)\n"); 377 gprint (GP_ERR, " imageID : ID of source image (32 bit)\n"); 378 gprint (GP_ERR, " externID : externID of source image (32 bit)\n"); 379 380 gprint (GP_ERR, " Mcal_offset : difference wrt nominal zero point (clouds are positive)\n"); 381 gprint (GP_ERR, " flat : flat-field correction (measure.Mcal - image.Mcal)\n"); 407 408 gprint (GP_ERR, " <photcode>:aperinst : instrumental aperture magnitude\n"); 409 gprint (GP_ERR, " <photcode>:aper_inst : instrumental aperture magnitude\n"); 410 gprint (GP_ERR, " <photcode>:kron : kron mag\n"); 411 gprint (GP_ERR, " <photcode>:kroninst : instrumental kron mag\n"); 412 gprint (GP_ERR, " <photcode>:kron_inst : instrumental kron mag\n"); 413 gprint (GP_ERR, " <photcode>:kronerr : kron mag error\n"); 414 415 gprint (GP_ERR, " <photcode>:photflags : photometry flags for measurements\n"); 416 gprint (GP_ERR, " <photcode>:flags : photometry flags for measurements\n"); 417 gprint (GP_ERR, " <photcode>:fluxpsf : average psf flux\n"); 418 gprint (GP_ERR, " <photcode>:fluxpsferr : average psf flux error\n"); 419 gprint (GP_ERR, " <photcode>:fluxkron : average kron flux\n"); 420 gprint (GP_ERR, " <photcode>:fluxkronerr : average kron flux error\n"); 421 382 422 return (FALSE); 383 423 } -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/mmatch.c
r34678 r34772 124 124 125 125 // call the remote client 126 int status = HostTableParallelOps (targc, targv, RESULT_FILE, 0, VERBOSE);126 int status = HostTableParallelOps (targc, targv, RESULT_FILE, TRUE, 0, VERBOSE); 127 127 if (vec) free (vec); 128 128 -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/procks.c
r20936 r34772 113 113 graphmode.style = 2; /* set style to points */ 114 114 graphmode.etype = 0; /* no errorbars */ 115 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);115 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 116 116 117 117 /* now plot vectors between two extrema */ … … 146 146 graphmode.etype = 0; /* no errorbars */ 147 147 148 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);148 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 149 149 150 150 free (Xvec.elements.Flt); -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/remote.c
r33963 r34772 12 12 remove_argument (N, &argc, argv); 13 13 VERBOSE = TRUE; 14 } 15 16 int ReadVectors = TRUE; 17 if ((N = get_argument (argc, argv, "-skip-result"))) { 18 remove_argument (N, &argc, argv); 19 ReadVectors = FALSE; 14 20 } 15 21 … … 43 49 44 50 // strip of the 'remote' and send the remaining arguments to the remote machine 45 int status = HostTableParallelOps (argc - 1, &argv[1], NULL, 0, VERBOSE);51 int status = HostTableParallelOps (argc - 1, &argv[1], NULL, ReadVectors, 0, VERBOSE); 46 52 return status; 47 53 } -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/showtile.c
r20936 r34772 86 86 graphmode.ptype = 100; /* connect pairs of points */ 87 87 graphmode.etype = 0; 88 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);88 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 89 89 } 90 90 -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/simage.c
r34088 r34772 151 151 graphmode.etype = 0; 152 152 153 PlotVectorTriplet (kapa, &Xvec, &Yvec, &Zvec, &graphmode);153 PlotVectorTriplet (kapa, &Xvec, &Yvec, &Zvec, NULL, &graphmode); 154 154 155 155 free (Xvec.elements.Flt); -
branches/czw_branch/20120906/Ohana/src/opihi/dvo/skycat.c
r34088 r34772 100 100 graphmode.ptype = 100; /* connect pairs of points */ 101 101 graphmode.etype = 0; 102 PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);102 PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode); 103 103 } 104 104 -
branches/czw_branch/20120906/Ohana/src/opihi/include/data.h
r31636 r34772 84 84 85 85 /* in spline.c */ 86 void spline_construct (float *x, float *y, int N, float *y2); 87 float spline_apply (float *x, float *y, float *y2, int N, float X); 86 void spline_construct_flt (float *x, float *y, int N, float *y2); 87 float spline_apply_flt (float *x, float *y, float *y2, int N, float X); 88 void spline_construct_dbl (opihi_flt *x, opihi_flt *y, int N, opihi_flt *y2); 89 opihi_flt spline_apply_dbl (opihi_flt *x, opihi_flt *y, opihi_flt *y2, int N, opihi_flt X); 88 90 89 91 /* in svdcmp.c */ … … 168 170 void FreeQueues (void); 169 171 void FreeBooks (void); 172 173 // the interpolating spline has valu 174 typedef struct { 175 int Nknots; 176 opihi_flt *xk; 177 opihi_flt *yk; 178 opihi_flt *y2; 179 char *name; 180 } Spline; 181 182 /* in SplineOps.c */ 183 void InitSplines (); 184 void FreeSplines (); 185 void InitSpline (Spline *spline, char *name, int Nknots); 186 void FreeSpline (Spline *spline); 187 Spline *GetSpline (int where); 188 Spline *FindSpline (char *name); 189 Spline *CreateSpline (char *name, int Nknots); 190 int DeleteSpline (Spline *spline); 191 void ListSplines (); 192 int SaveSpline (char *filename, char *name, int append); 193 int LoadSpline (char *filename, char *name); 170 194 171 195 /* hermitian functions */ -
branches/czw_branch/20120906/Ohana/src/opihi/include/display.h
r31636 r34772 7 7 8 8 /*** kapa graph functions ***/ 9 int PlotVectorSingle PROTO((int kapa, Vector *vec, char *m ode));10 int PlotVectorPair PROTO((int kapa, Vector *xVec, Vector *yVec, Graphdata *graphmode));9 int PlotVectorSingle PROTO((int kapa, Vector *vec, char *mask, char *mode)); 10 int PlotVectorPair PROTO((int kapa, Vector *xVec, Vector *yVec, char *mask, Graphdata *graphmode)); 11 11 int PlotVectorPairErrors PROTO((int kapa, Vector *xVec, Vector *yVec, Vector *dyValues, Graphdata *graphmode)); 12 int PlotVectorTriplet PROTO((int kapa, Vector *xVec, Vector *yVec, Vector *zValues, Graphdata *graphmode)); 12 13 int PlotVectorTriplet PROTO((int kapa, Vector *xVec, Vector *yVec, Vector *zValues, char *mask, Graphdata *graphmode)); 13 14 // int GetGraphData PROTO((Graphdata *data, int *kapa, char *name)); 14 15 int GetGraph PROTO((Graphdata *data, int *kapa, char *name)); -
branches/czw_branch/20120906/Ohana/src/opihi/include/dvoshell.h
r33963 r34772 100 100 101 101 int HostTableLaunchJobs PROTO((HostTable *table, char *basecmd, char *options, int VERBOSE)); 102 int HostTableParallelOps PROTO((int argc, char **argv, char *ResultFile, int Nelements, int VERBOSE));102 int HostTableParallelOps PROTO((int argc, char **argv, char *ResultFile, int ReadVectors, int Nelements, int VERBOSE)); 103 103 int HostTableReloadResults PROTO((char *uniquer, int VERBOSE)); 104 104 -
branches/czw_branch/20120906/Ohana/src/opihi/lib.data/Makefile
r31635 r34772 23 23 $(SDIR)/bracket.$(ARCH).o \ 24 24 $(SDIR)/spline.$(ARCH).o \ 25 $(SDIR)/SplineOps.$(ARCH).o \ 25 26 $(SDIR)/mrqmin.$(ARCH).o \ 26 27 $(SDIR)/mrq2dmin.$(ARCH).o \ -
branches/czw_branch/20120906/Ohana/src/opihi/lib.data/PlotVectors.c
r20936 r34772 1 1 # include "display.h" 2 2 3 int PlotVectorSingle (int kapa, Vector *vec, char *m ode) {4 5 int i, Npts ;3 int PlotVectorSingle (int kapa, Vector *vec, char *mask, char *mode) { 4 5 int i, Npts, Nout; 6 6 float *temp; 7 7 … … 9 9 ALLOCATE (temp, float, Npts); 10 10 11 Nout = 0; 11 12 if (vec->type == OPIHI_FLT) { 12 13 opihi_flt *value = vec->elements.Flt; 13 14 for (i = 0; i < Npts; i++) { 14 temp[i] = value[i]; 15 if (mask && mask[i]) continue; 16 temp[Nout] = value[i]; 17 Nout ++; 15 18 } 16 19 } else { 17 20 opihi_int *value = vec->elements.Int; 18 21 for (i = 0; i < Npts; i++) { 19 temp[i] = value[i]; 20 } 21 } 22 KapaPlotVector (kapa, Npts, temp, mode); 23 24 free (temp); 25 26 return (TRUE); 27 } 28 29 int PlotVectorPair (int kapa, Vector *xVec, Vector *yVec, Graphdata *graphmode) { 30 31 int i, Npts; 22 if (mask && mask[i]) continue; 23 temp[Nout] = value[i]; 24 Nout ++; 25 } 26 } 27 KapaPlotVector (kapa, Nout, temp, mode); 28 29 free (temp); 30 31 return (TRUE); 32 } 33 34 int PlotVectorPair (int kapa, Vector *xVec, Vector *yVec, char *mask, Graphdata *graphmode) { 35 36 int i, Npts, Nout; 32 37 float *temp; 33 38 … … 37 42 ALLOCATE (temp, float, Npts); 38 43 39 KapaPrepPlot (kapa, Npts, graphmode); 40 44 Nout = 0; 41 45 if (xVec->type == OPIHI_FLT) { 42 46 opihi_flt *value = xVec->elements.Flt; 43 47 for (i = 0; i < Npts; i++) { 44 temp[i] = value[i]; 48 if (mask && mask[i]) continue; 49 temp[Nout] = value[i]; 50 Nout ++; 45 51 } 46 52 } else { 47 53 opihi_int *value = xVec->elements.Int; 48 54 for (i = 0; i < Npts; i++) { 49 temp[i] = value[i]; 50 } 51 } 52 KapaPlotVector (kapa, Npts, temp, "x"); 53 55 if (mask && mask[i]) continue; 56 temp[Nout] = value[i]; 57 Nout ++; 58 } 59 } 60 KapaPrepPlot (kapa, Nout, graphmode); 61 KapaPlotVector (kapa, Nout, temp, "x"); 62 63 Nout = 0; 54 64 if (yVec->type == OPIHI_FLT) { 55 65 opihi_flt *value = yVec->elements.Flt; 56 66 for (i = 0; i < Npts; i++) { 57 temp[i] = value[i]; 67 if (mask && mask[i]) continue; 68 temp[Nout] = value[i]; 69 Nout ++; 58 70 } 59 71 } else { 60 72 opihi_int *value = yVec->elements.Int; 61 73 for (i = 0; i < Npts; i++) { 62 temp[i] = value[i]; 63 } 64 } 65 KapaPlotVector (kapa, Npts, temp, "y"); 66 67 free (temp); 68 69 return (TRUE); 70 } 71 72 int PlotVectorTriplet (int kapa, Vector *xVec, Vector *yVec, Vector *zVec, Graphdata *graphmode) { 73 74 int i, Npts; 74 if (mask && mask[i]) continue; 75 temp[Nout] = value[i]; 76 Nout ++; 77 } 78 } 79 KapaPlotVector (kapa, Nout, temp, "y"); 80 81 free (temp); 82 83 return (TRUE); 84 } 85 86 int PlotVectorTriplet (int kapa, Vector *xVec, Vector *yVec, Vector *zVec, char *mask, Graphdata *graphmode) { 87 88 int i, Npts, Nout; 75 89 float *temp; 76 90 … … 81 95 ALLOCATE (temp, float, Npts); 82 96 83 KapaPrepPlot (kapa, Npts, graphmode); 84 97 Nout = 0; 85 98 if (xVec->type == OPIHI_FLT) { 86 99 opihi_flt *value = xVec->elements.Flt; 87 100 for (i = 0; i < Npts; i++) { 88 temp[i] = value[i]; 101 if (mask && mask[i]) continue; 102 temp[Nout] = value[i]; 103 Nout ++; 89 104 } 90 105 } else { 91 106 opihi_int *value = xVec->elements.Int; 92 107 for (i = 0; i < Npts; i++) { 93 temp[i] = value[i]; 94 } 95 } 96 KapaPlotVector (kapa, Npts, temp, "x"); 97 108 if (mask && mask[i]) continue; 109 temp[Nout] = value[i]; 110 Nout ++; 111 } 112 } 113 KapaPrepPlot (kapa, Nout, graphmode); 114 KapaPlotVector (kapa, Nout, temp, "x"); 115 116 Nout = 0; 98 117 if (yVec->type == OPIHI_FLT) { 99 118 opihi_flt *value = yVec->elements.Flt; 100 119 for (i = 0; i < Npts; i++) { 101 temp[i] = value[i]; 120 if (mask && mask[i]) continue; 121 temp[Nout] = value[i]; 122 Nout ++; 102 123 } 103 124 } else { 104 125 opihi_int *value = yVec->elements.Int; 105 126 for (i = 0; i < Npts; i++) { 106 temp[i] = value[i]; 107 } 108 } 109 KapaPlotVector (kapa, Npts, temp, "y"); 110 127 if (mask && mask[i]) continue; 128 temp[Nout] = value[i]; 129 Nout ++; 130 } 131 } 132 KapaPlotVector (kapa, Nout, temp, "y"); 133 134 Nout = 0; 111 135 if (zVec->type == OPIHI_FLT) { 112 136 opihi_flt *value = zVec->elements.Flt; 113 137 for (i = 0; i < Npts; i++) { 114 temp[i] = value[i]; 138 if (mask && mask[i]) continue; 139 temp[Nout] = value[i]; 140 Nout ++; 115 141 } 116 142 } else { 117 143 opihi_int *value = zVec->elements.Int; 118 144 for (i = 0; i < Npts; i++) { 119 temp[i] = value[i]; 120 } 121 } 122 KapaPlotVector (kapa, Npts, temp, "z"); 145 if (mask && mask[i]) continue; 146 temp[Nout] = value[i]; 147 Nout ++; 148 } 149 } 150 KapaPlotVector (kapa, Nout, temp, "z"); 123 151 124 152 free (temp); -
branches/czw_branch/20120906/Ohana/src/opihi/lib.data/spline.c
r16119 r34772 2 2 3 3 /* construct the natural spline for x, y in y2 */ 4 void spline_construct (float *x, float *y, int N, float *y2) {4 void spline_construct_flt (float *x, float *y, int N, float *y2) { 5 5 6 6 int i; … … 27 27 28 28 /* evaluate spline for x, y, y2 at X */ 29 float spline_apply (float *x, float *y, float *y2, int N, float X) {29 float spline_apply_flt (float *x, float *y, float *y2, int N, float X) { 30 30 31 31 int i, lo, hi; … … 58 58 59 59 } 60 61 /* construct the natural spline for x, y in y2 */ 62 void spline_construct_dbl (opihi_flt *x, opihi_flt *y, int N, opihi_flt *y2) { 63 64 int i; 65 opihi_flt dy, dx, *tmp; 66 67 ALLOCATE (tmp, opihi_flt, N); 68 69 y2[0] = tmp[0] = 0.0; 70 71 for (i = 1; i < N-1; i++) { 72 dx = (x[i+0] - x[i-1]) / (x[i+1] - x[i-1]); 73 dy = dx * y2[i-1] + 2.0; 74 y2[i] = (dx - 1.0) / dy; 75 tmp[i] = (y[i+1] - y[i+0]) / (x[i+1] - x[i+0]) - (y[i+0] - y[i-1]) / (x[i+0] - x[i-1]); 76 tmp[i] = (6.0 * tmp[i] / (x[i+1] - x[i-1]) - dx*tmp[i-1]) / dy; 77 } 78 79 y2[N-1] = 0; 80 for (i = N-2; i >= 1; i--) 81 y2[i] = y2[i]*y2[i+1] + tmp[i]; 82 83 free (tmp); 84 } 85 86 /* evaluate spline for x, y, y2 at X */ 87 opihi_flt spline_apply_dbl (opihi_flt *x, opihi_flt *y, opihi_flt *y2, int N, opihi_flt X) { 88 89 int i, lo, hi; 90 opihi_flt dx, a, b, value; 91 92 /* find correct element in array (x must be sorted) */ 93 lo = 0; 94 hi = N-1; 95 while (hi - lo > 1) { 96 i = 0.5*(hi+lo); 97 if (x[i] > X) { 98 hi = i; 99 } else { 100 lo = i; 101 } 102 } 103 104 /* error condition: duplicate abssisca */ 105 dx = x[hi] - x[lo]; 106 if (dx == 0.0) { 107 return (HUGE_VAL); 108 } 109 110 /* evaluate spline */ 111 a = (x[hi] - X) / dx; 112 b = (X - x[lo]) / dx; 113 114 value = a*y[lo] + b*y[hi] + ((a*a*a - a)*y2[lo] + (b*b*b - b)*y2[hi])*(dx*dx) / 6.0; 115 return (value); 116 117 } -
branches/czw_branch/20120906/Ohana/src/opihi/lib.shell/VectorIO.c
r33963 r34772 2 2 3 3 // write a set of vectors to a FITS file (vectors names become fits column names) 4 int WriteVectorTableFITS (char *filename, char *extname, Vector **vec, int Nvec, int append, char *format) { 5 4 int WriteVectorTable (Header *theader, FTable *ftable, char *extname, Vector **vec, int Nvec, char *format) { 5 6 int j; 7 6 8 char *tformat = NULL; 7 Header header; 8 Matrix matrix; 9 Header theader; 10 FTable ftable; 11 12 int j; 13 FILE *f = NULL; 14 15 /* open file for outuput */ 16 if (append) { 17 f = fopen (filename, "a"); 18 } else { 19 f = fopen (filename, "w"); 20 } 21 if (f == (FILE *) NULL) { 22 gprint (GP_ERR, "can't open file for write : %s\n", filename); 23 return (FALSE); 24 } 25 26 if (!append) { 27 gfits_init_header (&header); 28 header.extend = TRUE; 29 gfits_create_header (&header); 30 gfits_create_matrix (&header, &matrix); 31 } 32 33 gfits_create_table_header (&theader, "BINTABLE", extname); 9 10 gfits_create_table_header (theader, "BINTABLE", extname); 34 11 35 12 ALLOCATE (tformat, char, 2*Nvec); … … 71 48 // this somehow 72 49 for (j = 0; j < Nvec; j++) { 73 gfits_define_bintable_column ( &theader, &tformat[2*j], vec[j][0].name, NULL, NULL, 1.0, 0.0);50 gfits_define_bintable_column (theader, &tformat[2*j], vec[j][0].name, NULL, NULL, 1.0, 0.0); 74 51 } 75 52 free (tformat); 76 53 77 54 // generate the output array that carries the data 78 gfits_create_table ( &theader, &ftable);55 gfits_create_table (theader, ftable); 79 56 80 57 // add the vectors to the output array 81 58 for (j = 0; j < Nvec; j++) { 82 59 if (vec[j][0].type == OPIHI_FLT) { 83 gfits_set_bintable_column_reformat ( &theader, &ftable, vec[j][0].name, "double", vec[j][0].elements.Flt, vec[j][0].Nelements);60 gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "double", vec[j][0].elements.Flt, vec[j][0].Nelements); 84 61 } else { 85 gfits_set_bintable_column_reformat (&theader, &ftable, vec[j][0].name, "int", vec[j][0].elements.Int, vec[j][0].Nelements); 86 } 87 } 62 gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "int", vec[j][0].elements.Int, vec[j][0].Nelements); 63 } 64 } 65 return (TRUE); 66 67 escape: 68 if (tformat) free (tformat); 69 return (FALSE); 70 } 71 72 // write a set of vectors to a FITS file (vectors names become fits column names) 73 int WriteVectorTableFITS (char *filename, char *extname, Vector **vec, int Nvec, int append, char *format) { 74 75 Header header; 76 Matrix matrix; 77 Header theader; 78 FTable ftable; 79 80 FILE *f = NULL; 81 82 /* open file for outuput */ 83 if (append) { 84 f = fopen (filename, "a"); 85 } else { 86 f = fopen (filename, "w"); 87 } 88 if (f == (FILE *) NULL) { 89 gprint (GP_ERR, "can't open file for write : %s\n", filename); 90 return (FALSE); 91 } 92 93 if (!WriteVectorTable (&theader, &ftable, extname, vec, Nvec, format)) goto escape; 88 94 89 95 if (!append) { 96 gfits_init_header (&header); 97 header.extend = TRUE; 98 gfits_create_header (&header); 99 gfits_create_matrix (&header, &matrix); 90 100 gfits_fwrite_header (f, &header); 91 101 gfits_fwrite_matrix (f, &matrix); … … 111 121 gfits_free_table (&ftable); 112 122 113 if (tformat) free (tformat);114 123 fclose (f); 115 124 fflush (f);
Note:
See TracChangeset
for help on using the changeset viewer.
