IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36975


Ignore:
Timestamp:
Jul 7, 2014, 10:48:43 AM (12 years ago)
Author:
eugene
Message:

photcode.astrom,photom masks need to be unsigned int or we get invalid conversions when using strtol (on 32 bit only?); change secfilt.Xm to secfilt.Mchisq for formats which use a float representation for that field; store the real chisq, not the log10 recast version; correct zero point for conversion from instrumental flux to Jy

Location:
branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/LoadPhotcodesText.c

    r36908 r36975  
    142142    photcode[Ncode].photomErrSys      = atof (photomErrSys);
    143143
    144     photcode[Ncode].astromPoorMask    = strtol (astromPoorMask, NULL, 0);
    145     photcode[Ncode].astromBadMask     = strtol (astromBadMask, NULL, 0);
    146     photcode[Ncode].photomPoorMask    = strtol (photomPoorMask, NULL, 0);
    147     photcode[Ncode].photomBadMask     = strtol (photomBadMask, NULL, 0);
     144    photcode[Ncode].astromPoorMask    = strtoll (astromPoorMask, NULL, 0);
     145    photcode[Ncode].astromBadMask     = strtoll (astromBadMask, NULL, 0);
     146    photcode[Ncode].photomPoorMask    = strtoll (photomPoorMask, NULL, 0);
     147    photcode[Ncode].photomBadMask     = strtoll (photomBadMask, NULL, 0);
    148148
    149149    switch (photcode[Ncode].type) {
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_catalog.c

    r36946 r36975  
    174174  secfilt->Mmin        = NAN;
    175175  secfilt->Mmax        = NAN;
    176   secfilt->Xm          = NAN;
     176  secfilt->Mchisq      = NAN;
    177177
    178178  secfilt->Ncode       = 0;
     
    770770    for (in = out = i = 0; i < catalog[0].Naverage; i++) {
    771771      for (j = 0; j < catalog[0].Nsecfilt; j++, in++, out++) {
    772         outsec[out].M  = insec[in].M;
    773         outsec[out].dM = insec[in].dM;
    774         outsec[out].Xm = insec[in].Xm;
     772        outsec[out].M      = insec[in].M;
     773        outsec[out].dM     = insec[in].dM;
     774        outsec[out].Mchisq = insec[in].Mchisq;
    775775      }
    776776      for (j = 0; j < Nextra; j++, out++) {
    777         outsec[out].M  = NAN;
    778         outsec[out].dM = NAN;
    779         outsec[out].Xm = NAN_S_SHORT;
     777        outsec[out].M      = NAN;
     778        outsec[out].dM     = NAN;
     779        outsec[out].Mchisq = NAN;
    780780      }
    781781    }
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c

    r36898 r36975  
    184184    out[i].M     = in[i].M;     
    185185    out[i].dM    = in[i].dM;     
    186     out[i].Xm    = in[i].Xm;     
     186    out[i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
    187187    out[i].Ncode = in[i].Ncode;
    188188    out[i].Nused = in[i].Nused;
     
    201201    out[i].M     = in[i].M;     
    202202    out[i].dM    = in[i].dM;     
    203     out[i].Xm    = in[i].Xm;     
     203    out[i].Xm    = 100.0*log10(in[i].Mchisq);     
    204204    out[i].Ncode = in[i].Ncode;
    205205    out[i].Nused = in[i].Nused;
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c

    r36898 r36975  
    179179    out[i].M     = in[i].M;     
    180180    out[i].dM    = in[i].dM;     
    181     out[i].Xm    = in[i].Xm;     
     181    out[i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
    182182    out[i].Ncode = in[i].Ncode;
    183183    out[i].Nused = in[i].Nused;
     
    196196    out[i].M     = in[i].M;     
    197197    out[i].dM    = in[i].dM;     
    198     out[i].Xm    = in[i].Xm;     
     198    out[i].Xm    = 100.0*log10(in[i].Mchisq);     
    199199    out[i].Ncode = in[i].Ncode;
    200200    out[i].Nused = in[i].Nused;
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c

    r36898 r36975  
    199199    out[i].M     = in[i].M;     
    200200    out[i].dM    = in[i].dM;     
    201     out[i].Xm    = in[i].Xm;     
     201    out[i].Mchisq= in[i].Mchisq;     
    202202    out[i].Ncode = in[i].Ncode;
    203203    out[i].Nused = in[i].Nused;
     
    218218    out[i].M     = in[i].M;     
    219219    out[i].dM    = in[i].dM;     
    220     out[i].Xm    = in[i].Xm;     
     220    out[i].Mchisq= in[i].Mchisq;     
    221221    out[i].Ncode = in[i].Ncode;
    222222    out[i].Nused = in[i].Nused;
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c

    r36898 r36975  
    208208    out[i].M     = in[i].M;     
    209209    out[i].dM    = in[i].dM;     
    210     out[i].Xm    = in[i].Xm;     
     210    out[i].Mchisq= in[i].Mchisq;     
    211211    out[i].flags = in[i].flags;     
    212212    out[i].Ncode = in[i].Ncode;
     
    228228    out[i].M     = in[i].M;     
    229229    out[i].dM    = in[i].dM;     
    230     out[i].Xm    = in[i].Xm;     
     230    out[i].Mchisq= in[i].Mchisq;     
    231231    out[i].flags = in[i].flags;     
    232232    out[i].Ncode = in[i].Ncode;
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c

    r36898 r36975  
    213213    out[i].Map         = in[i].Map;     
    214214    out[i].dM          = in[i].dM;     
    215     out[i].Xm          = in[i].Xm;     
     215    out[i].Mchisq      = in[i].Mchisq;     
    216216    out[i].flags       = in[i].flags;     
    217217    out[i].Ncode       = in[i].Ncode;
     
    236236    out[i].Map         = in[i].Map;     
    237237    out[i].dM          = in[i].dM;     
    238     out[i].Xm          = in[i].Xm;     
     238    out[i].Mchisq      = in[i].Mchisq;     
    239239    out[i].flags       = in[i].flags;     
    240240    out[i].Ncode       = in[i].Ncode;
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c

    r36898 r36975  
    239239    out[i].dMkron        = in[i].dMkron;     
    240240    out[i].dM            = in[i].dM;     
    241     out[i].Xm            = in[i].Xm;     
     241    out[i].Mchisq        = in[i].Mchisq;     
    242242    out[i].FpsfStk       = in[i].FluxPSF;
    243243    out[i].dFpsfStk      = in[i].dFluxPSF;
     
    269269    out[i].dMkron        = in[i].dMkron;     
    270270    out[i].dM            = in[i].dM;     
    271     out[i].Xm            = in[i].Xm;     
     271    out[i].Mchisq        = in[i].Mchisq;
    272272    out[i].FluxPSF       = in[i].FpsfStk;
    273273    out[i].dFluxPSF      = in[i].dFpsfStk;
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c

    r36921 r36975  
    292292    out[i].Mmin          = in[i].Mmin;     
    293293    out[i].Mmax          = in[i].Mmax;     
    294     out[i].Xm            = in[i].Xm;     
     294    out[i].Mchisq        = in[i].Mchisq;     
    295295
    296296    out[i].Ncode         = in[i].Ncode;
     
    360360    out[i].Mmin          = in[i].Mmin;     
    361361    out[i].Mmax          = in[i].Mmax;     
    362     out[i].Xm            = in[i].Xm;     
     362    out[i].Mchisq        = in[i].Mchisq;     
    363363
    364364    out[i].Ncode         = in[i].Ncode;
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert_elixir.c

    r36898 r36975  
    111111    primary[0][i].M     = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M  * 0.001;     
    112112    primary[0][i].dM    = (in[i].dM == NAN_S_SHORT) ? NAN : in[i].dM * 0.001;     
    113     primary[0][i].Xm    = in[i].Xm;     
     113    primary[0][i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
    114114
    115115    // added for PANSTARRS_DEV_0
     
    144144    out[i].M       = isnan(primary[i].M)  ? NAN_S_SHORT : primary[i].M   * 1000.0;
    145145    out[i].dM      = isnan(primary[i].dM) ? NAN_S_SHORT : primary[i].dM  * 1000.0;
    146     out[i].Xm      = primary[i].Xm;     
     146    out[i].Xm      = 100.0*log10(primary[i].Mchisq);     
    147147
    148148    // changed or added for PS1_DEV_2
     
    169169    dvo_secfilt_init (&out[i]);
    170170
    171     out[i].Xm    = in[i].Xm;     
     171    out[i].Mchisq = pow (10.0, 0.01*in[i].Xm);     
    172172
    173173    // added or changed for PANSTARRS_DEV_0
     
    187187
    188188  for (i = 0; i < Nvalues; i++) {
    189     out[i].Xm    = in[i].Xm;     
     189    out[i].Xm    = 100.0*log10(in[i].Mchisq);     
    190190
    191191    // added or changed for PANSTARRS_DEV_0
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert_loneos.c

    r36898 r36975  
    9090    // changed for PANSTARRS_DEV_0 (moved from Average to Measure)
    9191    primary[0][i].M     = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M  * 0.001;     
    92     primary[0][i].Xm    = in[i].Xm;     
     92    primary[0][i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
    9393
    9494    // added for PANSTARRS_DEV_0
     
    124124    // changed for PANSTARRS_DEV_0 (moved from Average to Measure)
    125125    out[i].M       = isnan(primary[i].M)  ? NAN_S_SHORT : primary[i].M   * 1000.0;
    126     out[i].Xm      = primary[i].Xm;     
     126    out[i].Xm      = 100.0*log10(primary[i].Mchisq);     
    127127
    128128    // changed or added for PS1_DEV_2
     
    149149    dvo_secfilt_init (&out[i]);
    150150
    151     out[i].Xm    = in[i].Xm;      
     151    out[i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
    152152
    153153    // added or changed for PANSTARRS_DEV_0
     
    166166
    167167  for (i = 0; i < Nvalues; i++) {
    168     out[i].Xm   = in[i].Xm;     
     168    out[i].Xm   = 100.0*log10(in[i].Mchisq);     
    169169
    170170    // added or changed for PANSTARRS_DEV_0
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c

    r36898 r36975  
    188188    out[i].M     = in[i].M;     
    189189    out[i].dM    = in[i].dM;     
    190     out[i].Xm    = in[i].Xm;     
     190    out[i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
    191191    out[i].Ncode = in[i].Ncode;
    192192    out[i].Nused = in[i].Nused;
     
    206206    out[i].M     = in[i].M;     
    207207    out[i].dM    = in[i].dM;     
    208     out[i].Xm    = in[i].Xm;     
     208    out[i].Xm    = 100.0*log10(in[i].Mchisq);     
    209209    out[i].Ncode = in[i].Ncode;
    210210    out[i].Nused = in[i].Nused;
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c

    r36898 r36975  
    188188    out[i].M     = in[i].M;     
    189189    out[i].dM    = in[i].dM;     
    190     out[i].Xm    = in[i].Xm;     
     190    out[i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
    191191    out[i].Ncode = in[i].Ncode;
    192192    out[i].Nused = in[i].Nused;
     
    206206    out[i].M     = in[i].M;     
    207207    out[i].dM    = in[i].dM;     
    208     out[i].Xm    = in[i].Xm;     
     208    out[i].Xm    = 100.0*log10(in[i].Mchisq);     
    209209    out[i].Ncode = in[i].Ncode;
    210210    out[i].Nused = in[i].Nused;
  • branches/eam_branches/ipp-20140610/Ohana/src/libdvo/src/dvo_photcode_ops.c

    r36912 r36975  
    795795}
    796796
    797 // XXX return NAN or NAN_S_SHORT? (secfilt->Xm is short)
     797// Xm is now (2014.07.03) stored as the chisq except in dvo formats which use as short
    798798float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt) {
    799799
    800800  int Ns;
    801   short Mi;
    802801  float Xm;
    803802
     
    805804
    806805  Ns = photcodes[0].hashNsec[code[0].code];
    807   Mi = (Ns == -1) ? NAN : secfilt[Ns].Xm;
    808   Xm = (isnan(Mi)) ? -1.0 : pow (10.0, 0.01*Mi);
     806  Xm = (Ns == -1) ? NAN : secfilt[Ns].Mchisq;
    809807  return (Xm);
    810808}
     
    889887  PhotCode *code = &photcodes[0].code[Np];
    890888
     889  // mag_AB = -2.5 log (flux_cgs) - 48.6 (by definition) [~Vega flux in V-band]
     890  // flux_Jy = flux_cgs * 10^23
     891  // -2.5 log (flux_cgs) = -2.5 log (flux_Jy * 10^-23) = -2.5 log (flux_Jy) + 2.5*23
     892
     893  // from these we get:
     894  // mag_AB = -2.5 log (flux_Jy) + 8.9
     895  // log (flux_Jy) = -0.4*mag_AB + 3.56
     896
     897  // mag_AB = mag_inst + ZP
     898
     899  // log(flux_Jy) = -0.4*mag_inst -0.4*ZP + 3.56
     900  // mag_inst = -2.5 log (flux_Jy) - ZP + 8.9
     901
     902  // log (flux_Jy) = -0.4*(mag_inst + ZP - 8.9)
     903
     904  // -2.5 log (flux_inst) = -2.5 log (flux_Jy) - ZP + 8.9
     905  // log (flux_inst) = log (flux_Jy) + 0.4 ZP - 3.56
     906  // flux_inst = flux_Jy * 10^(0.4*ZP - 3.56)
     907  // flux_Jy = flux_inst * 10^(3.56 - 0.4*ZP) = flux_inst * zpFactor
     908  // flux_Jy = flux_inst * 3630.8 * 10^(-0.4*ZP)
     909
    891910  // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux
    892911  float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;
    893   float Moff = Mcal - ZERO_POINT;
    894   float Foff = MagToFlux(Mcal);
     912  float Moff = Mcal - ZERO_POINT + 8.9;
     913  float Foff = 3630.8 * MagToFlux(Mcal);
    895914  float Fcat = NAN;
    896915  switch (class) {
     
    919938  // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux
    920939  float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;
    921   float Moff = Mcal - ZERO_POINT;
    922   float Foff = MagToFlux(Mcal);
     940  float Moff = Mcal - ZERO_POINT + 8.9;
     941  float Foff = 3630.8 * MagToFlux(Mcal);
    923942  float Fcat = NAN;
    924943  switch (class) {
     
    964983  // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux
    965984  float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal;
    966   float Moff = Mcal - ZERO_POINT;
    967   float Foff = MagToFlux(Mcal);
     985  float Moff = Mcal - ZERO_POINT + 8.9;
     986  float Foff = 3630.8 * MagToFlux(Mcal);
    968987  float Fcat = NAN;
    969988  switch (class) {
     
    11681187  // measure.M has the static ZERO_POINT (25.0) applied, but not measure.Flux
    11691188  float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;
    1170   float Moff = Mcal - ZERO_POINT;
    1171   float Foff = MagToFlux(Mcal);
     1189  float Moff = Mcal - ZERO_POINT + 8.9;
     1190  float Foff = 3630.8 * MagToFlux(Mcal);
    11721191
    11731192  // use dFlux if we can, but use dMag if we must:
     
    15441563}
    15451564
    1546 // XXX return NAN or NAN_S_SHORT? (secfilt->Xm is short)
     1565// Xm is now (2014.07.03) stored as the chisq except in dvo formats which use as short
    15471566float PhotXmTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) {
    15481567
    15491568  int Ns;
    1550   short Mi;
    15511569  float Xm;
    15521570
     
    15541572
    15551573  Ns = photcodes[0].hashNsec[code[0].code];
    1556   Mi = (Ns == -1) ? NAN : secfilt[Ns].Xm;
    1557   Xm = (isnan(Mi)) ? -1.0 : pow (10.0, 0.01*Mi);
     1574  Xm = (Ns == -1) ? NAN : secfilt[Ns].Mchisq;
    15581575  return (Xm);
    15591576}
Note: See TracChangeset for help on using the changeset viewer.