IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13742


Ignore:
Timestamp:
Jun 10, 2007, 7:54:46 AM (19 years ago)
Author:
magnier
Message:

parsing trimsec and biassec regions with psRegionAndParityFromString

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/concepts/pmConceptsStandard.c

    r13646 r13742  
    4949// FPA.FILTER
    5050psMetadataItem *p_pmConceptParse_FPA_FILTER(const psMetadataItem *concept,
    51         const psMetadataItem *pattern,
     51                                            const psMetadataItem *pattern,
    5252                                            pmConceptSource source,
    53         const psMetadata *cameraFormat,
    54         const pmFPA *fpa,
    55         const pmChip *chip,
    56         const pmCell *cell)
     53                                            const psMetadata *cameraFormat,
     54                                            const pmFPA *fpa,
     55                                            const pmChip *chip,
     56                                            const pmCell *cell)
    5757{
    5858    assert(concept);
     
    8686
    8787psMetadataItem *p_pmConceptFormat_FPA_FILTER(const psMetadataItem *concept,
    88                                             pmConceptSource source,
    89         const psMetadata *cameraFormat,
    90         const pmFPA *fpa,
    91         const pmChip *chip,
    92         const pmCell *cell)
     88                                             pmConceptSource source,
     89                                             const psMetadata *cameraFormat,
     90                                             const pmFPA *fpa,
     91                                             const pmChip *chip,
     92                                             const pmCell *cell)
    9393{
    9494    assert(concept);
     
    137137// FPA.RA and FPA.DEC
    138138psMetadataItem *p_pmConceptParse_FPA_Coords(const psMetadataItem *concept,
    139         const psMetadataItem *pattern,
     139                                            const psMetadataItem *pattern,
    140140                                            pmConceptSource source,
    141         const psMetadata *cameraFormat,
    142         const pmFPA *fpa,
    143         const pmChip *chip,
    144         const pmCell *cell)
     141                                            const psMetadata *cameraFormat,
     142                                            const pmFPA *fpa,
     143                                            const pmChip *chip,
     144                                            const pmCell *cell)
    145145{
    146146    assert(concept);
     
    150150    double coords = NAN;                // The coordinates
    151151    switch (concept->type) {
    152     case PS_TYPE_F32:
     152      case PS_TYPE_F32:
    153153        coords = concept->data.F32;
    154154        break;
    155     case PS_TYPE_F64:
     155      case PS_TYPE_F64:
    156156        coords = concept->data.F64;
    157157        break;
    158     case PS_DATA_STRING:
     158      case PS_DATA_STRING:
    159159        // Sexagesimal format
    160160        {
     
    163163            // XXX: Upgrade path is to allow dd:mm.mmm
    164164            if (sscanf(concept->data.V, "%d:%d:%f", &big, &medium, &small) != 3 &&
    165                     sscanf(concept->data.V, "%d %d %f", &big, &medium, &small) != 3)
     165                sscanf(concept->data.V, "%d %d %f", &big, &medium, &small) != 3)
    166166            {
    167167                psError(PS_ERR_UNKNOWN, true, "Cannot interpret %s: %s\n", pattern->name, concept->data.str);
     
    175175        }
    176176        break;
    177     default:
     177      default:
    178178        psError(PS_ERR_UNKNOWN, true, "%s concept is of an unexpected type: %x\n",
    179179                pattern->name, concept->type);
     
    208208// FPA.RA and FPA.DEC
    209209psMetadataItem *p_pmConceptFormat_FPA_Coords(const psMetadataItem *concept,
    210                                             pmConceptSource source,
    211         const psMetadata *cameraFormat,
    212         const pmFPA *fpa,
    213         const pmChip *chip,
    214         const pmCell *cell)
     210                                             pmConceptSource source,
     211                                             const psMetadata *cameraFormat,
     212                                             const pmFPA *fpa,
     213                                             const pmChip *chip,
     214                                             const pmCell *cell)
    215215{
    216216    assert(concept);
     
    226226    bool mdok = true;                   // Status of MD lookup
    227227    psMetadata *formats = psMetadataLookupMetadata(&mdok,
    228                           cameraFormat,
    229                           "FORMATS");
     228                                                   cameraFormat,
     229                                                   "FORMATS");
    230230    if (mdok && formats) {
    231231        psString format = psMetadataLookupStr(&mdok,formats, concept->name);
     
    270270
    271271psMetadataItem *p_pmConceptParse_CELL_TRIMSEC(const psMetadataItem *concept,
    272         const psMetadataItem *pattern,
    273                                             pmConceptSource source,
    274         const psMetadata *cameraFormat,
    275         const pmFPA *fpa,
    276         const pmChip *chip,
    277         const pmCell *cell)
     272                                              const psMetadataItem *pattern,
     273                                              pmConceptSource source,
     274                                              const psMetadata *cameraFormat,
     275                                              const pmFPA *fpa,
     276                                              const pmChip *chip,
     277                                              const pmCell *cell)
    278278{
    279279    assert(concept);
     
    281281    assert(pattern);
    282282
     283    int xParity = 0;
     284    int yParity = 0;
    283285    psRegion *trimsec = psRegionAlloc(0, 0, 0, 0);
    284286
     
    288290        return NULL;
    289291    } else {
    290         *trimsec = psRegionFromString(concept->data.V);
     292        // allow for x and y flips in regions
     293        *trimsec = psRegionAndParityFromString(&xParity, &yParity, concept->data.V);
    291294    }
    292295
     
    304307
    305308psMetadataItem *p_pmConceptParse_CELL_BIASSEC(const psMetadataItem *concept,
    306         const psMetadataItem *pattern,
    307                                             pmConceptSource source,
    308         const psMetadata *cameraFormat,
    309         const pmFPA *fpa,
    310         const pmChip *chip,
    311         const pmCell *cell)
     309                                              const psMetadataItem *pattern,
     310                                              pmConceptSource source,
     311                                              const psMetadata *cameraFormat,
     312                                              const pmFPA *fpa,
     313                                              const pmChip *chip,
     314                                              const pmCell *cell)
    312315{
    313316    assert(concept);
     
    321324          // a single BIASSEC is of the form [AAAA]
    322325          // we may have multiple BIASSEC entries separated by space, commas, or semicolons
     326          int xParity = 0;
     327          int yParity = 0;
    323328          char *p = strchr (concept->data.V, '[');
    324329          while (p != NULL) {
     
    330335         
    331336              psRegion *region = psAlloc(sizeof(psRegion)); // The region
    332               *region = psRegionFromString(regionString);
     337              *region = psRegionAndParityFromString(&xParity, &yParity, regionString);
    333338              psListAdd(biassecs, PS_LIST_TAIL, region);
    334339              psFree(region);           // Drop reference
     
    340345      }
    341346      case PS_DATA_LIST: {
    342             psList *regions = concept->data.V; // The list of regions
    343             psListIterator *regionsIter = psListIteratorAlloc(regions, PS_LIST_HEAD, false); // Iterator
    344             psMetadataItem *regionItem = NULL; // Item from list iteration
    345             while ((regionItem = psListGetAndIncrement(regionsIter))) {
    346                 if (regionItem->type != PS_DATA_STRING) {
    347                     psWarning("CELL.BIASSEC member is not of type STR --- ignored.\n");
    348                     continue;
    349                 }
    350                 psRegion *region = psAlloc(sizeof(psRegion)); // The region
    351                 *region = psRegionFromString(regionItem->data.V);
    352                 psListAdd(biassecs, PS_LIST_TAIL, region);
    353                 psFree(region);           // Drop reference
    354             }
    355             psFree(regionsIter);
    356             break;
    357         }
    358     default:
     347          psList *regions = concept->data.V; // The list of regions
     348          psListIterator *regionsIter = psListIteratorAlloc(regions, PS_LIST_HEAD, false); // Iterator
     349          psMetadataItem *regionItem = NULL; // Item from list iteration
     350          while ((regionItem = psListGetAndIncrement(regionsIter))) {
     351              if (regionItem->type != PS_DATA_STRING) {
     352                  psWarning("CELL.BIASSEC member is not of type STR --- ignored.\n");
     353                  continue;
     354              }
     355              int xParity = 0;
     356              int yParity = 0;
     357              psRegion *region = psAlloc(sizeof(psRegion)); // The region
     358              *region = psRegionAndParityFromString(&xParity, &yParity, regionItem->data.V);
     359              psListAdd(biassecs, PS_LIST_TAIL, region);
     360              psFree(region);           // Drop reference
     361          }
     362          psFree(regionsIter);
     363          break;
     364      }
     365      default:
    359366        psError(PS_ERR_UNKNOWN, true, "CELL.BIASSEC after read is not of type STRING or LIST --- assuming "
    360367                "blank.\n");
     
    375382// CELL.XBIN and CELL.YBIN
    376383psMetadataItem *p_pmConceptParse_CELL_Binning(const psMetadataItem *concept,
    377         const psMetadataItem *pattern,
    378                                             pmConceptSource source,
    379         const psMetadata *cameraFormat,
    380         const pmFPA *fpa,
    381         const pmChip *chip,
    382         const pmCell *cell)
     384                                              const psMetadataItem *pattern,
     385                                              pmConceptSource source,
     386                                              const psMetadata *cameraFormat,
     387                                              const pmFPA *fpa,
     388                                              const pmChip *chip,
     389                                              const pmCell *cell)
    383390{
    384391    assert(concept);
     
    387394    int binning = 1;                    // Binning factor in x
    388395    switch (concept->type) {
    389     case PS_DATA_STRING: {
    390             psString binString = concept->data.V; // The string containing the binning
    391             if ((strcmp(pattern->name, "CELL.XBIN") == 0 && sscanf(binString, "%d %*d", &binning) != 1 &&
    392                     sscanf(binString, "%d,%*d", &binning) != 1) ||
    393                     (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 &&
    394                      sscanf(binString, "%*d,%d", &binning) != 1)) {
    395                 psError(PS_ERR_UNKNOWN, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
    396             }
    397             break;
    398         }
     396      case PS_DATA_STRING: {
     397          psString binString = concept->data.V; // The string containing the binning
     398          if ((strcmp(pattern->name, "CELL.XBIN") == 0 && sscanf(binString, "%d %*d", &binning) != 1 &&
     399               sscanf(binString, "%d,%*d", &binning) != 1) ||
     400              (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 &&
     401               sscanf(binString, "%*d,%d", &binning) != 1)) {
     402              psError(PS_ERR_UNKNOWN, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
     403          }
     404          break;
     405      }
    399406        TYPE_CASE(binning, concept, U8);
    400407        TYPE_CASE(binning, concept, U16);
     
    403410        TYPE_CASE(binning, concept, S16);
    404411        TYPE_CASE(binning, concept, S32);
    405     default:
     412      default:
    406413        psError(PS_ERR_UNKNOWN, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,
    407414                concept->type);
     
    413420
    414421psMetadataItem *p_pmConceptParse_TIMESYS(const psMetadataItem *concept,
    415         const psMetadataItem *pattern,
    416                                             pmConceptSource source,
    417         const psMetadata *cameraFormat,
    418         const pmFPA *fpa,
    419         const pmChip *chip,
    420         const pmCell *cell)
     422                                        const psMetadataItem *pattern,
     423                                        pmConceptSource source,
     424                                        const psMetadata *cameraFormat,
     425                                        const pmFPA *fpa,
     426                                        const pmChip *chip,
     427                                        const pmCell *cell)
    421428{
    422429    assert(concept);
     
    444451psMetadataItem *p_pmConceptParse_TIME(const psMetadataItem *concept,
    445452                                      const psMetadataItem *pattern,
    446                                             pmConceptSource source,
     453                                      pmConceptSource source,
    447454                                      const psMetadata *cameraFormat,
    448455                                      const pmFPA *fpa,
     
    469476    if (!mdok || (timeSys == 0xffffffff)) {
    470477        psWarning("Unable to find %s in concepts when parsing %s --- assuming UTC.\n",
    471                  timesysName, pattern->name);
     478                  timesysName, pattern->name);
    472479        timeSys = PS_TIME_UTC;
    473480    }
     
    548555    psTime *time = NULL;                // The time
    549556    switch (concept->type) {
    550     case PS_DATA_LIST: {
    551             if (!separateTime) {
    552                 psWarning ("DATE and TIME stored separately, but not specified in format\n");
    553             }
    554             // The date and time are stored separately
    555             // Assume the date is first and the time second
    556             psList *dateTime = concept->data.V; // The list containing items for date and time
    557             if (psListLength(dateTime) != 2) {
    558                 psError(PS_ERR_BAD_PARAMETER_SIZE, false,
    559                         "Unable to parse %s: date and time are not both available.", pattern->name);
    560                 return NULL;
    561             }
    562             psMetadataItem *dateItem = psListGet(dateTime, PS_LIST_HEAD); // Item containing the date
    563             if (!dateItem) {
    564                 psError(PS_ERR_UNKNOWN, true, "Date is not found.\n");
    565                 return NULL;
    566             }
    567             if (dateItem->type != PS_DATA_STRING) {
    568                 psError(PS_ERR_UNKNOWN, true, "Date is not of type STR.\n");
    569                 return NULL;
    570             }
    571             psString dateString = dateItem->data.V; // The string with the date
    572             int day = 0, month = 0, year = 0;
    573             if (sscanf(dateString, "%d-%d-%d", &year, &month, &day) != 3 &&
    574                     sscanf(dateString, "%d/%d/%d", &year, &month, &day) != 3) {
    575                 psError(PS_ERR_UNKNOWN, true, "Unable to read date: %s\n", dateString);
    576                 return NULL;
    577             }
    578             if (backwardsTime) {
    579                 // Need to switch days and years
    580                 int temp = day;
    581                 day = year;
    582                 year = temp;
    583             }
    584             if (usaTime) {
    585                 // Need to switch everything around.... Yanks!
    586                 int temp = day;
    587                 day = month;
    588                 month = year;
    589                 year = temp;
    590             }
    591             if (year < 100) {
    592                 if (pre2000Time) {
    593                     year += 1900;
    594                 } else {
    595                     year += 2000;
    596                 }
    597             }
    598             sprintf(dateString,"%04d-%02d-%02d", year, month, day);
    599 
    600             psMetadataItem *timeItem = psListGet(dateTime, PS_LIST_HEAD + 1); // Item containing the time
    601             if (!timeItem) {
    602                 psError(PS_ERR_UNKNOWN, true, "Time is not found.\n");
    603                 return NULL;
    604             }
    605             psString timeString = NULL; // The string with the time
    606             if (timeItem->type == PS_DATA_STRING) {
    607                 timeString = timeItem->data.V;
    608             } else {
    609                 // Assume that time is specified in Second of Day (!)
    610                 double seconds = NAN;
    611                 switch (timeItem->type) {
    612                     TYPE_CASE(seconds, timeItem, U8);
    613                     TYPE_CASE(seconds, timeItem, U16);
    614                     TYPE_CASE(seconds, timeItem, U32);
    615                     TYPE_CASE(seconds, timeItem, S8);
    616                     TYPE_CASE(seconds, timeItem, S16);
    617                     TYPE_CASE(seconds, timeItem, S32);
    618                     TYPE_CASE(seconds, timeItem, F32);
    619                     TYPE_CASE(seconds, timeItem, F64);
     557      case PS_DATA_LIST: {
     558          if (!separateTime) {
     559              psWarning ("DATE and TIME stored separately, but not specified in format\n");
     560          }
     561          // The date and time are stored separately
     562          // Assume the date is first and the time second
     563          psList *dateTime = concept->data.V; // The list containing items for date and time
     564          if (psListLength(dateTime) != 2) {
     565              psError(PS_ERR_BAD_PARAMETER_SIZE, false,
     566                      "Unable to parse %s: date and time are not both available.", pattern->name);
     567              return NULL;
     568          }
     569          psMetadataItem *dateItem = psListGet(dateTime, PS_LIST_HEAD); // Item containing the date
     570          if (!dateItem) {
     571              psError(PS_ERR_UNKNOWN, true, "Date is not found.\n");
     572              return NULL;
     573          }
     574          if (dateItem->type != PS_DATA_STRING) {
     575              psError(PS_ERR_UNKNOWN, true, "Date is not of type STR.\n");
     576              return NULL;
     577          }
     578          psString dateString = dateItem->data.V; // The string with the date
     579          int day = 0, month = 0, year = 0;
     580          if (sscanf(dateString, "%d-%d-%d", &year, &month, &day) != 3 &&
     581              sscanf(dateString, "%d/%d/%d", &year, &month, &day) != 3) {
     582              psError(PS_ERR_UNKNOWN, true, "Unable to read date: %s\n", dateString);
     583              return NULL;
     584          }
     585          if (backwardsTime) {
     586              // Need to switch days and years
     587              int temp = day;
     588              day = year;
     589              year = temp;
     590          }
     591          if (usaTime) {
     592              // Need to switch everything around.... Yanks!
     593              int temp = day;
     594              day = month;
     595              month = year;
     596              year = temp;
     597          }
     598          if (year < 100) {
     599              if (pre2000Time) {
     600                  year += 1900;
     601              } else {
     602                  year += 2000;
     603              }
     604          }
     605          sprintf(dateString,"%04d-%02d-%02d", year, month, day);
     606
     607          psMetadataItem *timeItem = psListGet(dateTime, PS_LIST_HEAD + 1); // Item containing the time
     608          if (!timeItem) {
     609              psError(PS_ERR_UNKNOWN, true, "Time is not found.\n");
     610              return NULL;
     611          }
     612          psString timeString = NULL; // The string with the time
     613          if (timeItem->type == PS_DATA_STRING) {
     614              timeString = timeItem->data.V;
     615          } else {
     616              // Assume that time is specified in Second of Day (!)
     617              double seconds = NAN;
     618              switch (timeItem->type) {
     619                  TYPE_CASE(seconds, timeItem, U8);
     620                  TYPE_CASE(seconds, timeItem, U16);
     621                  TYPE_CASE(seconds, timeItem, U32);
     622                  TYPE_CASE(seconds, timeItem, S8);
     623                  TYPE_CASE(seconds, timeItem, S16);
     624                  TYPE_CASE(seconds, timeItem, S32);
     625                  TYPE_CASE(seconds, timeItem, F32);
     626                  TYPE_CASE(seconds, timeItem, F64);
    620627                default:
    621                     psError(PS_ERR_UNKNOWN, true, "Time is not of an expected type: %x\n", timeItem->type);
    622                     return NULL;
    623                 }
    624                 // Now print to timeString as "hh:mm:ss.ss"
    625                 int hours = seconds / 3600;
    626                 seconds -= (double)hours * 3600.0;
    627                 int minutes = seconds / 60;
    628                 seconds -= (double)minutes * 60.0;
    629                 psStringAppend(&timeString, "%02d:%02d:%02f", hours, minutes, seconds);
    630             }
    631             psString dateTimeString = NULL;
    632             psStringAppend(&dateTimeString, "%sT%s", dateString, timeString);
    633             time = psTimeFromISO(dateTimeString, timeSys);
    634             psFree(dateTimeString);
    635             break;
    636         }
    637     case PS_DATA_STRING: {
    638             psString timeString = concept->data.V;   // String with the time
    639             if (jdTime) {
    640                 double timeValue = strtod (timeString, NULL);
    641                 time = psTimeFromJD(timeValue);
    642             } else if (mjdTime) {
    643                 double timeValue = strtod (timeString, NULL);
    644                 time = psTimeFromMJD(timeValue);
    645             } else {
    646                 // It's ISO
    647                 time = psTimeFromISO(timeString, timeSys);
    648             } // Interpreting the time string
    649             break;
    650         }
    651     case PS_TYPE_F32: {
    652             double timeValue = (double)concept->data.F32;
    653             if (jdTime) {
    654                 time = psTimeFromJD(timeValue);
    655             } else if (mjdTime) {
    656                 time = psTimeFromMJD(timeValue);
    657             } else {
    658                 psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
    659                         pattern->name, timeValue);
    660                 time = psTimeFromJD(timeValue);
    661             }
    662             break;
    663         }
    664     case PS_TYPE_F64: {
    665             double timeValue = (double)concept->data.F64;
    666             if (jdTime) {
    667                 time = psTimeFromJD(timeValue);
    668             } else if (mjdTime) {
    669                 time = psTimeFromMJD(timeValue);
    670             } else {
    671                 psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
    672                         pattern->name, timeValue);
    673                 time = psTimeFromJD(timeValue);
    674             }
    675             break;
    676         }
    677     default:
     628                  psError(PS_ERR_UNKNOWN, true, "Time is not of an expected type: %x\n", timeItem->type);
     629                  return NULL;
     630              }
     631              // Now print to timeString as "hh:mm:ss.ss"
     632              int hours = seconds / 3600;
     633              seconds -= (double)hours * 3600.0;
     634              int minutes = seconds / 60;
     635              seconds -= (double)minutes * 60.0;
     636              psStringAppend(&timeString, "%02d:%02d:%02f", hours, minutes, seconds);
     637          }
     638          psString dateTimeString = NULL;
     639          psStringAppend(&dateTimeString, "%sT%s", dateString, timeString);
     640          time = psTimeFromISO(dateTimeString, timeSys);
     641          psFree(dateTimeString);
     642          break;
     643      }
     644      case PS_DATA_STRING: {
     645          psString timeString = concept->data.V;   // String with the time
     646          if (jdTime) {
     647              double timeValue = strtod (timeString, NULL);
     648              time = psTimeFromJD(timeValue);
     649          } else if (mjdTime) {
     650              double timeValue = strtod (timeString, NULL);
     651              time = psTimeFromMJD(timeValue);
     652          } else {
     653              // It's ISO
     654              time = psTimeFromISO(timeString, timeSys);
     655          } // Interpreting the time string
     656          break;
     657      }
     658      case PS_TYPE_F32: {
     659          double timeValue = (double)concept->data.F32;
     660          if (jdTime) {
     661              time = psTimeFromJD(timeValue);
     662          } else if (mjdTime) {
     663              time = psTimeFromMJD(timeValue);
     664          } else {
     665              psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
     666                      pattern->name, timeValue);
     667              time = psTimeFromJD(timeValue);
     668          }
     669          break;
     670      }
     671      case PS_TYPE_F64: {
     672          double timeValue = (double)concept->data.F64;
     673          if (jdTime) {
     674              time = psTimeFromJD(timeValue);
     675          } else if (mjdTime) {
     676              time = psTimeFromMJD(timeValue);
     677          } else {
     678              psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
     679                      pattern->name, timeValue);
     680              time = psTimeFromJD(timeValue);
     681          }
     682          break;
     683      }
     684      default:
    678685        psError(PS_ERR_UNKNOWN, true, "Unable to parse %s.\n", pattern->name);
    679686        return NULL;
     
    688695static int fortranCorr(const psMetadata *cameraFormat, // The camera format description
    689696                       const char *name // Name of concept to check for FORTRAN indexing
    690                       )
     697    )
    691698{
    692699    bool mdok = false;                  // Result of MD lookup
     
    702709
    703710psMetadataItem *p_pmConceptParse_Positions(const psMetadataItem *concept,
    704         const psMetadataItem *pattern,
    705                                             pmConceptSource source,
    706         const psMetadata *cameraFormat,
    707         const pmFPA *fpa,
    708         const pmChip *chip,
    709         const pmCell *cell)
     711                                           const psMetadataItem *pattern,
     712                                           pmConceptSource source,
     713                                           const psMetadata *cameraFormat,
     714                                           const pmFPA *fpa,
     715                                           const pmChip *chip,
     716                                           const pmCell *cell)
    710717{
    711718    assert(concept);
     
    721728        TYPE_CASE(offset, concept, S16);
    722729        TYPE_CASE(offset, concept, S32);
    723         #if 0
    724 
    725     case PS_DATA_STRING: {
    726             // Interpret as a region specifier [x0:x1,y0:y1]
    727             psRegion region = psRegionFromString(concept->data.V);
    728             if (strstr(pattern->name, ".X0")) {
    729                 offset = region.x0;
    730             } else if (strstr(pattern->name, ".Y0")) {
    731                 offset = region.y0;
    732             } else if (strstr(pattern->name, ".X1")) {
    733                 offset = region.x1;
    734             } else if (strstr(pattern->name, ".Y1")) {
    735                 offset = region.y1;
    736             } else {
    737                 psError(PS_ERR_UNKNOWN, true,
    738                         "Unable to interpret %s because unable to determine if concept is X or Y.\n",
    739                         pattern->name);
    740                 return NULL;
    741             }
    742             break;
    743         }
    744         #endif
    745     default:
     730#if 0
     731
     732      case PS_DATA_STRING: {
     733          // Interpret as a region specifier [x0:x1,y0:y1]
     734          int xParity = 0;
     735          int yParity = 0;
     736          psRegion region = psRegionAndParityFromString(&xParity, &yParity, concept->data.V);
     737          if (strstr(pattern->name, ".X0")) {
     738              offset = region.x0;
     739          } else if (strstr(pattern->name, ".Y0")) {
     740              offset = region.y0;
     741          } else if (strstr(pattern->name, ".X1")) {
     742              offset = region.x1;
     743          } else if (strstr(pattern->name, ".Y1")) {
     744              offset = region.y1;
     745          } else {
     746              psError(PS_ERR_UNKNOWN, true,
     747                      "Unable to interpret %s because unable to determine if concept is X or Y.\n",
     748                      pattern->name);
     749              return NULL;
     750          }
     751          break;
     752      }
     753#endif
     754      default:
    746755        if (concept->type == PS_TYPE_F32 && concept->data.F32 - (int)concept->data.F32 == 0) {
    747756            offset = concept->data.F32;
     
    759768
    760769psMetadataItem *p_pmConceptFormat_CELL_TRIMSEC(const psMetadataItem *concept,
    761                                             pmConceptSource source,
    762         const psMetadata *cameraFormat,
    763         const pmFPA *fpa,
    764         const pmChip *chip,
    765         const pmCell *cell)
     770                                               pmConceptSource source,
     771                                               const psMetadata *cameraFormat,
     772                                               const pmFPA *fpa,
     773                                               const pmChip *chip,
     774                                               const pmCell *cell)
    766775{
    767776    assert(concept);
     
    788797    psFree(trimsec);
    789798    psMetadataItem *formatted = psMetadataItemAllocStr(concept->name, concept->comment,
    790                                 trimsecString);
     799                                                       trimsecString);
    791800    psFree(trimsecString);
    792801    return formatted;
     
    794803
    795804psMetadataItem *p_pmConceptFormat_CELL_BIASSEC(const psMetadataItem *concept,
    796                                             pmConceptSource source,
    797         const psMetadata *cameraFormat,
    798         const pmFPA *fpa,
    799         const pmChip *chip,
    800         const pmCell *cell)
     805                                               pmConceptSource source,
     806                                               const psMetadata *cameraFormat,
     807                                               const pmFPA *fpa,
     808                                               const pmChip *chip,
     809                                               const pmCell *cell)
    801810{
    802811    // Return a metadata item containing a list of metadata items of region strings
     
    840849psMetadataItem *p_pmConceptFormat_CELL_XBIN(const psMetadataItem *concept,
    841850                                            pmConceptSource source,
    842         const psMetadata *cameraFormat,
    843         const pmFPA *fpa,
    844         const pmChip *chip,
    845         const pmCell *cell)
     851                                            const psMetadata *cameraFormat,
     852                                            const pmFPA *fpa,
     853                                            const pmChip *chip,
     854                                            const pmCell *cell)
    846855{
    847856    assert(concept);
     
    852861    psString yKeyword = psMetadataLookupStr(&yBinOK, translation, "CELL.YBIN");
    853862    if (xBinOK && yBinOK && strlen(xKeyword) > 0 && strlen(yKeyword) > 0 &&
    854             strcasecmp(xKeyword, yKeyword) == 0) {
     863        strcasecmp(xKeyword, yKeyword) == 0) {
    855864        psMetadataItem *yBinItem = psMetadataLookup(cell->concepts, "CELL.YBIN"); // Binning factor in y
    856865        psString binString = NULL;
     
    868877psMetadataItem *p_pmConceptFormat_CELL_YBIN(const psMetadataItem *concept,
    869878                                            pmConceptSource source,
    870         const psMetadata *cameraFormat,
    871         const pmFPA *fpa,
    872         const pmChip *chip,
    873         const pmCell *cell)
     879                                            const psMetadata *cameraFormat,
     880                                            const pmFPA *fpa,
     881                                            const pmChip *chip,
     882                                            const pmCell *cell)
    874883{
    875884    assert(concept);
     
    880889    psString yKeyword = psMetadataLookupStr(&yBinOK, translation, "CELL.YBIN");
    881890    if (xBinOK && yBinOK && strlen(xKeyword) > 0 && strlen(yKeyword) > 0 &&
    882             strcasecmp(xKeyword, yKeyword) == 0) {
     891        strcasecmp(xKeyword, yKeyword) == 0) {
    883892        // Censor this --- it's already done (though no harm if it's done twice
    884893        return NULL;
     
    891900
    892901psMetadataItem *p_pmConceptFormat_TIMESYS(const psMetadataItem *concept,
    893                                             pmConceptSource source,
    894         const psMetadata *cameraFormat,
    895         const pmFPA *fpa,
    896         const pmChip *chip,
    897         const pmCell *cell)
     902                                          pmConceptSource source,
     903                                          const psMetadata *cameraFormat,
     904                                          const pmFPA *fpa,
     905                                          const pmChip *chip,
     906                                          const pmCell *cell)
    898907{
    899908    psString sys = NULL;            // String to store
    900909    switch (concept->data.S32) {
    901     case PS_TIME_TAI:
     910      case PS_TIME_TAI:
    902911        sys = psStringCopy("TAI");
    903912        break;
    904     case PS_TIME_UTC:
     913      case PS_TIME_UTC:
    905914        sys = psStringCopy("UTC");
    906915        break;
    907     case PS_TIME_UT1:
     916      case PS_TIME_UT1:
    908917        sys = psStringCopy("UT1");
    909918        break;
    910     case PS_TIME_TT:
     919      case PS_TIME_TT:
    911920        sys = psStringCopy("TT");
    912921        break;
    913     default:
     922      default:
    914923        sys = psStringCopy("Unknown");
    915924    }
     
    921930
    922931psMetadataItem *p_pmConceptFormat_TIME(const psMetadataItem *concept,
    923                                             pmConceptSource source,
     932                                       pmConceptSource source,
    924933                                       const psMetadata *cameraFormat,
    925934                                       const pmFPA *fpa,
     
    980989                } else {
    981990                    psWarning("Unrecognised FORMATS option for %s: %s --- "
    982                              "ignored.\n", concept->name, format);
     991                              "ignored.\n", concept->name, format);
    983992                }
    984993            }
     
    10211030
    10221031        psMetadataItem *dateItem = psMetadataItemAllocStr(concept->name, "The date of observation",
    1023                                    dateString);
     1032                                                          dateString);
    10241033        psMetadataItem *timeItem = psMetadataItemAllocStr(concept->name, "The time of observation",
    1025                                    timeString);
     1034                                                          timeString);
    10261035
    10271036        psListRemove(dateTime, PS_LIST_HEAD);
     
    10321041
    10331042        psMetadataItem *item = psMetadataItemAllocPtr(concept->name, PS_DATA_LIST, concept->comment,
    1034                                dateTime);
     1043                                                      dateTime);
    10351044        psFree (dateItem);
    10361045        psFree (timeItem);
     
    10571066psMetadataItem *p_pmConceptFormat_Positions(const psMetadataItem *concept,
    10581067                                            pmConceptSource source,
    1059         const psMetadata *cameraFormat,
    1060         const pmFPA *fpa,
    1061         const pmChip *chip,
    1062         const pmCell *cell)
     1068                                            const psMetadata *cameraFormat,
     1069                                            const pmFPA *fpa,
     1070                                            const pmChip *chip,
     1071                                            const pmCell *cell)
    10631072{
    10641073    assert(concept);
     
    10701079    }
    10711080
    1072     #if 0
     1081#if 0
    10731082    // If both the X0 and Y0 positions are specified by the same header keyword, write both together, as part
    10741083    // of the call for the X0 position.
     
    10901099        psString yKeyword = psMetadataLookupStr(&yFound, translation, companion);
    10911100        if (xFound && yFound && strlen(xKeyword) > 0 && strlen(yKeyword) > 0 &&
    1092                 strcasecmp(xKeyword, yKeyword) == 0) {
     1101            strcasecmp(xKeyword, yKeyword) == 0) {
    10931102            psMetadataItem *yItem = psMetadataLookup(cell->concepts, companion); // Corresponding y value
    10941103
     
    11151124        psFree(companion);
    11161125        if (xFound && yFound && strlen(xKeyword) > 0 && strlen(yKeyword) > 0 &&
    1117                 strcasecmp(xKeyword, yKeyword) == 0) {
     1126            strcasecmp(xKeyword, yKeyword) == 0) {
    11181127            return NULL;                // We did it with the X; don't do anything.
    11191128        }
    11201129    }
    1121     #endif
     1130#endif
    11221131
    11231132    int offset = concept->data.S32;
Note: See TracChangeset for help on using the changeset viewer.