IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 12, 2025, 5:00:47 PM (8 months ago)
Author:
eugene
Message:

fixes to cgrid for inverted regions; add features tdhistogram and region; free memory on exit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.astro/cgrid.c

    r41515 r42942  
    1212# define ADD_COORDINATE(RA,DEC)                                         \
    1313  status = RD_to_XY (&Xvec.elements.Flt[N], &Yvec.elements.Flt[N], (RA), (DEC), &graphmode.coords); \
    14   if ((Xvec.elements.Flt[N] >= graphmode.xmin) && (Xvec.elements.Flt[N] <= graphmode.xmax) && \
    15       (Yvec.elements.Flt[N] >= graphmode.ymin) && (Yvec.elements.Flt[N] <= graphmode.ymax) && status) { \
     14  if ((Xvec.elements.Flt[N] >= Xmin) && (Xvec.elements.Flt[N] <= Xmax) && \
     15      (Yvec.elements.Flt[N] >= Ymin) && (Yvec.elements.Flt[N] <= Ymax) && status) { \
    1616    N++;                                                                \
    1717    CHECKELEMENTS;                                                      \
     
    154154  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
    155155
     156  // we need to rationalize graphmode.xmin,xmax (can be flipped)
     157  int Xmin = MIN(graphmode.xmin,graphmode.xmax);
     158  int Xmax = MAX(graphmode.xmin,graphmode.xmax);
     159  int Ymin = MIN(graphmode.ymin,graphmode.ymax);
     160  int Ymax = MAX(graphmode.ymin,graphmode.ymax);
     161
    156162  if (argc != 1) goto usage;
    157163
     
    159165  NorthPole = SouthPole = FALSE;
    160166  status = RD_to_XY (&x, &y, 0.0, 90.0, &graphmode.coords);
    161   if ((x >= graphmode.xmin) && (x <= graphmode.xmax) &&
    162       (y >= graphmode.ymin) && (y <= graphmode.ymax) && status)
     167  // if the parity is flipped in either direction, xmin > xmax or ymin > ymax
     168  if ((x >= Xmin) && (x <= Xmax) &&
     169      (y >= Ymin) && (y <= Ymax) && status)
    163170    NorthPole = TRUE;
    164171  status = RD_to_XY (&x, &y, 0.0, -90.0, &graphmode.coords);
    165   if ((x >= graphmode.xmin) && (x <= graphmode.xmax) &&
    166       (y >= graphmode.ymin) && (y <= graphmode.ymax) && status)
     172  if ((x >= Xmin) && (x <= Xmax) &&
     173      (y >= Ymin) && (y <= Ymax) && status)
    167174    SouthPole = TRUE;
    168175
     
    173180  if (mode == PROJ_MODE_PSEUDOCYL) {
    174181    // for PSEUDOCYL, the ra range is 360 if the corners are invalid
    175     InvalidCorner |= XY_to_RD (&r, &d, graphmode.xmin, graphmode.ymin, &graphmode.coords);
    176     InvalidCorner |= XY_to_RD (&r, &d, graphmode.xmax, graphmode.ymin, &graphmode.coords);
    177     InvalidCorner |= XY_to_RD (&r, &d, graphmode.xmax, graphmode.ymax, &graphmode.coords);
    178     InvalidCorner |= XY_to_RD (&r, &d, graphmode.xmin, graphmode.ymax, &graphmode.coords);
     182    InvalidCorner |= XY_to_RD (&r, &d, Xmin, Ymin, &graphmode.coords);
     183    InvalidCorner |= XY_to_RD (&r, &d, Xmax, Ymin, &graphmode.coords);
     184    InvalidCorner |= XY_to_RD (&r, &d, Xmax, Ymax, &graphmode.coords);
     185    InvalidCorner |= XY_to_RD (&r, &d, Xmin, Ymax, &graphmode.coords);
    179186  }   
    180187
    181   range = MIN (fabs(graphmode.coords.cdelt1*(graphmode.xmax-graphmode.xmin)), fabs(graphmode.coords.cdelt2*(graphmode.ymax-graphmode.ymin)));
     188  range = MIN (fabs(graphmode.coords.cdelt1*(Xmax-Xmin)), fabs(graphmode.coords.cdelt2*(Ymax-Ymin)));
    182189  if (NorthPole || SouthPole || InvalidCorner) range = 360;
    183190  dR = range * GRID_SPACING;
     
    266273    char line[16], format[16];
    267274    double xt, yt, frac;
    268     // dx = +0.01 * (graphmode.xmax - graphmode.xmin);
    269     // dy = -0.02 * (graphmode.ymax - graphmode.ymin);
     275    // dx = +0.01 * (Xmax - Xmin);
     276    // dy = -0.02 * (Ymax - Ymin);
    270277
    271278    if (isnan(LabelRA)) LabelRA = graphmode.coords.crval1;
     
    274281      status = RD_to_XY (&xt, &yt, r, LabelDEC, &graphmode.coords);
    275282      if (!status) continue;
    276       if (xt < graphmode.xmin) continue;
    277       if (xt > graphmode.xmax) continue;
    278       if (yt < graphmode.ymin) continue;
    279       if (yt > graphmode.ymax) continue;
     283      if (xt < Xmin) continue;
     284      if (xt > Xmax) continue;
     285      if (yt < Ymin) continue;
     286      if (yt > Ymax) continue;
    280287      frac = -1.0 * log10(minorRA);
    281288      if (frac != (int)frac) {
     
    295302      status = RD_to_XY (&xt, &yt, r, LabelDEC, &graphmode.coords);
    296303      if (!status) continue;
    297       if (xt < graphmode.xmin) continue;
    298       if (xt > graphmode.xmax) continue;
    299       if (yt < graphmode.ymin) continue;
    300       if (yt > graphmode.ymax) continue;
     304      if (xt < Xmin) continue;
     305      if (xt > Xmax) continue;
     306      if (yt < Ymin) continue;
     307      if (yt > Ymax) continue;
    301308      frac = -1.0 * log10(minorRA);
    302309      if (frac != (int)frac) {
     
    316323      status = RD_to_XY (&xt, &yt, LabelRA, d, &graphmode.coords);
    317324      if (!status) continue;
    318       if (xt < graphmode.xmin) continue;
    319       if (xt > graphmode.xmax) continue;
    320       if (yt < graphmode.ymin) continue;
    321       if (yt > graphmode.ymax) continue;
     325      if (xt < Xmin) continue;
     326      if (xt > Xmax) continue;
     327      if (yt < Ymin) continue;
     328      if (yt > Ymax) continue;
    322329      frac = -1.0 * log10(minorDEC);
    323330      if (frac != (int)frac) {
     
    332339      status = RD_to_XY (&xt, &yt, LabelRA, d, &graphmode.coords);
    333340      if (!status) continue;
    334       if (xt < graphmode.xmin) continue;
    335       if (xt > graphmode.xmax) continue;
    336       if (yt < graphmode.ymin) continue;
    337       if (yt > graphmode.ymax) continue;
     341      if (xt < Xmin) continue;
     342      if (xt > Xmax) continue;
     343      if (yt < Ymin) continue;
     344      if (yt > Ymax) continue;
    338345      frac = -1.0 * log10(minorDEC);
    339346      if (frac != (int)frac) {
Note: See TracChangeset for help on using the changeset viewer.