Changeset 39266 for branches/eam_branches/ipp-20151113/Ohana
- Timestamp:
- Dec 13, 2015, 5:50:46 AM (11 years ago)
- Location:
- branches/eam_branches/ipp-20151113
- Files:
-
- 89 edited
- 9 copied
-
. (modified) (1 prop)
-
Ohana/src/addstar/src/loadgalphot_readstars.c (modified) (1 diff)
-
Ohana/src/addstar/src/mkcmf.c (modified) (13 diffs)
-
Ohana/src/dvomerge/src/merge_catalogs_old.c (modified) (8 diffs)
-
Ohana/src/dvopsps/src/insert_FGshape_dvopsps_catalog.c (modified) (1 diff)
-
Ohana/src/dvopsps/src/insert_FWobjects_dvopsps_catalog.c (modified) (13 diffs)
-
Ohana/src/dvopsps/src/insert_diffobj_dvopsps_catalog.c (modified) (3 diffs)
-
Ohana/src/dvopsps/src/insert_objects_dvopsps_catalog.c (modified) (3 diffs)
-
Ohana/src/fakeastro/Makefile (modified) (1 diff)
-
Ohana/src/fakeastro/src/fakeastro.c (modified) (1 diff)
-
Ohana/src/fakeastro/src/make_2mass_measures.c (modified) (1 diff)
-
Ohana/src/fakeastro/src/make_fake_stars_catalog.c (modified) (1 diff)
-
Ohana/src/fakeastro/src/make_fakeqsos.c (modified) (1 diff)
-
Ohana/src/fakeastro/src/make_fakestars.c (modified) (2 diffs)
-
Ohana/src/libautocode/def/measure-ps1-sim.d (modified) (2 diffs)
-
Ohana/src/libautocode/def/measure-ps1-v5.d (modified) (1 diff)
-
Ohana/src/libautocode/def/measure.d (modified) (1 diff)
-
Ohana/src/libdvo/include/dvo.h (modified) (2 diffs)
-
Ohana/src/libdvo/include/libdvo_astro.h (modified) (1 diff)
-
Ohana/src/libdvo/src/coord_systems.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dbExtractMeasures.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/dvo_catalog.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_convert_PS1_SIM.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_V5.c (modified) (3 diffs)
-
Ohana/src/libdvo/src/dvo_tiny_values.c (modified) (1 diff)
-
Ohana/src/libohana/Makefile (modified) (1 diff)
-
Ohana/src/libohana/include/ohana.h (modified) (1 diff)
-
Ohana/src/libohana/src/gaussdev.c (copied) (copied from trunk/Ohana/src/libohana/src/gaussdev.c )
-
Ohana/src/misc/src/fakedist.c (modified) (5 diffs)
-
Ohana/src/misc/src/fakepop.c (modified) (5 diffs)
-
Ohana/src/misc/src/fakestars.c (modified) (3 diffs)
-
Ohana/src/misc/src/fitdist.c (modified) (4 diffs)
-
Ohana/src/misc/src/magtoage.c (modified) (4 diffs)
-
Ohana/src/misc/src/magtomass.c (modified) (4 diffs)
-
Ohana/src/misc/src/mkgauss.c (modified) (3 diffs)
-
Ohana/src/opihi/cmd.astro/Makefile (modified) (2 diffs)
-
Ohana/src/opihi/cmd.astro/astrom_ops.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/astrom_ops.c )
-
Ohana/src/opihi/cmd.astro/cdensify.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.astro/cdhistogram.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.astro/crotation.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/crotation.c )
-
Ohana/src/opihi/cmd.astro/fitplx.c (modified) (7 diffs)
-
Ohana/src/opihi/cmd.astro/fitpm.c (modified) (4 diffs)
-
Ohana/src/opihi/cmd.astro/fitpm_irls.c (modified) (9 diffs)
-
Ohana/src/opihi/cmd.astro/fiximage.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.astro/getcoords.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.astro/imfit.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.astro/init.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.astro/shimage.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.astro/vshimage.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/densify.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/fft2d.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/gaussdeviate.c (modified) (4 diffs)
-
Ohana/src/opihi/cmd.data/gridify.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.data/mcreate.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/medimage_commands.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/mslice.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/read_vectors.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/reindex.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/shift.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/squash3d.c (modified) (3 diffs)
-
Ohana/src/opihi/cmd.data/tdhistogram.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/vgrid.c (modified) (1 diff)
-
Ohana/src/opihi/dimm/camera_cmds.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/coordimage.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/coordmosaic.c (modified) (2 diffs)
-
Ohana/src/opihi/dvo/fitcolors.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/imphot.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/objectcoverage.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/skycoverage.c (modified) (1 diff)
-
Ohana/src/opihi/include/astro.h (modified) (1 diff)
-
Ohana/src/opihi/include/shell.h (modified) (1 diff)
-
Ohana/src/opihi/lib.data/Makefile (modified) (2 diffs)
-
Ohana/src/opihi/lib.data/spline.c (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/BufferOps.c (modified) (2 diffs)
-
Ohana/src/opihi/lib.shell/ListOps.c (modified) (1 diff)
-
Ohana/src/opihi/mana/simsignal.c (modified) (3 diffs)
-
Ohana/src/relastro/Makefile (modified) (5 diffs)
-
Ohana/src/relastro/include/relastro.h (modified) (6 diffs)
-
Ohana/src/relastro/src/BootstrapOps.c (copied) (copied from trunk/Ohana/src/relastro/src/BootstrapOps.c )
-
Ohana/src/relastro/src/BrightCatalog.c (modified) (9 diffs)
-
Ohana/src/relastro/src/FitAstromOps.c (modified) (8 diffs)
-
Ohana/src/relastro/src/FitPM_IRLS.c (copied) (copied from trunk/Ohana/src/relastro/src/FitPM_IRLS.c )
-
Ohana/src/relastro/src/FitPMandPar.c (modified) (2 diffs)
-
Ohana/src/relastro/src/FitPMandPar_IRLS.c (copied) (copied from trunk/Ohana/src/relastro/src/FitPMandPar_IRLS.c )
-
Ohana/src/relastro/src/ImageOps.c (modified) (1 diff)
-
Ohana/src/relastro/src/UpdateObjects.c (modified) (6 diffs)
-
Ohana/src/relastro/src/fitpm.c (copied) (copied from trunk/Ohana/src/relastro/src/fitpm.c )
-
Ohana/src/relphot/src/BrightCatalog.c (modified) (8 diffs)
-
Ohana/src/relphot/src/setMrelCatalog.c (modified) (4 diffs)
-
Ohana/src/uniphot/Makefile (modified) (2 diffs)
-
Ohana/src/uniphot/include/setphot.h (modified) (1 diff)
-
Ohana/src/uniphot/src/cam_correction.c (modified) (3 diffs)
-
Ohana/src/uniphot/src/cam_zpt_correction.c (copied) (copied from trunk/Ohana/src/uniphot/src/cam_zpt_correction.c )
-
Ohana/src/uniphot/src/initialize_setphot.c (modified) (1 diff)
-
Ohana/src/uniphot/src/initialize_setphot_client.c (modified) (1 diff)
-
Ohana/src/uniphot/src/match_camcorr_to_images.c (copied) (copied from trunk/Ohana/src/uniphot/src/match_camcorr_to_images.c )
-
Ohana/src/uniphot/src/setphot.c (modified) (3 diffs)
-
Ohana/src/uniphot/src/update_catalog_setphot.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20151113
-
branches/eam_branches/ipp-20151113/Ohana/src/addstar/src/loadgalphot_readstars.c
r39125 r39266 204 204 fit->ClipNsigma = 5.0; 205 205 206 // use the list of index values from above to join entries with the same index 207 206 208 int Nbad = 0; 207 209 for (i = 0; i < Nrow; i++) { -
branches/eam_branches/ipp-20151113/Ohana/src/addstar/src/mkcmf.c
r39121 r39266 13 13 # define FLAGS 0x1101 14 14 15 void gauss_init (int Nbin);16 double rnd_gauss (double mean, double sigma);17 15 void writeStars_PS1_V5_Lensing (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); 18 16 void writeStars_PS1_V5 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars); … … 282 280 } 283 281 284 gauss_init (2048);282 ohana_gaussdev_init (); 285 283 286 284 // load test stars from a file: … … 564 562 565 563 566 static int Ngaussint = 0;567 static double *gaussint;568 569 extern double drand48();570 571 double gaussian (double x, double mean, double sigma) {572 573 double f;574 575 f = exp (-0.5 * SQ(x - mean) / SQ(sigma)) / sqrt(2 * M_PI * SQ(sigma));576 577 return (f);578 579 }580 581 /* integrate a gaussian from -5 sigma to +5 sigma */582 void gauss_init (int Nbin) {583 584 int i;585 double val, x, dx, dx1, dx2, dx3, df;586 double mean, sigma;587 588 /* no need to generate this if it already exists */589 if (Ngaussint == Nbin) return;590 591 // A = time(NULL);592 // // XXX this is expensive if called a lot (1 sec min)593 // // for (B = 0; A == time(NULL); B++);594 // B = A + 10000;595 // srand48(B);596 597 Ngaussint = Nbin;598 ALLOCATE (gaussint, double, Ngaussint + 1);599 600 val = 0;601 dx = 1.0 / Ngaussint;602 dx1 = dx / 3.0;603 dx2 = 2.0*dx/3.0;604 dx3 = dx;605 mean = 0.0;606 sigma = 1.0;607 608 for (i = 0, x = -7.0; (i < Ngaussint) && (x < 7.0); x += dx) {609 df = (3.0*gaussian(x , mean, sigma) +610 9.0*gaussian(x+dx1, mean, sigma) +611 9.0*gaussian(x+dx2, mean, sigma) +612 3.0*gaussian(x+dx3, mean, sigma)) * (dx1/8.0);613 val += df;614 if (val > (i + 0.5) / (double) Ngaussint) {615 gaussint[i] = x + dx / 2.0;616 i++;617 }618 }619 }620 621 double rnd_gauss (double mean, double sigma) {622 623 int i;624 double y;625 626 y = drand48();627 i = Ngaussint*y;628 y = gaussint[i]*sigma + mean;629 630 return (y);631 632 }633 634 double int_gauss (int i) {635 double y;636 y = gaussint[i];637 return (y);638 }639 640 564 void writeStars_PS1_DEV_0 (FTable *ftable, double *X, double *Y, double *M, int Nstars) { 641 565 … … 654 578 655 579 if (ADDNOISE) { 656 X[i] += FX * fSN * rnd_gauss(0.0, 1.0);657 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0);658 M[i] += fSN* rnd_gauss(0.0, 1.0);580 X[i] += FX * fSN * ohana_gaussdev_rnd(0.0, 1.0); 581 Y[i] += FY * fSN * ohana_gaussdev_rnd(0.0, 1.0); 582 M[i] += fSN*ohana_gaussdev_rnd(0.0, 1.0); 659 583 flux = pow (10.0, -0.4*M[i]); 660 584 fSN = 1.0 / sqrt(flux); … … 700 624 701 625 if (ADDNOISE) { 702 X[i] += FX * fSN * rnd_gauss(0.0, 1.0);703 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0);704 M[i] += fSN* rnd_gauss(0.0, 1.0);626 X[i] += FX * fSN * ohana_gaussdev_rnd(0.0, 1.0); 627 Y[i] += FY * fSN * ohana_gaussdev_rnd(0.0, 1.0); 628 M[i] += fSN*ohana_gaussdev_rnd(0.0, 1.0); 705 629 flux = pow (10.0, -0.4*M[i]); 706 630 fSN = 1.0 / sqrt(flux); … … 749 673 750 674 if (ADDNOISE) { 751 X[i] += FX * fSN * rnd_gauss(0.0, 1.0);752 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0);753 M[i] += fSN* rnd_gauss(0.0, 1.0);675 X[i] += FX * fSN * ohana_gaussdev_rnd(0.0, 1.0); 676 Y[i] += FY * fSN * ohana_gaussdev_rnd(0.0, 1.0); 677 M[i] += fSN*ohana_gaussdev_rnd(0.0, 1.0); 754 678 flux = pow (10.0, -0.4*M[i]); 755 679 fSN = 1.0 / sqrt(flux); … … 800 724 801 725 if (ADDNOISE) { 802 X[i] += FX * fSN * rnd_gauss(0.0, 1.0);803 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0);804 M[i] += fSN* rnd_gauss(0.0, 1.0);726 X[i] += FX * fSN * ohana_gaussdev_rnd(0.0, 1.0); 727 Y[i] += FY * fSN * ohana_gaussdev_rnd(0.0, 1.0); 728 M[i] += fSN*ohana_gaussdev_rnd(0.0, 1.0); 805 729 flux = pow (10.0, -0.4*M[i]); 806 730 fSN = 1.0 / sqrt(flux); … … 857 781 858 782 if (ADDNOISE) { 859 X[i] += FX * fSN * rnd_gauss(0.0, 1.0);860 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0);861 M[i] += fSN* rnd_gauss(0.0, 1.0);783 X[i] += FX * fSN * ohana_gaussdev_rnd(0.0, 1.0); 784 Y[i] += FY * fSN * ohana_gaussdev_rnd(0.0, 1.0); 785 M[i] += fSN*ohana_gaussdev_rnd(0.0, 1.0); 862 786 flux = pow (10.0, -0.4*M[i]); 863 787 fSN = 1.0 / sqrt(flux); … … 918 842 919 843 if (ADDNOISE) { 920 X[i] += FX * fSN * rnd_gauss(0.0, 1.0);921 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0);922 M[i] += fSN* rnd_gauss(0.0, 1.0);844 X[i] += FX * fSN * ohana_gaussdev_rnd(0.0, 1.0); 845 Y[i] += FY * fSN * ohana_gaussdev_rnd(0.0, 1.0); 846 M[i] += fSN*ohana_gaussdev_rnd(0.0, 1.0); 923 847 flux = pow (10.0, -0.4*M[i]); 924 848 fSN = 1.0 / sqrt(flux); … … 987 911 988 912 if (ADDNOISE) { 989 X[i] += FX * fSN * rnd_gauss(0.0, 1.0);990 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0);991 M[i] += fSN* rnd_gauss(0.0, 1.0);913 X[i] += FX * fSN * ohana_gaussdev_rnd(0.0, 1.0); 914 Y[i] += FY * fSN * ohana_gaussdev_rnd(0.0, 1.0); 915 M[i] += fSN*ohana_gaussdev_rnd(0.0, 1.0); 992 916 flux = pow (10.0, -0.4*M[i]); 993 917 fSN = 1.0 / sqrt(flux); … … 1094 1018 1095 1019 if (ADDNOISE) { 1096 X[i] += FX * fSN * rnd_gauss(0.0, 1.0);1097 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0);1098 M[i] += fSN* rnd_gauss(0.0, 1.0);1020 X[i] += FX * fSN * ohana_gaussdev_rnd(0.0, 1.0); 1021 Y[i] += FY * fSN * ohana_gaussdev_rnd(0.0, 1.0); 1022 M[i] += fSN*ohana_gaussdev_rnd(0.0, 1.0); 1099 1023 flux = pow (10.0, -0.4*M[i]); 1100 1024 fSN = 1.0 / sqrt(flux); … … 1198 1122 1199 1123 if (ADDNOISE) { 1200 X[i] += FX * fSN * rnd_gauss(0.0, 1.0);1201 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0);1202 M[i] += fSN * rnd_gauss(0.0, 1.0);1124 X[i] += FX * fSN * ohana_gaussdev_rnd(0.0, 1.0); 1125 Y[i] += FY * fSN * ohana_gaussdev_rnd(0.0, 1.0); 1126 M[i] += fSN * ohana_gaussdev_rnd(0.0, 1.0); 1203 1127 flux = pow(10.0, -0.4 * M[i]); 1204 1128 fSN = 1.0 / sqrt(flux); … … 1324 1248 1325 1249 if (ADDNOISE) { 1326 X[i] += FX * fSN * rnd_gauss(0.0, 1.0);1327 Y[i] += FY * fSN * rnd_gauss(0.0, 1.0);1328 M[i] += fSN* rnd_gauss(0.0, 1.0);1250 X[i] += FX * fSN * ohana_gaussdev_rnd(0.0, 1.0); 1251 Y[i] += FY * fSN * ohana_gaussdev_rnd(0.0, 1.0); 1252 M[i] += fSN*ohana_gaussdev_rnd(0.0, 1.0); 1329 1253 flux = pow (10.0, -0.4*M[i]); 1330 1254 fSN = 1.0 / sqrt(flux); -
branches/eam_branches/ipp-20151113/Ohana/src/dvomerge/src/merge_catalogs_old.c
r39220 r39266 85 85 N1[Nstars] = i; 86 86 Nstars ++; 87 input[0].found_t[i] = -1;87 input[0].found_t[i] = FALSE; 88 88 } 89 89 if (Nstars < 1) { … … 180 180 off_t N = N1[i]; 181 181 182 input[0].found_t[N] = TRUE; 183 182 184 /* make sure there is space for next Nmeasure entries */ 183 185 if (Nmeas + input[0].average[N].Nmeasure >= NMEAS) { … … 209 211 Nreplace = replace_tycho (&output[0].average[n], output[0].measure, next_meas, &input[0].average[N], &input[0].measure[Minp]); 210 212 if (Nreplace == 6) { 211 input[0].found_t[N] = Nmeas;212 213 output[0].found_t[n] = Nmeas; 213 214 i++; … … 224 225 // XXX this does not support lensing, starpar, or galphot measurements 225 226 if (replace_match (&output[0].average[n], output[0].measure, next_meas, &input[0].average[N], &input[0].measure[offset])) { 226 input[0].found_t[N] = output[0].average[n].measureOffset;227 227 continue; 228 228 } … … 274 274 } 275 275 } 276 input[0].found_t[N] = Nmeas;277 276 output[0].average[n].Nmeasure ++; 278 277 Nmeas ++; … … 394 393 } 395 394 396 if (input[0].found_t[N] >= 0) continue;395 if (input[0].found_t[N]) continue; 397 396 398 397 // if we are using MATCHED_TABLES, we are going to leave the edge cases in their 399 398 // source catalog, even if they have leaked beyond the edge 400 399 if (!MATCHED_TABLES && !IN_REGION (input[0].average[N].R, input[0].average[N].D)) continue; 400 401 input[0].found_t[N] = TRUE; 401 402 402 403 // XXX should we accept the input measurements for these fields? … … 450 451 451 452 /* we set next[Nmeas] to -1 here, and update correctly below */ 452 input[0].found_t[N] = Nmeas;453 453 next_meas[Nmeas] = -1; 454 454 Nmeas ++; … … 559 559 } 560 560 561 /* note stars which have been found in this catalog */562 for (i = 0; i < input[0].Naverage; i++) {563 if (input[0].found_t[i] > -1) {564 input[0].found_t[i] = -2;565 } else {566 input[0].found_t[i] = -3;567 }568 }569 570 561 /* check if the catalog has changed? if no change, no need to write */ 571 562 output[0].objID = objID; // new max value, save on catalog close -
branches/eam_branches/ipp-20151113/Ohana/src/dvopsps/src/insert_FGshape_dvopsps_catalog.c
r39126 r39266 229 229 230 230 float sersic_index = galphot->index; 231 if (galphot->modelType == 6) sersic_index = 1.0; 232 if (galphot->modelType == 7) sersic_index = 4.0; 231 if (galphot->modelType == 6) { 232 sersic_index = 1.0; 233 } 234 else if (galphot->modelType == 7) { 235 sersic_index = 4.0; 236 } 237 else { 238 sersic_index = 1.0 / (2.0 * sersic_index); 239 } 233 240 234 241 PRINT_FLOAT(gal_buffer, galphot->mag, "%.6e, "); -
branches/eam_branches/ipp-20151113/Ohana/src/dvopsps/src/insert_FWobjects_dvopsps_catalog.c
r39092 r39266 148 148 "FLUX_PSF_WRP_ERR FLOAT, " 149 149 "FLUX_PSF_WRP_STDEV FLOAT, " 150 150 "MAG_PSF_WRP FLOAT, " 151 "MAG_PSF_WRP_ERR FLOAT, " 152 151 153 "FLUX_KRON_WRP FLOAT, " 152 154 "FLUX_KRON_WRP_ERR FLOAT, " 153 155 "FLUX_KRON_WRP_STDEV FLOAT, " 154 156 "MAG_KRON_WRP FLOAT, " 157 "MAG_KRON_WRP_ERR FLOAT, " 158 155 159 "FLUX_AP_WRP FLOAT, " 156 160 "FLUX_AP_WRP_ERR FLOAT, " 157 "FLUX_AP_WRP_STDEV FLOAT, " 161 "FLUX_AP_WRP_STDEV FLOAT, " 162 "MAG_AP_WRP FLOAT, " 163 "MAG_AP_WRP_ERR FLOAT, " 158 164 159 165 "FLAGS INT " … … 188 194 "FLUX_STD_AP_R5 FLOAT, " 189 195 "FLUX_FIL_AP_R5 FLOAT, " 196 "MAG_AP_R5 FLOAT, " 197 "MAG_ERR_AP_R5 FLOAT, " 190 198 191 199 "FLUX_AP_R6 FLOAT, " … … 193 201 "FLUX_STD_AP_R6 FLOAT, " 194 202 "FLUX_FIL_AP_R6 FLOAT, " 203 "MAG_AP_R6 FLOAT, " 204 "MAG_ERR_AP_R6 FLOAT, " 195 205 196 206 "FLUX_AP_R7 FLOAT, " … … 198 208 "FLUX_STD_AP_R7 FLOAT, " 199 209 "FLUX_FIL_AP_R7 FLOAT, " 210 "MAG_AP_R7 FLOAT, " 211 "MAG_ERR_AP_R7 FLOAT, " 200 212 201 213 "X11_SM_OBJ FLOAT, " … … 262 274 "FLUX_PSF_WRP, " 263 275 "FLUX_PSF_WRP_ERR, " 264 "FLUX_PSF_WRP_STDEV, " 276 "FLUX_PSF_WRP_STDEV, " 277 "MAG_PSF_WRP, " 278 "MAG_PSF_WRP_ERR, " 265 279 266 280 "FLUX_KRON_WRP, " 267 281 "FLUX_KRON_WRP_ERR, " 268 "FLUX_KRON_WRP_STDEV, " 282 "FLUX_KRON_WRP_STDEV, " 283 "MAG_KRON_WRP, " 284 "MAG_KRON_WRP_ERR, " 269 285 270 286 "FLUX_AP_WRP, " 271 287 "FLUX_AP_WRP_ERR, " 272 "FLUX_AP_WRP_STDEV, " 288 "FLUX_AP_WRP_STDEV, " 289 "MAG_AP_WRP, " 290 "MAG_AP_WRP_ERR, " 273 291 274 292 "FLAGS" … … 287 305 "FLUX_STD_AP_R5, " 288 306 "FLUX_FIL_AP_R5, " 307 "MAG_AP_R5, " 308 "MAG_ERR_AP_R5, " 289 309 290 310 "FLUX_AP_R6, " … … 292 312 "FLUX_STD_AP_R6, " 293 313 "FLUX_FIL_AP_R6, " 314 "MAG_AP_R6, " 315 "MAG_ERR_AP_R6, " 294 316 295 317 "FLUX_AP_R7, " … … 297 319 "FLUX_STD_AP_R7, " 298 320 "FLUX_FIL_AP_R7, " 321 "MAG_AP_R7, " 322 "MAG_ERR_AP_R7, " 299 323 300 324 "X11_SM_OBJ, " … … 348 372 float meanPSFFluxErr = NAN; 349 373 float meanPSFFluxStd = NAN; 374 float meanPSFMag = NAN; 375 float meanPSFMagErr = NAN; 350 376 if (isfinite(secfilt->dFpsfWrp) && isfinite(secfilt->FpsfWrp)) { 351 377 meanPSFFlux = secfilt-> FpsfWrp; 352 378 meanPSFFluxErr = secfilt->dFpsfWrp; 353 379 meanPSFFluxStd = secfilt->sFpsfWrp; 380 if (meanPSFFlux > 0.0) { 381 meanPSFMag = -2.5 * log10(meanPSFFlux / 3631.0); 382 meanPSFMagErr = (2.5 * meanPSFFluxErr) / (meanPSFFlux * log(10)); 383 } 354 384 } 355 385 … … 357 387 float meanKronFluxErr = NAN; 358 388 float meanKronFluxStd = NAN; 389 float meanKronMag = NAN; 390 float meanKronMagErr = NAN; 359 391 if (isfinite(secfilt->dFkronWrp) && isfinite(secfilt->FkronWrp)) { 360 392 meanKronFlux = secfilt-> FkronWrp; 361 393 meanKronFluxErr = secfilt->dFkronWrp; 362 394 meanKronFluxStd = secfilt->sFkronWrp; 395 if (meanKronFlux > 0.0) { 396 meanKronMag = -2.5 * log10(meanKronFlux / 3631.0); 397 meanKronMagErr = (2.5 * meanKronFluxErr) / (meanKronFlux * log(10)); 398 } 363 399 } 364 400 … … 366 402 float meanApFluxErr = NAN; 367 403 float meanApFluxStd = NAN; 404 float meanApMag = NAN; 405 float meanApMagErr = NAN; 368 406 if (isfinite(secfilt->dFapWrp) && isfinite(secfilt->FapWrp)) { 369 407 meanApFlux = secfilt-> FapWrp; 370 408 meanApFluxErr = secfilt->dFapWrp; 371 409 meanApFluxStd = secfilt->sFapWrp; 410 if (meanApFlux > 0.0) { 411 meanApMag = -2.5 * log10(meanApFlux / 3631.0); 412 meanApMagErr = (2.5 * meanApFluxErr) / (meanApFlux * log(10)); 413 } 372 414 } 373 415 … … 382 424 PRINT_FLOAT(sec_buffer, meanPSFFluxErr, "%.6e, "); // uflux precision 383 425 PRINT_FLOAT(sec_buffer, meanPSFFluxStd, "%.6e, "); // uflux precision 384 426 PRINT_FLOAT(sec_buffer, meanPSFMag, "%.6f, "); 427 PRINT_FLOAT(sec_buffer, meanPSFMagErr, "%.6f, "); 428 385 429 PRINT_FLOAT(sec_buffer, meanKronFlux, "%.6e, "); // uflux precision 386 430 PRINT_FLOAT(sec_buffer, meanKronFluxErr, "%.6e, "); // uflux precision 387 431 PRINT_FLOAT(sec_buffer, meanKronFluxStd, "%.6e, "); // uflux precision 432 PRINT_FLOAT(sec_buffer, meanKronMag, "%.6f, "); 433 PRINT_FLOAT(sec_buffer, meanKronMagErr, "%.6f, "); 388 434 389 435 PRINT_FLOAT(sec_buffer, meanApFlux, "%.6e, "); // uflux precision 390 436 PRINT_FLOAT(sec_buffer, meanApFluxErr, "%.6e, "); // uflux precision 391 437 PRINT_FLOAT(sec_buffer, meanApFluxStd, "%.6e, "); // uflux precision 438 PRINT_FLOAT(sec_buffer, meanApMag, "%.6f, "); 439 PRINT_FLOAT(sec_buffer, meanApMagErr, "%.6f, "); 392 440 393 441 PrintIOBuffer (sec_buffer, "%u ", secfilt->flags); … … 402 450 PrintIOBuffer (cpy_buffer, "%hd, ", lensobj->photcode); 403 451 452 float magApR5 = NAN; 453 float magErrApR5 = NAN; 454 float magApR6 = NAN; 455 float magErrApR6 = NAN; 456 float magApR7 = NAN; 457 float magErrApR7 = NAN; 458 459 if (lensobj->F_ApR5 > 0.0) { 460 magApR5 = -2.5 * log10(lensobj->F_ApR5 / 3631.0); 461 magErrApR5 = (2.5 * lensobj->dF_ApR5) / (lensobj->F_ApR5 * log(10)); 462 } 463 if (lensobj->F_ApR6 > 0.0) { 464 magApR6 = -2.5 * log10(lensobj->F_ApR6 / 3631.0); 465 magErrApR6 = (2.5 * lensobj->dF_ApR6) / (lensobj->F_ApR6 * log(10)); 466 } 467 if (lensobj->F_ApR7 > 0.0) { 468 magApR7 = -2.5 * log10(lensobj->F_ApR7 / 3631.0); 469 magErrApR7 = (2.5 * lensobj->dF_ApR7) / (lensobj->F_ApR7 * log(10)); 470 } 471 404 472 PRINT_FLOAT(cpy_buffer, lensobj-> F_ApR5, "%.6e, "); 405 473 PRINT_FLOAT(cpy_buffer, lensobj->dF_ApR5, "%.6e, "); 406 474 PRINT_FLOAT(cpy_buffer, lensobj->sF_ApR5, "%.6e, "); 407 475 PRINT_FLOAT(cpy_buffer, lensobj->fF_ApR5, "%.6e, "); 476 PRINT_FLOAT(cpy_buffer, magApR5, "%.6f, "); 477 PRINT_FLOAT(cpy_buffer, magErrApR5, "%.6f, "); 408 478 PRINT_FLOAT(cpy_buffer, lensobj-> F_ApR6, "%.6e, "); 409 479 PRINT_FLOAT(cpy_buffer, lensobj->dF_ApR6, "%.6e, "); 410 480 PRINT_FLOAT(cpy_buffer, lensobj->sF_ApR6, "%.6e, "); 411 481 PRINT_FLOAT(cpy_buffer, lensobj->fF_ApR6, "%.6e, "); 482 PRINT_FLOAT(cpy_buffer, magApR6, "%.6f, "); 483 PRINT_FLOAT(cpy_buffer, magErrApR6, "%.6f, "); 412 484 PRINT_FLOAT(cpy_buffer, lensobj-> F_ApR7, "%.6e, "); 413 485 PRINT_FLOAT(cpy_buffer, lensobj->dF_ApR7, "%.6e, "); 414 486 PRINT_FLOAT(cpy_buffer, lensobj->sF_ApR7, "%.6e, "); 415 487 PRINT_FLOAT(cpy_buffer, lensobj->fF_ApR7, "%.6e, "); 488 PRINT_FLOAT(cpy_buffer, magApR7, "%.6f, "); 489 PRINT_FLOAT(cpy_buffer, magErrApR7, "%.6f, "); 416 490 PRINT_FLOAT(cpy_buffer, lensobj->X11_sm_obj, "%.6e, "); 417 491 PRINT_FLOAT(cpy_buffer, lensobj->X12_sm_obj, "%.6e, "); -
branches/eam_branches/ipp-20151113/Ohana/src/dvopsps/src/insert_diffobj_dvopsps_catalog.c
r39092 r39266 94 94 "CAT_ID INT, " 95 95 "RA_MEAN DOUBLE, " 96 "DEC_MEAN DOUBLE, " 96 "DEC_MEAN DOUBLE, " 97 97 "RA_ERR FLOAT, " 98 "DEC_ERR FLOAT, " 98 "DEC_ERR FLOAT, " 99 "IAU_NAME VARCHAR(32), " 100 "PSO_NAME VARCHAR(32), " 99 101 "FLAGS INT " 100 102 ")\n", basename); … … 167 169 "DEC_MEAN, " 168 170 "RA_ERR, " 169 "DEC_ERR, " 171 "DEC_ERR, " 172 "IAU_NAME, " 173 "PSO_NAME, " 170 174 "FLAGS " 171 175 ") VALUES \n", basename); … … 218 222 PRINT_FLOAT(ave_buffer, average->dD, "%.5f, "); // 0.010 mas precision 219 223 224 // Add names. 225 int ra_hr,ra_min,ra_sec,ra_fracsec; 226 int dec_deg,dec_min,dec_sec,dec_fracsec; 227 double tmp_ra = average->R; 228 double tmp_dec = average->D; 229 double dec_sign = tmp_dec / fabs(tmp_dec); 230 tmp_dec = fabs(tmp_dec); 231 232 tmp_ra /= 15.0; 233 ra_hr = (int) floor(tmp_ra); 234 235 tmp_ra -= ra_hr; 236 tmp_ra *= 60.0; 237 ra_min = (int) floor(tmp_ra); 238 239 tmp_ra -= ra_min; 240 tmp_ra *= 60.0; 241 ra_sec = (int) floor(tmp_ra); 242 243 tmp_ra -= ra_sec; 244 tmp_ra *= 1000.0; 245 ra_fracsec = (int) floor(tmp_ra); 246 247 dec_deg = (int) floor(tmp_dec); 248 249 tmp_dec -= dec_deg; 250 tmp_dec *= 60.0; 251 dec_min = (int) floor(tmp_dec); 252 253 tmp_dec -= dec_min; 254 tmp_dec *= 60.0; 255 dec_sec = (int) floor(tmp_dec); 256 257 tmp_dec -= dec_sec; 258 tmp_dec *= 1000.0; 259 dec_fracsec = (int) floor(tmp_dec); 260 261 dec_deg *= (int) dec_sign; 262 263 // IAU NAME 264 PrintIOBuffer(ave_buffer, "'PSO J%02d%02d%02d.%03d%+02d%02d%02d.%03d', ", 265 ra_hr,ra_min,ra_sec,ra_fracsec, 266 dec_deg,dec_min,dec_sec,dec_fracsec); 267 268 // PSO NAME 269 tmp_ra = average->R; 270 tmp_dec = average->D; 271 PrintIOBuffer(ave_buffer, "'PSO J%.5f%+.5f', ", 272 tmp_ra,tmp_dec); 273 274 // End names 275 220 276 PrintIOBuffer (ave_buffer, "%u ", average->flags); 221 277 PrintIOBuffer (ave_buffer, "),\n"); -
branches/eam_branches/ipp-20151113/Ohana/src/dvopsps/src/insert_objects_dvopsps_catalog.c
r39098 r39266 101 101 "EPOCH_MEAN DOUBLE, " 102 102 "RA_ERR FLOAT, " 103 "DEC_ERR FLOAT, " 103 "DEC_ERR FLOAT, " 104 "IAU_NAME VARCHAR(32), " 105 "PSO_NAME VARCHAR(32), " 104 106 "CHISQ_POS FLOAT, " 105 107 "CHISQ_PM FLOAT, " … … 208 210 "EPOCH_MEAN, " 209 211 "RA_ERR, " 210 "DEC_ERR, " 212 "DEC_ERR, " 213 "IAU_NAME, " 214 "PSO_NAME, " 211 215 "CHISQ_POS, " 212 216 "CHISQ_PM, " … … 276 280 PRINT_FLOAT(ave_buffer, average->dD, "%.5f, "); // 0.010 mas precision 277 281 282 // Add names. 283 int ra_hr,ra_min,ra_sec,ra_fracsec; 284 int dec_deg,dec_min,dec_sec,dec_fracsec; 285 double tmp_ra,tmp_dec; 286 287 if (secfilt->NstackDet != 0) { 288 tmp_ra = average->Rstk; 289 tmp_dec = average->Dstk; 290 } 291 else { 292 tmp_ra = average->R; 293 tmp_dec = average->D; 294 } 295 296 double dec_sign = tmp_dec / fabs(tmp_dec); 297 tmp_dec = fabs(tmp_dec); 298 299 300 tmp_ra /= 15.0; 301 ra_hr = (int) floor(tmp_ra); 302 303 tmp_ra -= ra_hr; 304 tmp_ra *= 60.0; 305 ra_min = (int) floor(tmp_ra); 306 307 tmp_ra -= ra_min; 308 tmp_ra *= 60.0; 309 ra_sec = (int) floor(tmp_ra); 310 311 tmp_ra -= ra_sec; 312 tmp_ra *= 1000.0; 313 ra_fracsec = (int) floor(tmp_ra); 314 315 dec_deg = (int) floor(tmp_dec); 316 317 tmp_dec -= dec_deg; 318 tmp_dec *= 60.0; 319 dec_min = (int) floor(tmp_dec); 320 321 tmp_dec -= dec_min; 322 tmp_dec *= 60.0; 323 dec_sec = (int) floor(tmp_dec); 324 325 tmp_dec -= dec_sec; 326 tmp_dec *= 1000.0; 327 dec_fracsec = (int) floor(tmp_dec); 328 329 dec_deg *= (int) dec_sign; 330 331 // IAU NAME 332 PrintIOBuffer(ave_buffer, "'PSO J%02d%02d%02d.%03d%+02d%02d%02d.%03d', ", 333 ra_hr,ra_min,ra_sec,ra_fracsec, 334 dec_deg,dec_min,dec_sec,dec_fracsec); 335 336 // PSO NAME 337 if (secfilt->NstackDet != 0) { 338 tmp_ra = average->Rstk; 339 tmp_dec = average->Dstk; 340 } 341 else { 342 tmp_ra = average->R; 343 tmp_dec = average->D; 344 } 345 346 PrintIOBuffer(ave_buffer, "'PSO J%.5f%+.5f', ", 347 tmp_ra,tmp_dec); 348 349 // End names 350 278 351 PRINT_FLOAT(ave_buffer, average->ChiSqAve, "%.4f, "); 279 352 PRINT_FLOAT(ave_buffer, average->ChiSqPM, "%.4f, "); -
branches/eam_branches/ipp-20151113/Ohana/src/fakeastro/Makefile
r37846 r39266 38 38 $(SRC)/fakestar_io.$(ARCH).o \ 39 39 $(SRC)/insert_fakestar.$(ARCH).o \ 40 $(SRC)/gaussian.$(ARCH).o \41 40 $(SRC)/fakeastro_images.$(ARCH).o \ 42 41 $(SRC)/fakeastro_images_region.$(ARCH).o \ -
branches/eam_branches/ipp-20151113/Ohana/src/fakeastro/src/fakeastro.c
r37807 r39266 3 3 int main (int argc, char **argv) { 4 4 5 gauss_init (50000);5 ohana_gaussdev_init (); 6 6 7 7 /* get configuration info, args */ -
branches/eam_branches/ipp-20151113/Ohana/src/fakeastro/src/make_2mass_measures.c
r38986 r39266 80 80 81 81 // uR,uD in linear arcsec 82 double dRsee = rnd_gauss(0.0, 1.0 / SN);83 double dDsee = rnd_gauss(0.0, 1.0 / SN);82 double dRsee = ohana_gaussdev_rnd (0.0, 1.0 / SN); 83 double dDsee = ohana_gaussdev_rnd (0.0, 1.0 / SN); 84 84 85 85 double dRoff = (dRpm + dRsee) / 3600.0; -
branches/eam_branches/ipp-20151113/Ohana/src/fakeastro/src/make_fake_stars_catalog.c
r37807 r39266 113 113 114 114 // uR,uD in linear arcsec 115 double dRsee = rnd_gauss(0.0, 1.0 / SN);116 double dDsee = rnd_gauss(0.0, 1.0 / SN);115 double dRsee = ohana_gaussdev_rnd (0.0, 1.0 / SN); 116 double dDsee = ohana_gaussdev_rnd (0.0, 1.0 / SN); 117 117 118 118 double dRoff = (dRpm + dRsee) / 3600.0; -
branches/eam_branches/ipp-20151113/Ohana/src/fakeastro/src/make_fakeqsos.c
r37807 r39266 51 51 52 52 // Mr will be interpretted as m_r 53 double Mr = rnd_gauss(18.0, 1.5);53 double Mr = ohana_gaussdev_rnd (18.0, 1.5); 54 54 55 55 stars[i].R = R; -
branches/eam_branches/ipp-20151113/Ohana/src/fakeastro/src/make_fakestars.c
r37807 r39266 48 48 int inPatch = FALSE; 49 49 while (!inPatch) { 50 z = rnd_gauss(0.0, FAKEASTRO_ZGAL);50 z = ohana_gaussdev_rnd (0.0, FAKEASTRO_ZGAL); 51 51 r = sqrt(drand48()) * FAKEASTRO_RGAL; 52 52 Lrad = drand48() * 2 * M_PI; … … 98 98 double Mr; 99 99 if (bigPeak) { 100 Mr = rnd_gauss(11.25, 1.0);100 Mr = ohana_gaussdev_rnd (11.25, 1.0); 101 101 } else { 102 Mr = rnd_gauss(10.00, 2.5);102 Mr = ohana_gaussdev_rnd (10.00, 2.5); 103 103 } 104 104 -
branches/eam_branches/ipp-20151113/Ohana/src/libautocode/def/measure-ps1-sim.d
r37807 r39266 27 27 FIELD XoffDCR, X_OFF_DCR, float, X offset from correction, pixels 28 28 FIELD YoffDCR, Y_OFF_DCR, float, Y offset from correction, pixels 29 FIELD RoffGAL, R_OFF_GAL, float, RA offset from correction, arcsec 30 FIELD DoffGAL, D_OFF_GAL, float, DEC offset from correction, arcsec 29 30 FIELD Mflat, M_FLAT, float, Static Flat-field offset, mag 31 FIELD dummy2, PADDING, int, unused 4 bytes 31 32 32 33 FIELD t, TIME, int, time in seconds (UNIX) … … 48 49 FIELD dRsys, POS_SYS_ERR, short, systematic error from astrom, 1/100 of pixels 49 50 50 FIELD dummy, PADDING ,short, padding51 FIELD dummy, PADDING2, short, padding 51 52 FIELD posangle, POSANGLE, short, position angle sky to chip, (0xffff/360) deg 52 53 FIELD pltscale, PLTSCALE, float, plate scale, arcsec/pixel -
branches/eam_branches/ipp-20151113/Ohana/src/libautocode/def/measure-ps1-v5.d
r38986 r39266 42 42 FIELD XoffCAM, X_OFF_CAM, float, X offset from correction, pixels 43 43 FIELD YoffCAM, Y_OFF_CAM, float, Y offset from correction, pixels 44 FIELD RoffGAL, R_OFF_GAL, float, RA offset from correction, arcsec 45 FIELD DoffGAL, D_OFF_GAL, float, DEC offset from correction, arcsec 44 45 FIELD Mflat, M_FLAT, float, Static Flat-field offset, mag 46 FIELD dummy2, PADDING, int, unused 4 bytes 46 47 47 48 # could these be packed into fewer bits? -
branches/eam_branches/ipp-20151113/Ohana/src/libautocode/def/measure.d
r39205 r39266 43 43 FIELD YoffCAM, Y_OFF_CAM, float, Y offset from correction, pixels 44 44 45 # XXX I can deprecate these as I am going to apply the correct uR,uD offset 46 # XXX not sure how to use this yet... 47 # XXX replace RoffGall with Moff -> static component of the zpt correction 48 FIELD RoffGAL, R_OFF_GAL, float, RA offset from correction, arcsec 49 FIELD DoffGAL, D_OFF_GAL, float, DEC offset from correction, arcsec 45 FIELD Mflat, M_FLAT, float, Static Flat-field offset, mag 46 FIELD dummy2, PADDING, int, unused 4 bytes 50 47 51 48 # could these be packed into fewer bits? -
branches/eam_branches/ipp-20151113/Ohana/src/libdvo/include/dvo.h
r39125 r39266 476 476 double R; 477 477 double D; 478 float RoffGAL;479 float DoffGAL;480 478 float M; 481 479 float Mcal; 480 float Mflat; 482 481 float dM; 483 482 float airmass; … … 620 619 float XoffDCR; // X offset from correction (pixels) 621 620 float YoffDCR; // Y offset from correction (pixels) 622 float RoffGAL; // RAoffset from correction (arcsec)623 float DoffGAL; // DEC offset from correction (arcsec)621 float Mflat; // flat offset from correction (arcsec) 622 int padding2; // dummy 624 623 float Sky; // local estimate of sky flux (counts/sec) 625 624 float dSky; // local estimate of sky flux (counts/sec) -
branches/eam_branches/ipp-20151113/Ohana/src/libdvo/include/libdvo_astro.h
r38986 r39266 138 138 } Image; 139 139 140 CoordTransform *AllocTransform (double phi, double Xo, double xo); 140 141 CoordTransform *InitTransform (CoordTransformSystem input, CoordTransformSystem output); 141 142 int ApplyTransform (double *x, double *y, double X, double Y, CoordTransform *transform); -
branches/eam_branches/ipp-20151113/Ohana/src/libdvo/src/coord_systems.c
r37807 r39266 1 1 # include "dvo.h" 2 2 3 CoordTransform *AllocTransform (double phi, double Xo, double xo) { 4 5 CoordTransform *transform; 6 ALLOCATE (transform, CoordTransform, 1); 7 transform->isIdentity = FALSE; 8 9 transform->phi = phi*RAD_DEG; 10 transform->Xo = Xo*RAD_DEG; 11 transform->xo = xo; 12 13 // pre-calculated constants: 14 transform->sin_phi_cos_Xo = sin(transform->phi)*cos(transform->Xo); 15 transform->sin_phi_sin_Xo = sin(transform->phi)*sin(transform->Xo); 16 transform->cos_phi = cos(transform->phi); 17 18 transform->cos_phi_cos_Xo = cos(transform->phi)*cos(transform->Xo); 19 transform->cos_phi_sin_Xo = cos(transform->phi)*sin(transform->Xo); 20 transform->sin_phi = sin(transform->phi); 21 transform->cos_Xo = cos(transform->Xo); 22 transform->sin_Xo = sin(transform->Xo); 23 24 return transform; 25 } 26 3 27 CoordTransform *InitTransform (CoordTransformSystem input, CoordTransformSystem output) { 4 28 -
branches/eam_branches/ipp-20151113/Ohana/src/libdvo/src/dbExtractMeasures.c
r38986 r39266 597 597 case MEAS_XOFF_CAM: { value.Flt = measure[0].XoffCAM; break; } 598 598 case MEAS_YOFF_CAM: { value.Flt = measure[0].YoffCAM; break; } 599 case MEAS_ROFF_GAL: { value.Flt = measure[0].RoffGAL; break; }600 case MEAS_DOFF_GAL: { value.Flt = measure[0].DoffGAL; break; }601 599 602 600 case MEAS_XFIELD: /* offset relative to exposure center in ra,dec space */ … … 723 721 724 722 case MEAS_MCAL_OFFSET: { value.Flt = measure[0].Mcal; break; } 725 726 case MEAS_FLAT: /* OK */ 727 // flat = measure.Mcal - image.Mcal 728 if (REMOTE_CLIENT) { 729 ImageMetadata *image = MatchImageMetadataDVO (measure[0].imageID); 730 if (image == NULL) break; 731 value.Flt = measure[0].Mcal - image[0].Mcal; 732 } else { 733 Image *image = MatchImageDVO (measure[0].t, measure[0].photcode, measure[0].imageID); 734 if (image == NULL) break; 735 value.Flt = measure[0].Mcal - image[0].Mcal; 736 } 737 break; 723 case MEAS_FLAT: { value.Flt = measure[0].Mflat; break; } 738 724 739 725 // we have measure[0].Xccd,Yccd and image[0].NX,NY. Find the distance to the center -
branches/eam_branches/ipp-20151113/Ohana/src/libdvo/src/dvo_catalog.c
r39125 r39266 332 332 measure->XoffCAM = NAN; 333 333 measure->YoffCAM = NAN; 334 measure->RoffGAL = NAN; 335 measure->DoffGAL = NAN; 334 335 measure->Mflat = 0.0; 336 measure->dummy2 = 0; 336 337 337 338 measure->Sky = NAN; -
branches/eam_branches/ipp-20151113/Ohana/src/libdvo/src/dvo_convert_PS1_SIM.c
r38462 r39266 29 29 out[i].XoffDCR = in[i].XoffDCR; 30 30 out[i].YoffDCR = in[i].YoffDCR; 31 out[i].RoffGAL = in[i].RoffGAL; 32 out[i].DoffGAL = in[i].DoffGAL; 31 out[i].Mflat = in[i].Mflat; 33 32 out[i].t = in[i].t; 34 33 out[i].averef = in[i].averef; … … 75 74 out[i].XoffDCR = in[i].XoffDCR; 76 75 out[i].YoffDCR = in[i].YoffDCR; 77 out[i].RoffGAL = in[i].RoffGAL; 78 out[i].DoffGAL = in[i].DoffGAL; 76 out[i].Mflat = in[i].Mflat; 79 77 out[i].t = in[i].t; 80 78 out[i].averef = in[i].averef; -
branches/eam_branches/ipp-20151113/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c
r39125 r39266 42 42 out[i].XoffCAM = in[i].XoffCAM; 43 43 out[i].YoffCAM = in[i].YoffCAM; 44 out[i].RoffGAL = in[i].RoffGAL; 45 out[i].DoffGAL = in[i].DoffGAL; 44 out[i].Mflat = in[i].Mflat; 46 45 out[i].Sky = in[i].Sky; 47 46 out[i].dSky = in[i].dSky; … … 116 115 out[i].XoffCAM = in[i].XoffCAM; 117 116 out[i].YoffCAM = in[i].YoffCAM; 118 out[i].RoffGAL = in[i].RoffGAL; 119 out[i].DoffGAL = in[i].DoffGAL; 117 out[i].Mflat = in[i].Mflat; 120 118 out[i].Sky = in[i].Sky; 121 119 out[i].dSky = in[i].dSky; … … 1678 1676 out[i].XoffDCR = in[i].XoffDCR; 1679 1677 out[i].YoffDCR = in[i].YoffDCR; 1680 out[i].RoffGAL = in[i].RoffGAL; 1681 out[i].DoffGAL = in[i].DoffGAL; 1678 out[i].Mflat = in[i].Mflat; 1682 1679 out[i].Sky = in[i].Sky; 1683 1680 out[i].dSky = in[i].dSky; -
branches/eam_branches/ipp-20151113/Ohana/src/libdvo/src/dvo_tiny_values.c
r38062 r39266 22 22 measureT[0].dM = measure[0].dM; 23 23 measureT[0].airmass = measure[0].airmass; 24 measureT[0].RoffGAL = measure[0].RoffGAL; 25 measureT[0].DoffGAL = measure[0].DoffGAL; 24 measureT[0].Mflat = measure[0].Mflat; 26 25 measureT[0].Xccd = measure[0].Xccd; 27 26 measureT[0].Yccd = measure[0].Yccd; -
branches/eam_branches/ipp-20151113/Ohana/src/libohana/Makefile
r39058 r39266 35 35 $(SRC)/sorts.$(ARCH).o \ 36 36 $(SRC)/bisection.$(ARCH).o \ 37 $(SRC)/gaussdev.$(ARCH).o \ 37 38 $(SRC)/string.$(ARCH).o \ 38 39 $(SRC)/findexec.$(ARCH).o \ -
branches/eam_branches/ipp-20151113/Ohana/src/libohana/include/ohana.h
r39040 r39266 486 486 int sprintf_double (char *output, double value); 487 487 488 # endif 488 /* in gaussdev.c */ 489 double ohana_gaussian (double x, double mean, double sigma); 490 void ohana_gaussdev_init (void); 491 void ohana_gaussdev_free (void); 492 double ohana_gaussdev_rnd (double mean, double sigma); 493 494 # endif -
branches/eam_branches/ipp-20151113/Ohana/src/misc/src/fakedist.c
r15487 r39266 1 1 # include <ohana.h> 2 3 # define NGAUSS 20484 double drand48();5 double gaussint[NGAUSS];6 double gaussian();7 double rnd_gauss();8 2 9 3 # define MMIN 1.0 … … 45 39 init_outmatrix (); 46 40 47 gauss_init ();41 ohana_gaussdev_init (); 48 42 49 43 read_datafiles (); … … 349 343 if (noise < dMo) { 350 344 *Noise = noise; 351 *mag = rnd_gauss(v, noise);352 *color = rnd_gauss(uv, 1.4*noise);345 *mag = ohana_gaussdev_rnd (v, noise); 346 *color = ohana_gaussdev_rnd (uv, 1.4*noise); 353 347 return; 354 348 } … … 414 408 415 409 /*****************************************************************************/ 416 417 double418 rnd_gauss (mean, sigma)419 double mean, sigma;420 {421 422 int i;423 double y;424 425 y = drand48();426 i = NGAUSS*y;427 y = gaussint[i]*sigma + mean;428 429 return (y);430 431 }432 433 gauss_init ()434 {435 436 int i;437 long A, B;438 double val, x, dx, dx1, dx2, dx3, df;439 double mean, sigma;440 441 A = time(NULL);442 for (B = 0; A == time(NULL); B++);443 srand48(B);444 445 val = 0;446 dx = 0.001;447 dx1 = dx / 3.0;448 dx2 = 2.0*dx/3.0;449 dx3 = dx;450 mean = 0.0;451 sigma = 1.0;452 453 for (i = 0, x = -7.0; (i < NGAUSS) && (x < 7.0); x += dx) {454 df = (3.0*gaussian(x , mean, sigma) +455 9.0*gaussian(x+dx1, mean, sigma) +456 9.0*gaussian(x+dx2, mean, sigma) +457 3.0*gaussian(x+dx3, mean, sigma)) * (dx1/8.0);458 val += df;459 if (val > (i / (double) NGAUSS)) {460 gaussint[i] = x + dx / 2.0;461 i++;462 }463 }464 return (x + dx / 2.0);465 }466 467 double468 gaussian (x, mean, sigma)469 double x, mean, sigma;470 {471 472 double f, X;473 474 f = exp (-0.5 * SQ(x - mean) / SQ(sigma)) / sqrt(2 * M_PI * SQ(sigma));475 476 return (f);477 478 }479 410 480 411 /*****************************************************************************/ … … 505 436 Ngood = 1.0; 506 437 for (k = 0; k < NTRY; k++) { 507 v = rnd_gauss(mag, noise);508 uv = rnd_gauss(color, 1.4*noise);438 v = ohana_gaussdev_rnd (mag, noise); 439 uv = ohana_gaussdev_rnd (color, 1.4*noise); 509 440 x = (uv - UV0 - 0.7*A_V) / DUV; 510 441 y = (v - V0 - Dist - A_V) / DV; -
branches/eam_branches/ipp-20151113/Ohana/src/misc/src/fakepop.c
r7080 r39266 2 2 # define MMIN 1.0 3 3 # define MMAX 120.0 4 extern double drand48();5 4 extern double rnd_mass(); 6 5 double rnd_mass(); 7 6 double term; 8 extern double rnd_gauss();9 extern double rnd_integrate ();10 extern double gaussian ();11 12 double gaussian();13 double rnd_gauss();14 double rnd_integrate();15 16 # define NGAUSS 204817 double gaussint[NGAUSS];18 7 19 8 double AgeS, AgeE, alpha, d, Av, dMo, dVo, dVref; … … 47 36 gfits_scan (&UV_h, "DEC_Y", "%lf", 1, &ldM); 48 37 49 gauss_init ();38 ohana_gaussdev_init (); 50 39 51 40 fprintf (stderr, "beginning main loop\n"); … … 68 57 v = gfits_get_matrix_value (&V_i, X, Y) + d + Av; 69 58 noise = dVo*sqrt(1.0 + pow (10.0, (0.4*(v - dVref)))); 70 V = rnd_gauss(v, noise);71 UV = rnd_gauss(uv, 1.4*noise);59 V = ohana_gaussdev_rnd (v, noise); 60 UV = ohana_gaussdev_rnd (uv, 1.4*noise); 72 61 if (noise < dMo) { 73 62 fprintf (stdout, "%f %f %f %f %f %f\n", V, noise, V+UV, noise, mass, age); … … 96 85 } 97 86 98 99 double100 rnd_gauss (mean, sigma)101 double mean, sigma;102 {103 104 int i;105 double y;106 107 y = drand48();108 i = NGAUSS*y;109 y = gaussint[i]*sigma + mean;110 111 return (y);112 113 }114 115 116 gauss_init ()117 {118 119 int i;120 long A, B;121 double val, x, dx, dx1, dx2, dx3, df;122 double mean, sigma;123 124 A = time(NULL);125 for (B = 0; A == time(NULL); B++);126 srand48(B);127 128 val = 0;129 dx = 0.001;130 dx1 = dx / 3.0;131 dx2 = 2.0*dx/3.0;132 dx3 = dx;133 mean = 0.0;134 sigma = 1.0;135 136 for (i = 0, x = -7.0; (i < NGAUSS) && (x < 7.0); x += dx) {137 df = (3.0*gaussian(x , mean, sigma) +138 9.0*gaussian(x+dx1, mean, sigma) +139 9.0*gaussian(x+dx2, mean, sigma) +140 3.0*gaussian(x+dx3, mean, sigma)) * (dx1/8.0);141 val += df;142 if (val > (i / (double) NGAUSS)) {143 gaussint[i] = x + dx / 2.0;144 i++;145 }146 }147 return (x + dx / 2.0);148 }149 87 150 88 double … … 172 110 return (x + dx / 2.0); 173 111 } 174 175 double176 gaussian (x, mean, sigma)177 double x, mean, sigma;178 {179 180 double f, X;181 182 f = exp (-0.5 * SQ(x - mean) / SQ(sigma)) / sqrt(2 * M_PI * SQ(sigma));183 184 return (f);185 186 }187 188 112 189 113 /*****************************************************************************/ -
branches/eam_branches/ipp-20151113/Ohana/src/misc/src/fakestars.c
r27435 r39266 17 17 int found; 18 18 } Stars; 19 20 void gauss_init ();21 double gaussian (double x, double mean, double sigma);22 double rnd_gauss (double mean, double sigma);23 19 24 20 /* … … 45 41 offset = atof (argv[4]); 46 42 47 gauss_init ();43 ohana_gaussdev_init (); 48 44 49 45 /* load header, open file */ … … 98 94 dMr = 0.001 * stars[i].dM; 99 95 dMo = hypot (dMs, dMr); 100 dM = rnd_gauss(0.0, dMo);96 dM = ohana_gaussdev_rnd (0.0, dMo); 101 97 stars[i].M += dM + offset; 102 98 } -
branches/eam_branches/ipp-20151113/Ohana/src/misc/src/fitdist.c
r8301 r39266 1 1 # include <ohana.h> 2 3 # define NGAUSS 20484 double drand48();5 double gaussint[NGAUSS];6 double gaussian();7 double rnd_gauss();8 2 9 3 # define MMIN 1.0 … … 45 39 fprintf (stderr, "read in parameters\n"); 46 40 47 gauss_init ();41 ohana_gaussdev_init (); 48 42 49 43 read_datafiles (); … … 360 354 /*****************************************************************************/ 361 355 362 double363 rnd_gauss (mean, sigma)364 double mean, sigma;365 {366 367 int i;368 double y;369 370 y = drand48();371 i = NGAUSS*y;372 y = gaussint[i]*sigma + mean;373 374 return (y);375 376 }377 378 gauss_init ()379 {380 381 int i;382 long A, B;383 double val, x, dx, dx1, dx2, dx3, df;384 double mean, sigma;385 386 A = time(NULL);387 for (B = 0; A == time(NULL); B++);388 srand48(B);389 390 val = 0;391 dx = 0.001;392 dx1 = dx / 3.0;393 dx2 = 2.0*dx/3.0;394 dx3 = dx;395 mean = 0.0;396 sigma = 1.0;397 398 for (i = 0, x = -7.0; (i < NGAUSS) && (x < 7.0); x += dx) {399 df = (3.0*gaussian(x , mean, sigma) +400 9.0*gaussian(x+dx1, mean, sigma) +401 9.0*gaussian(x+dx2, mean, sigma) +402 3.0*gaussian(x+dx3, mean, sigma)) * (dx1/8.0);403 val += df;404 if (val > (i / (double) NGAUSS)) {405 gaussint[i] = x + dx / 2.0;406 i++;407 }408 }409 return (x + dx / 2.0);410 }411 412 double413 gaussian (x, mean, sigma)414 double x, mean, sigma;415 {416 417 double f, X;418 419 f = exp (-0.5 * SQ(x - mean) / SQ(sigma)) / sqrt(2 * M_PI * SQ(sigma));420 421 return (f);422 423 }424 425 356 /*****************************************************************************/ 426 357 … … 453 384 Ngood = 1.0; 454 385 for (k = 0; k < NTRY; k++) { 455 v = rnd_gauss(Mag, Noise);456 uv = rnd_gauss(Color, 1.4*Noise);386 v = ohana_gaussdev_rnd (Mag, Noise); 387 uv = ohana_gaussdev_rnd (Color, 1.4*Noise); 457 388 x = (uv - UV0 - 0.7*A_V) / DUV; 458 389 y = (v - V0 - Dist - A_V) / DV; -
branches/eam_branches/ipp-20151113/Ohana/src/misc/src/magtoage.c
r7080 r39266 2 2 # define MMIN 1.0 3 3 # define MMAX 120.0 4 extern double drand48();5 extern double rnd_gauss();6 extern double rnd_integrate ();7 extern double gaussian ();8 9 double gaussian();10 double rnd_gauss();11 double rnd_integrate();12 4 13 5 void main (argc, argv) … … 29 21 long A, B; 30 22 23 ohana_gaussdev_init(); 24 31 25 lAo = 0.0; 32 26 ldA = 1.0; … … 118 112 } 119 113 else { 120 v = rnd_gauss(V, dV);121 uv = rnd_gauss((U-V), dUV);114 v = ohana_gaussdev_rnd (V, dV); 115 uv = ohana_gaussdev_rnd ((U-V), dUV); 122 116 } 123 117 x = (uv - UV0 - 0.7*Av) / DUV; … … 167 161 } 168 162 169 double170 rnd_gauss (mean, sigma)171 double mean, sigma;172 {173 174 double range, x;175 176 range = drand48();177 x = rnd_integrate (*gaussian, range, mean, sigma);178 179 return (x);180 181 }182 183 184 double185 rnd_integrate (function, range, mean, sigma)186 double (*function) ();187 double range, mean, sigma;188 {189 190 double val, x, dx, dx1, dx2, dx3, df;191 192 range += 0.0001;193 val = 0;194 dx = sigma / 10.0;195 dx1 = dx / 3.0;196 dx2 = 2.0*dx/3.0;197 dx3 = dx;198 199 for (x = mean - 7*sigma; (val < range) && (x < mean + 7*sigma); x += dx) {200 df = (3.0*function(x , mean, sigma) +201 9.0*function(x+dx1, mean, sigma) +202 9.0*function(x+dx2, mean, sigma) +203 3.0*function(x+dx3, mean, sigma)) * (dx1/8.0);204 val += df;205 }206 return (x + dx / 2.0);207 }208 209 double210 gaussian (x, mean, sigma)211 double x, mean, sigma;212 {213 214 double f, X;215 216 f = exp (-0.5 * SQ(x - mean) / SQ(sigma)) / sqrt(2 * M_PI * SQ(sigma));217 218 return (f);219 220 }221 -
branches/eam_branches/ipp-20151113/Ohana/src/misc/src/magtomass.c
r7080 r39266 1 1 # include <ohana.h> 2 extern double drand48();3 extern double rnd_gauss();4 extern double rnd_integrate ();5 extern double gaussian ();6 2 # define NEWWAY 1 7 8 double gaussian();9 double rnd_gauss();10 double rnd_integrate();11 12 # define NGAUSS 204813 double gaussint[NGAUSS];14 3 15 4 void main (argc, argv) … … 52 41 fprintf (stderr, "using mags in columns %d & %d\n", col1, col2); 53 42 54 gauss_init ();43 ohana_gaussdev_init (); 55 44 56 45 lAo = 0.1; … … 147 136 Ngood = 1.0; 148 137 for (k = 0; k < Ntry; k++) { 149 v = rnd_gauss(V, dV);150 uv = rnd_gauss((U-V), dUV);138 v = ohana_gaussdev_rnd (V, dV); 139 uv = ohana_gaussdev_rnd ((U-V), dUV); 151 140 x = (uv - UV0 - 0.7*Av) / DUV; 152 141 y = (v - d - V0 - Av) / DV; … … 202 191 */ 203 192 204 double205 rnd_gauss (mean, sigma)206 double mean, sigma;207 {208 209 int i;210 double y;211 212 y = drand48();213 i = NGAUSS*y;214 y = gaussint[i]*sigma + mean;215 216 return (y);217 218 }219 220 221 gauss_init ()222 {223 224 int i;225 long A, B;226 double val, x, dx, dx1, dx2, dx3, df;227 double mean, sigma;228 229 A = time(NULL);230 for (B = 0; A == time(NULL); B++);231 srand48(B);232 233 val = 0;234 dx = 0.001;235 dx1 = dx / 3.0;236 dx2 = 2.0*dx/3.0;237 dx3 = dx;238 mean = 0.0;239 sigma = 1.0;240 241 for (i = 0, x = -7.0; (i < NGAUSS) && (x < 7.0); x += dx) {242 df = (3.0*gaussian(x , mean, sigma) +243 9.0*gaussian(x+dx1, mean, sigma) +244 9.0*gaussian(x+dx2, mean, sigma) +245 3.0*gaussian(x+dx3, mean, sigma)) * (dx1/8.0);246 val += df;247 if (val > (i / (double) NGAUSS)) {248 gaussint[i] = x + dx / 2.0;249 i++;250 }251 }252 return (x + dx / 2.0);253 }254 255 double256 rnd_integrate (function, range, mean, sigma)257 double (*function) ();258 double range, mean, sigma;259 {260 261 double val, x, dx, dx1, dx2, dx3, df;262 263 range += 0.0001;264 val = 0;265 dx = sigma / 100.0;266 dx1 = dx / 3.0;267 dx2 = 2.0*dx/3.0;268 dx3 = dx;269 270 for (x = mean - 7*sigma; (val < range) && (x < mean + 7*sigma); x += dx) {271 df = (3.0*function(x , mean, sigma) +272 9.0*function(x+dx1, mean, sigma) +273 9.0*function(x+dx2, mean, sigma) +274 3.0*function(x+dx3, mean, sigma)) * (dx1/8.0);275 val += df;276 }277 return (x + dx / 2.0);278 }279 280 double281 gaussian (x, mean, sigma)282 double x, mean, sigma;283 {284 285 double f, X;286 287 f = exp (-0.5 * SQ(x - mean) / SQ(sigma)) / sqrt(2 * M_PI * SQ(sigma));288 289 return (f);290 291 }292 -
branches/eam_branches/ipp-20151113/Ohana/src/misc/src/mkgauss.c
r34088 r39266 1 1 # include <ohana.h> 2 3 void gauss_init ();4 double gaussian (double x, double mean, double sigma);5 double rnd_gauss (double mean, double sigma);6 7 /* NGAUSS defines the resolution of the distribution */8 # define NGAUSS 20489 static double gaussint[NGAUSS];10 2 11 3 int main (int argc, char **argv) { … … 23 15 Npts = atoi (argv[3]); 24 16 25 gauss_init ();17 ohana_gaussdev_init (); 26 18 27 19 for (i = 0; i < Npts; i++) { 28 f = rnd_gauss(mean, sigma);20 f = ohana_gaussdev_rnd (mean, sigma); 29 21 fprintf (stdout, "%f\n", f); 30 22 } … … 33 25 } 34 26 35 void gauss_init () {36 37 int i;38 long A, B;39 double val, x, dx, dx1, dx2, dx3, df;40 41 A = time(NULL);42 for (B = 0; A == time(NULL); B++);43 srand48(B);44 45 val = 0;46 dx = 0.001;47 dx1 = dx / 3.0;48 dx2 = 2.0*dx/3.0;49 dx3 = dx;50 51 for (i = 0, x = -7.0; (i < NGAUSS) && (x < 7.0); x += dx) {52 df = (3.0*gaussian(x , 0.0, 1.0) +53 9.0*gaussian(x+dx1, 0.0, 1.0) +54 9.0*gaussian(x+dx2, 0.0, 1.0) +55 3.0*gaussian(x+dx3, 0.0, 1.0)) * (dx1/8.0);56 val += df;57 if (val > (i / (double) NGAUSS)) {58 gaussint[i] = x + dx / 2.0;59 i++;60 }61 }62 return;63 }64 65 double gaussian (double x, double mean, double sigma) {66 double f;67 68 f = exp (-0.5 * SQ(x - mean) / SQ(sigma)) / sqrt(2 * M_PI * SQ(sigma));69 return (f);70 }71 72 double rnd_gauss (double mean, double sigma) {73 74 int i;75 double y;76 77 i = 0;78 while ((i == 0) || (i == NGAUSS - 1)) {79 y = drand48();80 i = MIN (NGAUSS - 1, MAX (0, NGAUSS*y));81 }82 y = gaussint[i]*sigma + mean;83 84 return (y);85 } -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/Makefile
r39223 r39266 25 25 $(SRC)/cneedles.$(ARCH).o \ 26 26 $(SRC)/cplot.$(ARCH).o \ 27 $(SRC)/crotation.$(ARCH).o \ 27 28 $(SRC)/csystem.$(ARCH).o \ 28 29 $(SRC)/ctimes.$(ARCH).o \ … … 37 38 $(SRC)/fitpm_irls.$(ARCH).o \ 38 39 $(SRC)/fitplx_irls.$(ARCH).o \ 40 $(SRC)/astrom_ops.$(ARCH).o \ 39 41 $(SRC)/fixwrap.$(ARCH).o \ 40 42 $(SRC)/fixcols.$(ARCH).o \ -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/cdensify.c
r38463 r39266 84 84 gfits_free_matrix (&bf[0].matrix); 85 85 gfits_free_header (&bf[0].header); 86 CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0);86 if (!CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0)) return FALSE; 87 87 strcpy (bf[0].file, "(empty)"); 88 88 PutCoords (&newcoords, &bf[0].header); -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/cdhistogram.c
r38062 r39266 101 101 gfits_free_matrix (&bf[0].matrix); 102 102 gfits_free_header (&bf[0].header); 103 CreateBuffer3D (bf, Nx, Ny, Nz, -32, 0.0, 1.0);103 if (!CreateBuffer3D (bf, Nx, Ny, Nz, -32, 0.0, 1.0)) return FALSE; 104 104 strcpy (bf[0].file, "(empty)"); 105 105 PutCoords (&newcoords, &bf[0].header); -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/fitplx.c
r38986 r39266 1 1 # include "astro.h" 2 # define J2000 51544.5 /* Modified Julian date at standard epoch J2000 */3 4 # define ESCAPE(MSG,...) { \5 gprint (GP_ERR, MSG, __VA_ARGS__); \6 return FALSE; }7 8 typedef struct {9 double *X;10 double *Y;11 double *t;12 double *pX;13 double *pY;14 double *dX;15 double *dY;16 int *index;17 int Npts;18 } PlxFitData;19 20 typedef struct {21 double Ro, dRo;22 double Do, dDo;23 24 double uR, duR;25 double uD, duD;26 27 double p, dp;28 29 double chisq;30 int Nfit;31 int getChisq;32 } PlxFit;33 34 int VectorRobustStats (Vector *vector, double *median, double *sigma);35 double VectorFractionInterpolate (double *values, float fraction, int Npts);36 37 int PlxSetMeanEpoch (double *R, double *D, double *T, double *Rmean, double *Dmean, double *Tmean, int *mask, int Ntotal);38 int PlxSetEpochPosition (PlxFitData *fitdata, double *R, double *D, double *dR, double *dD, double *T, int *mask, int Ntotal, Coords *coords, double Tmean);39 int PlxOutlierClip (PlxFitData *fitdata, int *mask, int Noutlier, float dPsigMax, Vector *dPvec, int VERBOSE);40 41 int PlxFitDataAlloc (PlxFitData *data, int N);42 void PlxFitDataFree (PlxFitData *data);43 int PlxBootstrapResample (PlxFitData *src, PlxFitData *tgt);44 45 int FitPMandPar (PlxFit *fit, double *X, double *dX, double *Y, double *dY, double *T, double *pR, double *pD, int Npts, int VERBOSE);46 int sun_ecliptic (double mjd, double *lambda, double *beta, double *epsilon, double *Radius);47 int ParFactor (double *pR, double *pD, double RA, double DEC, double Time);48 2 49 3 int fitplx (int argc, char **argv) { … … 100 54 gprint (GP_ERR, " -outlier-tests Nsamples dPsigMax : run Nsample bootstrap-resamples to define the path deviations and reject based on dPsigMax\n"); 101 55 gprint (GP_ERR, " -dPsig vec : save path deviations in vec\n"); 56 gprint (GP_ERR, " -mask mask : excluded points are marked with a 0 mask value\n"); 102 57 return (FALSE); 103 58 } … … 148 103 PlxFit fit; memset (&fit, 0, sizeof(PlxFit)); 149 104 150 // determine dPsig for detections based on Noutlier attempts 105 // determine dPsig for detections based on Noutlier attempts (mask is updated to mark the bad stars, mask == 0) 151 106 if (Noutlier) { 152 107 int clipRetry = TRUE; 153 108 for (i = 0; clipRetry && (i < 3); i++) { 109 // XXX NOTE This will segfault is mask is not supplied: 154 110 clipRetry = !PlxOutlierClip (&fitdata, mask, Noutlier, dPsigMax, dPvec, VERBOSE); 155 111 … … 163 119 for (i = 0; (VERBOSE == 2) && (i < fitdata.Npts); i++) { 164 120 int n = fitdata.index[i]; 165 int maskValue = mask ? mask[n] : 0;121 int maskValue = mask ? mask[n] : 1; 166 122 fprintf (stderr, "%f %f : %f %d : %f %f %f\n", R[n], D[n], T[n], maskValue, fitdata.t[i], fitdata.X[i], fitdata.Y[i]); 167 123 } … … 401 357 fit[0].Nfit = Npts; 402 358 return (TRUE); 403 }404 405 /* Low precision formulae for the sun, from Astro. Almanac p. C5 (2012) */406 int sun_ecliptic (double mjd, double *lambda, double *beta, double *epsilon, double *Radius) {407 408 double n = mjd - J2000; // day number relative to standard epoch409 double L = 280.460 + 0.9856474 * n; // mean solar longitute (corr. for aberration)410 double g = (357.528 + 0.9856003 * n)*RAD_DEG; // Mean anomaly411 412 *lambda = L + 1.915 * sin(g) + 0.020 * sin(2*g); // solar longitude in degrees413 *beta = 0.0; // approx latitude414 *epsilon = (23.439 - 0.0000004 * n); // obliquity of ecliptic in degrees415 *Radius = 1.00014 - 0.01671*cos(g) - 0.00014*cos(2*g); // earth-to-sun dist in AU416 return TRUE;417 }418 419 /* given RA, DEC, Time, calculate the parallax factor */420 // RA,DEC are decimal degrees421 // Time is MJD422 int ParFactor (double *pR, double *pD, double RA, double DEC, double Time) {423 424 double lambda, beta, epsilon, Radius;425 426 // Time must be mjd427 sun_ecliptic (Time, &lambda, &beta, &epsilon, &Radius);428 429 double lambda_rad = lambda*RAD_DEG;430 double epsilon_rad = epsilon*RAD_DEG;431 double RA_rad = RA*RAD_DEG;432 double DEC_rad = DEC*RAD_DEG;433 434 double x = Radius*cos(lambda_rad);435 double y = Radius*cos(epsilon_rad)*sin(lambda_rad);436 double z = Radius*sin(epsilon_rad)*sin(lambda_rad);437 438 *pR = +(y*cos(RA_rad) - x*sin(RA_rad));439 *pD = -(y*sin(RA_rad) + x*cos(RA_rad))*sin(DEC_rad) + z*cos(DEC_rad);440 441 return TRUE;442 }443 444 // allocate arrays but not the container445 int PlxFitDataAlloc (PlxFitData *data, int N) {446 447 data->Npts = N;448 ALLOCATE (data->X, double, N);449 ALLOCATE (data->Y, double, N);450 ALLOCATE (data->dX, double, N);451 ALLOCATE (data->dY, double, N);452 ALLOCATE (data->t, double, N);453 ALLOCATE (data->pX, double, N);454 ALLOCATE (data->pY, double, N);455 ALLOCATE (data->index, int, N);456 return TRUE;457 }458 459 void PlxFitDataFree (PlxFitData *data) {460 FREE (data->X);461 FREE (data->Y);462 FREE (data->dX);463 FREE (data->dY);464 FREE (data->t);465 FREE (data->pX);466 FREE (data->pY);467 FREE (data->index);468 359 } 469 360 … … 481 372 tgt->pX[i] = src->pX[N]; 482 373 tgt->pY[i] = src->pY[N]; 374 375 // *** make this optional? 376 tgt->Wx[i] = src->Wx[N]; 377 tgt->Wy[i] = src->Wy[N]; 483 378 } 484 379 return TRUE; … … 539 434 pYmin = MIN (pYmin, fitdata->pY[Nsubset]); 540 435 pYmax = MAX (pYmax, fitdata->pY[Nsubset]); 436 437 fitdata->Wx[Nsubset] = 1.0; 438 fitdata->Wy[Nsubset] = 1.0; 541 439 fitdata->index[Nsubset] = i; 542 440 Nsubset++; -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/fitpm.c
r37807 r39266 1 1 # include "astro.h" 2 # define J2000 51544.5 /* Modified Julian date at standard epoch J2000 */3 4 # define ESCAPE(MSG,...) { \5 gprint (GP_ERR, MSG, __VA_ARGS__); \6 return FALSE; }7 8 typedef struct {9 double Ro, dRo;10 double Do, dDo;11 12 double uR, duR;13 double uD, duD;14 15 double chisq;16 int Nfit;17 } PMFit;18 19 int FitPMonly (PMFit *fit, double *X, double *dX, double *Y, double *dY, double *T, int Npts, int VERBOSE);20 2 21 3 int fitpm (int argc, char **argv) { … … 122 104 } 123 105 124 P MFit fit;106 PlxFit fit; 125 107 if (!FitPMonly (&fit, X, dX, Y, dY, t, n, VERBOSE)) { 126 108 return FALSE; … … 158 140 159 141 /* do we want an init function which does the alloc and a clear function to free? */ 160 int FitPMonly (P MFit *fit, double *X, double *dX, double *Y, double *dY, double *T, int Npts, int VERBOSE) {142 int FitPMonly (PlxFit *fit, double *X, double *dX, double *Y, double *dY, double *T, int Npts, int VERBOSE) { 161 143 162 144 int i; … … 241 223 fit[0].duD = sqrt(A[3][3]); 242 224 225 fit[0].p = 0.0; 226 fit[0].dp = NAN; 227 243 228 // add up the chi square for the fit 244 229 chisq = 0.0; -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/fitpm_irls.c
r39223 r39266 1 1 # include "astro.h" 2 # define J2000 51544.5 /* Modified Julian date at standard epoch J2000 */3 4 # define ESCAPE(MSG,...) { \5 gprint (GP_ERR, MSG, __VA_ARGS__); \6 return FALSE; }7 8 typedef struct {9 double Ro, dRo;10 double Do, dDo;11 12 double uR, duR;13 double uD, duD;14 15 double chisq;16 int Nfit;17 } PMFit_IRLS;18 19 int FitPMonly_IRLS (PMFit_IRLS *fit, double *X, double *dX, double *Y, double *dY, double *T, int Npts, int VERBOSE);20 int IRLS_converged (PMFit_IRLS *fit);21 int weighted_LS (double *T, double *X, double *WX, double *Y, double *WY, int Npts,22 double **A, double **B, int VERBOSE);23 double weight_cauchy (double x);24 double dpsi_cauchy (double x);25 double MAD(double *in, int N);26 27 2 28 3 int fitpm_irls (int argc, char **argv) { … … 129 104 } 130 105 131 P MFit_IRLSfit;106 PlxFit fit; 132 107 if (!FitPMonly_IRLS (&fit, X, dX, Y, dY, t, n, VERBOSE)) { 133 108 return FALSE; … … 165 140 166 141 /* do we want an init function which does the alloc and a clear function to free? */ 167 int FitPMonly_IRLS (P MFit_IRLS*fit, double *X, double *dX, double *Y, double *dY, double *T, int Npts, int VERBOSE) {142 int FitPMonly_IRLS (PlxFit *fit, double *X, double *dX, double *Y, double *dY, double *T, int Npts, int VERBOSE) { 168 143 169 144 int i,j; … … 222 197 223 198 // Solve OLS equation 224 if (!weighted_LS (T,X,Wx,Y,Wy,Npts,199 if (!weighted_LS_PM(T,X,Wx,Y,Wy,Npts, 225 200 A,B,VERBOSE)) { 226 201 // Handle fail case … … 267 242 268 243 // Solve 269 if (!weighted_LS (T,X,Wx,Y,Wy,Npts,244 if (!weighted_LS_PM(T,X,Wx,Y,Wy,Npts, 270 245 A,B,VERBOSE)) { 271 246 // Handle fail case … … 284 259 u[i] = sqrt(SQ(rx[i] / dX[i]) + SQ(ry[i] / dY[i])); 285 260 } 286 sigma_hat = M AD(u,Npts) / 0.6745;261 sigma_hat = MedianAbsDeviation(u,Npts) / 0.6745; 287 262 288 263 // Check convergence … … 310 285 double Sum_Wx, Sum_Wy; 311 286 287 Sum_Wx = 0.0; 288 Sum_Wy = 0.0; 312 289 ax = 0.0; ay = 0.0; 313 290 bx = 0.0; by = 0.0; … … 387 364 } 388 365 389 390 double weight_cauchy (double x) { 391 double r = x / 2.385; 392 return (1.0 / (1.0 + SQ(r))); 393 } 394 395 // dpsi = (d/dx) (x * weight(x)) 396 double dpsi_cauchy (double x) { 397 double r2 = SQ(x / 2.385); 398 return ((1.0 - r2) / (SQ(1 + r2))); 399 } 400 401 402 // median absolute deviation 403 // MAD = median(abs(x - median(x))) 404 double MAD(double *in, int N) { 405 double *x; 406 double median = 0.0; 407 int i; 408 409 ALLOCATE(x,double,N); 410 for (i = 0; i < N; i++) { 411 x[i] = in[i]; 412 } 413 414 dsort(x,N); 415 416 if (N % 2) { 417 median = 0.5*(x[(int)(0.5*N)] + x[(int)(0.5*N) - 1]); 418 } else { 419 median = x[(int)(0.5*N)]; 420 } 421 422 for (i = 0; i < N; i++ ) { 423 x[i] = fabs(x[i] - median); 424 } 425 426 dsort(x,N); 427 428 if (N % 2) { 429 median = 0.5*(x[(int)(0.5*N)] + x[(int)(0.5*N) - 1]); 430 } else { 431 median = x[(int)(0.5*N)]; 432 } 433 434 return(median); 435 } 436 437 438 439 int weighted_LS (double *T, double *X, double *WX, double *Y, double *WY, int Npts, 440 double **A, double **B, int VERBOSE) { 366 int weighted_LS_PM (double *T, double *X, double *WX, double *Y, double *WY, int Npts, double **A, double **B, int VERBOSE) { 441 367 442 368 int i,j; … … 497 423 return TRUE; 498 424 } 425 426 double weight_cauchy (double x) { 427 double r = x / 2.385; 428 return (1.0 / (1.0 + SQ(r))); 429 } 430 431 // dpsi = (d/dx) (x * weight(x)) 432 double dpsi_cauchy (double x) { 433 double r2 = SQ(x / 2.385); 434 return ((1.0 - r2) / (SQ(1 + r2))); 435 } 436 437 438 // median absolute deviation 439 // MAD = median(abs(x - median(x))) 440 double MedianAbsDeviation(double *in, int N) { 441 double *x; 442 double median = 0.0; 443 int i; 444 445 ALLOCATE(x,double,N); 446 for (i = 0; i < N; i++) { 447 x[i] = in[i]; 448 } 449 450 dsort(x,N); 451 452 if (N % 2) { 453 median = 0.5*(x[(int)(0.5*N)] + x[(int)(0.5*N) - 1]); 454 } else { 455 median = x[(int)(0.5*N)]; 456 } 457 458 for (i = 0; i < N; i++ ) { 459 x[i] = fabs(x[i] - median); 460 } 461 462 dsort(x,N); 463 464 if (N % 2) { 465 median = 0.5*(x[(int)(0.5*N)] + x[(int)(0.5*N) - 1]); 466 } else { 467 median = x[(int)(0.5*N)]; 468 } 469 470 return(median); 471 } 472 -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/fiximage.c
r34088 r39266 26 26 gfits_free_matrix (&mask[0].matrix); 27 27 gfits_free_header (&mask[0].header); 28 CreateBuffer (mask, Nx, Ny, -32, 0.0, 1.0);28 if (!CreateBuffer (mask, Nx, Ny, -32, 0.0, 1.0)) return FALSE; 29 29 strcpy (mask[0].file, "(empty)"); 30 30 memset (mask[0].matrix.buffer, 0, Nx*Ny*sizeof(float)); -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/getcoords.c
r37807 r39266 73 73 gfits_free_matrix (&outC1[0].matrix); 74 74 gfits_free_header (&outC1[0].header); 75 CreateBuffer (outC1, Nx, Ny, -32, 1.0, 0.0);75 if (!CreateBuffer (outC1, Nx, Ny, -32, 1.0, 0.0)) return FALSE; 76 76 77 77 gfits_free_matrix (&outC2[0].matrix); 78 78 gfits_free_header (&outC2[0].header); 79 CreateBuffer (outC2, Nx, Ny, -32, 1.0, 0.0);79 if (!CreateBuffer (outC2, Nx, Ny, -32, 1.0, 0.0)) return FALSE; 80 80 81 81 float *valC1 = (float *) outC1[0].matrix.buffer; -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/imfit.c
r34088 r39266 141 141 142 142 strcpy (out[0].file, "(empty)"); 143 CreateBuffer (out, 2*nx, 2*ny, -32, 0.0, 1.0);143 if (!CreateBuffer (out, 2*nx, 2*ny, -32, 0.0, 1.0)) return FALSE; 144 144 145 145 /* four panels: 1) raw image. 2) fit 3) raw - fit 4) ?? */ -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/init.c
r39223 r39266 9 9 int cneedles PROTO((int, char **)); 10 10 int cplot PROTO((int, char **)); 11 int crotation PROTO((int, char **)); 11 12 int csystem PROTO((int, char **)); 12 13 int ctimes PROTO((int, char **)); … … 78 79 {1, "cneedles", cneedles, "plot vectors in sky coordinates"}, 79 80 {1, "cplot", cplot, "plot vectors in sky coordinates"}, 81 {1, "crotation", crotation, "rotate in 3D"}, 80 82 {1, "csystem", csystem, "convert between coordinate systems"}, 81 83 {1, "ctimes", ctimes, "convert between time formats"}, -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/shimage.c
r37807 r39266 30 30 int Ny = src[0].header.Naxis[1]; 31 31 32 gfits_free_matrix (&FrIm[0].matrix); gfits_free_header (&FrIm[0].header); CreateBuffer (FrIm, Nx, Ny, -32, 1.0, 0.0);33 gfits_free_matrix (&FiIm[0].matrix); gfits_free_header (&FiIm[0].header); CreateBuffer (FiIm, Nx, Ny, -32, 1.0, 0.0);32 gfits_free_matrix (&FrIm[0].matrix); gfits_free_header (&FrIm[0].header); if (!CreateBuffer (FrIm, Nx, Ny, -32, 1.0, 0.0)) return FALSE; 33 gfits_free_matrix (&FiIm[0].matrix); gfits_free_header (&FiIm[0].header); if (!CreateBuffer (FiIm, Nx, Ny, -32, 1.0, 0.0)) return FALSE; 34 34 35 35 // l=0 allocates space for a single value -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.astro/vshimage.c
r37807 r39266 32 32 int Ny = src[0].header.Naxis[1]; 33 33 34 gfits_free_matrix (&Rbim[0].matrix); gfits_free_header (&Rbim[0].header); CreateBuffer (Rbim, Nx, Ny, -32, 1.0, 0.0);35 gfits_free_matrix (&Reim[0].matrix); gfits_free_header (&Reim[0].header); CreateBuffer (Reim, Nx, Ny, -32, 1.0, 0.0);36 gfits_free_matrix (&Dbim[0].matrix); gfits_free_header (&Dbim[0].header); CreateBuffer (Dbim, Nx, Ny, -32, 1.0, 0.0);37 gfits_free_matrix (&Deim[0].matrix); gfits_free_header (&Deim[0].header); CreateBuffer (Deim, Nx, Ny, -32, 1.0, 0.0);34 gfits_free_matrix (&Rbim[0].matrix); gfits_free_header (&Rbim[0].header); if (!CreateBuffer (Rbim, Nx, Ny, -32, 1.0, 0.0)) return FALSE; 35 gfits_free_matrix (&Reim[0].matrix); gfits_free_header (&Reim[0].header); if (!CreateBuffer (Reim, Nx, Ny, -32, 1.0, 0.0)) return FALSE; 36 gfits_free_matrix (&Dbim[0].matrix); gfits_free_header (&Dbim[0].header); if (!CreateBuffer (Dbim, Nx, Ny, -32, 1.0, 0.0)) return FALSE; 37 gfits_free_matrix (&Deim[0].matrix); gfits_free_header (&Deim[0].header); if (!CreateBuffer (Deim, Nx, Ny, -32, 1.0, 0.0)) return FALSE; 38 38 39 39 // l=0 allocates space for a single value -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/densify.c
r36489 r39266 96 96 gfits_free_matrix (&bf[0].matrix); 97 97 gfits_free_header (&bf[0].header); 98 CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0);98 if (!CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0)) return FALSE; 99 99 strcpy (bf[0].file, "(empty)"); 100 100 -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/fft2d.c
r16107 r39266 58 58 59 59 /* fix up output headers (real) & allocate data buffer */ 60 CreateBuffer (Ore, Nx, Ny, -32, 0.0, 1.0);61 CreateBuffer (Oim, Nx, Ny, -32, 0.0, 1.0);60 if (!CreateBuffer (Ore, Nx, Ny, -32, 0.0, 1.0)) return FALSE; 61 if (!CreateBuffer (Oim, Nx, Ny, -32, 0.0, 1.0)) return FALSE; 62 62 63 63 gfits_copy_header (&Ire[0].header, &Ore[0].header); -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/gaussdeviate.c
r34088 r39266 17 17 ResetVector (vec, OPIHI_FLT, Npts); 18 18 19 gauss_init (2048);19 ohana_gaussdev_init (); 20 20 for (i = 0; i < Npts; i++) { 21 vec[0].elements.Flt[i] = rnd_gauss(mean, sigma);21 vec[0].elements.Flt[i] = ohana_gaussdev_rnd (mean, sigma); 22 22 } 23 23 return (TRUE); … … 29 29 } 30 30 31 double int_gauss (int i);32 33 31 int gaussintegral (int argc, char **argv) { 34 32 33 gprint (GP_ERR, "fix gaussintegral\n"); 34 return (FALSE); 35 36 /* 35 37 int i, Npts; 36 38 Vector *vec; … … 46 48 ResetVector (vec, OPIHI_FLT, Npts); 47 49 48 gauss_init (Npts);50 ohana_gaussdev_init (); 49 51 for (i = 0; i < Npts; i++) { 50 vec[0].elements.Flt[i] = int_gauss(i);52 vec[0].elements.Flt[i] = gaussian_int (i); 51 53 } 52 54 return (TRUE); … … 55 57 gprint (GP_ERR, "USAGE: gaussintegral Npts mean sigma\n"); 56 58 return (FALSE); 59 */ 57 60 58 61 } -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/gridify.c
r33963 r39266 85 85 gfits_free_matrix (&bf[0].matrix); 86 86 gfits_free_header (&bf[0].header); 87 CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0);87 if (!CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0)) return FALSE; 88 88 strcpy (bf[0].file, "(empty)"); 89 89 } … … 111 111 gfits_free_matrix (&ct[0].matrix); 112 112 gfits_free_header (&ct[0].header); 113 CreateBuffer (ct, Nx, Ny, -32, 0.0, 1.0);113 if (!CreateBuffer (ct, Nx, Ny, -32, 0.0, 1.0)) return FALSE; 114 114 strcpy (ct[0].file, "(empty)"); 115 115 -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/mcreate.c
r38062 r39266 27 27 28 28 if (Nz) { 29 CreateBuffer3D (buf, Nx, Ny, Nz, -32, 1.0, 0.0);29 if (!CreateBuffer3D (buf, Nx, Ny, Nz, -32, 1.0, 0.0)) return FALSE; 30 30 } else { 31 CreateBuffer (buf, Nx, Ny, -32, 1.0, 0.0);31 if (!CreateBuffer (buf, Nx, Ny, -32, 1.0, 0.0)) return FALSE; 32 32 } 33 33 return (TRUE); -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/medimage_commands.c
r36679 r39266 82 82 gfits_free_matrix (&output->matrix); 83 83 gfits_free_header (&output->header); 84 CreateBuffer (output, Nx, Ny, -32, 0.0, 1.0);84 if (!CreateBuffer (output, Nx, Ny, -32, 0.0, 1.0)) return FALSE; 85 85 86 86 float *outvalue = (float *) output->matrix.buffer; -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/mslice.c
r38234 r39266 35 35 gfits_free_matrix (&out[0].matrix); 36 36 gfits_free_header (&out[0].header); 37 CreateBuffer (out, Nx, Ny, -32, 1.0, 0.0);37 if (!CreateBuffer (out, Nx, Ny, -32, 1.0, 0.0)) return FALSE; 38 38 39 39 float *inF = (float *) in[0].matrix.buffer + plane*Nx*Ny; -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/read_vectors.c
r39223 r39266 348 348 } 349 349 350 # undef ESCAPE 350 351 # define ESCAPE(...) { \ 351 352 gprint (GP_ERR, __VA_ARGS__); \ -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/reindex.c
r34461 r39266 1 1 # include "data.h" 2 3 # define ESCAPE(MSG,...){ gprint (GP_ERR, MSG, __VA_ARGS__); goto error; }4 2 5 3 int reindex (int argc, char **argv) { -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/shift.c
r34088 r39266 48 48 gfits_free_matrix (&out[0].matrix); 49 49 gfits_free_header (&out[0].header); 50 CreateBuffer (out, nx, ny, -32, 0.0, 1.0);50 if (!CreateBuffer (out, nx, ny, -32, 0.0, 1.0)) return FALSE; 51 51 52 52 DXin = (dx < 0) ? -dx : 0; -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/squash3d.c
r38062 r39266 46 46 int oNx = iNz; 47 47 int oNy = iNy; 48 CreateBuffer (tgt, oNx, oNy, -32, 0.0, 1.0);48 if (!CreateBuffer (tgt, oNx, oNy, -32, 0.0, 1.0)) return FALSE; 49 49 float *oBuf = (float *) tgt[0].matrix.buffer; 50 50 … … 70 70 int oNx = iNx; 71 71 int oNy = iNz; 72 CreateBuffer (tgt, oNx, oNy, -32, 0.0, 1.0);72 if (!CreateBuffer (tgt, oNx, oNy, -32, 0.0, 1.0)) return FALSE; 73 73 float *oBuf = (float *) tgt[0].matrix.buffer; 74 74 … … 94 94 int oNx = iNx; 95 95 int oNy = iNy; 96 CreateBuffer (tgt, oNx, oNy, -32, 0.0, 1.0);96 if (!CreateBuffer (tgt, oNx, oNy, -32, 0.0, 1.0)) return FALSE; 97 97 float *oBuf = (float *) tgt[0].matrix.buffer; 98 98 -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/tdhistogram.c
r38062 r39266 140 140 gfits_free_matrix (&bf[0].matrix); 141 141 gfits_free_header (&bf[0].header); 142 CreateBuffer3D (bf, Nx, Ny, Nz, -32, 0.0, 1.0);142 if (!CreateBuffer3D (bf, Nx, Ny, Nz, -32, 0.0, 1.0)) return FALSE; 143 143 strcpy (bf[0].file, "(empty)"); 144 144 -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/cmd.data/vgrid.c
r20936 r39266 43 43 gfits_free_matrix (&bf[0].matrix); 44 44 gfits_free_header (&bf[0].header); 45 CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0);45 if (!CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0)) return FALSE; 46 46 strcpy (bf[0].file, "(empty)"); 47 47 -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/dimm/camera_cmds.c
r23530 r39266 107 107 gfits_free_matrix (&buf[0].matrix); 108 108 gfits_free_header (&buf[0].header); 109 CreateBuffer (buf, dx, dy, -32, 0.0, 1.0);109 if (!CreateBuffer (buf, dx, dy, -32, 0.0, 1.0)) return FALSE; 110 110 strcpy (buf[0].file, "(empty)"); 111 111 -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/dvo/coordimage.c
r36375 r39266 79 79 gfits_free_matrix (&bufX[0].matrix); 80 80 gfits_free_header (&bufX[0].header); 81 CreateBuffer (bufX, Nx, Ny, -32, 0.0, 1.0); // initialized to 0.0 here81 if (!CreateBuffer (bufX, Nx, Ny, -32, 0.0, 1.0)) return FALSE; // initialized to 0.0 here 82 82 strcpy (bufX[0].file, "(empty)"); 83 83 84 84 gfits_free_matrix (&bufY[0].matrix); 85 85 gfits_free_header (&bufY[0].header); 86 CreateBuffer (bufY, Nx, Ny, -32, 0.0, 1.0); // initialized to 0.0 here86 if (!CreateBuffer (bufY, Nx, Ny, -32, 0.0, 1.0)) return FALSE; // initialized to 0.0 here 87 87 strcpy (bufY[0].file, "(empty)"); 88 88 -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/dvo/coordmosaic.c
r36833 r39266 88 88 gfits_free_matrix (&bufX[0].matrix); 89 89 gfits_free_header (&bufX[0].header); 90 CreateBuffer (bufX, Nx, Ny, -32, 0.0, 1.0); // initialized to 0.0 here90 if (!CreateBuffer (bufX, Nx, Ny, -32, 0.0, 1.0)) return FALSE; // initialized to 0.0 here 91 91 strcpy (bufX[0].file, "(empty)"); 92 92 93 93 gfits_free_matrix (&bufY[0].matrix); 94 94 gfits_free_header (&bufY[0].header); 95 CreateBuffer (bufY, Nx, Ny, -32, 0.0, 1.0); // initialized to 0.0 here95 if (!CreateBuffer (bufY, Nx, Ny, -32, 0.0, 1.0)) return FALSE; // initialized to 0.0 here 96 96 strcpy (bufY[0].file, "(empty)"); 97 97 … … 224 224 } 225 225 226 # undef ESCAPE 226 227 # define ESCAPE(MSG) { \ 227 228 if (src) fclose (src); \ -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/dvo/fitcolors.c
r38471 r39266 145 145 gfits_free_matrix (&buf[0].matrix); 146 146 gfits_free_header (&buf[0].header); 147 CreateBuffer (buf, NP, NP, -32, 0.0, 1.0);147 if (!CreateBuffer (buf, NP, NP, -32, 0.0, 1.0)) return FALSE; 148 148 strcpy (buf[0].file, "(empty)"); 149 149 -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/dvo/imphot.c
r34088 r39266 36 36 if (GreyScale) { 37 37 if ((buf = SelectBuffer (bufname, ANYBUFFER, TRUE)) == NULL) return (FALSE); 38 CreateBuffer (buf, 100, 200, -32, 0.0, 1.0);38 if (!CreateBuffer (buf, 100, 200, -32, 0.0, 1.0)) return FALSE; 39 39 } 40 40 -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/dvo/objectcoverage.c
r38471 r39266 144 144 gfits_free_matrix (&buf[0].matrix); 145 145 gfits_free_header (&buf[0].header); 146 CreateBuffer (buf, Nx, Ny, -32, 0.0, 1.0);146 if (!CreateBuffer (buf, Nx, Ny, -32, 0.0, 1.0)) return FALSE; 147 147 strcpy (buf[0].file, "(empty)"); 148 148 -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/dvo/skycoverage.c
r37807 r39266 201 201 gfits_free_matrix (&buf[0].matrix); 202 202 gfits_free_header (&buf[0].header); 203 CreateBuffer (buf, Nx, Ny, -32, 0.0, 1.0);203 if (!CreateBuffer (buf, Nx, Ny, -32, 0.0, 1.0)) return FALSE; 204 204 strcpy (buf[0].file, "(empty)"); 205 205 -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/include/astro.h
r37807 r39266 12 12 void FreeAstro (void); 13 13 14 typedef struct { 15 double *X; 16 double *Y; 17 double *t; 18 double *pX; 19 double *pY; 20 double *dX; 21 double *dY; 22 double *Wx; 23 double *Wy; 24 int *index; 25 int Npts; 26 } PlxFitData; 27 28 typedef struct { 29 double Ro, dRo; 30 double Do, dDo; 31 32 double uR, duR; 33 double uD, duD; 34 35 double p, dp; 36 37 double chisq; 38 int Nfit; 39 int getChisq; 40 } PlxFit; 41 42 int VectorRobustStats (Vector *vector, double *median, double *sigma); 43 double VectorFractionInterpolate (double *values, float fraction, int Npts); 44 45 int PlxSetMeanEpoch (double *R, double *D, double *T, double *Rmean, double *Dmean, double *Tmean, int *mask, int Ntotal); 46 int PlxSetEpochPosition (PlxFitData *fitdata, double *R, double *D, double *dR, double *dD, double *T, int *mask, int Ntotal, Coords *coords, double Tmean); 47 int PlxOutlierClip (PlxFitData *fitdata, int *mask, int Noutlier, float dPsigMax, Vector *dPvec, int VERBOSE); 48 49 int PlxFitDataAlloc (PlxFitData *data, int N); 50 void PlxFitDataFree (PlxFitData *data); 51 int PlxBootstrapResample (PlxFitData *src, PlxFitData *tgt); 52 53 int FitPMonly (PlxFit *fit, double *X, double *dX, double *Y, double *dY, double *T, int Npts, int VERBOSE); 54 int FitPMandPar (PlxFit *fit, double *X, double *dX, double *Y, double *dY, double *T, double *pR, double *pD, int Npts, int VERBOSE); 55 int sun_ecliptic (double mjd, double *lambda, double *beta, double *epsilon, double *Radius); 56 int ParFactor (double *pR, double *pD, double RA, double DEC, double Time); 57 58 /***** */ 59 60 int FitPMonly_IRLS (PlxFit *fit, double *X, double *dX, double *Y, double *dY, double *T, int Npts, int VERBOSE); 61 int FitPMandPar_IRLS (PlxFit *fit, double *X, double *dX, double *Y, double *dY, double *T, double *pR, double *pD, double *Wx, double *Wy, int Npts, int max_iterations, double outlier_limit, int VERBOSE); 62 63 int weighted_LS_PLX (double *T, double *pR, double *pD, double *X, double *WX, double *Y, double *WY, int Npts, double **A, double **B, int VERBOSE); 64 int weighted_LS_PM (double *T, double *X, double *WX, double *Y, double *WY, int Npts, double **A, double **B, int VERBOSE); 65 66 double weight_cauchy (double x); 67 double dpsi_cauchy (double x); 68 double MedianAbsDeviation(double *in, int N); 69 14 70 # endif -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/include/shell.h
r37049 r39266 4 4 # ifndef SHELL_H 5 5 # define SHELL_H 6 7 # define ESCAPE(MSG,...) { gprint (GP_ERR, MSG, __VA_ARGS__); return FALSE; } 6 8 7 9 # define ISVAR(a) (isalnum (a) || (a == ':') || (a == '_')) -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/lib.data/Makefile
r36679 r39266 30 30 $(SDIR)/starfuncs.$(ARCH).o \ 31 31 $(SDIR)/hermitian.$(ARCH).o \ 32 $(SDIR)/gaussian.$(ARCH).o \33 32 $(SDIR)/graphtools.$(ARCH).o \ 34 33 $(SDIR)/queues.$(ARCH).o \ … … 36 35 $(SDIR)/open_kapa.$(ARCH).o \ 37 36 $(SDIR)/style_args.$(ARCH).o 37 38 # moved to libohana 39 # $(SDIR)/gaussian.$(ARCH).o \ 38 40 39 41 # fix malloc -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/lib.data/spline.c
r39230 r39266 32 32 float dx, a, b, value; 33 33 34 // saturate correction at high and low ends 35 if (X < x[0]) return y[0]; 36 if (X > x[N-1]) return y[N-1]; 37 34 38 /* find correct element in array (x must be sorted) */ 35 39 lo = 0; -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/lib.shell/BufferOps.c
r38062 r39266 92 92 gfits_free_matrix (&buf[0].matrix); 93 93 gfits_free_header (&buf[0].header); 94 CreateBuffer (buf, Nx, Ny, bitpix, bzero, bscale);94 if (!CreateBuffer (buf, Nx, Ny, bitpix, bzero, bscale)) return FALSE; 95 95 return TRUE; 96 96 } 97 97 98 98 int CreateBuffer (Buffer *buf, int Nx, int Ny, int bitpix, float bzero, float bscale) { 99 100 if (Nx < 0) { gprint (GP_ERR, "invalid negative matrix size Nx : %d\n", Nx); return FALSE; } 101 if (Ny < 0) { gprint (GP_ERR, "invalid negative matrix size Ny : %d\n", Ny); return FALSE; } 99 102 100 103 /* store the default output values */ … … 123 126 // buffer[x + Nx*y + Nx*Ny*z + ...] 124 127 int CreateBuffer3D (Buffer *buf, int Nx, int Ny, int Nz, int bitpix, float bzero, float bscale) { 128 129 if (Nx < 0) { gprint (GP_ERR, "invalid negative matrix size Nx : %d\n", Nx); return FALSE; } 130 if (Ny < 0) { gprint (GP_ERR, "invalid negative matrix size Ny : %d\n", Ny); return FALSE; } 131 if (Nz < 0) { gprint (GP_ERR, "invalid negative matrix size Nz : %d\n", Nz); return FALSE; } 125 132 126 133 /* store the default output values */ -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/lib.shell/ListOps.c
r36681 r39266 212 212 if (temp != NULL) { 213 213 if (!strcmp (temp, "-x")) goto escape; 214 if (!strcmp (temp, "-glob")) goto escape; 214 215 if (!strcmp (temp, "-split")) goto escape; 215 216 if (!strcmp (temp, "-splitbychar")) goto escape; -
branches/eam_branches/ipp-20151113/Ohana/src/opihi/mana/simsignal.c
r7917 r39266 6 6 float *buf; 7 7 double cvalue, dvalue, sigma, SN, period; 8 double rnd_gauss ();9 8 10 9 if (argc != 5) { … … 28 27 ivalue = scale * 0.5 * (sin (i*2*M_PI/period) + 1) + 0.5; 29 28 /* 30 dvalue = rnd_gauss(cvalue, sigma);29 dvalue = ohana_gaussdev_rnd (cvalue, sigma); 31 30 cvalue = (dvalue + range) / (2.0*range); 32 31 dvalue = MAX (0, MIN (0.99999, cvalue)); … … 44 43 8 bit = 2^8 45 44 46 gauss_init (2*scale);45 ohana_gaussdev_init (); 47 46 sigma = 2.0 / SN; 48 47 range = 1 + 5*sigma; -
branches/eam_branches/ipp-20151113/Ohana/src/relastro/Makefile
r38986 r39266 10 10 MAN = $(HOME)/doc 11 11 INC = $(HOME)/include 12 TESTDIR = $(HOME)/test 13 TESTBIN = $(HOME)/test 12 14 include ../../Makefile.Common 13 15 … … 22 24 install: $(DESTBIN)/relastro $(DESTBIN)/relastro_client 23 25 24 # $(DESTBIN)/testparallax25 26 26 RELASTRO = \ 27 27 $(SRC)/ConfigInit.$(ARCH).o \ … … 29 29 $(SRC)/FitMosaic.$(ARCH).o \ 30 30 $(SRC)/FitSimple.$(ARCH).o \ 31 $(SRC)/FitAstromOps.$(ARCH).o \31 $(SRC)/FitAstromOps.$(ARCH).o \ 32 32 $(SRC)/FitPM.$(ARCH).o \ 33 $(SRC)/FitPM_IRLS.$(ARCH).o \ 33 34 $(SRC)/FitPMandPar.$(ARCH).o \ 35 $(SRC)/FitPMandPar_IRLS.$(ARCH).o \ 34 36 $(SRC)/FitPosPMfixed.$(ARCH).o \ 37 $(SRC)/BootstrapOps.$(ARCH).o \ 35 38 $(SRC)/ImageOps.$(ARCH).o \ 36 39 $(SRC)/MosaicOps.$(ARCH).o \ … … 103 106 $(SRC)/ConfigInit.$(ARCH).o \ 104 107 $(SRC)/FitSimple.$(ARCH).o \ 105 $(SRC)/FitAstromOps.$(ARCH).o \108 $(SRC)/FitAstromOps.$(ARCH).o \ 106 109 $(SRC)/FitPM.$(ARCH).o \ 110 $(SRC)/FitPM_IRLS.$(ARCH).o \ 107 111 $(SRC)/FitPMandPar.$(ARCH).o \ 112 $(SRC)/FitPMandPar_IRLS.$(ARCH).o \ 108 113 $(SRC)/FitPosPMfixed.$(ARCH).o \ 114 $(SRC)/BootstrapOps.$(ARCH).o \ 109 115 $(SRC)/ImageOps.$(ARCH).o \ 110 116 $(SRC)/MosaicOps.$(ARCH).o \ … … 159 165 $(TESTPAR): $(INC)/relastro.h 160 166 $(BIN)/testparallax.$(ARCH): $(TESTPAR) 167 168 fitpm: $(BIN)/fitpm.$(ARCH) 169 170 FITPM = \ 171 $(SRC)/fitpm.$(ARCH).o \ 172 $(SRC)/ParFactor.$(ARCH).o \ 173 $(SRC)/FitAstromOps.$(ARCH).o \ 174 $(SRC)/FitPM.$(ARCH).o \ 175 $(SRC)/FitPM_IRLS.$(ARCH).o \ 176 $(SRC)/FitPMandPar.$(ARCH).o \ 177 $(SRC)/FitPMandPar_IRLS.$(ARCH).o \ 178 $(SRC)/BootstrapOps.$(ARCH).o \ 179 $(SRC)/mkpolyterm.$(ARCH).o \ 180 $(SRC)/fitpoly.$(ARCH).o 181 182 $(FITPM): $(INC)/relastro.h 183 $(BIN)/fitpm.$(ARCH): $(FITPM) -
branches/eam_branches/ipp-20151113/Ohana/src/relastro/include/relastro.h
r39207 r39266 134 134 double **A; 135 135 double **B; 136 double **Cov; 137 double *Beta; 138 double *Beta_prev; 136 139 int Nterms; 140 int getChisq; 141 int getError; 137 142 } FitAstromData; 138 143 144 // XXX do we need doubles for all of these? I actually only have of order 100 of these 145 // allocated at a time, so size is not an issue. 139 146 typedef struct { 140 147 double X, dX; … … 143 150 double D, dD; 144 151 double T, dT; 152 double Wx, Wy; 153 double rx, ry; 154 double u; 145 155 double pR; 146 156 double pD; … … 148 158 double C_red; 149 159 int measure; 160 int mask; 150 161 } FitAstromPoint; 151 162 … … 164 175 FitAstromPoint *points; 165 176 FitAstromPoint *sample; 177 FitAstromPoint *nomask; 166 178 int Npoints; 167 179 int NpointsAlloc; … … 723 735 int BootstrapRobustStats (FitAstromResult *result, FitAstromResult *fit, int Nfit, int mode); 724 736 int BootstrapResample (FitAstromPoint *sample, FitAstromPoint *points, int Npoints); 737 int BootstrapSaveUnmasked (FitAstromPoint *nomask, FitAstromPoint *points, int Npoints); 738 725 739 int CatalogMaxNmeasure (Catalog *catalog, int Ncatalog); 726 740 int FitAstromPoints_Project (FitStats *fitStats, double *Tmean, double *Trange, double *parRange); … … 739 753 int FitAstromResultSetPM (FitAstromResult *fit, int Nfit, Average *average); 740 754 void AstromErrorSetLoop (int Nloop, int isImageMode); 755 756 int FitPM_IRLS (FitAstromResult *fit, FitAstromData *data, FitAstromPoint *points, int Npoints, int VERBOSE); 757 int FitPMandPar_IRLS (FitAstromResult *fit, FitAstromData *data, FitAstromPoint *points, int Npoints, int VERBOSE); 758 759 double MedianAbsDeviation(FitAstromPoint *points, int Npoints); 760 761 int weighted_LS_PM (FitAstromResult *fit, FitAstromData *data, FitAstromPoint *points, int Npoints, int VERBOSE); 762 int weighted_LS_PLX (FitAstromResult *fit, FitAstromData *data, FitAstromPoint *points, int Npoints, int VERBOSE); 763 764 double weight_cauchy (double x); 765 double dpsi_cauchy (double x); -
branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/BrightCatalog.c
r39212 r39266 67 67 GET_COLUMN(R, "RA", double); 68 68 GET_COLUMN(D, "DEC", double); 69 GET_COLUMN(RoffGAL, "ROFF_GAL", float);70 GET_COLUMN(DoffGAL, "DOFF_GAL", float);71 69 GET_COLUMN(M, "MAG_SYS", float); 72 70 GET_COLUMN(Mcal, "MAG_CAL", float); … … 94 92 measure[i].R = R[i]; 95 93 measure[i].D = D[i]; 96 measure[i].RoffGAL = RoffGAL[i];97 measure[i].DoffGAL = DoffGAL[i];98 94 measure[i].M = M[i]; 99 95 measure[i].Mcal = Mcal[i]; … … 121 117 free (R ); 122 118 free (D ); 123 free (RoffGAL );124 free (DoffGAL );125 119 free (M ); 126 120 free (Mcal ); … … 362 356 gfits_define_bintable_column (&theader, "D", "RA", "ra", "degrees", 1.0, 0.0); 363 357 gfits_define_bintable_column (&theader, "D", "DEC", "dec", "degrees", 1.0, 0.0); 364 gfits_define_bintable_column (&theader, "E", "ROFF_GAL", "ra offset", "arcsec", 1.0, 0.0);365 gfits_define_bintable_column (&theader, "E", "DOFF_GAL", "dec offset", "arcsec", 1.0, 0.0);366 358 gfits_define_bintable_column (&theader, "E", "MAG_SYS", "magnitude (sys)", NULL, 1.0, 0.0); 367 359 gfits_define_bintable_column (&theader, "E", "MAG_CAL", "magnitude (cal)", NULL, 1.0, 0.0); … … 382 374 383 375 // generate the output array that carries the data 384 ohana_memcheck (1);385 376 gfits_create_table (&theader, &ftable); 386 ohana_memcheck (1);387 377 388 378 // create intermediate storage arrays 389 379 double *R ; ALLOCATE (R , double, catalog->Nmeasure); 390 380 double *D ; ALLOCATE (D , double, catalog->Nmeasure); 391 float *RoffGAL ; ALLOCATE (RoffGAL , float, catalog->Nmeasure);392 float *DoffGAL ; ALLOCATE (DoffGAL , float, catalog->Nmeasure);393 381 float *M ; ALLOCATE (M , float, catalog->Nmeasure); 394 382 float *Mcal ; ALLOCATE (Mcal , float, catalog->Nmeasure); … … 407 395 int *catID ; ALLOCATE (catID , int , catalog->Nmeasure); 408 396 short *photcode ; ALLOCATE (photcode , short, catalog->Nmeasure); 409 ohana_memcheck (1);410 397 411 398 // assign the storage arrays … … 414 401 R[i] = measure[i].R ; 415 402 D[i] = measure[i].D ; 416 RoffGAL[i] = measure[i].RoffGAL ;417 DoffGAL[i] = measure[i].DoffGAL ;418 403 M[i] = measure[i].M ; 419 404 Mcal[i] = measure[i].Mcal ; … … 433 418 photcode[i] = measure[i].photcode ; 434 419 } 435 ohana_memcheck (1);436 420 437 421 // add the columns to the output array 438 422 gfits_set_bintable_column (&theader, &ftable, "RA", R, catalog->Nmeasure); 439 ohana_memcheck (1);440 423 gfits_set_bintable_column (&theader, &ftable, "DEC", D, catalog->Nmeasure); 441 ohana_memcheck (1);442 gfits_set_bintable_column (&theader, &ftable, "ROFF_GAL", RoffGAL, catalog->Nmeasure);443 gfits_set_bintable_column (&theader, &ftable, "DOFF_GAL", DoffGAL, catalog->Nmeasure);444 424 gfits_set_bintable_column (&theader, &ftable, "MAG_SYS", M, catalog->Nmeasure); 445 425 gfits_set_bintable_column (&theader, &ftable, "MAG_CAL", Mcal, catalog->Nmeasure); … … 461 441 free (R ); 462 442 free (D ); 463 free (RoffGAL );464 free (DoffGAL );465 443 free (M ); 466 444 free (Mcal ); -
branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/FitAstromOps.c
r38986 r39266 2 2 3 3 // I am modifying FitPM with an eye to (a) threaded operations and (b) bootstrap resampling tests. 4 5 int FitAstromPoints_Project (FitStats *fitStats, double *Tmean, double *Trange, double *parRange) { 6 7 int k; 8 9 int Npoints = fitStats->Npoints; 10 FitAstromPoint *points = fitStats->points; 11 12 // find Tmin & Tmax from the list of accepted measurements 13 double Tmin = points[0].T; 14 double Tmax = points[0].T; 15 double pRmin = +2.0; 16 double pRmax = -2.0; 17 double pDmin = +2.0; 18 double pDmax = -2.0; 19 20 *Tmean = 0.0; 21 22 double Tsum = 0.0; 23 double Wsum = 0.0; 24 for (k = 0; k < Npoints; k++) { 25 Tmin = MIN(Tmin, points[k].T); 26 Tmax = MAX(Tmax, points[k].T); 27 28 float wx = 1.0 / SQ(points[k].dX); 29 30 Tsum += points[k].T * wx; 31 Wsum += wx; 32 33 // at this point, T is in years since J2000 34 ParFactor (&points[k].pR, &points[k].pD, points[k].R, points[k].D, points[k].T); 35 pRmin = MIN (pRmin, points[k].pR); 36 pRmax = MAX (pRmax, points[k].pR); 37 pDmin = MIN (pDmin, points[k].pD); 38 pDmax = MAX (pDmax, points[k].pD); 39 } 40 *Trange = Tmax - Tmin; 41 42 // mean epoch 43 *Tmean = Tsum / Wsum; 44 45 // for HIGH_SPEED, just use the center of the range 46 if (RELASTRO_OP == OP_HIGH_SPEED) { 47 *Tmean = 0.5*(Tmax - Tmin); 48 } 49 50 *parRange = hypot (pRmax - pRmin, pDmax - pDmin); 51 52 /* we need to do the fit in a locally linear space; choose a ref coordinate */ 53 fitStats->coords.crval1 = points[0].R; 54 fitStats->coords.crval2 = points[0].D; 55 56 // project all of the R,D coordinates to a plane centered on this coordinate. set 57 // the times to be relative to Tmean 58 for (k = 0; k < Npoints; k++) { 59 RD_to_XY (&points[k].X, &points[k].Y, points[k].R, points[k].D, &fitStats->coords); 60 points[k].T -= *Tmean; 61 } 62 return TRUE; 63 } 4 64 5 65 FitStats *FitStatsInit (int Nmax, int Nboot) { … … 27 87 fitStats->points = NULL; 28 88 fitStats->sample = NULL; 89 fitStats->nomask = NULL; 29 90 fitStats->Npoints = 0; 30 91 fitStats->NpointsAlloc = Nmax; … … 32 93 ALLOCATE (fitStats->points, FitAstromPoint, Nmax); 33 94 ALLOCATE (fitStats->sample, FitAstromPoint, Nmax); 95 ALLOCATE (fitStats->nomask, FitAstromPoint, Nmax); 34 96 } 35 97 … … 79 141 FREE (fitStats->points); 80 142 FREE (fitStats->sample); 143 FREE (fitStats->nomask); 81 144 82 145 FitAstromDataFree (fitStats->fitdataPos); … … 93 156 94 157 /* do I need to do this as 2 2x2 matrix equations? */ 95 fit->A = array_init (Nterms, Nterms); 96 fit->B = array_init (Nterms, 1); 158 fit->B = array_init (Nterms, 1); 159 fit->A = array_init (Nterms, Nterms); 160 fit->Cov = array_init (Nterms, Nterms); 161 162 ALLOCATE (fit->Beta, double, Nterms); 163 ALLOCATE (fit->Beta_prev, double, Nterms); 97 164 fit->Nterms = Nterms; 165 166 fit->getChisq = TRUE; 167 fit->getError = TRUE; 98 168 99 169 return fit; … … 106 176 array_free (fit->A, fit->Nterms); 107 177 array_free (fit->B, fit->Nterms); 178 array_free (fit->Cov, fit->Nterms); 179 180 free (fit->Beta); 181 free (fit->Beta_prev); 182 108 183 free (fit); 109 184 return; … … 126 201 object->C_red = 0.0; 127 202 object->measure= -1; 203 204 object->Wx = 1.0; 205 object->Wy = 1.0; 206 207 object->rx = 0.0; 208 object->ry = 0.0; 209 object->u = 0.0; 210 211 object->mask = 0; // keep point if mask == 0 128 212 return; 129 213 } … … 147 231 return; 148 232 } 233 234 double weight_cauchy (double x) { 235 double r = x / 2.385; 236 return (1.0 / (1.0 + SQ(r))); 237 } 238 239 // dpsi = (d/dx) (x * weight(x)) 240 double dpsi_cauchy (double x) { 241 double r2 = SQ(x / 2.385); 242 return ((1.0 - r2) / (SQ(1 + r2))); 243 } 244 245 246 // median absolute deviation 247 // MAD = median(abs(x - median(x))) 248 double MedianAbsDeviation(FitAstromPoint *points, int Npoints) { 249 250 double *x; 251 double median = 0.0; 252 int i; 253 254 ALLOCATE(x, double, Npoints); 255 for (i = 0; i < Npoints; i++) { 256 x[i] = points[i].u; 257 } 258 dsort(x, Npoints); 259 260 if (Npoints % 2) { 261 median = 0.5*(x[(int)(0.5*Npoints)] + x[(int)(0.5*Npoints) - 1]); 262 } else { 263 median = x[(int)(0.5*Npoints)]; 264 } 265 266 for (i = 0; i < Npoints; i++ ) { 267 x[i] = fabs(x[i] - median); 268 } 269 dsort(x, Npoints); 270 271 if (Npoints % 2) { 272 median = 0.5*(x[(int)(0.5*Npoints)] + x[(int)(0.5*Npoints) - 1]); 273 } else { 274 median = x[(int)(0.5*Npoints)]; 275 } 276 277 return median; 278 } -
branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/FitPMandPar.c
r38986 r39266 15 15 16 16 for (i = 0; i < Npoints; i++) { 17 if (points[i].mask) continue; // respect the mask if set 18 fit->Nfit ++; 19 17 20 /* handle case where dX or dY = 0.0 */ 18 21 wx = 1.0 / SQ(points[i].dX); … … 89 92 fit->dp = sqrt(data->A[4][4]); 90 93 91 fit->Nfit = Npoints;92 93 94 return (TRUE); 94 95 } -
branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/ImageOps.c
r38986 r39266 769 769 ref[i].R += dTime * catalog[c].average[n].uR / 3600.0 / cos(ref[i].D*RAD_DEG); 770 770 ref[i].D += dTime * catalog[c].average[n].uD / 3600.0; 771 }772 773 // if we are correcting for the Galaxy Motion Model, we assume the mean R,D is at the J2000 epoch position774 if (0) {775 myAssert (!isnan(measure[0].RoffGAL), "oops");776 myAssert (!isnan(measure[0].DoffGAL), "oops");777 ref[i].R += measure[0].RoffGAL / 3600.0;778 ref[i].D += measure[0].DoffGAL / 3600.0;779 771 } 780 772 -
branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/UpdateObjects.c
r38986 r39266 140 140 // use a fit with fewer parameters. 141 141 142 // fit the parallax + proper-motion model 143 // NOTE : we only fit PAR if we have already fitted for proper motion. if we do not fit PM or we fail 144 // to fit PM, we do not attempt PAR. thus failure to fit PAR falls back to PM-only 145 if (mode == FIT_PM_AND_PAR) { 146 if (Trange < PM_DT_MIN) { 147 mode = FIT_AVERAGE; 148 goto justPosition; 149 } 150 if (parRange < PAR_FACTOR_MIN) { 151 mode = FIT_PM_ONLY; 152 goto skipParallax; 153 } 154 if (fitStats->Npoints <= PAR_TOOFEW) { 155 mode = FIT_PM_ONLY; 156 goto skipParallax; 157 } 158 159 // we are going to use the IRLS analysis to calculate the mean solution and the masking 160 // then run N_BOOTSTRAP_SAMPLES to measure the errors 161 fitStats->fitdataPar->getError = (N_BOOTSTRAP_SAMPLES < 3); 162 FitPMandPar_IRLS (&fitPar, fitStats->fitdataPar, fitStats->points, fitStats->Npoints, VERBOSE); 163 164 if (N_BOOTSTRAP_SAMPLES >= 3) { 165 fitStats->Nfit = 0; 166 int Nnomask = BootstrapSaveUnmasked (fitStats->nomask, fitStats->points, fitStats->Npoints); 167 if (Nnomask < 5) { 168 myAbort ("handle this case, please"); 169 } 170 for (k = 0; k < fitStats->NfitAlloc; k++) { 171 BootstrapResample (fitStats->sample, fitStats->nomask, Nnomask); 172 FitPMandPar (&fitStats->fit[k], fitStats->fitdataPar, fitStats->sample, Nnomask); 173 fitStats->Nfit ++; 174 } 175 // these calls set the ERRORS on the fit parameters, not the fit values (set in IRLS above) 176 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA); 177 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC); 178 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_uR); 179 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_uD); 180 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_PLX); 181 } 182 183 // project Ro, Do back to RA,DEC 184 XY_to_RD (&fitPar.Ro, &fitPar.Do, fitPar.Ro, fitPar.Do, &fitStats->coords); 185 if (fabs(fitPar.Ro) < 0.01) fprintf (stderr, "watch out for 0,360 boundary\n"); 186 187 average[0].flags |= ID_STAR_FIT_PAR; 188 fitStats->Npar ++; 189 190 // XXX a hard-wired hack... 191 // unless there is a clear problems (below) with the parallax fit, we will use it 192 if ((fabs(fitPar.uR) > 4.0) || (fabs(fitPar.uD) > 4.0)) { 193 mode = FIT_PM_ONLY; 194 } else { 195 average[0].flags |= ID_STAR_USE_PAR; 196 } 197 } 198 199 skipParallax: 200 142 201 // *** first fit for the proper motion (skip fit if Trange or Npts is too small) *** 143 202 if ((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) { … … 151 210 } 152 211 153 if (fitStats->NfitAlloc == 1) { 154 // if N_BOOTSTRAP_SAMPLES = 1, no bootstrap resampling: 155 FitPM (&fitPM, fitStats->fitdataPM, fitStats->points, fitStats->Npoints); 212 if (average[0].flags & ID_STAR_USE_PAR) { 213 if (!FitPM (&fitPM, fitStats->fitdataPM, fitStats->points, fitStats->Npoints)) { 214 myAbort ("oops"); 215 } 156 216 } else { 157 fitStats->Nfit = 0; 158 for (k = 0; k < fitStats->NfitAlloc; k++) { 159 BootstrapResample (fitStats->sample, fitStats->points, fitStats->Npoints); 160 if (!FitPM (&fitStats->fit[k], fitStats->fitdataPM, fitStats->sample, fitStats->Npoints)) continue; 161 fitStats->Nfit ++; 162 } 163 BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA); 164 BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC); 165 BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uR); 166 BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uD); 167 } 168 FitAstromSetChisq (&fitPM, fitStats->points, fitStats->Npoints, FIT_PM_ONLY); 217 fitStats->fitdataPM->getError = (N_BOOTSTRAP_SAMPLES < 3); 218 FitPM_IRLS (&fitPM, fitStats->fitdataPM, fitStats->points, fitStats->Npoints, VERBOSE); 219 220 if (N_BOOTSTRAP_SAMPLES >= 3) { 221 fitStats->Nfit = 0; 222 int Nnomask = BootstrapSaveUnmasked (fitStats->nomask, fitStats->points, fitStats->Npoints); 223 if (Nnomask < 5) { 224 myAbort ("handle this case, please"); 225 } 226 for (k = 0; k < fitStats->NfitAlloc; k++) { 227 BootstrapResample (fitStats->sample, fitStats->nomask, Nnomask); 228 if (!FitPM (&fitStats->fit[k], fitStats->fitdataPM, fitStats->sample, fitStats->Npoints)) continue; 229 fitStats->Nfit ++; 230 } 231 BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA); 232 BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC); 233 BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uR); 234 BootstrapRobustStats (&fitPM, fitStats->fit, fitStats->Nfit, FIT_RESULT_uD); 235 } 236 } 169 237 170 238 // project Ro, Do back to RA,DEC … … 172 240 if (fabs(fitPM.Ro) < 0.01) fprintf (stderr, "watch out for 0,360 boundary\n"); 173 241 174 fitPM.p = fitPM.dp = 0.0;175 242 average[0].flags |= ID_STAR_FIT_PM; 176 243 fitStats->Npm ++; 177 244 178 245 // XXX a hard-wired hack... 179 if ((fabs(fitPM.uR) > 2.0) || (fabs(fitPM.uD) > 2.0)) { 246 // unless there is a clear problems (below) with the proper-motion fit or we have a parallax fit, we will use pm fit 247 if ((fabs(fitPM.uR) > 4.0) || (fabs(fitPM.uD) > 4.0)) { 180 248 mode = FIT_AVERAGE; 181 249 average[0].flags |= ID_STAR_BAD_PM; 250 } else { 251 if (!(average[0].flags & ID_STAR_USE_PAR)) { 252 average[0].flags |= ID_STAR_USE_PM; 253 } 182 254 } 183 255 } 184 256 185 // fit the parallax + proper-motion model186 // NOTE : we only fit PAR if we have already fitted for proper motion. if we do not fit PM or we fail187 // to fit PM, we do not attempt PAR. thus failure to fit PAR falls back to PM-only188 if (mode == FIT_PM_AND_PAR) {189 if (parRange < PAR_FACTOR_MIN) {190 mode = FIT_PM_ONLY;191 goto justPosition;192 }193 if (fitStats->Npoints <= PAR_TOOFEW) {194 mode = FIT_PM_ONLY;195 goto justPosition;196 }197 198 if (fitStats->NfitAlloc == 1) {199 // if N_BOOTSTRAP_SAMPLES = 1, no bootstrap resampling:200 FitPMandPar (&fitPar, fitStats->fitdataPar, fitStats->points, fitStats->Npoints);201 } else {202 fitStats->Nfit = 0;203 for (k = 0; k < fitStats->NfitAlloc; k++) {204 BootstrapResample (fitStats->sample, fitStats->points, fitStats->Npoints);205 FitPMandPar (&fitStats->fit[k], fitStats->fitdataPar, fitStats->sample, fitStats->Npoints);206 fitStats->Nfit ++;207 }208 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_RA);209 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_DEC);210 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_uR);211 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_uD);212 BootstrapRobustStats (&fitPar, fitStats->fit, fitStats->Nfit, FIT_RESULT_PLX);213 }214 FitAstromSetChisq (&fitPar, fitStats->points, fitStats->Npoints, FIT_PM_AND_PAR);215 216 // project Ro, Do back to RA,DEC217 XY_to_RD (&fitPar.Ro, &fitPar.Do, fitPar.Ro, fitPar.Do, &fitStats->coords);218 if (fabs(fitPar.Ro) < 0.01) fprintf (stderr, "watch out for 0,360 boundary\n");219 220 average[0].flags |= ID_STAR_FIT_PAR;221 fitStats->Npar ++;222 223 // XXX a hard-wired hack...224 if ((fabs(fitPar.uR) > 2.0) || (fabs(fitPar.uD) > 2.0)) {225 mode = FIT_PM_ONLY;226 }227 }228 229 257 justPosition: 230 258 { … … 232 260 // if we only have one point, this is silly... 233 261 262 // XXX I need to rethink here : use a median for the position or weighted average? use IRLS anyway? 263 234 264 if (fitStats->NfitAlloc == 1) { 235 265 FitAstromResultSetPM (&fitPos, 1, average); … … 618 648 } 619 649 620 int FitAstromPoints_Project (FitStats *fitStats, double *Tmean, double *Trange, double *parRange) {621 622 int k;623 624 int Npoints = fitStats->Npoints;625 FitAstromPoint *points = fitStats->points;626 627 // find Tmin & Tmax from the list of accepted measurements628 double Tmin = points[0].T;629 double Tmax = points[0].T;630 double pRmin = +2.0;631 double pRmax = -2.0;632 double pDmin = +2.0;633 double pDmax = -2.0;634 635 *Tmean = 0.0;636 637 double Tsum = 0.0;638 double Wsum = 0.0;639 for (k = 0; k < Npoints; k++) {640 Tmin = MIN(Tmin, points[k].T);641 Tmax = MAX(Tmax, points[k].T);642 643 float wx = 1.0 / SQ(points[k].dX);644 645 Tsum += points[k].T * wx;646 Wsum += wx;647 648 // at this point, T is in years since J2000649 ParFactor (&points[k].pR, &points[k].pD, points[k].R, points[k].D, points[k].T);650 pRmin = MIN (pRmin, points[k].pR);651 pRmax = MAX (pRmax, points[k].pR);652 pDmin = MIN (pDmin, points[k].pD);653 pDmax = MAX (pDmax, points[k].pD);654 }655 *Trange = Tmax - Tmin;656 657 // mean epoch658 *Tmean = Tsum / Wsum;659 660 // for HIGH_SPEED, just use the center of the range661 if (RELASTRO_OP == OP_HIGH_SPEED) {662 *Tmean = 0.5*(Tmax - Tmin);663 }664 665 *parRange = hypot (pRmax - pRmin, pDmax - pDmin);666 667 /* we need to do the fit in a locally linear space; choose a ref coordinate */668 fitStats->coords.crval1 = points[0].R;669 fitStats->coords.crval2 = points[0].D;670 671 // project all of the R,D coordinates to a plane centered on this coordinate. set672 // the times to be relative to Tmean673 for (k = 0; k < Npoints; k++) {674 RD_to_XY (&points[k].X, &points[k].Y, points[k].R, points[k].D, &fitStats->coords);675 points[k].T -= *Tmean;676 }677 return TRUE;678 }679 680 650 int CatalogMaxNmeasure (Catalog *catalog, int Ncatalog) { 681 651 … … 689 659 } 690 660 return Nmax; 691 }692 693 int BootstrapResample (FitAstromPoint *sample, FitAstromPoint *points, int Npoints) {694 int i;695 696 // I need to draw Npoints random entries from 'points' with replacement:697 for (i = 0; i < Npoints; i++) {698 int N = Npoints * drand48();699 sample[i] = points[N];700 }701 return TRUE;702 }703 704 // calculate mean and sigma points for the 5 fit parameter705 int BootstrapRobustStats (FitAstromResult *result, FitAstromResult *fit, int Nfit, int mode) {706 707 // generate a histogram for the selected element708 double *values = NULL;709 ALLOCATE (values, double, Nfit);710 711 int i;712 713 for (i = 0; i < Nfit; i++) {714 switch (mode) {715 case FIT_RESULT_RA:716 values[i] = fit[i].Ro;717 break;718 case FIT_RESULT_DEC:719 values[i] = fit[i].Do;720 break;721 case FIT_RESULT_uR:722 values[i] = fit[i].uR;723 break;724 case FIT_RESULT_uD:725 values[i] = fit[i].uD;726 break;727 case FIT_RESULT_PLX:728 values[i] = fit[i].p;729 break;730 default:731 myAbort ("invalid option");732 }733 }734 735 dsort (values, Nfit);736 737 double median;738 if (Nfit % 2) {739 int Ncenter = Nfit / 2;740 median = values[Ncenter];741 } else {742 int Ncenter = Nfit / 2 - 1;743 median = 0.5*(values[Ncenter] + values[Ncenter + 1]);744 }745 746 double Slo = VectorFractionInterpolate (values, 0.158655, Nfit);747 double Shi = VectorFractionInterpolate (values, 0.841345, Nfit);748 double sigma = (Shi - Slo) / 2.0;749 750 switch (mode) {751 case FIT_RESULT_RA:752 result->Ro = median;753 result->dRo = sigma;754 break;755 case FIT_RESULT_DEC:756 result->Do = median;757 result->dDo = sigma;758 break;759 case FIT_RESULT_uR:760 result->uR = median;761 result->duR = sigma;762 break;763 case FIT_RESULT_uD:764 result->uD = median;765 result->duD = sigma;766 break;767 case FIT_RESULT_PLX:768 result->p = median;769 result->dp = sigma;770 break;771 default:772 myAbort ("invalid option");773 }774 775 return TRUE;776 }777 778 double VectorFractionInterpolate (double *values, float fraction, int Npts) {779 780 float F = fraction * Npts;781 int N = fraction * Npts;782 783 if (N < 0 ) return NAN;784 if (N >= Npts - 2) return NAN;785 786 // interpolate between N,N+1787 788 double S = (F - N) * (values[N+1] - values[N]) + values[N];789 return S;790 661 } 791 662 -
branches/eam_branches/ipp-20151113/Ohana/src/relphot/src/BrightCatalog.c
r37037 r39266 67 67 GET_COLUMN(M, "MAG_SYS", float); 68 68 GET_COLUMN(Mcal, "MAG_CAL", float); 69 GET_COLUMN(Mflat, "MAG_FLAT", float); 69 70 GET_COLUMN(dM, "MAG_ERR", float); 70 71 GET_COLUMN(airmass, "AIRMASS", float); … … 89 90 measure[i].M = M[i]; 90 91 measure[i].Mcal = Mcal[i]; 92 measure[i].Mflat = Mflat[i]; 91 93 measure[i].dM = dM[i]; 92 94 measure[i].airmass = airmass[i]; … … 109 111 free (M ); 110 112 free (Mcal ); 113 free (Mflat ); 111 114 free (dM ); 112 115 free (airmass ); … … 269 272 gfits_define_bintable_column (&theader, "E", "MAG_SYS", "magnitude (sys)", NULL, 1.0, 0.0); 270 273 gfits_define_bintable_column (&theader, "E", "MAG_CAL", "magnitude (cal)", NULL, 1.0, 0.0); 274 gfits_define_bintable_column (&theader, "E", "MAG_FLAT", "magnitude (flat)", NULL, 1.0, 0.0); 271 275 gfits_define_bintable_column (&theader, "E", "MAG_ERR", "magnitude (err)", NULL, 1.0, 0.0); 272 276 gfits_define_bintable_column (&theader, "E", "AIRMASS", "airmass", NULL, 1.0, 0.0); … … 290 294 float *M ; ALLOCATE (M , float, catalog->Nmeasure); 291 295 float *Mcal ; ALLOCATE (Mcal , float, catalog->Nmeasure); 296 float *Mflat ; ALLOCATE (Mflat , float, catalog->Nmeasure); 292 297 float *dM ; ALLOCATE (dM , float, catalog->Nmeasure); 293 298 float *airmass ; ALLOCATE (airmass , float, catalog->Nmeasure); … … 310 315 M[i] = measure[i].M ; 311 316 Mcal[i] = measure[i].Mcal ; 317 Mflat[i] = measure[i].Mflat ; 312 318 dM[i] = measure[i].dM ; 313 319 airmass[i] = measure[i].airmass ; … … 329 335 gfits_set_bintable_column (&theader, &ftable, "MAG_SYS", M, catalog->Nmeasure); 330 336 gfits_set_bintable_column (&theader, &ftable, "MAG_CAL", Mcal, catalog->Nmeasure); 337 gfits_set_bintable_column (&theader, &ftable, "MAG_FLAT", Mflat, catalog->Nmeasure); 331 338 gfits_set_bintable_column (&theader, &ftable, "MAG_ERR", dM, catalog->Nmeasure); 332 339 gfits_set_bintable_column (&theader, &ftable, "AIRMASS", airmass, catalog->Nmeasure); … … 346 353 free (M ); 347 354 free (Mcal ); 355 free (Mflat ); 348 356 free (dM ); 349 357 free (airmass ); -
branches/eam_branches/ipp-20151113/Ohana/src/relphot/src/setMrelCatalog.c
r39107 r39266 1 1 # include "relphot.h" 2 3 /* 4 # define TEST_OBJ_ID 0x3ae2 5 # define TEST_CAT_ID 0x16c5f 6 */ 7 # define TEST_OBJ_ID 0 8 # define TEST_CAT_ID 0 9 2 10 int markMeasureByRanking (StatDataSet *dataset, Measure *measure, int minrank, DVOMeasureFlags flags); 3 11 … … 113 121 114 122 // option for a test print 115 if ( FALSE && (averageT[0].objID == 0x7146) && (averageT[0].catID == 0x49d8)) {123 if ((averageT[0].objID == TEST_OBJ_ID) && (averageT[0].catID == TEST_CAT_ID)) { 116 124 fprintf (stderr, "test obj\n"); 117 125 print_measure_set_alt (average, secfilt, measure); … … 353 361 354 362 if (isSetMrelFinal) { 355 if ( FALSE && (average->objID == 0x1) && (average->catID)) {363 if ((average[0].objID == TEST_OBJ_ID) && (average[0].catID == TEST_CAT_ID)) { 356 364 fprintf (stderr, "test obj\n"); 357 365 } … … 723 731 724 732 // option for a test print 725 if ( FALSE && (average[0].objID == 0x0000049c) && (average[0].catID == 0x00016c5e)) {733 if ((average[0].objID == TEST_OBJ_ID) && (average[0].catID == TEST_CAT_ID)) { 726 734 fprintf (stderr, "test obj\n"); 727 735 print_measure_set_alt (average, secfilt, measure); -
branches/eam_branches/ipp-20151113/Ohana/src/uniphot/Makefile
r38986 r39266 1 default: uniphot setphot setphot_client setfwhm setposangle setposangle_client setastrom setastrom_client setgalmodel setgalmodel_client fiximids fiximids_client fixstkids fixstkids_client ckids ckids_client 1 # default: uniphot setphot setphot_client setfwhm setposangle setposangle_client setastrom setastrom_client setgalmodel setgalmodel_client fiximids fiximids_client fixstkids fixstkids_client ckids ckids_client 2 default: uniphot setfwhm setposangle setposangle_client setastrom setastrom_client setgalmodel setgalmodel_client fiximids fiximids_client fixstkids fixstkids_client ckids ckids_client 3 2 4 help: 3 5 @echo "make options: uniphot setphot setfwhm default help install default (uniphot setphot setfwhm)" … … 34 36 ckids_client: $(BIN)/ckids_client.$(ARCH) 35 37 36 install: $(DESTBIN)/uniphot $(DESTBIN)/setfwhm $(DESTBIN)/setphot $(DESTBIN)/setphot_client $(DESTBIN)/setposangle $(DESTBIN)/setposangle_client $(DESTBIN)/setastrom $(DESTBIN)/setastrom_client $(DESTBIN)/setgalmodel $(DESTBIN)/setgalmodel_client $(DESTBIN)/fiximids $(DESTBIN)/fiximids_client $(DESTBIN)/fixstkids $(DESTBIN)/fixstkids_client $(DESTBIN)/ckids $(DESTBIN)/ckids_client 38 # install: $(DESTBIN)/uniphot $(DESTBIN)/setfwhm $(DESTBIN)/setphot $(DESTBIN)/setphot_client $(DESTBIN)/setposangle $(DESTBIN)/setposangle_client $(DESTBIN)/setastrom $(DESTBIN)/setastrom_client $(DESTBIN)/setgalmodel $(DESTBIN)/setgalmodel_client $(DESTBIN)/fiximids $(DESTBIN)/fiximids_client $(DESTBIN)/fixstkids $(DESTBIN)/fixstkids_client $(DESTBIN)/ckids $(DESTBIN)/ckids_client 39 install: $(DESTBIN)/uniphot $(DESTBIN)/setfwhm $(DESTBIN)/setposangle $(DESTBIN)/setposangle_client $(DESTBIN)/setastrom $(DESTBIN)/setastrom_client $(DESTBIN)/setgalmodel $(DESTBIN)/setgalmodel_client $(DESTBIN)/fiximids $(DESTBIN)/fiximids_client $(DESTBIN)/fixstkids $(DESTBIN)/fixstkids_client $(DESTBIN)/ckids $(DESTBIN)/ckids_client 37 40 38 41 UNIPHOT = \ -
branches/eam_branches/ipp-20151113/Ohana/src/uniphot/include/setphot.h
r39219 r39266 17 17 unsigned int flags; 18 18 } ImageSubset; 19 20 // we have one correction (an image) for each filter and chip 21 typedef struct { 22 int Nx; // number of chips in x 23 int Ny; // number of chips in y 24 int Nfilter; // number of filters 25 int Nseason; // number of correction peridos 26 27 int Nchips; // chip offset (Nx*Ny) 28 int Nflats; // season offset (Nx*Ny*Nfilters) 29 int Nvalues; // Nx*Ny*Nfilters*Nseason 30 31 int dX; // superpixel size 32 int dY; // superpixel size 33 34 int NxCCD; // number of pixels 35 int NyCCD; // number of pixels 36 37 Matrix **matrix; // allocate an array of pointers 38 // index = ix + iy*Nx + filter*Nchips + dir*Ngroup 39 } CamCorrection; 19 40 20 41 /* global variables set in parameter file */ -
branches/eam_branches/ipp-20151113/Ohana/src/uniphot/src/cam_correction.c
r38062 r39266 29 29 30 30 int Ndir, Nfilter, Nx, Ny, dX, dY, NxCCD, NyCCD; 31 if (!gfits_scan (&header, "NDIR", "%d", 1, &Ndir)) return FALSE;32 if (!gfits_scan (&header, "NFILTER", "%d", 1, &Nfilter)) return FALSE;31 if (!gfits_scan (&header, "NDIR", "%d", 1, &Ndir)) return FALSE; 32 if (!gfits_scan (&header, "NFILTER", "%d", 1, &Nfilter)) return FALSE; 33 33 if (!gfits_scan (&header, "NX", "%d", 1, &Nx)) return FALSE; 34 34 if (!gfits_scan (&header, "NY", "%d", 1, &Ny)) return FALSE; … … 61 61 } 62 62 63 int found = FALSE;64 63 while (TRUE) { 65 64 Header theader; … … 90 89 // assert that cam->matrix[index] is NULL? 91 90 cam->matrix[index] = matrix; 92 93 if (!found) {94 95 }96 91 } 97 92 return TRUE; -
branches/eam_branches/ipp-20151113/Ohana/src/uniphot/src/initialize_setphot.c
r39219 r39266 33 33 34 34 int N; 35 36 CAM_FILE = NULL; 37 if ((N = get_argument (argc, argv, "-CAM"))) { 38 remove_argument (N, &argc, argv); 39 char *tmpfile = strcreate (argv[N]); 40 CAM_FILE = abspath (tmpfile, DVO_MAX_PATH); 41 remove_argument (N, &argc, argv); 42 } 43 CAM_RESET = FALSE; 44 if ((N = get_argument (argc, argv, "-CAM-reset"))) { 45 remove_argument (N, &argc, argv); 46 CAM_RESET = TRUE; 47 } 35 48 36 49 VERBOSE = FALSE; -
branches/eam_branches/ipp-20151113/Ohana/src/uniphot/src/initialize_setphot_client.c
r38986 r39266 26 26 27 27 int N; 28 29 CAM_FILE = NULL; 30 if ((N = get_argument (argc, argv, "-CAM"))) { 31 remove_argument (N, &argc, argv); 32 char *tmpfile = strcreate (argv[N]); 33 CAM_FILE = abspath (tmpfile, DVO_MAX_PATH); 34 remove_argument (N, &argc, argv); 35 } 36 CAM_RESET = FALSE; 37 if ((N = get_argument (argc, argv, "-CAM-reset"))) { 38 remove_argument (N, &argc, argv); 39 CAM_RESET = TRUE; 40 } 28 41 29 42 VERBOSE = FALSE; -
branches/eam_branches/ipp-20151113/Ohana/src/uniphot/src/setphot.c
r38986 r39266 8 8 ZptTable *zpts; 9 9 Image *image; 10 FlatCorrectionTable flatcorrTable; 10 11 // FlatCorrectionTable flatcorrTable; 11 12 12 13 /* get configuration info, args, lockfile */ … … 33 34 } 34 35 36 // if supplied, read in the camera-static flat-field correction 37 if (CAM_FILE) { 38 if (!load_cam_correction (CAM_FILE)) { 39 fprintf (stderr, "failed to load camera-static flat-field correction\n"); 40 exit (2); 41 } 42 merge_flatcorr_with_cam (flatcorrTable); 43 } else { 44 convert_flatcorr_to_cam (flatcorrTable); 45 } 46 47 { 48 char newflatfile[DVO_MAX_PATH]; 49 int size = snprintf (newflatfile, DVO_MAX_PATH, "%s/flatfield.fits", CATDIR); 50 assert (size < DVO_MAX_PATH); 51 save_cam_correction (newflatfile); 52 } 53 35 54 if (!zpts) Shutdown ("failed to load zero points, or empty table"); 36 55 … … 42 61 43 62 if (UBERCAL) { 44 match_flatcorr_to_images (image, Nimage, &flatcorrTable); 63 // we are going to deprecate the flatcorr imaage lookup 64 // match_flatcorr_to_images (image, Nimage, &flatcorrTable); 65 match_camcorr_to_images (image, Nimage); 45 66 } 46 67 47 68 if (!IMAGES_ONLY) { 48 status = update_dvo_setphot (image, Nimage , &flatcorrTable);69 status = update_dvo_setphot (image, Nimage); 49 70 } 50 71 -
branches/eam_branches/ipp-20151113/Ohana/src/uniphot/src/update_catalog_setphot.c
r35425 r39266 1 1 # include "setphot.h" 2 2 3 void update_catalog_setphot (Catalog *catalog, Image *image, off_t *index, off_t Nimage , FlatCorrectionTable *flatcorr) {3 void update_catalog_setphot (Catalog *catalog, Image *image, off_t *index, off_t Nimage) { 4 4 5 5 off_t i, j, found; … … 7 7 // if we are resetting, reset all flags 8 8 DVOMeasureFlags photomFlags = ID_MEAS_POOR_PHOTOM | ID_MEAS_SKIP_PHOTOM | ID_MEAS_PHOTOM_UBERCAL; 9 10 CamCorrection *camcorr = get_cam_correction_ptr (); 9 11 10 12 found = 0; … … 21 23 float Mcal = image[id].Mcal; 22 24 float dMcal = image[id].dMcal; 23 float M cal_offset = 0.0;25 float Mflat = 0.0; 24 26 25 27 // if we know about a flat-field correction, then we need to apply the sub-chip correction 26 28 int flat_id = image[id].photom_map_id; 27 29 if (flat_id > 0) { 28 Mcal_offset = FlatCorrectionOffset (flatcorr, flat_id, catalog[0].measure[m].Xccd, catalog[0].measure[m].Yccd);30 Mflat = CamCorrectionOffset (camcorr, flat_id, catalog[0].measure[m].Xccd, catalog[0].measure[m].Yccd); 29 31 } 30 32 31 catalog[0].measure[m].Mcal = Mcal - Mcal_offset; 33 catalog[0].measure[m].Mcal = Mcal; 34 catalog[0].measure[m].Mflat = Mflat; 32 35 catalog[0].measure[m].dMcal = dMcal; 33 36 myAssert(isfinite(catalog[0].measure[m].Mcal), "oops: ubercal made a nan");
Note:
See TracChangeset
for help on using the changeset viewer.
