IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36906


Ignore:
Timestamp:
Jun 18, 2014, 9:43:19 PM (12 years ago)
Author:
eugene
Message:

add PS1_V5 to mkcmf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140610/Ohana/src/addstar/src/mkcmf.c

    r35760 r36906  
    11# include "mkcmf.h"
    22
     3# define ZERO_POINT 25.0
    34# define SKY 100.0
    45# define DSKY 2.0
     
    1415void gauss_init (int Nbin);
    1516double rnd_gauss (double mean, double sigma);
     17void writeStars_PS1_V5 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars);
    1618void writeStars_PS1_V4 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars);
    1719void writeStars_PS1_V3 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars);
     
    2426float BAD_PSFQF_FRAC = 0.0;
    2527
     28static float exptime = 1.0;
     29static Coords coords;
     30
    2631int main (int argc, char **argv) {
    2732
     
    3843  Matrix matrix;
    3944  FTable ftable;
    40   Coords coords;
    4145
    4246  int APPEND = FALSE;
     
    105109  }
    106110
    107   float exptime = 1.0;
    108111  if ((N = get_argument (argc, argv, "-exptime"))) {
    109112    remove_argument (N, &argc, argv);
     
    288291    gfits_modify (&header, "UTC-OBS",  "%s", 1, time);
    289292  }
    290   gfits_modify (&header, "ZERO_PT", "%lf", 1, 25.0);
     293  gfits_modify (&header, "ZERO_PT", "%lf", 1, ZERO_POINT);
    291294  gfits_modify (&header, "EXPTIME", "%lf", 1, exptime);
    292295  gfits_modify (&header, "AIRMASS", "%lf", 1, airmass);
     
    327330  if (!strcmp(type, "PS1_V4")) {
    328331    writeStars_PS1_V4 (&ftable, X, Y, M, Flag, Nstars);
     332    found = TRUE;
     333  }
     334  if (!strcmp(type, "PS1_V5")) {
     335    writeStars_PS1_V5 (&ftable, X, Y, M, Flag, Nstars);
    329336    found = TRUE;
    330337  }
     
    764771}
    765772
     773void writeStars_PS1_V5 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars) {
     774
     775  int i;
     776  CMF_PS1_V5 *stars;
     777  float flux, fSN;
     778
     779  // XXX add gaussian-distributed noise based on counts
     780  // this needs to make different output 'stars' entries depending on the desired type
     781  ALLOCATE (stars, CMF_PS1_V5, Nstars);
     782  for (i = 0; i < Nstars; i++) {
     783
     784    flux = pow (10.0, -0.4*M[i]);
     785    fSN = 1.0 / sqrt(flux);
     786
     787    stars[i].detID = i;
     788    stars[i].X = X[i];
     789    stars[i].Y = Y[i];
     790    stars[i].dX = FX * fSN;
     791    stars[i].dY = FY * fSN;
     792
     793    stars[i].posangle = 10.0;
     794    stars[i].pltscale = 0.25;
     795
     796    stars[i].M = M[i];
     797    stars[i].dM = fSN;
     798
     799    stars[i].Flux = flux;
     800    stars[i].dFlux = flux * fSN;
     801
     802    stars[i].Map = M[i] - 0.05;
     803    stars[i].MapRaw = M[i] - 0.10;
     804
     805    stars[i].apRadius = 8.0;
     806
     807    stars[i].apFlux = pow(10.0, -0.4*stars[i].Map);
     808    stars[i].apFluxErr = stars[i].apFlux * fSN;
     809
     810    stars[i].Mcalib = M[i] + ZERO_POINT + 2.5*log10(exptime);
     811    stars[i].dMcal = 0.05;
     812
     813    stars[i].dMcal = 0.05;
     814
     815    XY_to_RD (&stars[i].RA, &stars[i].DEC, X[i], Y[i], &coords);
     816    stars[i].apNpix = 3.14*8.0*8.0;
     817
     818    stars[i].Mpeak     = M[i] + 1.0;
     819    stars[i].sky       = SKY;
     820    stars[i].dSky      = DSKY;
     821    stars[i].psfChisq  = PSFCHI;
     822    stars[i].crNsigma  = CRN;
     823    stars[i].extNsigma = EXTN;
     824    stars[i].fx        = FX;
     825    stars[i].fy        = FY;
     826    stars[i].df        = DF;
     827
     828    stars[i].k         = 1.0;
     829    stars[i].fwhmMaj   = FX*2.8;
     830    stars[i].fwhmMin   = FY*2.8;
     831
     832    // randomly give poor PSFQF values
     833    if ((BAD_PSFQF_FRAC > 0.0) && (drand48() < BAD_PSFQF_FRAC)) {
     834      stars[i].psfQF     = 0.25;
     835      stars[i].psfQFperf = 0.24;
     836    } else {
     837      stars[i].psfQF     = PSFQUAL;
     838      stars[i].psfQFperf = MAX(PSFQUAL - 0.01, 0.0);
     839    }
     840
     841    stars[i].psfNdof   = 1;
     842    stars[i].psfNpix   = 2;
     843
     844    stars[i].Mxx       = FX;
     845    stars[i].Mxy       = 0.01;
     846    stars[i].Myy       = FX;
     847    stars[i].M3c       = FX;
     848    stars[i].M3s       = FX;
     849    stars[i].M4c       = FX;
     850    stars[i].M4s       = FX;
     851    stars[i].Mr1       = FX;
     852    stars[i].Mrh       = FX;
     853
     854    stars[i].kronFlux  = flux * 1.25;
     855    stars[i].kronFluxErr = fSN * flux * 1.25;
     856
     857    stars[i].kronInner = fSN * flux * 0.9;
     858    stars[i].kronOuter = fSN * flux * 1.5;
     859
     860    stars[i].skyLimitRad = 1;
     861    stars[i].skyLimitFlux = 2;
     862    stars[i].skyLimitSlope = 0.2;
     863
     864    stars[i].flags     = Flag[i];
     865    stars[i].flags2    = 0x80;
     866
     867    stars[i].nFrames   = 1;
     868
     869    if (ADDNOISE) {
     870      stars[i].X += FX * fSN * rnd_gauss(0.0, 1.0);
     871      stars[i].Y += FY * fSN * rnd_gauss(0.0, 1.0);
     872      stars[i].M += fSN*rnd_gauss(0.0, 1.0);
     873    }
     874  }
     875
     876  gfits_table_set_CMF_PS1_V5 (ftable, stars, Nstars);
     877  gfits_modify (ftable->header, "EXTTYPE",   "%s", 1, "PS1_V5");
     878}
     879
Note: See TracChangeset for help on using the changeset viewer.