IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37453


Ignore:
Timestamp:
Oct 2, 2014, 11:03:19 AM (12 years ago)
Author:
eugene
Message:

first working example of fakeastro

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

Legend:

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

    r37449 r37453  
    112112echo {$MAX / $dX^2}
    113113echo {3000 / 34}
     114echo {dsin(30+90)} {dcos(30)}
     115echo {dsin(30-90)} {-dcos(30)}
     116echo {dsin(30-90)} {-1*dcos(30)}
     117echo {dcos(30-90)} {dsin(30)}
     118echo {dcos(120-90)} {dsin(120)}
     119echo {dcos(-20-90)} {dsin(-20)}
     120echo {dcos(-20+90)} {dsin(-20)}
     121echo {dcos(30+90)} {dsin(30)}
     122echo {dcos(30+90)} {-1*dsin(30)}
     123echo {dcos(-20+90)} {-1*dsin(-20)}
     124!ps ux | grep fakes
     125!ps ux | grep fake
     126ll /proc/25713/fd/
     127!ll /proc/25713/fd/
     128!ll /proc/25713/fd/
     129!ll /proc/25713/fd/
     130!fhead /data/pikake.1/eugene/relastro.20140923/catdir.fake1/s3730.cpt
     131!ls -lrt /data/pikake.1/eugene/relastro.20140923/catdir.fake1/
     132!ls -lrt /data/pikake.1/eugene/relastro.20140923/catdir.fake1/
     133!ls -lrt /data/pikake.1/eugene/relastro.20140923/catdir.fake1/*.cpt
     134!ls -lrt /data/pikake.1/eugene/relastro.20140923/catdir.fake1/*.cpt
     135!ls -lrth /data/pikake.1/eugene/relastro.20140923/catdir.fake1/*.cpt
     136!ls -lrth /data/pikake.1/eugene/relastro.20140923/catdir.fake1/*.cp?
     137!ps ux | grep fake
     138kill 25713
     139!kill 25713
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/include/fakeastro.h

    r37449 r37453  
    3030char   CATDIR[DVO_MAX_PATH];
    3131char   SKY_TABLE[DVO_MAX_PATH];
     32char   MasterPhotcodeFile[DVO_MAX_PATH];
    3233
    3334char   CATMODE[16];    /* raw, mef, split, mysql */
     
    4647int    VERBOSE;
    4748int    VERBOSE2;
     49
     50int    FORCE;
    4851
    4952SkyRegion UserPatch;
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/ConfigInit.c

    r37449 r37453  
    55  char  *config, *file;
    66  char CatdirPhotcodeFile[256];
    7   struct stat filestat;
    8   int status;
    97
    108  /*** load configuration info ***/
     
    3028  ScanConfig(config, "CATMODE",                "%s",  0, CATMODE);
    3129  ScanConfig(config, "CATFORMAT",              "%s",  0, CATFORMAT);
     30  GetConfig (config, "PHOTCODE_FILE",          "%s",  0, MasterPhotcodeFile);
    3231
    3332  sprintf (ImageCat, "%s/Images.dat", CATDIR);
     
    3938  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
    4039
    41   // check for existence of CATDIR
    42   status = stat (CATDIR, &filestat);
    43   if (status == -1) {
    44     fprintf (stderr, "directory %s does not exist, giving up\n", CATDIR);
    45     exit (1);
    46   }
    47 
    4840  /* update master photcode table if not defined */
    4941  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    50   if (!LoadPhotcodes (CatdirPhotcodeFile, NULL, FALSE)) {
     42  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    5143    fprintf (stderr, "error loading photcode table %s\n", CatdirPhotcodeFile);
    5244    exit (1);
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/args.c

    r37449 r37453  
    8585  // }
    8686
     87  FORCE = FALSE;
     88  if ((N = get_argument (argc, argv, "-force"))) {
     89    FORCE = TRUE;
     90    remove_argument (N, &argc, argv);
     91  }
     92
    8793  VERBOSE = VERBOSE2 = FALSE;
    8894  if ((N = get_argument (argc, argv, "-v"))) {
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/fakeastro_galaxy.c

    r37449 r37453  
    44
    55  int n, i;
    6 
    7   // INITTIME;
    86
    97  // XXX check for an existing CATDIR and exit?
     
    1816  gauss_init (50000);
    1917
    20   int Nloop = 10;
    21   int Nstars = 1000000;
     18  int Nloop = 1;
     19  int Nstars = 2000000;
    2220
    2321  for (n = 0; n < Nloop; n++) {
    2422
     23    INITTIME;
     24
    2525    FakeAstro_Stars *stars = make_fakestars (Nstars);
     26
     27    MARKTIME ("generate %d fake stars in %f sec\n", Nstars, dtime);
    2628
    2729    // sort the stars by RA
    2830    sortStars (stars, Nstars);
     31
     32    MARKTIME ("sorted %d fake stars: %f sec\n", Nstars, dtime);
    2933
    3034    // scan through the stars, loading the containing catalogs
     
    4448      int Nsubset;
    4549      FakeAstro_Stars *subset = make_subset (stars, Nstars, i, region, &Nsubset);
     50      // MARKTIME ("subset %d fake stars: %f sec\n", Nsubset, dtime);
    4651
    4752      // In parallel mode, write out the subset to a disk file.  Block until a remote host
    4853      // is available.  In serial mode, just match against the appropriate region and save
    4954      save_fakestars (subset, Nsubset, hosts, region, skylist[0].filename[0]);
     55      // MARKTIME ("saved %d fake stars: %f sec\n", Nsubset, dtime);
     56
     57      free (subset);
     58      SkyListFree (skylist);
    5059    }
     60    free (stars);
     61
     62    MARKTIME ("saved %d fake stars: %f sec\n", Nstars, dtime);
    5163
    5264    // wait for last remote clients to finish
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/initialize.c

    r37449 r37453  
    11# include "fakeastro.h"
     2
     3void usage (void);
     4void usage_client (void);
    25
    36void initialize (int argc, char **argv) {
    47
     8  if (argc == 1) usage();
     9  if (get_argument (argc, argv, "-h")) usage();
     10  if (get_argument (argc, argv, "--h")) usage();
     11  if (get_argument (argc, argv, "-help")) usage();
     12  if (get_argument (argc, argv, "--help")) usage();
     13
    514  ConfigInit (&argc, argv);
    615  args (argc, argv);
     16
     17  // check for existence of CATDIR
     18  struct stat filestat;
     19  int status = stat (CATDIR, &filestat);
     20  if (!FORCE && (status == 0)) {
     21    fprintf (stderr, "directory %s exist, refusing to contaminate\n", CATDIR);
     22    exit (1);
     23  }
     24
    725}
    826
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/insert_fakestar.c

    r37449 r37453  
    1616
    1717  int Nsecfilt = catalog[0].Nsecfilt;
    18 
     18  NAVE = Nave = catalog[0].Naverage;
     19  NSTARPAR = Nstarpar = catalog[0].Nstarpar;
     20 
    1921  /** incorporate unmatched image stars? **/
    2022  for (i = 0; i < Nstars; i++) {
     
    5052    }
    5153
     54    // I need a photcode for r-band
     55    catalog[0].secfilt[Nave*Nsecfilt+1].M = stars[i].starpar.M_r + stars[i].starpar.DistMag;
     56
    5257    catalog[0].starpar[Nstarpar]        = stars[i].starpar;
    5358    catalog[0].starpar[Nstarpar].averef = Nave;
  • branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fakestars.c

    r37449 r37453  
    11# include "fakeastro.h"
    22
    3 # define Z_GAL 50.0
     3# define Z_GAL 500.0
    44# define R_GAL 2000.0
     5
     6static double iFkap = 1.0 / 4.74047; // (km/sec/kpc) / (milli-arcsec/ year)
     7static double A_oort = +14.5;  // km/sec/kpc
     8static double B_oort = -13.0;  // km/sec/kpc
     9
     10static double U_sol  =  9.44; // km/sec
     11static double V_sol  = 11.90; // km/sec
     12static double W_sol  =  7.20; // km/sec
    513
    614FakeAstro_Stars *make_fakestars (int Nstars) {
     
    1220  // but Greg Green / LSD use the older Reid et al 2004 (ApJ 616, 872) definition
    1321  CoordTransform *transform = InitTransform (COORD_GALACTIC, COORD_CELESTIAL);
     22  CoordTransform *transback = InitTransform (COORD_CELESTIAL, COORD_GALACTIC);
    1423
    1524  int i;
     
    2837    double z = rnd_gauss (0.0, Z_GAL);
    2938    double r = sqrt(drand48()) * R_GAL;
    30     double L = drand48() * 2 * M_PI;
    31 
    32     double distance = sqrt (SQ(r) + SQ(z));
    33     double B = atan2(z,r);
     39    double Lrad = drand48() * 2 * M_PI;
    3440
    3541    // double x = r*cos(L);
    3642    // double y = r*sin(L);
     43
     44    double distance = sqrt (SQ(r) + SQ(z));
     45    double Brad = atan2(z,r);
     46
     47    double uL_gal = (A_oort * cos(2.0*Lrad) + B_oort) * cos(Brad) * iFkap;
     48    double uB_gal = -0.5*A_oort * sin(2.0*Lrad) * sin(2.0*Brad) * iFkap;
     49
     50    double uL_sol =  (U_sol * sin(Lrad) - V_sol * cos(Lrad))                              * iFkap / distance;
     51    double uB_sol = ((U_sol * cos(Lrad) + V_sol * sin(Lrad))*sin(Brad) - W_sol*cos(Brad)) * iFkap / distance;
     52
     53    double uL = uL_gal + uL_sol;
     54    double uB = uB_gal + uB_sol;
    3755
    3856    // crude Mr distribution from
     
    4159    double Mr = rnd_gauss (11.25, 1.0);
    4260   
     61    double L = Lrad*DEG_RAD;
     62    double B = Brad*DEG_RAD;
     63
    4364    double R, D;
    4465    ApplyTransform (&R, &D, L, B, transform);
    4566 
    46     stars[Nstars].R = R;
    47     stars[Nstars].D = D;
    48     stars[Nstars].flag  = FALSE;
    49     stars[Nstars].found = FALSE;
     67    // C1, C2 are from http://arxiv.org/pdf/1306.2945v2.pdf
     68    double Rrad = R*RAD_DEG;
     69    double Drad = D*RAD_DEG;
    5070
    51     stars[Nstars].starpar.galLon = L;
    52     stars[Nstars].starpar.galLat = B;
     71    double C1 =
     72      cos(Drad)*transback->cos_phi +
     73      sin(Drad)*cos(Rrad)*transback->sin_phi_sin_Xo -
     74      sin(Drad)*sin(Rrad)*transback->sin_phi_cos_Xo;
    5375
    54     stars[Nstars].starpar.Ebv      = 0.0;
    55     stars[Nstars].starpar.dEbv     = 0.0;
    56     stars[Nstars].starpar.DistMag  = 5.0*log10(distance) - 5.0;
    57     stars[Nstars].starpar.dDistMag = 0.0;
    58     stars[Nstars].starpar.M_r      = Mr;
    59     stars[Nstars].starpar.dM_r     = 0.0;
    60     stars[Nstars].starpar.FeH      = 0.0;
    61     stars[Nstars].starpar.dFeH     = 0.0;
     76    double C2 =
     77      - cos(Rrad)*transback->sin_phi_cos_Xo
     78      - sin(Rrad)*transback->sin_phi_sin_Xo;
    6279
    63     Nstars ++;
     80    double cosBinv = 1.0 / sqrt(C1*C1 + C2*C2);
     81
     82    // XXX add errors : I need to be able to choose the stars based on the error distribution
     83    double uR = cosBinv * (C1 * uL - C2 * uB);
     84    double uD = cosBinv * (C1 * uB + C2 * uL);
     85
     86    stars[i].R = R;
     87    stars[i].D = D;
     88    stars[i].flag  = FALSE;
     89    stars[i].found = FALSE;
     90
     91    stars[i].starpar.galLon = L;
     92    stars[i].starpar.galLat = B;
     93
     94    stars[i].starpar.Ebv      = 0.0;
     95    stars[i].starpar.dEbv     = 0.0;
     96    stars[i].starpar.DistMag  = 5.0*log10(distance) - 5.0;
     97    stars[i].starpar.dDistMag = 0.0;
     98    stars[i].starpar.M_r      = Mr;
     99    stars[i].starpar.dM_r     = 0.0;
     100    stars[i].starpar.FeH      = 0.0;
     101    stars[i].starpar.dFeH     = 0.0;
     102
     103    stars[i].starpar.uRA  = uR;
     104    stars[i].starpar.uDEC = uD;
    64105  }
    65106  return stars;
Note: See TracChangeset for help on using the changeset viewer.