Changeset 37532
- Timestamp:
- Oct 27, 2014, 5:56:01 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140904/Ohana/src/fakeastro
- Files:
-
- 8 edited
-
include/fakeastro.h (modified) (2 diffs)
-
src/fakeastro_images.c (modified) (2 diffs)
-
src/fakeastro_images_region.c (modified) (2 diffs)
-
src/get_image_patch.c (modified) (1 diff)
-
src/make_fake_stars.c (modified) (2 diffs)
-
src/make_fake_stars_catalog.c (modified) (5 diffs)
-
src/match_fake_stars.c (modified) (4 diffs)
-
src/save_fake_stars.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/include/fakeastro.h
r37523 r37532 155 155 156 156 SkyRegion *get_image_patch (Image *image); 157 SkyRegion *get_mosaic_patch (Image *image); 158 157 159 int SkyRegionsOverlap (SkyRegion *region, SkyRegion *patch); 158 160 int SkyRegionHasPoint (SkyRegion *region, double R, double D); … … 161 163 Catalog *load_fake_stars (SkyList *skylist, int *ncatalog); 162 164 163 Stars *make_fake_stars (Catalog *catalog, int Ncatalog, SkyList *skylist, Image *image, int *nstars);165 Stars *make_fake_stars (Catalog *catalog, int Ncatalog, SkyList *skylist, Image *image, Stars *stars, int *nstars); 164 166 Stars *make_fake_stars_catalog (Stars *stars, int *nstars, SkyRegion *patch, Catalog *catalog, Image *image); 165 167 166 168 int save_fake_stars (SkyTable *sky, Image *image, Stars *stars, int Nstars); 167 int match_fake_stars (Stars *stars, unsigned int NstarsIn, SkyRegion *region, Catalog *catalog , Image *image);169 int match_fake_stars (Stars *stars, unsigned int NstarsIn, SkyRegion *region, Catalog *catalog); 168 170 169 171 int InitStar (Stars *star); -
branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/fakeastro_images.c
r37477 r37532 4 4 5 5 int fakeastro_images () { 6 7 INITTIME; 6 8 7 9 FITS_DB dbfake, dbtrue; … … 37 39 save_image_db (&dbfake, imageInfo.fakeImage, imageInfo.NfakeImage); 38 40 save_image_db (&dbtrue, imageInfo.trueImage, imageInfo.NtrueImage); 41 42 MARKTIME ("generate fake stars in %f sec\n", dtime) 39 43 40 44 exit (0); -
branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/fakeastro_images_region.c
r37477 r37532 40 40 } 41 41 42 int NfakeStars = 0; 43 Stars *fakeStars = NULL; 44 42 45 for (j = 0; j < NfakeImage; j++) { 43 46 … … 45 48 if (strcmp(&fakeImage[j].coords.ctype[4], "-WRP")) continue; 46 49 47 int N fakeStars;48 Stars *fakeStars = make_fake_stars (catalog, Ncatalog, skyListInput, &fakeImage[j], &NfakeStars);50 int Nstart = NfakeStars; 51 fakeStars = make_fake_stars (catalog, Ncatalog, skyListInput, &fakeImage[j], fakeStars, &NfakeStars); 49 52 50 fit_fake_stars (fakeStars, NfakeStars, &fakeImage[j]); 53 // only fit the new stars to this image 54 fit_fake_stars (&fakeStars[Nstart], NfakeStars - Nstart, &fakeImage[j]); 51 55 52 save_fake_stars (skyTableOutput, &fakeImage[j], fakeStars, NfakeStars); 53 54 free (fakeStars); 56 fprintf (stderr, "%s : %d\n", fakeImage[j].name, NfakeStars - Nstart); 55 57 } 58 // send in just the PHU image for reference 59 save_fake_stars (skyTableOutput, &fakeImage[0], fakeStars, NfakeStars); 60 free (fakeStars); 56 61 57 62 // append the new fake images to the end of the full set: -
branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/get_image_patch.c
r37531 r37532 9 9 static double Xpt[] = {0.0, 0.5, 1.0, 0.0, 1.0, 0.0, 0.5, 1.0}; 10 10 static double Ypt[] = {0.0, 0.0, 0.0, 0.5, 0.5, 1.0, 1.0, 1.0}; 11 12 double Rmin = +480.0; 13 double Rmax = -360.0; 14 double Dmin = +90.0; 15 double Dmax = -90.0; 16 17 int i; 18 for (i = 0; i < 8; i++) { 19 double R, D; 20 XY_to_RD (&R, &D, Xpt[i]*image->NX, Ypt[i]*image->NY, &image->coords); 21 22 // fprintf (stderr, "%f %f -> %f %f\n", Xpt[i]*image->NX, Ypt[i]*image->NY, R, D); 23 Rmin = MIN(R,Rmin); 24 Rmax = MAX(R,Rmax); 25 Dmin = MIN(D,Dmin); 26 Dmax = MAX(D,Dmax); 27 } 28 29 ALLOCATE (region, SkyRegion, 1); 30 31 region->Rmin = Rmin; 32 region->Rmax = Rmax; 33 region->Dmin = Dmin; 34 region->Dmax = Dmax; 35 36 // fprintf (stderr, "%f %f , %f %f\n", Rmin, Rmax, Dmin, Dmax); 37 38 return region; 39 } 40 41 SkyRegion *get_mosaic_patch (Image *image) { 42 43 SkyRegion *region; 44 45 // find the R,D coords of the 4 corners and 4 edge midpoints 46 47 static double Xpt[] = {-0.5, 0.0, 0.5, -0.5, 0.5, -0.5, 0.0, 0.5}; 48 static double Ypt[] = {-0.5, -0.5, -0.5, 0.0, 0.0, 0.5, 0.5, 0.5}; 11 49 12 50 double Rmin = +480.0; -
branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_stars.c
r37531 r37532 1 1 # include "fakeastro.h" 2 2 3 Stars *make_fake_stars (Catalog *catalog, int Ncatalog, SkyList *skylist, Image *image, int *nstars) {3 Stars *make_fake_stars (Catalog *catalog, int Ncatalog, SkyList *skylist, Image *image, Stars *stars, int *nstars) { 4 4 5 5 // patch is generous region around image, but limited ot this image … … 8 8 // fprintf (stderr, "image patch: %f %f , %f %f\n", imagePatch->Rmin, imagePatch->Rmax, imagePatch->Dmin, imagePatch->Dmax); 9 9 10 int Nstars = 0; 11 Stars *stars = NULL; 10 int Nstars = *nstars; 12 11 13 12 // load stars from database in these regions -
branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_stars_catalog.c
r37531 r37532 41 41 42 42 // XXX put in airmass? 43 float ZP = SCALE*code->C - image->Mcal + Mtime; 43 float ZP = SCALE*code->C - image->Mcal + Mtime; 44 float ZPo = 25.0 - image->Mcal + Mtime; 44 45 // float ZP = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 45 46 … … 74 75 75 76 // which filter? 77 // float Mraw = Minst + measure[0].dt + 25.0; 78 // float Minst = Msky - SCALE*code->C - measure[0].dt 79 76 80 double Minst = secfilt[i*Nsecfilt + Nsec].M - ZP; 77 81 double Counts = pow(10.0, -0.4*Minst); … … 80 84 double SN = Counts / sqrt(SkyCts + Counts); 81 85 86 // XXX skip stars with low S/N 87 if (SN < 5.0) continue; 88 82 89 // true position from src catalog 83 90 double Rtru = average[i].R; 84 91 double Dtru = average[i].D; 85 92 86 93 stars[Nstars].starpar = starpar[nStar]; // keep this so we can save it on the generated stars 87 94 … … 140 147 // stars[Nstars].measure.pltscale = ps1data[i].pltscale; 141 148 142 stars[Nstars].measure.M = Minst + ZP ; // XX I need to compensate for the internal zero point of 25.0149 stars[Nstars].measure.M = Minst + ZPo; // XX I need to compensate for the internal zero point of 25.0 143 150 stars[Nstars].measure.dM = 1.0 / SN; 144 151 … … 152 159 stars[Nstars].average.R = Robs; 153 160 stars[Nstars].average.D = Dobs; 161 162 stars[Nstars].measure.photcode = image->photcode; 154 163 155 164 stars[Nstars].measure.airmass = airmass (image->secz, stars[Nstars].average.R, stars[Nstars].average.D, image->sidtime, image->latitude); -
branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/match_fake_stars.c
r37527 r37532 1 1 # include "fakeastro.h" 2 2 3 // Image *image is only used to set the equiv photcode, which in turn is used to set Nsec, which 4 // is only used to set the average photometry, but is not really needed. 5 6 int match_fake_stars (Stars *stars, unsigned int NstarsIn, SkyRegion *region, Catalog *catalog, Image *image) { 3 int match_fake_stars (Stars *stars, unsigned int NstarsIn, SkyRegion *region, Catalog *catalog) { 7 4 8 5 off_t i, j, n, N, J, Jmin, status, Nstars; … … 16 13 17 14 int Nsecfilt = GetPhotcodeNsecfilt (); 18 19 // which equiv photcode are we?20 PhotCode *code = GetPhotcodebyCode (image->photcode);21 int Nsec = GetPhotcodeNsec (code->equiv);22 myAssert (Nsec >= 0, "undefined Nsec?");23 15 24 16 /** allocate local arrays (stars) **/ … … 197 189 } 198 190 199 /* set the average magnitude if not already set and the photcode.equiv is not 0 */200 /* in UPDATE mode, this value is not saved; use relphot to recalculate */201 if (Nsec > -1) {202 if (isnan(catalog[0].secfilt[n*Nsecfilt+Nsec].M)) {203 catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas], MAG_CLASS_PSF);204 }205 }206 207 191 /* Nm is updated, but not written out in -update mode (for existing entries) 208 192 Nm is recalculated in build_meas_links if loaded table is not sorted */ … … 265 249 catalog[0].measure[Nmeas].catID = catalog[0].catID; 266 250 267 /* set the average magnitude if not already set and the photcode.equiv is not 0 */268 /* XXX NOTE : this value is not saved; use relphot to recalculate */269 if (Nsec > -1) {270 catalog[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas], MAG_CLASS_PSF);271 }272 273 251 // supply the starpar values from this detection 274 252 dvo_starpar_init (&catalog[0].starpar[Nstarpar]); -
branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/save_fake_stars.c
r37523 r37532 1 1 # include "fakeastro.h" 2 2 3 int save_fake_stars (SkyTable *sky, Image * image, Stars *stars, int Nstars) {3 int save_fake_stars (SkyTable *sky, Image *mosaic, Stars *stars, int Nstars) { 4 4 5 5 Catalog catalog; 6 6 7 7 // patch is generous region around image, but limited to this image 8 SkyRegion * imagePatch = get_image_patch (image);8 SkyRegion *mosaicPatch = get_mosaic_patch (mosaic); 9 9 10 10 // list of regions which cover this image 11 SkyList *skylist = SkyListByPatch (sky, -1, imagePatch);11 SkyList *skylist = SkyListByPatch (sky, -1, mosaicPatch); 12 12 13 13 int Naverage = 0; … … 23 23 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 24 24 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 25 catalog.catflags = LOAD_AVES | LOAD_SECF | LOAD_MEAS | LOAD_STARPAR; 25 // catalog.catflags = LOAD_AVES | LOAD_SECF | LOAD_MEAS | LOAD_STARPAR; // use this for non-update mode 26 catalog.catflags = LOAD_AVES | LOAD_SECF | LOAD_STARPAR; 26 27 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 27 28 … … 32 33 } 33 34 34 match_fake_stars (stars, Nstars, skylist[0].regions[i], &catalog , image);35 match_fake_stars (stars, Nstars, skylist[0].regions[i], &catalog); 35 36 36 37 /* report total updated values */ … … 47 48 } 48 49 49 free ( imagePatch);50 free (mosaicPatch); 50 51 SkyListFree (skylist); 51 52 return TRUE;
Note:
See TracChangeset
for help on using the changeset viewer.
