Changeset 39223
- Timestamp:
- Dec 3, 2015, 4:13:55 PM (11 years ago)
- Location:
- branches/eam_branches/ipp-20151113/Ohana/src/opihi
- Files:
-
- 5 edited
- 1 copied
-
cmd.astro (modified) (1 prop)
-
cmd.astro/Makefile (modified) (1 diff)
-
cmd.astro/fitplx_irls.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/fitplx_irls.c )
-
cmd.astro/fitpm_irls.c (modified) (2 diffs)
-
cmd.astro/init.c (modified) (2 diffs)
-
cmd.data/read_vectors.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro
- Property svn:mergeinfo changed
/trunk/Ohana/src/opihi/cmd.astro (added) merged: 39167-39169,39181
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/Makefile
r39194 r39223 35 35 $(SRC)/fitplx.$(ARCH).o \ 36 36 $(SRC)/fitpm.$(ARCH).o \ 37 $(SRC)/fitpm_irls.$(ARCH).o \ 38 $(SRC)/fitplx_irls.$(ARCH).o \ 37 39 $(SRC)/fixwrap.$(ARCH).o \ 38 40 $(SRC)/fixcols.$(ARCH).o \ -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/fitpm_irls.c
r39086 r39223 231 231 sigma_ols = 0.0; 232 232 for (i = 0; i < Npts; i++) { 233 rx[i] = X[i] - (T[i] * B[ 0][0] + B[1][0]);234 ry[i] = Y[i] - (T[i] * B[ 2][0] + B[3][0]);233 rx[i] = X[i] - (T[i] * B[1][0] + B[0][0]); 234 ry[i] = Y[i] - (T[i] * B[3][0] + B[2][0]); 235 235 // u[i] = r[i] / 236 236 sigma_ols += SQ(rx[i]) + SQ(ry[i]); … … 280 280 sigma_hat = 0.0; 281 281 for (i = 0; i < Npts; i++) { 282 rx[i] = X[i] - (T[i] * B[ 0][0] + B[1][0]);283 ry[i] = Y[i] - (T[i] * B[ 2][0] + B[3][0]);282 rx[i] = X[i] - (T[i] * B[1][0] + B[0][0]); 283 ry[i] = Y[i] - (T[i] * B[3][0] + B[2][0]); 284 284 u[i] = sqrt(SQ(rx[i] / dX[i]) + SQ(ry[i] / dY[i])); 285 285 } -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/init.c
r39194 r39223 20 20 int fitplx PROTO((int, char **)); 21 21 int fitpm PROTO((int, char **)); 22 int fitpm_irls PROTO((int, char **)); 23 int fitplx_irls PROTO((int, char **)); 22 24 int fixwrap PROTO((int, char **)); 23 25 int fiximage PROTO((int, char **)); … … 87 89 {1, "fitplx", fitplx, "fit proper motion and parallax"}, 88 90 {1, "fitpm", fitpm, "fit proper motion only"}, 91 {1, "fitpm_irls", fitpm_irls, "fit proper motion only using irls method"}, 92 {1, "fitplx_irls", fitplx_irls, "fit proper motion and parallax using irls method"}, 89 93 {1, "fixwrap", fixwrap, "fix megacam over-wrapped pixels"}, 90 94 {1, "fiximage", fiximage, "fix pixels in an image by interpolation"}, -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/read_vectors.c
r38989 r39223 41 41 time_t TimeReference; 42 42 int i, j, Nskip, Narg, IsCSV, VERBOSE; 43 int Nbytes, N start, NELEM, Nelem, nread;43 int Nbytes, NELEM, nread; 44 44 char *colstr, *c0, *c1, *extname; 45 45 char varname[1024]; // used as a buffer for the names of string fields … … 188 188 } 189 189 190 // we allocate one extra byte into which we never read so there will always be a NULL terminating the string 190 191 ALLOCATE (buffer, char, 0x10001); 191 192 bzero (buffer, 0x10001); 192 193 /*194 for (i = 0; i < Nskip; i++) {195 if (scan_line_maxlen (f, buffer, 0x10000) == EOF) {196 gprint (GP_ERR, "problem reading file %s\n", filename);197 read_vectors_cleanup();198 return FALSE;199 }200 }201 */202 193 203 194 int Nline_read = 0; // track number of lines read so far (use to skip lines as well) … … 209 200 // we treat \n\r pair as a single EOL char to handle mac files: 210 201 211 Nstart = 0; // location of the last valid byte in the buffer (start filling here) 212 Nelem = 0; // number of valid rows read (vector elements) 213 while (TRUE) { 202 int Nstart = 0; // location of the last valid byte in the buffer (start filling here) 203 int Nelem = 0; // number of valid rows read (vector elements) 204 int EndOfFile = FALSE; 205 while (!EndOfFile) { 214 206 Nbytes = 0x10000 - Nstart; 215 bzero (&buffer[Nstart], Nbytes); 207 // we have allocated one extra byte into which we never read so there will always be a NULL terminating the string 208 bzero (&buffer[Nstart], Nbytes + 1); 216 209 nread = fread (&buffer[Nstart], 1, Nbytes, f); 217 210 if (ferror (f)) { … … 219 212 break; 220 213 } 221 if (nread == 0) break; // end of the file 222 // nbytes = nread + Nstart; 214 // we still need to parse the rest of the buffer, but there might not be an EOL on the last line 215 if (nread == 0) { 216 EndOfFile = TRUE; 217 } 223 218 224 219 int bufferStatus = TRUE; … … 227 222 c1 = strchr (c0, '\n'); // find the end of this current line (also valid for a Mac: \r\n) 228 223 if (!c1) { 229 c1 = strchr (c0, '\r'); // try \r for non-UNIXfiles230 } 231 if ( c1 == (char *) NULL) {224 c1 = strchr (c0, '\r'); // try \r for Windows files 225 } 226 if (!c1) { 232 227 Nstart = strlen (c0); 233 memmove (buffer, c0, Nstart); 234 bufferStatus = FALSE; 235 continue; 228 if (EndOfFile) { 229 // if we have reached EOF, we need to do one last pass in case there is a line without a return 230 c1 = c0 + Nstart; 231 bufferStatus = FALSE; 232 } else { 233 // if we have not reached EOF, we need to shift the buffer to the start of this line and read more data 234 memmove (buffer, c0, Nstart); 235 bufferStatus = FALSE; 236 continue; 237 } 236 238 } 237 239 *c1 = 0; // mark the end of the line 238 240 Nline_read ++; 239 241 240 if (Nline_read <= Nskip) { c0 = c1 + 1; continue; }241 242 if (*c0 == '#') { c0 = c1 + 1;continue; }243 if (*c0 == '!') { c0 = c1 + 1;continue; }242 // skip to the next line (but if EOF, do not overrun buffer) 243 if (Nline_read <= Nskip) { if (!EndOfFile) { c0 = c1 + 1; } continue; } 244 if (*c0 == '#') { if (!EndOfFile) { c0 = c1 + 1; } continue; } 245 if (*c0 == '!') { if (!EndOfFile) { c0 = c1 + 1; } continue; } 244 246 245 247 // parse the vectors in this line. this code is a bit inefficient: each column … … 319 321 } 320 322 } 321 c0 = c1 + 1; 323 if (!EndOfFile) { 324 c0 = c1 + 1; 325 } 322 326 } 323 327 }
Note:
See TracChangeset
for help on using the changeset viewer.
