IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37532


Ignore:
Timestamp:
Oct 27, 2014, 5:56:01 PM (12 years ago)
Author:
eugene
Message:

fakeastro is generating sensible stars at reasonable speeds

Location:
branches/eam_branches/ipp-20140904/Ohana/src/fakeastro
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/include/fakeastro.h

    r37523 r37532  
    155155
    156156SkyRegion *get_image_patch (Image *image);
     157SkyRegion *get_mosaic_patch (Image *image);
     158
    157159int SkyRegionsOverlap (SkyRegion *region, SkyRegion *patch);
    158160int SkyRegionHasPoint (SkyRegion *region, double R, double D);
     
    161163Catalog *load_fake_stars (SkyList *skylist, int *ncatalog);
    162164
    163 Stars *make_fake_stars (Catalog *catalog, int Ncatalog, SkyList *skylist, Image *image, int *nstars);
     165Stars *make_fake_stars (Catalog *catalog, int Ncatalog, SkyList *skylist, Image *image, Stars *stars, int *nstars);
    164166Stars *make_fake_stars_catalog (Stars *stars, int *nstars, SkyRegion *patch, Catalog *catalog, Image *image);
    165167
    166168int 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);
     169int match_fake_stars (Stars *stars, unsigned int NstarsIn, SkyRegion *region, Catalog *catalog);
    168170
    169171int InitStar (Stars *star);
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/fakeastro_images.c

    r37477 r37532  
    44
    55int fakeastro_images () {
     6
     7  INITTIME;
    68
    79  FITS_DB dbfake, dbtrue;
     
    3739  save_image_db (&dbfake, imageInfo.fakeImage, imageInfo.NfakeImage);
    3840  save_image_db (&dbtrue, imageInfo.trueImage, imageInfo.NtrueImage);
     41
     42  MARKTIME ("generate fake stars in %f sec\n", dtime)
    3943
    4044  exit (0);
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/fakeastro_images_region.c

    r37477 r37532  
    4040    }
    4141
     42    int NfakeStars = 0;
     43    Stars *fakeStars = NULL;
     44
    4245    for (j = 0; j < NfakeImage; j++) {
    4346
     
    4548      if (strcmp(&fakeImage[j].coords.ctype[4], "-WRP")) continue;
    4649
    47       int NfakeStars;
    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);
    4952     
    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]);
    5155
    52       save_fake_stars (skyTableOutput, &fakeImage[j], fakeStars, NfakeStars);
    53 
    54       free (fakeStars);
     56      fprintf (stderr, "%s : %d\n", fakeImage[j].name, NfakeStars - Nstart);
    5557    }
     58    // send in just the PHU image for reference
     59    save_fake_stars (skyTableOutput, &fakeImage[0], fakeStars, NfakeStars);
     60    free (fakeStars);
    5661
    5762    // 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  
    99  static double Xpt[] = {0.0, 0.5, 1.0, 0.0, 1.0, 0.0, 0.5, 1.0};
    1010  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
     41SkyRegion *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};
    1149
    1250  double Rmin = +480.0;
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_stars.c

    r37531 r37532  
    11# include "fakeastro.h"
    22
    3 Stars *make_fake_stars (Catalog *catalog, int Ncatalog, SkyList *skylist, Image *image, int *nstars) {
     3Stars *make_fake_stars (Catalog *catalog, int Ncatalog, SkyList *skylist, Image *image, Stars *stars, int *nstars) {
    44
    55  // patch is generous region around image, but limited ot this image
     
    88  // fprintf (stderr, "image patch: %f %f , %f %f\n", imagePatch->Rmin, imagePatch->Rmax, imagePatch->Dmin, imagePatch->Dmax);
    99
    10   int Nstars = 0;
    11   Stars *stars = NULL;
     10  int Nstars = *nstars;
    1211
    1312  // load stars from database in these regions
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_stars_catalog.c

    r37531 r37532  
    4141
    4242  // 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;
    4445  // float ZP = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal;
    4546 
     
    7475
    7576    // which filter?
     77    // float Mraw = Minst + measure[0].dt + 25.0;
     78    // float Minst = Msky - SCALE*code->C - measure[0].dt
     79
    7680    double Minst = secfilt[i*Nsecfilt + Nsec].M  - ZP;
    7781    double Counts = pow(10.0, -0.4*Minst);
     
    8084    double SN = Counts / sqrt(SkyCts + Counts);
    8185
     86    // XXX skip stars with low S/N
     87    if (SN < 5.0) continue;
     88
    8289    // true position from src catalog
    8390    double Rtru = average[i].R;
    8491    double Dtru = average[i].D;
    85 
     92   
    8693    stars[Nstars].starpar = starpar[nStar]; // keep this so we can save it on the generated stars
    8794
     
    140147    // stars[Nstars].measure.pltscale   = ps1data[i].pltscale;
    141148
    142     stars[Nstars].measure.M      = Minst + ZP; // XX I need to compensate for the internal zero point of 25.0
     149    stars[Nstars].measure.M      = Minst + ZPo; // XX I need to compensate for the internal zero point of 25.0
    143150    stars[Nstars].measure.dM     = 1.0 / SN;
    144151
     
    152159    stars[Nstars].average.R = Robs;
    153160    stars[Nstars].average.D = Dobs;
     161
     162    stars[Nstars].measure.photcode = image->photcode;
    154163
    155164    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  
    11# include "fakeastro.h"
    22
    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) {
     3int match_fake_stars (Stars *stars, unsigned int NstarsIn, SkyRegion *region, Catalog *catalog) {
    74 
    85  off_t i, j, n, N, J, Jmin, status, Nstars;
     
    1613
    1714  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?");
    2315
    2416  /** allocate local arrays (stars) **/
     
    197189    }
    198190
    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 
    207191    /* Nm is updated, but not written out in -update mode (for existing entries)
    208192       Nm is recalculated in build_meas_links if loaded table is not sorted */
     
    265249    catalog[0].measure[Nmeas].catID    = catalog[0].catID;
    266250
    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    
    273251    // supply the starpar values from this detection
    274252    dvo_starpar_init (&catalog[0].starpar[Nstarpar]);
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/save_fake_stars.c

    r37523 r37532  
    11# include "fakeastro.h"
    22
    3 int save_fake_stars (SkyTable *sky, Image *image, Stars *stars, int Nstars) {
     3int save_fake_stars (SkyTable *sky, Image *mosaic, Stars *stars, int Nstars) {
    44
    55  Catalog catalog;
    66
    77  // 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);
    99
    1010  // list of regions which cover this image
    11   SkyList *skylist = SkyListByPatch (sky, -1, imagePatch);
     11  SkyList *skylist = SkyListByPatch (sky, -1, mosaicPatch);
    1212
    1313  int Naverage = 0;
     
    2323    catalog.catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
    2424    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;
    2627    catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
    2728
     
    3233    }
    3334
    34     match_fake_stars (stars, Nstars, skylist[0].regions[i], &catalog, image);
     35    match_fake_stars (stars, Nstars, skylist[0].regions[i], &catalog);
    3536
    3637    /* report total updated values */
     
    4748  }
    4849
    49   free (imagePatch);
     50  free (mosaicPatch);
    5051  SkyListFree (skylist);
    5152  return TRUE;
Note: See TracChangeset for help on using the changeset viewer.