- Timestamp:
- Mar 19, 2019, 6:30:13 AM (7 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/mana/deimos_fitobj.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/mana/deimos_fitobj.c
r40644 r40645 1 1 # include "data.h" 2 2 # include "deimos.h" 3 4 int deimos_fitobj (int argc, char **argv) { 5 OHANA_UNUSED_PARAM(argc); 6 OHANA_UNUSED_PARAM(argv); 7 return FALSE; 8 } 9 10 # if (0) 11 12 /* 13 this is starting to work OK. some improvements to make 14 * save all fitted obj,sky,bck vectors 15 * save chisq for each fit set 16 * use Gaussdev to sample 17 * do not scale down range (or user-set scale-down) 18 */ 3 19 4 20 // internal functions to fitobj … … 144 160 } 145 161 146 // Save the best 3 results for each of obj, sky, bck:147 Vector *obj1, *obj2, *obj3;148 if ((obj1 = SelectVector ("obj1", ANYVECTOR, TRUE)) == NULL) { return (FALSE); } ResetVector (obj1, OPIHI_FLT, Ny);149 if ((obj2 = SelectVector ("obj2", ANYVECTOR, TRUE)) == NULL) { return (FALSE); } ResetVector (obj2, OPIHI_FLT, Ny);150 if ((obj3 = SelectVector ("obj3", ANYVECTOR, TRUE)) == NULL) { return (FALSE); } ResetVector (obj3, OPIHI_FLT, Ny);151 Vector *sky1, *sky2, *sky3;152 if ((sky1 = SelectVector ("sky1", ANYVECTOR, TRUE)) == NULL) { return (FALSE); } ResetVector (sky1, OPIHI_FLT, Ny);153 if ((sky2 = SelectVector ("sky2", ANYVECTOR, TRUE)) == NULL) { return (FALSE); } ResetVector (sky2, OPIHI_FLT, Ny);154 if ((sky3 = SelectVector ("sky3", ANYVECTOR, TRUE)) == NULL) { return (FALSE); } ResetVector (sky3, OPIHI_FLT, Ny);155 Vector *bck1, *bck2, *bck3;156 if ((bck1 = SelectVector ("bck1", ANYVECTOR, TRUE)) == NULL) { return (FALSE); } ResetVector (bck1, OPIHI_FLT, Ny);157 if ((bck2 = SelectVector ("bck2", ANYVECTOR, TRUE)) == NULL) { return (FALSE); } ResetVector (bck2, OPIHI_FLT, Ny);158 if ((bck3 = SelectVector ("bck3", ANYVECTOR, TRUE)) == NULL) { return (FALSE); } ResetVector (bck3, OPIHI_FLT, Ny);159 160 for (int iy = 0; iy < Ny; iy++) {161 obj1->elements.Flt[iy] = 0.0; sky1->elements.Flt[iy] = 0.0; bck1->elements.Flt[iy] = 0.0;162 obj2->elements.Flt[iy] = 0.0; sky2->elements.Flt[iy] = 0.0; bck2->elements.Flt[iy] = 0.0;163 obj3->elements.Flt[iy] = 0.0; sky3->elements.Flt[iy] = 0.0; bck3->elements.Flt[iy] = 0.0;164 }165 166 162 // for the cross-dispersion reference pixle, use the user value or set to Nx/2 if < 0 167 163 deimos_set_cross_ref (atoi(argv[2]), Nx); … … 175 171 int NRESULT = Niter + Ntry*Niter; 176 172 ALLOCATE_PTR (result, DeimosResult, NRESULT); 173 174 // Save all result vectors for each of obj, sky, bck: 175 ALLOCATE_PTR (objOut, Vector, NRESULT); 176 ALLOCATE_PTR (skyOut, Vector, NRESULT); 177 ALLOCATE_PTR (bckOut, Vector, NRESULT); 178 for (int i = 0; i < NRESULT; i++) { 179 char name[64]; 180 snprintf (name, 64, "obj_%04d", i); if ((objOut[i] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) { return (FALSE); } ResetVector (&objOut[i], OPIHI_FLT, Ny); 181 snprintf (name, 64, "sky_%04d", i); if ((skyOut[i] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) { return (FALSE); } ResetVector (&skyOut[i], OPIHI_FLT, Ny); 182 snprintf (name, 64, "bck_%04d", i); if ((bckOut[i] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) { return (FALSE); } ResetVector (&bckOut[i], OPIHI_FLT, Ny); 183 for (int iy = 0; iy < Ny; iy++) { 184 objOut[i].elements.Flt[iy] = 0.0; 185 skyOut[i].elements.Flt[iy] = 0.0; 186 bckOut[i].elements.Flt[iy] = 0.0; 187 } 188 } 189 Vector *chisqVect; 190 if ((chisqVect = SelectVector ("chisqOut", ANYVECTOR, TRUE)) == NULL) { return FALSE; } 191 ResetVector (chisqVect, OPIHI_FLT, NRESULT); 192 for (int i = 0; i < NRESULT; i++) { chisqVect->elements.Flt[i] = 0.0; } 177 193 178 194 float noiseVar = SQ(noise); … … 302 318 // int *index = sort_result (result, Nresult); 303 319 // copy result[index[0]].obj,sky,bck to obj,sky,bck 304 int Nv = 0; 305 for (int iy = 0; iy < Nrow; iy++) { 306 Nv = IDX[0]; obj1->elements.Flt[iy + row] = result[Nv].obj[iy]; sky1->elements.Flt[iy + row] = result[Nv].sky[iy]; bck1->elements.Flt[iy + row] = result[Nv].bck[iy]; 307 Nv = IDX[1]; obj2->elements.Flt[iy + row] = result[Nv].obj[iy]; sky2->elements.Flt[iy + row] = result[Nv].sky[iy]; bck2->elements.Flt[iy + row] = result[Nv].bck[iy]; 308 Nv = IDX[2]; obj3->elements.Flt[iy + row] = result[Nv].obj[iy]; sky3->elements.Flt[iy + row] = result[Nv].sky[iy]; bck3->elements.Flt[iy + row] = result[Nv].bck[iy]; 320 for (int i = 0; i < Nresult; i++) { 321 for (int iy = 0; iy < Nrow; iy++) { 322 objOut[i].elements.Flt[iy + row] = result[IDX[i]].obj[iy]; 323 skyOut[i].elements.Flt[iy + row] = result[IDX[i]].sky[iy]; 324 bckOut[i].elements.Flt[iy + row] = result[IDX[i]].bck[iy]; 325 } 326 chisqVect->elements.Flt[i] += chisq; 309 327 } 310 328 } … … 402 420 return bin; 403 421 } 422 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
