IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 18, 2015, 6:33:51 AM (11 years ago)
Author:
eugene
Message:

merge changes from eam branch ipp-20150405: add R7 to lensing, fix R5,R6,R7 definitions and mean photometry; calculate E1,E2 in dvolens; fix precision for dvopsps FW objects; fix histograms at axis; new colormap options; require primary skycell in diff mean photometry

Location:
trunk
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Ohana/src/dvolens/Makefile

    r37358 r38153  
    2929$(SRC)/help.$(ARCH).o            \
    3030$(SRC)/initialize.$(ARCH).o      \
     31$(SRC)/myIndex.$(ARCH).o         \
    3132$(SRC)/update_objects.$(ARCH).o  \
    3233$(SRC)/update_objects_catalog.$(ARCH).o  \
     
    4445$(SRC)/help.$(ARCH).o            \
    4546$(SRC)/initialize.$(ARCH).o      \
     47$(SRC)/myIndex.$(ARCH).o         \
    4648$(SRC)/update_objects.$(ARCH).o  \
    4749$(SRC)/update_objects_catalog.$(ARCH).o  \
  • trunk/Ohana/src/dvolens/include/dvolens.h

    r37358 r38153  
    44# include <signal.h>
    55# include <pthread.h>
     6
     7# ifndef MAX_INT
     8# define MAX_INT 2147483647
     9# endif
     10
     11typedef struct {
     12  int minID;
     13  int maxID;
     14  int *index;
     15  int Nindex;
     16  int NINDEX;
     17} myIndexType;
    618
    719typedef enum {
     
    6375int           client_logger_message   PROTO((char *format,...));
    6476
     77myIndexType *myIndexAlloc ();
     78int myIndexFree (myIndexType *myIndex);
     79void myIndexInit (myIndexType *myIndex);
     80int myIndexUpdateLimits (myIndexType *myIndex, int value);
     81int myIndexSetRange (myIndexType *myIndex);
     82int myIndexSetEntry (myIndexType *myIndex, int value, int entry);
     83int myIndexGetEntry (myIndexType *myIndex, int value);
  • trunk/Ohana/src/dvolens/src/update_objects_catalog.c

    r37358 r38153  
    11# include "dvolens.h"
     2# define SCALE 0.001
     3float MagToFlux (float Mag); // in libdvo, but not exposed?
    24
    35int update_objects_catalog (Catalog *catalog) {
     
    1113  int Nsecfilt = GetPhotcodeNsecfilt ();
    1214 
     15  float *Mxx_obj = NULL;
     16  float *Mxy_obj = NULL;
     17  float *Myy_obj = NULL;
     18
     19  ALLOCATE (Mxx_obj, float, Nsecfilt);
     20  ALLOCATE (Mxy_obj, float, Nsecfilt);
     21  ALLOCATE (Myy_obj, float, Nsecfilt);
     22
    1323  // I think we have already allocated lensobj
    1424  REALLOCATE (catalog->lensobj, Lensobj, catalog->Naverage * Nsecfilt);
     
    1929  int Nlensobj = 0;
    2030
     31  myIndexType *measureIndex = myIndexAlloc();
     32
    2133  for (i = 0; i < catalog->Naverage; i++) {
    2234    Average *average = &catalog->average[i];
     
    2739    for (j = 0; j < Nsecfilt; j++) {
    2840      dvo_lensobj_init (&lensobj[j], TRUE); // init accumulated values to 0
     41      Mxx_obj[j] = 0.0;
     42      Mxy_obj[j] = 0.0;
     43      Myy_obj[j] = 0.0;
    2944    }
    3045
    3146    // reset the average values
    32 
    3347    off_t Loff = average->lensingOffset;
    3448    off_t Moff = average->measureOffset;
     49
     50    // I have Nmeasure entries for this object.  I need to match measure to lensing (by imageID)
     51    // I could generated a sorted list (imageID, measureSeq) and use bisection to find the desired imageID
     52    // I could make an index measureSeq[imageID-imageIDmin]
     53   
     54    myIndexInit (measureIndex);
     55
     56    // generate an index for these measure entries (based on Mj and imageID)
     57    for (Mj = 0; Mj < average->Nmeasure; Mj++) {
     58      myIndexUpdateLimits (measureIndex, catalog->measure[Moff + Mj].imageID);
     59    }
     60    myIndexSetRange (measureIndex);
     61    for (Mj = 0; Mj < average->Nmeasure; Mj++) {
     62      // if there are duplicates (multiple measures from the same image),
     63      // myIndexSetEntry will only select one
     64      myIndexSetEntry (measureIndex, catalog->measure[Moff + Mj].imageID, Mj);
     65    }
    3566
    3667    // loop over the lensing measurements.  for each one, I need to find the corresponding measurement (make an index in lensing?)
     
    4172      if (!isfinite(lensing->X11_sm_obj)) continue;
    4273
     74      // pointer from lensing entry to corresponding measure entry (keep updated?)
     75      // XX ALT int Mseq = lensing->measureSeq;
     76      // XX ALT myAssert (Mseq < average->Nmeasure, "oops");
     77      // XX ALT Measure *measure = &catalog->measure[Moff + Mseq];
     78      // XX ALT myAssert (measure->imageID == lensing->imageID, "oops, deux");
     79
     80      Mj = myIndexGetEntry (measureIndex, lensing->imageID);
     81      myAssert (Mj > -1, "missing index");
     82
     83      Measure *measure = &catalog->measure[Moff + Mj];
     84      myAssert (measure->imageID == lensing->imageID, "oops, deux");
     85
     86# if (0)     
    4387      Measure *measure = NULL;
    4488      int found = FALSE;
     
    5498        abort();
    5599      }
     100# endif
    56101     
    57102      // skip measurements that do not match the current photcode
     
    67112      if (measure->psfQFperf < 0.85) continue;
    68113     
    69 
     114      // I should probably only use lensing entries which correspond to warps
     115      // included in the mean warp flux (setMrelCatalog.c)
     116      if ((measure->dbFlags & ID_MEAS_WARP_USED) == 0) continue;
     117
     118      Mxx_obj[Nsec] += measure->Mxx;
     119      Mxy_obj[Nsec] += measure->Mxy;
     120      Myy_obj[Nsec] += measure->Myy;
     121     
    70122      lensobj[Nsec].X11_sm_obj += lensing->X11_sm_obj;
    71123      lensobj[Nsec].X12_sm_obj += lensing->X12_sm_obj;
     
    92144      lensobj[Nsec]. E2_sh_psf += lensing-> E2_sh_psf;
    93145
    94       lensobj[Nsec]. F_ApR5 += lensing-> F_ApR5;
    95       lensobj[Nsec].dF_ApR5 += SQ(lensing->dF_ApR5);
    96       lensobj[Nsec].sF_ApR5 += SQ(lensing->sF_ApR5);
    97       lensobj[Nsec].fF_ApR5 += lensing->fF_ApR5;
    98 
    99       lensobj[Nsec]. F_ApR6 += lensing-> F_ApR6;
    100       lensobj[Nsec].dF_ApR6 += SQ(lensing->dF_ApR6);
    101       lensobj[Nsec].sF_ApR6 += SQ(lensing->sF_ApR6);
    102       lensobj[Nsec].fF_ApR6 += lensing->fF_ApR6;
     146      // relphot sets measure->Mcal (setMcalOutput.c, called by setMrelFinal.c)
     147      float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure->Mcal;
     148      float Fcal = 3630.8 * MagToFlux(Mcal);
     149
     150      // lensing->F_ApR5, etc need to be in units of DN/sec
     151      // Fcal * lensing->F_ApR5 is in Jy
     152
     153      lensobj[Nsec]. F_ApR5 +=    Fcal * lensing-> F_ApR5;
     154      lensobj[Nsec].dF_ApR5 += SQ(Fcal * lensing->dF_ApR5);
     155      lensobj[Nsec].sF_ApR5 += SQ(Fcal * lensing->sF_ApR5);
     156      lensobj[Nsec].fF_ApR5 +=           lensing->fF_ApR5;
     157
     158      lensobj[Nsec]. F_ApR6 +=    Fcal * lensing-> F_ApR6;
     159      lensobj[Nsec].dF_ApR6 += SQ(Fcal * lensing->dF_ApR6);
     160      lensobj[Nsec].sF_ApR6 += SQ(Fcal * lensing->sF_ApR6);
     161      lensobj[Nsec].fF_ApR6 +=           lensing->fF_ApR6;
     162
     163      lensobj[Nsec]. F_ApR7 +=    Fcal * lensing-> F_ApR7;
     164      lensobj[Nsec].dF_ApR7 += SQ(Fcal * lensing->dF_ApR7);
     165      lensobj[Nsec].sF_ApR7 += SQ(Fcal * lensing->sF_ApR7);
     166      lensobj[Nsec].fF_ApR7 +=           lensing->fF_ApR7;
    103167
    104168      lensobj[Nsec].Nmeas   ++;
     
    139203      lensobj[j].sF_ApR5 /= Nmeas;
    140204      lensobj[j].fF_ApR5 /= Nmeas;
     205
    141206      lensobj[j]. F_ApR6 /= Nmeas;
    142207      lensobj[j].dF_ApR6 /= Nmeas;
     
    144209      lensobj[j].fF_ApR6 /= Nmeas;
    145210
     211      lensobj[j]. F_ApR7 /= Nmeas;
     212      lensobj[j].dF_ApR7 /= Nmeas;
     213      lensobj[j].sF_ApR7 /= Nmeas;
     214      lensobj[j].fF_ApR7 /= Nmeas;
     215
    146216      lensobj[j].dF_ApR5 = sqrt(lensobj[j].dF_ApR5);
    147217      lensobj[j].sF_ApR5 = sqrt(lensobj[j].sF_ApR5);
    148218      lensobj[j].dF_ApR6 = sqrt(lensobj[j].dF_ApR6);
    149219      lensobj[j].sF_ApR6 = sqrt(lensobj[j].sF_ApR6);
     220      lensobj[j].dF_ApR7 = sqrt(lensobj[j].dF_ApR7);
     221      lensobj[j].sF_ApR7 = sqrt(lensobj[j].sF_ApR7);
    150222
    151223      // somewhere in here I should calculate the values of E1, E2, and gamma
     224
     225      float e0 = Mxx_obj[j] + Myy_obj[j];
     226      lensobj[j].E1 = (Mxx_obj[j] - Myy_obj[j]) / e0;
     227      lensobj[j].E2 = 2.0 * Mxy_obj[j] / e0;
    152228    }
    153229
     
    159235  }
    160236
     237  free (Mxx_obj);
     238  free (Mxy_obj);
     239  free (Myy_obj);
     240
     241  myIndexFree (measureIndex);
     242
    161243  catalog->Nlensobj = Nlensobj;
    162244  catalog->Nlensobj_disk = 0;
Note: See TracChangeset for help on using the changeset viewer.