IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34439 for trunk


Ignore:
Timestamp:
Sep 13, 2012, 9:54:08 AM (14 years ago)
Author:
Serge CHASTEL
Message:

SEEING is the median of seeing of each skycell

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppTranslate/src/ppMopsWrite.c

    r34438 r34439  
    4545    if (detections->data[d] != NULL) {
    4646      if (det == NULL) {
    47         det = detections->data[d];
    48       }
    49       if (isfinite(detections->data[d]->seeing)) {
    50         validSeeingCount += 1;
     47        det = detections->data[d];
     48      }
     49      if (isfinite(((ppMopsDetections*) detections->data[d])->seeing)) {
     50        validSeeingCount += 1;
    5151      }
    5252    }
     
    5454  if (det != NULL) {
    5555    //Get the SEEING median
    56     seeingValues = psVectorAlloc(validSeeingCount, PS_TYPE_F32);
    57     psVectorInit(validSeeingCount, NAN);
     56    psVector* seeingValues = psVectorAlloc(validSeeingCount, PS_TYPE_F32);
     57    psVectorInit(seeingValues, NAN);
    5858    validSeeingCount = 0;
    5959    for (int d = 0; d < detections->n; d++) {
    60       if ( (detections->data[d] != NULL) && (isfinite(detections->data[d]->seeing)) ){
    61         seeingValues->data.F32[validSeeingCount++] = detections->data[d]->seeing;
     60      if ( (detections->data[d] != NULL) && (isfinite(((ppMopsDetections*) detections->data[d])->seeing)) ){
     61        seeingValues->data.F32[validSeeingCount++] = ((ppMopsDetections*) detections->data[d])->seeing;
    6262      }
    6363    }
     
    133133      // Write data of version 2 (see ICD)
    134134      psMetadataAdd (row, PS_LIST_TAIL, "IPP_IDET",         PS_DATA_U32, "IPP detection identifier index",
    135                      NAN);
     135                     NAN);
    136136      psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX",    PS_DATA_F32, "PSF fit instrumental magnitude",
    137                      NAN);
     137                     NAN);
    138138      psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental magnitude",
    139                      NAN);
     139                     NAN);
    140140      psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG",           PS_DATA_F32, "magnitude in standard aperture",
    141                      NAN);
     141                     NAN);
    142142      psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RAW",       PS_DATA_F32, "magnitude in real aperture",
    143                      NAN);
     143                     NAN);
    144144      psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS",    PS_DATA_F32, "radius used for aperture mags",
    145                      NAN);
     145                     NAN);
    146146      psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX",          PS_DATA_F32, "instrumental flux in standard aperture",
    147                      NAN);
     147                     NAN);
    148148      psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX_SIG",      PS_DATA_F32, "aperture flux error",
    149                      NAN);
     149                     NAN);
    150150      psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude",
    151                      NAN);
     151                     NAN);
    152152      psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG",      PS_DATA_F32, "PSF Magnitude using supplied calibration",
    153                      NAN);
     153                     NAN);
    154154      psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG_SIG",  PS_DATA_F32, "measured scatter of zero point calibration",
    155                      NAN);
     155                     NAN);
    156156      psMetadataAdd (row, PS_LIST_TAIL, "SKY",              PS_DATA_F32, "Sky level",
    157                      NAN);
     157                     NAN);
    158158      psMetadataAdd (row, PS_LIST_TAIL, "SKY_SIGMA",        PS_DATA_F32, "Sigma of sky level",
    159                      NAN);
     159                     NAN);
    160160      psMetadataAdd (row, PS_LIST_TAIL, "PSF_QF_PERFECT",   PS_DATA_F32, "PSF coverage/quality factor (poor)",
    161                      NAN);
     161                     NAN);
    162162      psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_R1",       PS_DATA_F32, "first radial moment",
    163                      NAN);
     163                     NAN);
    164164      psMetadataAdd (row, PS_LIST_TAIL, "MOMENTS_RH",       PS_DATA_F32, "half radial moment",
    165                      NAN);
     165                     NAN);
    166166      psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX",        PS_DATA_F32, "Kron Flux (in 2.5 R1)",
    167                      NAN);
     167                     NAN);
    168168      psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_ERR",    PS_DATA_F32, "Kron Flux Error",
    169                      NAN);
    170       psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_INNER",  PS_DATA_F32, "Kron Flux (in 1.0 R1)", 
    171                      NAN);
     169                     NAN);
     170      psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_INNER",  PS_DATA_F32, "Kron Flux (in 1.0 R1)",
     171                     NAN);
    172172      psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_OUTER",  PS_DATA_F32, "Kron Flux (in 4.0 R1)",
    173                      NAN);
     173                     NAN);
    174174      psMetadataAdd (row, PS_LIST_TAIL, "DIFF_R_P",         PS_DATA_F32, "distance to positive match source",
    175                      NAN);
     175                     NAN);
    176176      psMetadataAdd (row, PS_LIST_TAIL, "DIFF_SN_P",        PS_DATA_F32, "signal-to-noise of pos match src",
    177                      NAN);
     177                     NAN);
    178178      psMetadataAdd (row, PS_LIST_TAIL, "DIFF_R_M",         PS_DATA_F32, "distance to negative match source",
    179                      NAN);
     179                     NAN);
    180180      psMetadataAdd (row, PS_LIST_TAIL, "DIFF_SN_M",        PS_DATA_F32, "signal-to-noise of neg match src",
    181                      NAN);
     181                     NAN);
    182182      psMetadataAdd (row, PS_LIST_TAIL, "FLAGS2",           PS_DATA_U32, "psphot analysis flags (group 2)",
    183                      0);
    184       psMetadataAdd (row, PS_LIST_TAIL, "N_FRAMES",         PS_DATA_U16, "Number of frames overlapping source center", 
    185                      0);
    186       psMetadataAdd (row, PS_LIST_TAIL, "PADDING",          PS_DATA_S16, "padding", 
    187                      0);
     183                     0);
     184      psMetadataAdd (row, PS_LIST_TAIL, "N_FRAMES",         PS_DATA_U16, "Number of frames overlapping source center",
     185                     0);
     186      psMetadataAdd (row, PS_LIST_TAIL, "PADDING",          PS_DATA_S16, "padding",
     187                     0);
    188188      if (args->version == 3) {
    189         // TODO: Write data of version 3 (see ICD)
     189        // TODO: Write data of version 3 (see ICD)
    190190      }
    191191    }
     
    200200  } else {
    201201
    202 #define addColumn(_outName, _inName, _convertTo32)                      \
     202#define addColumn(_outName, _inName, _convertTo32)                      \
    203203    if (!addOutputColumn(table, detections, total, _outName, _inName, _convertTo32)) { \
    204204      psError(PS_ERR_UNKNOWN, false, "Failed to add column %s", _outName); \
    205       return false;                                                     \
     205      return false;                                                     \
    206206    }
    207207
     
    219219    addColumn("EXT_SIGNIFICANCE", "EXT_NSIGMA", 0);
    220220    addColumn("PSF_MAJOR", NULL, 0);
    221     addColumn("PSF_MINOR", NULL, 0);     
    222     addColumn("PSF_THETA", NULL, 0);   
    223     addColumn("PSF_QUALITY", "PSF_QF", 0); 
    224     addColumn("PSF_NPIX", NULL, 1);       
     221    addColumn("PSF_MINOR", NULL, 0);
     222    addColumn("PSF_THETA", NULL, 0);
     223    addColumn("PSF_QUALITY", "PSF_QF", 0);
     224    addColumn("PSF_NPIX", NULL, 1);
    225225    addColumn("MOMENTS_XX", NULL, 0);
    226226    addColumn("MOMENTS_XY", NULL, 0);
     
    308308      ppMopsDetections *det = detections->data[i];
    309309      if (!det || det->num == 0) {
    310         // no detections survived for this input
    311         continue;
     310        // no detections survived for this input
     311        continue;
    312312      }
    313313      psVector *in = NULL;
    314314      in = psMetadataLookupVector(NULL, det->table, inColumnName);
    315315      if (!in) {
    316         psError(PS_ERR_PROGRAMMING, true, "failed to find input column: %s (convertTo32 is true)", inColumnName);
    317         return false;
     316        psError(PS_ERR_PROGRAMMING, true, "failed to find input column: %s (convertTo32 is true)", inColumnName);
     317        return false;
    318318      }
    319319      if (in->type.type != PS_TYPE_S64 && in->type.type != PS_TYPE_U64) {
    320         psError(PS_ERR_PROGRAMMING, true, "input column to convert is not S64 or U64: %s %d",
    321                 inColumnName, in->type.type);
    322         return false;
     320        psError(PS_ERR_PROGRAMMING, true, "input column to convert is not S64 or U64: %s %d",
     321                inColumnName, in->type.type);
     322        return false;
    323323      }
    324324      if (out == NULL) {
    325         // First time through set up the output vector and the copy parameters
    326         if (in->type.type == PS_TYPE_S64) {
    327           out = psVectorAlloc(outputSize, PS_TYPE_S32);
    328         } else {
    329           out = psVectorAlloc(outputSize, PS_TYPE_U32);
    330         }
     325        // First time through set up the output vector and the copy parameters
     326        if (in->type.type == PS_TYPE_S64) {
     327          out = psVectorAlloc(outputSize, PS_TYPE_S32);
     328        } else {
     329          out = psVectorAlloc(outputSize, PS_TYPE_U32);
     330        }
    331331      }
    332332      for (long d=0; d < det->num; d++) {
    333         if (in->type.type == PS_TYPE_S64) {
    334           out->data.S32[next++] = in->data.S64[d];
    335         } else {
    336           out->data.U32[next++] = in->data.U64[d];
    337         }
     333        if (in->type.type == PS_TYPE_S64) {
     334          out->data.S32[next++] = in->data.S64[d];
     335        } else {
     336          out->data.U32[next++] = in->data.U64[d];
     337        }
    338338      }
    339339    }
     
    344344      ppMopsDetections *det = detections->data[i];
    345345      if (!det || det->num == 0) {
    346         // no detections survived for this input
    347         continue;
     346        // no detections survived for this input
     347        continue;
    348348      }
    349349      psVector *in = NULL;
    350350      in = psMetadataLookupVector(NULL, det->table, inColumnName);
    351351      if (!in) {
    352         psError(PS_ERR_PROGRAMMING, true, "failed to find input column: %s (convertTo32 is false)", inColumnName);
    353         out = psVectorAlloc(outputSize, PS_TYPE_F32);
    354         psVectorInit(out, NAN);
    355         psMetadataAddVector(table, PS_LIST_TAIL, outColumnName, 0, NULL, out);
    356         return false;
     352        psError(PS_ERR_PROGRAMMING, true, "failed to find input column: %s (convertTo32 is false)", inColumnName);
     353        out = psVectorAlloc(outputSize, PS_TYPE_F32);
     354        psVectorInit(out, NAN);
     355        psMetadataAddVector(table, PS_LIST_TAIL, outColumnName, 0, NULL, out);
     356        return false;
    357357      }
    358358      if (out == NULL) {
    359         // First time through set up the output vector and the copy parameters
    360         out = psVectorAlloc(outputSize, in->type.type);
    361         next = (void *) out->data.U8;
    362         switch (in->type.type) {
    363         case PS_TYPE_S8:
    364           elementSize = sizeof(psS8);
    365           break;
    366         case PS_TYPE_U8:
    367           elementSize = sizeof(psU8);
    368           break;
    369         case PS_TYPE_S16:
    370           elementSize = sizeof(psS16);
    371           break;
    372         case PS_TYPE_U16:
    373           elementSize = sizeof(psU16);
    374           break;
    375         case PS_TYPE_S32:
    376           elementSize = sizeof(psS32);
    377           break;
    378         case PS_TYPE_U32:
    379           elementSize = sizeof(psU32);
    380           break;
    381         case PS_TYPE_S64:
    382           elementSize = sizeof(psS64);
    383           break;
    384         case PS_TYPE_U64:
    385           elementSize = sizeof(psU64);
    386           break;
    387         case PS_TYPE_F32:
    388           elementSize = sizeof(psF32);
    389           break;
    390         case PS_TYPE_F64:
    391           elementSize = sizeof(psF64);
    392           break;
    393         default:
    394           psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unknown vector type %d", in->type.type);
    395           return false;
    396         }
    397       }
    398       // We are doing nasty things here so we can use memcpy. 
     359        // First time through set up the output vector and the copy parameters
     360        out = psVectorAlloc(outputSize, in->type.type);
     361        next = (void *) out->data.U8;
     362        switch (in->type.type) {
     363        case PS_TYPE_S8:
     364          elementSize = sizeof(psS8);
     365          break;
     366        case PS_TYPE_U8:
     367          elementSize = sizeof(psU8);
     368          break;
     369        case PS_TYPE_S16:
     370          elementSize = sizeof(psS16);
     371          break;
     372        case PS_TYPE_U16:
     373          elementSize = sizeof(psU16);
     374          break;
     375        case PS_TYPE_S32:
     376          elementSize = sizeof(psS32);
     377          break;
     378        case PS_TYPE_U32:
     379          elementSize = sizeof(psU32);
     380          break;
     381        case PS_TYPE_S64:
     382          elementSize = sizeof(psS64);
     383          break;
     384        case PS_TYPE_U64:
     385          elementSize = sizeof(psU64);
     386          break;
     387        case PS_TYPE_F32:
     388          elementSize = sizeof(psF32);
     389          break;
     390        case PS_TYPE_F64:
     391          elementSize = sizeof(psF64);
     392          break;
     393        default:
     394          psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unknown vector type %d", in->type.type);
     395          return false;
     396        }
     397      }
     398      // We are doing nasty things here so we can use memcpy.
    399399      // It would be safer to do a proper loop over the elements.
    400400      long toCopy = det->num * elementSize;
Note: See TracChangeset for help on using the changeset viewer.