IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15600


Ignore:
Timestamp:
Nov 13, 2007, 9:44:27 AM (18 years ago)
Author:
eugene
Message:

fixed -update-mosaics mode, added Parallax-only fit

Location:
trunk/Ohana/src/relastro
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relastro/Makefile

    r15590 r15600  
    2525$(SRC)/FitMosaic.$(ARCH).o       \
    2626$(SRC)/FitPM.$(ARCH).o           \
     27$(SRC)/FitPar.$(ARCH).o          \
    2728$(SRC)/FitPMandPar.$(ARCH).o     \
    2829$(SRC)/FitSimple.$(ARCH).o       \
     
    5051$(SRC)/sort.$(ARCH).o            \
    5152$(SRC)/relastro.$(ARCH).o        \
    52 $(SRC)/reload_catalogs.$(ARCH).o \
    5353$(SRC)/save_catalogs.$(ARCH).o   \
    5454$(SRC)/setExclusions.$(ARCH).o   \
  • trunk/Ohana/src/relastro/doc/notes.txt

    r15239 r15600  
     1
     22007.11.12
     3
     4  relastro is working for the SIMPLE (single-chip) and CHIP
     5  (mosaic-chip) modes.  it is not yet working for the MOSAIC mode.
     6  The image table contains one mosaic entry and N chip entries for a
     7  mosaic with N chips.  The mosaic entry has coord.ctype = DIS, while
     8  the corresponding chips have coord.ctype = WRP (and matching
     9  time/photcodes).
     10
     11  (this is fairly weak. we should just define the relationship when we
     12  register the chips...)
    113
    2142007.10.06
  • trunk/Ohana/src/relastro/include/relastro.h

    r15590 r15600  
    135135
    136136int FIT_MODE;
    137 enum {FIT_NONE, FIT_AVERAGE, FIT_PM_ONLY, FIT_PM_AND_PAR};
     137enum {FIT_NONE, FIT_AVERAGE, FIT_PM_ONLY, FIT_PAR_ONLY, FIT_PM_AND_PAR};
    138138
    139139int FIT_TARGET;
     
    256256void          write_coords        PROTO((Header *header, Coords *coords));
    257257
    258 
    259258double **array_init (int Nx, int Ny);
    260259void array_free (double **array, int Nx);
     
    281280int ParFactor (double *pR, double *pD, double R, double D, time_t T);
    282281int FitPM (PMFit *fit, double *X, double *dX, double *Y, double *dY, double *T, int Npts);
     282int FitPar (PMFit *fit, double *X, double *dX, double *Y, double *dY, double *pR, double *pD, int Npts);
    283283int FitPMandPar (PMFit *fit, double *X, double *dX, double *Y, double *dY, double *T, double *pR, double *pD, int Npts);
    284284
    285285Mosaic *getMosaicForImage (int N);
    286286
    287 StarData *getImageRef (Catalog *catalog, int Ncatalog, int im, int *Nstars, int isMosaic);
    288 StarData *getImageRaw (Catalog *catalog, int Ncatalog, int im, int *Nstars, int isMosaic);
     287StarData *getImageRef (Catalog *catalog, int Ncatalog, int im, int *Nstars, CoordMode mode);
     288StarData *getImageRaw (Catalog *catalog, int Ncatalog, int im, int *Nstars, CoordMode mode);
     289
     290Mosaic *getmosaics (int *N);
     291void initMosaics (Image *image, int Nimage);
     292StarData *getMosaicRaw (Catalog *catalog, int Ncatalog, int mos, int *Nstars);
     293StarData *getMosaicRef (Catalog *catalog, int Ncatalog, int mos, int *Nstars);
     294Mosaic *getMosaicForImage (int im);
    289295
    290296double getMeanR (Measure *measure, Average *average, SecFilt *secfilt);
  • trunk/Ohana/src/relastro/src/FitChip.c

    r15238 r15600  
    1313  fit_eval (fit);
    1414  fit_apply_coords (fit, coords);
     15  fit_free (fit);
    1516
    1617  // apply new coords to raw (X,Y -> L,M)
  • trunk/Ohana/src/relastro/src/FitSimple.c

    r15238 r15600  
    1313  fit_eval (fit);
    1414  fit_apply_coords (fit, coords);
     15  fit_free (fit);
    1516
    1617  // apply new coords to raw (X,Y -> P,Q)
  • trunk/Ohana/src/relastro/src/ImageOps.c

    r15590 r15600  
    9696 
    9797  measure = &catalog[cat].measure[meas];
     98
     99  /* find the image that supplied this measurement */
    98100  for (i = 0; i < Nimage; i++) {
    99101    if (image[0].photcode == -1) continue;
     
    102104    if (measure[0].t > stop[i]) continue;
    103105   
     106    // index for (catalog, measure) -> image
    104107    bin[cat][meas] = i;
    105108
     109    // index for image, Nentry -> catalog
    106110    clist[i][Nlist[i]] = cat;
     111
     112    // index for image, Nentry -> measure
    107113    mlist[i][Nlist[i]] = meas;
    108114    Nlist[i] ++;
     
    188194  mosaic = NULL;
    189195  moscoords = NULL;
    190   switch (mode) {
    191     case MODE_SIMPLE:
    192       break;
    193     case MODE_CHIP:
     196  if (mode == MODE_MOSAIC) {
    194197      mosaic = getMosaicForImage (im);
    195198      if (mosaic == NULL) {
    196         fprintf (stderr, "mosaic not found for image %s\n", image[i].name);
     199        fprintf (stderr, "mosaic not found for image %s\n", image[im].name);
    197200        exit (1);
    198201      }
    199202      moscoords = &mosaic[0].coords;
    200       break;
    201     case MODE_MOSAIC:
    202       // XXX find all images which are chips for this mosaic image
    203       // XXX count the stars in the superset of lists?
    204       fprintf (stderr, "problem with the mosaic mode (need to grab the correct set of stars)");
    205       abort ();
    206       break;
    207203  }
    208204
     
    228224        LM_to_RD (&raw[i].R, &raw[i].D, raw[i].P, raw[i].Q, &image[im].coords);
    229225        break;
    230       case MODE_CHIP:
     226      case MODE_MOSAIC:
    231227        XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[im].coords);
    232228        XY_to_LM (&raw[i].P, &raw[i].Q, raw[i].L, raw[i].M, moscoords);
    233229        LM_to_RD (&raw[i].R, &raw[i].D, raw[i].P, raw[i].Q, moscoords);
    234230        break;
    235       case MODE_MOSAIC:
    236         XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[im].coords);
    237         raw[i].P = raw[i].L;
    238         raw[i].Q = raw[i].M;
    239         LM_to_RD (&raw[i].R, &raw[i].D, raw[i].P, raw[i].Q, &image[im].coords);
    240         break;
     231    default:
     232      fprintf (stderr, "error: invalid mode in getImageRaw");
     233      abort ();
    241234    }
    242235  } 
     
    248241// return StarData values for averages positions in the specified image, converting coordinates from
    249242// the sky positions: R,D -> P,Q -> L,M -> X,Y
    250 StarData *getImageRef (Catalog *catalog, int Ncatalog, int im, int *Nstars, int isMosaic) {
     243StarData *getImageRef (Catalog *catalog, int Ncatalog, int im, int *Nstars, CoordMode mode) {
    251244
    252245  int i, m, c, n;
     
    260253  mosaic = NULL;
    261254  moscoords = NULL;
    262   if (isMosaic) {
     255  if (mode == MODE_MOSAIC) {
    263256    mosaic = getMosaicForImage (im);
     257    if (mosaic == NULL) {
     258      fprintf (stderr, "mosaic not found for image %s\n", image[im].name);
     259      exit (1);
     260    }
    264261    moscoords = &mosaic[0].coords;
    265262  }
     
    273270    ref[i].R = catalog[c].average[n].R;
    274271    ref[i].D = catalog[c].average[n].D;
     272   
     273    ref[i].Mag  = catalog[c].measure[m].M;
     274    ref[i].dMag = catalog[c].measure[m].dM;
     275
    275276    ref[i].mask = FALSE;
    276277
    277278    /* note that for a Simple image, L,M = P,Q */
    278     if (isMosaic) {
    279       RD_to_LM (&ref[i].P, &ref[i].Q, ref[i].R, ref[i].D, moscoords);
    280       LM_to_XY (&ref[i].M, &ref[i].L, ref[i].P, ref[i].Q, moscoords);
    281       LM_to_XY (&ref[i].X, &ref[i].Y, ref[i].L, ref[i].M, &image[im].coords);
    282     } else {
     279    switch (mode) {
     280      case MODE_SIMPLE:
    283281      RD_to_LM (&ref[i].P, &ref[i].Q, ref[i].R, ref[i].D, &image[im].coords);
    284282      ref[i].L = ref[i].P;
    285283      ref[i].M = ref[i].Q;
    286284      LM_to_XY (&ref[i].X, &ref[i].Y, ref[i].L, ref[i].M, &image[im].coords);
     285      break;
     286      case MODE_MOSAIC:
     287      RD_to_LM (&ref[i].P, &ref[i].Q, ref[i].R, ref[i].D, moscoords);
     288      LM_to_XY (&ref[i].M, &ref[i].L, ref[i].P, ref[i].Q, moscoords);
     289      LM_to_XY (&ref[i].X, &ref[i].Y, ref[i].L, ref[i].M, &image[im].coords);
     290      break;
    287291    }
    288292  }
  • trunk/Ohana/src/relastro/src/MosaicOps.c

    r15590 r15600  
    11# include "relastro.h"
    22
    3 Image *getimages (int *N);
    4 
     3// array of mosaic definition structures
    54static int    Nmosaic;
    65static Mosaic *mosaic;
    76
    8 static int    *Nimlist;
    9 static int   **imlist; /* mosaic -> image[] */
    10 static int   **bin;    /* catalog, measure -> mosaic */
     7// list of all images associated with a mosaic
     8static int   *Nmosaic_own_images; // number of images for this mosaic
     9static int   *Amosaic_own_images; // size of allocated array
     10static int   **mosaic_own_images; // array of arrays: mosaic -> images
    1111
    12 static int    Nimages;
    13 static int    *moslist; /* image -> mosaic */
     12// list of mosaic associated with each image 
     13static int    Nmosaic_for_images; // number of images (for internal checks)
     14static int    *mosaic_for_images; // array of: image -> mosaic
    1415
    15 static int   **clist;  /* mosaic -> catalog[] */
    16 static int   **mlist;  /* mosiac -> measure[] */
    17 static int    *Nlist;
    18 static int    *NLIST;
     16Mosaic *getmosaics (int *N) {
     17  *N = Nmosaic;
     18  return (mosaic);
     19}
    1920
    20 /* find mosaic frames (unique time periods & photcode name matches mosaic) */
    21 /* XXX what is a mosaic?  do we need to use the 'DIS/WRP' info to track? */
     21// find mosaic frames (unique time periods & photcode name matches mosaic)
    2222void initMosaics (Image *image, int Nimage) {
    2323
     
    2626  char *pname;
    2727
    28   // if (!MOSAICNAME[0]) return;
    29 
    3028  Nmosaic = 0;
    3129  NMOSAIC = 10;
    3230  ALLOCATE (mosaic, Mosaic, NMOSAIC);
    3331
    34   ALLOCATE (imlist, int *, NMOSAIC);
    35   ALLOCATE (Nimlist, int, NMOSAIC);
    36   ALLOCATE (NIMLIST, int, NMOSAIC);
     32  ALLOCATE (Nmosaic_own_images, int, NMOSAIC);
     33  ALLOCATE (Amosaic_own_images, int, NMOSAIC);
     34  ALLOCATE (mosaic_own_images, int *, NMOSAIC);
    3735
    38   Nimages = Nimage;
    39   ALLOCATE (moslist, int, Nimages);
     36  /* find the mosaic images (coords.ctype = DIS); generate list of unique mosaics */
     37  for (i = 0; i < Nimage; i++) {
     38    if (strcmp(&image[i].coords.ctype[4], "-DIS")) continue;
    4039
    41   /* generate list of unique mosaics */
     40    /* set image time range */
     41    start = image[i].tzero - MAX(0.05*image[i].trate*image[i].NY, 1);
     42    stop  = image[i].tzero + MAX(1.05*image[i].trate*image[i].NY, 1);
     43
     44    /* a new mosaic, define ranges */
     45    mosaic[Nmosaic].start = start;
     46    mosaic[Nmosaic].stop  = stop;
     47    mosaic[Nmosaic].Mcal  = 0.0;
     48    mosaic[Nmosaic].dMcal = 0.0;
     49    mosaic[Nmosaic].Xm    = 0.0;
     50    mosaic[Nmosaic].code  = image[i].code;
     51    mosaic[Nmosaic].secz  = image[i].secz;
     52    mosaic[Nmosaic].coords = image[i].coords;
     53
     54    // init the mosaic_own_images array data
     55    Nmosaic_own_images[Nmosaic] = 0;
     56    Amosaic_own_images[Nmosaic] = 10;
     57    ALLOCATE (mosaic_own_images[Nmosaic], int, Amosaic_own_images[Nmosaic]);
     58
     59    Nmosaic ++;
     60    if (Nmosaic == NMOSAIC) {
     61      NMOSAIC += 10;
     62      REALLOCATE (mosaic, Mosaic, NMOSAIC);
     63      REALLOCATE (mosaic_own_images, int *, NMOSAIC);
     64      REALLOCATE (Nmosaic_own_images, int, NMOSAIC);
     65      REALLOCATE (Amosaic_own_images, int, NMOSAIC);
     66    }
     67  }
     68
     69  // array to store image->mosaic index
     70  Nmosaic_for_images = Nimage;
     71  ALLOCATE (mosaic_for_images, int, Nmosaic_for_images);
     72
     73  /* now assign the WRP images to these mosaics */
    4274  for (i = 0; i < Nimage; i++) {
     75    mosaic_for_images[i] = -1; // default value for no mosaic found
    4376
    44     moslist[i] = -1; // default value for no mosaic found
    45 
    46     /* select valid mosaic images by photcode
    47     pname = GetPhotcodeNamebyCode (image[i].photcode);
    48     status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME));
    49     if (status) continue; */
     77    if (strcmp(&image[i].coords.ctype[4], "-WRP")) continue;
    5078
    5179    /* set image time range */
     
    5987      if (start > mosaic[j].stop)  continue;
    6088      found = TRUE;
     89      break;
     90    }
     91    /* if no matching mosaic exists, skip this image */
     92    if (!found) continue;
    6193
    62       /* add image to mosaic image list */
    63       imlist[j][Nimlist[j]] = i;
    64       Nimlist[j] ++;
    65       if (Nimlist[j] == NIMLIST[j]) {
    66         NIMLIST[j] += 10;
    67         REALLOCATE (imlist[j], int, NIMLIST[j]);
    68       }
     94    // mosaic corresponding to this image
     95    mosaic_for_images[i] = j;
    6996
    70       /* add mosaic to image -> mosaic list */
    71       moslist[i] = j;
     97    // add image to mosaic_own_image list
     98    mosaic_own_images[j][Nmosaic_own_images[j]] = i;
     99    Nmosaic_own_images[j] ++;
     100    if (Nmosaic_own_images[j] == Amosaic_own_images[j]) {
     101      Amosaic_own_images[j] += 10;
     102      REALLOCATE (mosaic_own_images[j], int, Amosaic_own_images[j]);
    72103    }
    73     if (found) continue;
    74    
    75     /* a new mosaic, define ranges */
    76     mosaic[Nmosaic].start = start;
    77     mosaic[Nmosaic].stop  = stop;
    78     mosaic[Nmosaic].Mcal  = 0.0;
    79     mosaic[Nmosaic].dMcal = 0.0;
    80     mosaic[Nmosaic].Xm    = 0.0;
    81     mosaic[Nmosaic].code  = image[i].code;
    82     mosaic[Nmosaic].secz  = image[i].secz;
    83     mosaic[Nmosaic].coords = image[i].coords;
     104    assert (Nmosaic_own_images[j] < Amosaic_own_images[j]);
     105  }
    84106
    85     /* add image to mosaic -> image list */
    86     NIMLIST[Nmosaic] = 10;
    87     Nimlist[Nmosaic] = 1;
    88     ALLOCATE (imlist[Nmosaic], int, NIMLIST[Nmosaic]);
    89     imlist[Nmosaic][0] = i;
    90 
    91     /* add mosaic to image -> mosaic list */
    92     moslist[i] = Nmosaic;
    93 
    94     Nmosaic ++;
    95     if (Nmosaic == NMOSAIC) {
    96       NMOSAIC += 10;
    97       REALLOCATE (mosaic, Mosaic, NMOSAIC);
    98       REALLOCATE (imlist, int *, NMOSAIC);
    99       REALLOCATE (Nimlist, int, NMOSAIC);
    100       REALLOCATE (NIMLIST, int, NMOSAIC);
    101     }
    102   }
    103107  return;
    104108}
    105109
    106 void initMosaicBins (Catalog *catalog, int Ncatalog) {
     110// return StarData values for detections in the specified image, converting coordinates from the
     111// chip positions: X,Y -> L,M -> P,Q -> R,D
     112StarData *getMosaicRaw (Catalog *catalog, int Ncatalog, int mos, int *Nstars) {
    107113
    108   int i, j;
     114  int i, j, im, Nraw, Nnew;
     115  StarData *raw, *new;
    109116
    110   /* measure -> mosaic */
    111   if (!MOSAICNAME[0]) return;
    112   ALLOCATE (bin, int *, Ncatalog);
    113   for (i = 0; i < Ncatalog; i++) {
    114     ALLOCATE (bin[i], int, MAX (catalog[i].Nmeasure, 1));
    115     for (j = 0; j < catalog[i].Nmeasure; j++) bin[i][j] = -1;
     117  Nraw = 0;
     118  ALLOCATE (raw, StarData, 1);
     119
     120  // loop over the images owned by this mosaic
     121  for (i = 0; i < Nmosaic_own_images[mos]; i++) {
     122
     123    im = mosaic_own_images[mos][i];
     124   
     125    // retrieve stars for this chip, applying chip and mosaic astrometry
     126    // this function does the reverse-lookup for the mosaic corresponding to this image
     127    new = getImageRaw (catalog, Ncatalog, im, &Nnew, MODE_MOSAIC);
     128   
     129    // merge new and raw
     130    REALLOCATE (raw, StarData, Nraw + Nnew);
     131    for (j = 0; j < Nnew; j++) {
     132      raw[Nraw+j] = new[j];
     133    }
     134    Nraw += Nnew;
     135
     136    free (new);
    116137  }
    117138
    118   /* mosaic -> measure */
    119   ALLOCATE (Nlist, int, Nmosaic);
    120   ALLOCATE (NLIST, int, Nmosaic);
    121   ALLOCATE (clist, int *, Nmosaic);
    122   ALLOCATE (mlist, int *, Nmosaic);
    123 
    124   for (i = 0; i < Nmosaic; i++) {
    125     Nlist[i] = 0;
    126     NLIST[i] = 100;
    127     ALLOCATE (clist[i], int, NLIST[i]);
    128     ALLOCATE (mlist[i], int, NLIST[i]);
    129   }
     139  *Nstars = Nraw;
     140  return (raw);
    130141}
    131142
    132 void freeMosaicBins (int Ncatalog) {
     143// return StarData values for averages positions in the specified image, converting coordinates from
     144// the sky positions: R,D -> P,Q -> L,M -> X,Y
     145StarData *getMosaicRef (Catalog *catalog, int Ncatalog, int mos, int *Nstars) {
    133146
    134   int i;
     147  int i, j, im, Nref, Nnew;
     148  StarData *ref, *new;
     149 
     150  Nref = 0;
     151  ALLOCATE (ref, StarData, 1);
    135152
    136   /* measure -> mosaic */
    137   if (!MOSAICNAME[0]) return;
    138   for (i = 0; i < Ncatalog; i++) {
    139     free (bin[i]);
     153  for (i = 0; i < Nmosaic_own_images[mos]; i++) {
     154
     155    im = mosaic_own_images[mos][i];
     156   
     157    // retrieve stars for this chip, applying chip and mosaic astrometry
     158    // this function does the reverse-lookup for the mosaic corresponding to this image
     159    new = getImageRef (catalog, Ncatalog, im, &Nnew, MODE_MOSAIC);
     160   
     161    // merge new and ref
     162    REALLOCATE (ref, StarData, Nref + Nnew);
     163    for (j = 0; j < Nnew; j++) {
     164      ref[Nref+j] = new[j];
     165    }
     166    Nref += Nnew;
     167
     168    free (new);
    140169  }
    141   free (bin);
    142170
    143   /* mosaic -> measure */
    144   for (i = 0; i < Nmosaic; i++) {
    145     free (clist[i]);
    146     free (mlist[i]);
    147   }
    148   free (Nlist);
    149   free (NLIST);
    150   free (clist);
    151   free (mlist);
     171  *Nstars = Nref;
     172  return (ref);
    152173}
    153174
    154 int findMosaics (Catalog *catalog, int Ncatalog) {
    155  
    156   int i, j;
     175Mosaic *getMosaicForImage (int im) {
    157176
    158   if (!MOSAICNAME[0]) return (FALSE);
    159   for (i = 0; i < Ncatalog; i++) {
    160     for (j = 0; j < catalog[i].Nmeasure; j++) {
    161       if (TimeSelect) {
    162         if (catalog[i].measure[j].t < TSTART) continue;
    163         if (catalog[i].measure[j].t > TSTOP) continue;
    164       }
    165       matchMosaics (catalog, j, i);
    166     }
    167   }
    168   return (TRUE);
    169 }
     177  int mos;
    170178
    171 /* modify this function to use the measure->imageID field ? */
    172 void matchMosaics (Catalog *catalog, int meas, int cat) {
    173 
    174   int i;
    175 
    176   for (i = 0; i < Nmosaic; i++) {
    177     if (catalog[cat].measure[meas].t < mosaic[i].start) continue;
    178     if (catalog[cat].measure[meas].t > mosaic[i].stop) continue;
    179    
    180     bin[cat][meas] = i;
    181 
    182     clist[i][Nlist[i]] = cat;
    183     mlist[i][Nlist[i]] = meas;
    184     Nlist[i] ++;
    185    
    186     if (Nlist[i] == NLIST[i]) {
    187       NLIST[i] += 100;
    188       REALLOCATE (clist[i], int, NLIST[i]);
    189       REALLOCATE (mlist[i], int, NLIST[i]);
    190     }   
    191     return;
    192   }
    193   return;
    194 }
    195 
    196 void plot_mosaic_fields (Catalog *catalog) {
    197 
    198   int i, j, m, c, N, ave, Nimage;
    199   double *xlist, *ylist;
    200   double Xmin, Xmax, Ymin, Ymax;
    201   char string[64];
    202   Image *image;
    203   Graphdata graphdata;
    204 
    205   if (!MOSAICNAME[0]) return;
    206 
    207   image = getimages (&Nimage);
    208 
    209   N = 0;
    210   for (i = 0; i < Nmosaic; i++)
    211     N = MAX (N, Nlist[i]);
    212 
    213   ALLOCATE (xlist, double, N);
    214   ALLOCATE (ylist, double, N);
    215 
    216   for (i = 0; i < Nmosaic; i++) {
    217     N = 0;
    218     Xmin = Ymin = +360.0;
    219     Xmax = Ymax = -360.0;
    220     for (j = 0; j < Nlist[i]; j++) {
    221      
    222       m = mlist[i][j];
    223       c = clist[i][j];
    224      
    225       if (catalog[c].measure[m].dbFlags & (ID_MEAS_AREA | ID_MEAS_NOCAL)) continue;
    226 
    227       ave = catalog[c].measure[m].averef;
    228       xlist[N] = catalog[c].average[ave].R - catalog[c].measure[m].dR / 3600.0;
    229       ylist[N] = catalog[c].average[ave].D - catalog[c].measure[m].dD / 3600.0;
    230       N++;
    231     }
    232  
    233     sprintf (string, "Mosaic %d", i);
    234     plot_defaults (&graphdata);
    235     plot_list (&graphdata, xlist, ylist, N, string, NULL);
    236   }
    237 
    238   free (ylist);
    239   free (xlist);
    240 }
    241 
    242 void plot_mosaics () {
    243 
    244   int i, bin;
    245   double *xlist, *Mlist, *dlist;
    246   Graphdata graphdata;
    247 
    248   if (!MOSAICNAME[0]) return;
    249 
    250   ALLOCATE (xlist, double, Nmosaic);
    251   ALLOCATE (dlist, double, Nmosaic);
    252   ALLOCATE (Mlist, double, Nmosaic);
    253 
    254   for (i = 0; i < Nmosaic; i++) {
    255     Mlist[i] = mosaic[i].Mcal;
    256     dlist[i] = mosaic[i].dMcal;
    257     xlist[i] = mosaic[i].secz;
    258   }
    259 
    260   plot_defaults (&graphdata);
    261   graphdata.xmin = 0.95;
    262   graphdata.xmax = 2.50;
    263   graphdata.ymin = PlotdMmin;
    264   graphdata.ymax = PlotdMmax;
    265   plot_list (&graphdata, xlist, Mlist, Nmosaic, "airmass vs Mcal", "airmass.png");
    266   plot_defaults (&graphdata);
    267   graphdata.size = 1.5;
    268   graphdata.ptype = 7;
    269   plot_list (&graphdata, Mlist, dlist, Nmosaic, "Mcal vs dMcal", "MdM.png");
    270 
    271 # define NBIN 200
    272   REALLOCATE (xlist, double, NBIN);
    273   REALLOCATE (Mlist, double, NBIN);
    274 
    275   /**** dMcal histgram ****/
    276   for (i = 0; i < NBIN; i++) xlist[i] = 0.00005*i;
    277   bzero (Mlist, NBIN*sizeof(double));
    278   for (i = 0; i < Nmosaic; i++) {
    279     bin = mosaic[i].dMcal / 0.00005;
    280     bin = MAX (0, MIN (NBIN - 1, bin));
    281     Mlist[bin] += 1.0;
    282   }
    283   plot_defaults (&graphdata);
    284   graphdata.style = 1;
    285   plot_list (&graphdata, xlist, Mlist, NBIN, "dMcal hist", "dMcalhist.png");
    286 
    287   free (dlist);
    288   free (xlist);
    289   free (Mlist);
    290 }
    291 
    292 Mosaic *getMosaicForImage (int Nim) {
    293 
    294   int i;
    295   Mosaic *myMosaic;
     179  if (im < 0) abort();
     180  if (im >= Nmosaic_for_images) abort();
    296181
    297182  // search for the mosaic that
    298   i = moslist[Nim];
    299   if (i < 0) return NULL;
     183  mos = mosaic_for_images[im];
     184  if (mos < 0) return NULL;
    300185
    301   myMosaic = &mosaic[i];
    302   return myMosaic;
     186  return &mosaic[mos];
    303187}
    304 
    305 int *SelectRefMosaic (Mosaic **refmosaic, int *Nimage) {
    306 
    307   int i, Imax, Nmax;
    308 
    309   Imax = 0;
    310   Nmax = Nimlist[0];
    311   for (i = 0; i < Nmosaic; i++) {
    312     if (Nimlist[i] > Nmax) {
    313       Imax = i;
    314       Nmax = Nimlist[i];
    315     }
    316   }
    317 
    318   *refmosaic = &mosaic[Imax];
    319   *Nimage = Nmax;
    320   return (imlist[Imax]);
    321 }
  • trunk/Ohana/src/relastro/src/UpdateChips.c

    r15590 r15600  
    1616
    1717    /* convert measure coordinates to raw entries */
    18     raw = getImageRaw (catalog, Ncatalog, i, &Nstars, MODE_CHIP);
     18    raw = getImageRaw (catalog, Ncatalog, i, &Nstars, MODE_MOSAIC);
    1919
    2020    /* convert average coordinates to ref entries */
    21     ref = getImageRef (catalog, Ncatalog, i, &Nstars, MODE_CHIP);
     21    ref = getImageRef (catalog, Ncatalog, i, &Nstars, MODE_MOSAIC);
    2222
    2323    FitChip (raw, ref, Nstars, &image[i].coords);
  • trunk/Ohana/src/relastro/src/UpdateMosaic.c

    r15590 r15600  
    44
    55  /* we can measure new image parameters for each mosaic independently */
    6   int i, Nimage, Nstars;
    7   Image *image;
     6  int i, Nmosaic, Nstars;
     7  Mosaic *mosaic;
    88  StarData *raw, *ref;
    99
    10   image = getimages (&Nimage);
     10  mosaic = getmosaics (&Nmosaic);
    1111
    12   for (i = 0; i < Nimage; i++) {
    13 
    14     /* skip all except DIS images */
    15     if (strcmp(&image[i].coords.ctype[4], "-DIS")) continue;
    16 
    17     /* XXX I probably need modes for getImageRaw/Ref to distinguish SIMPLE, CHIP, MOSAIC */
     12  for (i = 0; i < Nmosaic; i++) {
    1813
    1914    /* convert measure coordinates to raw entries */
    20     raw = getImageRaw (catalog, Ncatalog, i, &Nstars, MODE_MOSAIC);
     15    raw = getMosaicRaw (catalog, Ncatalog, i, &Nstars);
    2116
    2217    /* convert average coordinates to ref entries */
    23     ref = getImageRef (catalog, Ncatalog, i, &Nstars, MODE_MOSAIC);
     18    ref = getMosaicRef (catalog, Ncatalog, i, &Nstars);
    2419
    25     FitMosaic (raw, ref, Nstars, &image[i].coords);
     20    // XXX : I'll need to supply these back to the image[] entry
     21    FitMosaic (raw, ref, Nstars, &mosaic[i].coords);
    2622
    2723    free (raw);
  • trunk/Ohana/src/relastro/src/UpdateObjects.c

    r15509 r15600  
    153153          break;
    154154
     155        case FIT_PAR_ONLY:
     156          for (k = 0; k < N; k++) {
     157            ParFactor (&pX[k], &pY[k], R[k], D[k], T[k]);
     158          }
     159          FitPar (&fit, X, dX, Y, dY, pX, pY, N);
     160
     161          // project Ro, Do back to RA,DEC
     162          XY_to_RD (&fit.Ro, &fit.Do, fit.Ro, fit.Do, &coords);
     163          Npar ++;
     164          break;
     165
    155166        case FIT_PM_AND_PAR:
    156167          for (k = 0; k < N; k++) {
     
    161172          Npar ++;
    162173          break;
     174
    163175        default:
    164176          fprintf (stderr, "programming error at %s, %s", __FILE__, __LINE__);
  • trunk/Ohana/src/relastro/src/args.c

    r14590 r15600  
    1818        remove_argument (N, &argc, argv);
    1919        FIT_MODE = FIT_PM_ONLY;
     20    }
     21    if ((N = get_argument (argc, argv, "-par"))) {
     22        remove_argument (N, &argc, argv);
     23        FIT_MODE = FIT_PAR_ONLY;
    2024    }
    2125    if ((N = get_argument (argc, argv, "-pmpar"))) {
  • trunk/Ohana/src/relastro/src/relastro.c

    r15235 r15600  
    2727  catalog = load_catalogs (skylist, &Ncatalog, (FIT_TARGET != TARGET_OBJECTS));
    2828
    29   /* match measurements with images, mosaics */
    30   initImageBins  (catalog, Ncatalog);
    31   // initMosaicBins (catalog, Ncatalog);
    32 
     29  /* match measurements with images */
     30  initImageBins (catalog, Ncatalog);
    3331  findImages (catalog, Ncatalog);
    34   // findMosaics (catalog, Ncatalog);  /* also sets Grid values */
    3532
    3633  if (PLOTSTUFF) {
    3734    // plot_star_coords (catalog, Ncatalog);
    38     plot_mosaic_fields (catalog);
     35    // plot_mosaic_fields (catalog);
    3936  }
    4037
     
    6259  }
    6360
    64   /* put these types of functions inside the update functions
    65       plot_scatter (catalog, Ncatalog);
    66       plot_grid (catalog);
    67       plot_mosaics ();
    68       plot_images ();
    69       plot_stars (catalog, Ncatalog);
    70       plot_chisq (catalog, Ncatalog);
    71   */
    72 
    7361  if (!UPDATE) exit (0);
    7462
Note: See TracChangeset for help on using the changeset viewer.