IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 18, 2007, 10:28:32 AM (19 years ago)
Author:
Paul Price
Message:

Blank filter name yields blank filter id.

File:
1 edited

Legend:

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

    r13862 r14293  
    55#include <stdio.h>
    66#include <string.h>
    7 #include <strings.h>            /* for strn?casecmp */
     7#include <strings.h>            /* for strn?casecmp */
    88#include <assert.h>
    99#include <pslib.h>
     
    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);
     
    102102
    103103psMetadataItem *p_pmConceptFormat_FPA_FILTER(const psMetadataItem *concept,
    104                                              pmConceptSource source,
    105                                              const psMetadata *cameraFormat,
    106                                              const pmFPA *fpa,
    107                                              const pmChip *chip,
    108                                              const pmCell *cell)
     104                                             pmConceptSource source,
     105                                             const psMetadata *cameraFormat,
     106                                             const pmFPA *fpa,
     107                                             const pmChip *chip,
     108                                             const pmCell *cell)
    109109{
    110110    assert(concept);
     
    126126
    127127    const char *key = concept->data.str;        // The name to look up
    128    
     128    if (!key || strlen(key) == 0) {
     129        return psMetadataItemAllocStr(concept->name, concept->comment, NULL);
     130    }
     131
    129132    // the metadata is in the format (internal) STR (external)
    130133    // find the first internal name that matches
     
    141144// FPA.RA and FPA.DEC
    142145psMetadataItem *p_pmConceptParse_FPA_Coords(const psMetadataItem *concept,
    143                                             const psMetadataItem *pattern,
     146                                            const psMetadataItem *pattern,
    144147                                            pmConceptSource source,
    145                                             const psMetadata *cameraFormat,
    146                                             const pmFPA *fpa,
    147                                             const pmChip *chip,
    148                                             const pmCell *cell)
     148                                            const psMetadata *cameraFormat,
     149                                            const pmFPA *fpa,
     150                                            const pmChip *chip,
     151                                            const pmCell *cell)
    149152{
    150153    assert(concept);
     
    167170            // XXX: Upgrade path is to allow dd:mm.mmm
    168171            if (sscanf(concept->data.V, "%d:%d:%f", &big, &medium, &small) != 3 &&
    169                 sscanf(concept->data.V, "%d %d %f", &big, &medium, &small) != 3)
     172                sscanf(concept->data.V, "%d %d %f", &big, &medium, &small) != 3)
    170173            {
    171174                psError(PS_ERR_UNKNOWN, true, "Cannot interpret %s: %s\n", pattern->name, concept->data.str);
     
    212215// FPA.RA and FPA.DEC
    213216psMetadataItem *p_pmConceptFormat_FPA_Coords(const psMetadataItem *concept,
    214                                              pmConceptSource source,
    215                                              const psMetadata *cameraFormat,
    216                                              const pmFPA *fpa,
    217                                              const pmChip *chip,
    218                                              const pmCell *cell)
     217                                             pmConceptSource source,
     218                                             const psMetadata *cameraFormat,
     219                                             const pmFPA *fpa,
     220                                             const pmChip *chip,
     221                                             const pmCell *cell)
    219222{
    220223    assert(concept);
     
    230233    bool mdok = true;                   // Status of MD lookup
    231234    psMetadata *formats = psMetadataLookupMetadata(&mdok,
    232                                                    cameraFormat,
    233                                                    "FORMATS");
     235                                                   cameraFormat,
     236                                                   "FORMATS");
    234237    if (mdok && formats) {
    235238        psString format = psMetadataLookupStr(&mdok,formats, concept->name);
     
    274277
    275278psMetadataItem *p_pmConceptParse_CELL_TRIMSEC(const psMetadataItem *concept,
    276                                               const psMetadataItem *pattern,
    277                                               pmConceptSource source,
    278                                               const psMetadata *cameraFormat,
    279                                               const pmFPA *fpa,
    280                                               const pmChip *chip,
    281                                               const pmCell *cell)
     279                                              const psMetadataItem *pattern,
     280                                              pmConceptSource source,
     281                                              const psMetadata *cameraFormat,
     282                                              const pmFPA *fpa,
     283                                              const pmChip *chip,
     284                                              const pmCell *cell)
    282285{
    283286    assert(concept);
     
    294297        return NULL;
    295298    } else {
    296         // allow for x and y flips in regions
     299        // allow for x and y flips in regions
    297300        *trimsec = psRegionAndParityFromString(&xParity, &yParity, concept->data.V);
    298301    }
     
    311314
    312315psMetadataItem *p_pmConceptParse_CELL_BIASSEC(const psMetadataItem *concept,
    313                                               const psMetadataItem *pattern,
    314                                               pmConceptSource source,
    315                                               const psMetadata *cameraFormat,
    316                                               const pmFPA *fpa,
    317                                               const pmChip *chip,
    318                                               const pmCell *cell)
     316                                              const psMetadataItem *pattern,
     317                                              pmConceptSource source,
     318                                              const psMetadata *cameraFormat,
     319                                              const pmFPA *fpa,
     320                                              const pmChip *chip,
     321                                              const pmCell *cell)
    319322{
    320323    assert(concept);
     
    326329    switch (concept->type) {
    327330      case PS_DATA_STRING: {
    328           // a single BIASSEC is of the form [AAAA]
    329           // we may have multiple BIASSEC entries separated by space, commas, or semicolons
    330           int xParity = 0;
    331           int yParity = 0;
    332           char *p = strchr (concept->data.V, '[');
    333           while (p != NULL) {
    334               char *q = strchr (p, ']');
    335               if (q == NULL) break;
    336               char *regionString = psAlloc (q - p + 2);
    337               strncpy (regionString, p, q - p + 1);
    338               regionString[q - p + 1] = 0;
    339          
    340               psRegion *region = psAlloc(sizeof(psRegion)); // The region
    341               *region = psRegionAndParityFromString(&xParity, &yParity, regionString);
    342               psListAdd(biassecs, PS_LIST_TAIL, region);
    343               psFree(region);           // Drop reference
    344               psFree(regionString);     // Drop reference
    345          
    346               p = strchr (q, '[');
    347           }
    348           break;
     331          // a single BIASSEC is of the form [AAAA]
     332          // we may have multiple BIASSEC entries separated by space, commas, or semicolons
     333          int xParity = 0;
     334          int yParity = 0;
     335          char *p = strchr (concept->data.V, '[');
     336          while (p != NULL) {
     337              char *q = strchr (p, ']');
     338              if (q == NULL) break;
     339              char *regionString = psAlloc (q - p + 2);
     340              strncpy (regionString, p, q - p + 1);
     341              regionString[q - p + 1] = 0;
     342
     343              psRegion *region = psAlloc(sizeof(psRegion)); // The region
     344              *region = psRegionAndParityFromString(&xParity, &yParity, regionString);
     345              psListAdd(biassecs, PS_LIST_TAIL, region);
     346              psFree(region);           // Drop reference
     347              psFree(regionString);     // Drop reference
     348
     349              p = strchr (q, '[');
     350          }
     351          break;
    349352      }
    350353      case PS_DATA_LIST: {
    351           psList *regions = concept->data.V; // The list of regions
    352           psListIterator *regionsIter = psListIteratorAlloc(regions, PS_LIST_HEAD, false); // Iterator
    353           psMetadataItem *regionItem = NULL; // Item from list iteration
    354           while ((regionItem = psListGetAndIncrement(regionsIter))) {
    355               if (regionItem->type != PS_DATA_STRING) {
    356                   psWarning("CELL.BIASSEC member is not of type STR --- ignored.\n");
    357                   continue;
    358               }
    359               int xParity = 0;
    360               int yParity = 0;
    361               psRegion *region = psAlloc(sizeof(psRegion)); // The region
    362               *region = psRegionAndParityFromString(&xParity, &yParity, regionItem->data.V);
    363               psListAdd(biassecs, PS_LIST_TAIL, region);
    364               psFree(region);           // Drop reference
    365           }
    366           psFree(regionsIter);
    367           break;
     354          psList *regions = concept->data.V; // The list of regions
     355          psListIterator *regionsIter = psListIteratorAlloc(regions, PS_LIST_HEAD, false); // Iterator
     356          psMetadataItem *regionItem = NULL; // Item from list iteration
     357          while ((regionItem = psListGetAndIncrement(regionsIter))) {
     358              if (regionItem->type != PS_DATA_STRING) {
     359                  psWarning("CELL.BIASSEC member is not of type STR --- ignored.\n");
     360                  continue;
     361              }
     362              int xParity = 0;
     363              int yParity = 0;
     364              psRegion *region = psAlloc(sizeof(psRegion)); // The region
     365              *region = psRegionAndParityFromString(&xParity, &yParity, regionItem->data.V);
     366              psListAdd(biassecs, PS_LIST_TAIL, region);
     367              psFree(region);           // Drop reference
     368          }
     369          psFree(regionsIter);
     370          break;
    368371      }
    369372      default:
     
    386389// CELL.XBIN and CELL.YBIN
    387390psMetadataItem *p_pmConceptParse_CELL_Binning(const psMetadataItem *concept,
    388                                               const psMetadataItem *pattern,
    389                                               pmConceptSource source,
    390                                               const psMetadata *cameraFormat,
    391                                               const pmFPA *fpa,
    392                                               const pmChip *chip,
    393                                               const pmCell *cell)
     391                                              const psMetadataItem *pattern,
     392                                              pmConceptSource source,
     393                                              const psMetadata *cameraFormat,
     394                                              const pmFPA *fpa,
     395                                              const pmChip *chip,
     396                                              const pmCell *cell)
    394397{
    395398    assert(concept);
     
    399402    switch (concept->type) {
    400403      case PS_DATA_STRING: {
    401           psString binString = concept->data.V; // The string containing the binning
    402           if ((strcmp(pattern->name, "CELL.XBIN") == 0 && sscanf(binString, "%d %*d", &binning) != 1 &&
    403                sscanf(binString, "%d,%*d", &binning) != 1) ||
    404               (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 &&
    405                sscanf(binString, "%*d,%d", &binning) != 1)) {
    406               psError(PS_ERR_UNKNOWN, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
    407           }
    408           break;
     404          psString binString = concept->data.V; // The string containing the binning
     405          if ((strcmp(pattern->name, "CELL.XBIN") == 0 && sscanf(binString, "%d %*d", &binning) != 1 &&
     406               sscanf(binString, "%d,%*d", &binning) != 1) ||
     407              (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 &&
     408               sscanf(binString, "%*d,%d", &binning) != 1)) {
     409              psError(PS_ERR_UNKNOWN, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
     410          }
     411          break;
    409412      }
    410413        TYPE_CASE(binning, concept, U8);
     
    424427
    425428psMetadataItem *p_pmConceptParse_TIMESYS(const psMetadataItem *concept,
    426                                         const psMetadataItem *pattern,
    427                                         pmConceptSource source,
    428                                         const psMetadata *cameraFormat,
    429                                         const pmFPA *fpa,
    430                                         const pmChip *chip,
    431                                         const pmCell *cell)
     429                                        const psMetadataItem *pattern,
     430                                        pmConceptSource source,
     431                                        const psMetadata *cameraFormat,
     432                                        const pmFPA *fpa,
     433                                        const pmChip *chip,
     434                                        const pmCell *cell)
    432435{
    433436    assert(concept);
     
    455458psMetadataItem *p_pmConceptParse_TIME(const psMetadataItem *concept,
    456459                                      const psMetadataItem *pattern,
    457                                       pmConceptSource source,
     460                                      pmConceptSource source,
    458461                                      const psMetadata *cameraFormat,
    459462                                      const pmFPA *fpa,
     
    480483    if (!mdok || (timeSys == 0xffffffff)) {
    481484        psWarning("Unable to find %s in concepts when parsing %s --- assuming UTC.\n",
    482                   timesysName, pattern->name);
     485                  timesysName, pattern->name);
    483486        timeSys = PS_TIME_UTC;
    484487    }
     
    560563    switch (concept->type) {
    561564      case PS_DATA_LIST: {
    562           if (!separateTime) {
    563               psWarning ("DATE and TIME stored separately, but not specified in format\n");
    564           }
    565           // The date and time are stored separately
    566           // Assume the date is first and the time second
    567           psList *dateTime = concept->data.V; // The list containing items for date and time
    568           if (psListLength(dateTime) != 2) {
    569               psError(PS_ERR_BAD_PARAMETER_SIZE, false,
    570                       "Unable to parse %s: date and time are not both available.", pattern->name);
    571               return NULL;
    572           }
    573           psMetadataItem *dateItem = psListGet(dateTime, PS_LIST_HEAD); // Item containing the date
    574           if (!dateItem) {
    575               psError(PS_ERR_UNKNOWN, true, "Date is not found.\n");
    576               return NULL;
    577           }
    578           if (dateItem->type != PS_DATA_STRING) {
    579               psError(PS_ERR_UNKNOWN, true, "Date is not of type STR.\n");
    580               return NULL;
    581           }
    582           psString dateString = dateItem->data.V; // The string with the date
    583           int day = 0, month = 0, year = 0;
    584           if (sscanf(dateString, "%d-%d-%d", &year, &month, &day) != 3 &&
    585               sscanf(dateString, "%d/%d/%d", &year, &month, &day) != 3) {
    586               psError(PS_ERR_UNKNOWN, true, "Unable to read date: %s\n", dateString);
    587               return NULL;
    588           }
    589           if (backwardsTime) {
    590               // Need to switch days and years
    591               int temp = day;
    592               day = year;
    593               year = temp;
    594           }
    595           if (usaTime) {
    596               // Need to switch everything around.... Yanks!
    597               int temp = day;
    598               day = month;
    599               month = year;
    600               year = temp;
    601           }
    602           if (year < 100) {
    603               if (pre2000Time) {
    604                   year += 1900;
    605               } else {
    606                   year += 2000;
    607               }
    608           }
    609           sprintf(dateString,"%04d-%02d-%02d", year, month, day);
    610 
    611           psMetadataItem *timeItem = psListGet(dateTime, PS_LIST_HEAD + 1); // Item containing the time
    612           if (!timeItem) {
    613               psError(PS_ERR_UNKNOWN, true, "Time is not found.\n");
    614               return NULL;
    615           }
    616           psString timeString = NULL; // The string with the time
    617           if (timeItem->type == PS_DATA_STRING) {
    618               timeString = timeItem->data.V;
    619           } else {
    620               // Assume that time is specified in Second of Day (!)
    621               double seconds = NAN;
    622               switch (timeItem->type) {
    623                   TYPE_CASE(seconds, timeItem, U8);
    624                   TYPE_CASE(seconds, timeItem, U16);
    625                   TYPE_CASE(seconds, timeItem, U32);
    626                   TYPE_CASE(seconds, timeItem, S8);
    627                   TYPE_CASE(seconds, timeItem, S16);
    628                   TYPE_CASE(seconds, timeItem, S32);
    629                   TYPE_CASE(seconds, timeItem, F32);
    630                   TYPE_CASE(seconds, timeItem, F64);
     565          if (!separateTime) {
     566              psWarning ("DATE and TIME stored separately, but not specified in format\n");
     567          }
     568          // The date and time are stored separately
     569          // Assume the date is first and the time second
     570          psList *dateTime = concept->data.V; // The list containing items for date and time
     571          if (psListLength(dateTime) != 2) {
     572              psError(PS_ERR_BAD_PARAMETER_SIZE, false,
     573                      "Unable to parse %s: date and time are not both available.", pattern->name);
     574              return NULL;
     575          }
     576          psMetadataItem *dateItem = psListGet(dateTime, PS_LIST_HEAD); // Item containing the date
     577          if (!dateItem) {
     578              psError(PS_ERR_UNKNOWN, true, "Date is not found.\n");
     579              return NULL;
     580          }
     581          if (dateItem->type != PS_DATA_STRING) {
     582              psError(PS_ERR_UNKNOWN, true, "Date is not of type STR.\n");
     583              return NULL;
     584          }
     585          psString dateString = dateItem->data.V; // The string with the date
     586          int day = 0, month = 0, year = 0;
     587          if (sscanf(dateString, "%d-%d-%d", &year, &month, &day) != 3 &&
     588              sscanf(dateString, "%d/%d/%d", &year, &month, &day) != 3) {
     589              psError(PS_ERR_UNKNOWN, true, "Unable to read date: %s\n", dateString);
     590              return NULL;
     591          }
     592          if (backwardsTime) {
     593              // Need to switch days and years
     594              int temp = day;
     595              day = year;
     596              year = temp;
     597          }
     598          if (usaTime) {
     599              // Need to switch everything around.... Yanks!
     600              int temp = day;
     601              day = month;
     602              month = year;
     603              year = temp;
     604          }
     605          if (year < 100) {
     606              if (pre2000Time) {
     607                  year += 1900;
     608              } else {
     609                  year += 2000;
     610              }
     611          }
     612          sprintf(dateString,"%04d-%02d-%02d", year, month, day);
     613
     614          psMetadataItem *timeItem = psListGet(dateTime, PS_LIST_HEAD + 1); // Item containing the time
     615          if (!timeItem) {
     616              psError(PS_ERR_UNKNOWN, true, "Time is not found.\n");
     617              return NULL;
     618          }
     619          psString timeString = NULL; // The string with the time
     620          if (timeItem->type == PS_DATA_STRING) {
     621              timeString = timeItem->data.V;
     622          } else {
     623              // Assume that time is specified in Second of Day (!)
     624              double seconds = NAN;
     625              switch (timeItem->type) {
     626                  TYPE_CASE(seconds, timeItem, U8);
     627                  TYPE_CASE(seconds, timeItem, U16);
     628                  TYPE_CASE(seconds, timeItem, U32);
     629                  TYPE_CASE(seconds, timeItem, S8);
     630                  TYPE_CASE(seconds, timeItem, S16);
     631                  TYPE_CASE(seconds, timeItem, S32);
     632                  TYPE_CASE(seconds, timeItem, F32);
     633                  TYPE_CASE(seconds, timeItem, F64);
    631634                default:
    632                   psError(PS_ERR_UNKNOWN, true, "Time is not of an expected type: %x\n", timeItem->type);
    633                   return NULL;
    634               }
    635               // Now print to timeString as "hh:mm:ss.ss"
    636               int hours = seconds / 3600;
    637               seconds -= (double)hours * 3600.0;
    638               int minutes = seconds / 60;
    639               seconds -= (double)minutes * 60.0;
    640               psStringAppend(&timeString, "%02d:%02d:%02f", hours, minutes, seconds);
    641           }
    642           psString dateTimeString = NULL;
    643           psStringAppend(&dateTimeString, "%sT%s", dateString, timeString);
    644           time = psTimeFromISO(dateTimeString, timeSys);
    645           psFree(dateTimeString);
    646           break;
     635                  psError(PS_ERR_UNKNOWN, true, "Time is not of an expected type: %x\n", timeItem->type);
     636                  return NULL;
     637              }
     638              // Now print to timeString as "hh:mm:ss.ss"
     639              int hours = seconds / 3600;
     640              seconds -= (double)hours * 3600.0;
     641              int minutes = seconds / 60;
     642              seconds -= (double)minutes * 60.0;
     643              psStringAppend(&timeString, "%02d:%02d:%02f", hours, minutes, seconds);
     644          }
     645          psString dateTimeString = NULL;
     646          psStringAppend(&dateTimeString, "%sT%s", dateString, timeString);
     647          time = psTimeFromISO(dateTimeString, timeSys);
     648          psFree(dateTimeString);
     649          break;
    647650      }
    648651      case PS_DATA_STRING: {
    649           psString timeString = concept->data.V;   // String with the time
    650           if (jdTime) {
    651               double timeValue = strtod (timeString, NULL);
    652               time = psTimeFromJD(timeValue);
    653           } else if (mjdTime) {
    654               double timeValue = strtod (timeString, NULL);
    655               time = psTimeFromMJD(timeValue);
    656           } else {
    657               // It's ISO
    658               time = psTimeFromISO(timeString, timeSys);
    659           } // Interpreting the time string
    660           break;
     652          psString timeString = concept->data.V;   // String with the time
     653          if (jdTime) {
     654              double timeValue = strtod (timeString, NULL);
     655              time = psTimeFromJD(timeValue);
     656          } else if (mjdTime) {
     657              double timeValue = strtod (timeString, NULL);
     658              time = psTimeFromMJD(timeValue);
     659          } else {
     660              // It's ISO
     661              time = psTimeFromISO(timeString, timeSys);
     662          } // Interpreting the time string
     663          break;
    661664      }
    662665      case PS_TYPE_F32: {
    663           double timeValue = (double)concept->data.F32;
    664           if (jdTime) {
    665               time = psTimeFromJD(timeValue);
    666           } else if (mjdTime) {
    667               time = psTimeFromMJD(timeValue);
    668           } else {
    669               psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
    670                       pattern->name, timeValue);
    671               time = psTimeFromJD(timeValue);
    672           }
    673           break;
     666          double timeValue = (double)concept->data.F32;
     667          if (jdTime) {
     668              time = psTimeFromJD(timeValue);
     669          } else if (mjdTime) {
     670              time = psTimeFromMJD(timeValue);
     671          } else {
     672              psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
     673                      pattern->name, timeValue);
     674              time = psTimeFromJD(timeValue);
     675          }
     676          break;
    674677      }
    675678      case PS_TYPE_F64: {
    676           double timeValue = (double)concept->data.F64;
    677           if (jdTime) {
    678               time = psTimeFromJD(timeValue);
    679           } else if (mjdTime) {
    680               time = psTimeFromMJD(timeValue);
    681           } else {
    682               psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
    683                       pattern->name, timeValue);
    684               time = psTimeFromJD(timeValue);
    685           }
    686           break;
     679          double timeValue = (double)concept->data.F64;
     680          if (jdTime) {
     681              time = psTimeFromJD(timeValue);
     682          } else if (mjdTime) {
     683              time = psTimeFromMJD(timeValue);
     684          } else {
     685              psError(PS_ERR_UNKNOWN, true, "Not sure how to parse %s (%f) --- trying JD\n",
     686                      pattern->name, timeValue);
     687              time = psTimeFromJD(timeValue);
     688          }
     689          break;
    687690      }
    688691      default:
     
    713716
    714717psMetadataItem *p_pmConceptParse_Positions(const psMetadataItem *concept,
    715                                            const psMetadataItem *pattern,
    716                                            pmConceptSource source,
    717                                            const psMetadata *cameraFormat,
    718                                            const pmFPA *fpa,
    719                                            const pmChip *chip,
    720                                            const pmCell *cell)
     718                                           const psMetadataItem *pattern,
     719                                           pmConceptSource source,
     720                                           const psMetadata *cameraFormat,
     721                                           const pmFPA *fpa,
     722                                           const pmChip *chip,
     723                                           const pmCell *cell)
    721724{
    722725    assert(concept);
     
    735738
    736739      case PS_DATA_STRING: {
    737           // Interpret as a region specifier [x0:x1,y0:y1]
    738           int xParity = 0;
    739           int yParity = 0;
    740           psRegion region = psRegionAndParityFromString(&xParity, &yParity, concept->data.V);
    741           if (strstr(pattern->name, ".X0")) {
    742               offset = region.x0;
    743           } else if (strstr(pattern->name, ".Y0")) {
    744               offset = region.y0;
    745           } else if (strstr(pattern->name, ".X1")) {
    746               offset = region.x1;
    747           } else if (strstr(pattern->name, ".Y1")) {
    748               offset = region.y1;
    749           } else {
    750               psError(PS_ERR_UNKNOWN, true,
    751                       "Unable to interpret %s because unable to determine if concept is X or Y.\n",
    752                       pattern->name);
    753               return NULL;
    754           }
    755           break;
     740          // Interpret as a region specifier [x0:x1,y0:y1]
     741          int xParity = 0;
     742          int yParity = 0;
     743          psRegion region = psRegionAndParityFromString(&xParity, &yParity, concept->data.V);
     744          if (strstr(pattern->name, ".X0")) {
     745              offset = region.x0;
     746          } else if (strstr(pattern->name, ".Y0")) {
     747              offset = region.y0;
     748          } else if (strstr(pattern->name, ".X1")) {
     749              offset = region.x1;
     750          } else if (strstr(pattern->name, ".Y1")) {
     751              offset = region.y1;
     752          } else {
     753              psError(PS_ERR_UNKNOWN, true,
     754                      "Unable to interpret %s because unable to determine if concept is X or Y.\n",
     755                      pattern->name);
     756              return NULL;
     757          }
     758          break;
    756759      }
    757760#endif
     
    772775
    773776psMetadataItem *p_pmConceptFormat_CELL_TRIMSEC(const psMetadataItem *concept,
    774                                                pmConceptSource source,
    775                                                const psMetadata *cameraFormat,
    776                                                const pmFPA *fpa,
    777                                                const pmChip *chip,
    778                                                const pmCell *cell)
     777                                               pmConceptSource source,
     778                                               const psMetadata *cameraFormat,
     779                                               const pmFPA *fpa,
     780                                               const pmChip *chip,
     781                                               const pmCell *cell)
    779782{
    780783    assert(concept);
     
    801804    psFree(trimsec);
    802805    psMetadataItem *formatted = psMetadataItemAllocStr(concept->name, concept->comment,
    803                                                        trimsecString);
     806                                                       trimsecString);
    804807    psFree(trimsecString);
    805808    return formatted;
     
    807810
    808811psMetadataItem *p_pmConceptFormat_CELL_BIASSEC(const psMetadataItem *concept,
    809                                                pmConceptSource source,
    810                                                const psMetadata *cameraFormat,
    811                                                const pmFPA *fpa,
    812                                                const pmChip *chip,
    813                                                const pmCell *cell)
     812                                               pmConceptSource source,
     813                                               const psMetadata *cameraFormat,
     814                                               const pmFPA *fpa,
     815                                               const pmChip *chip,
     816                                               const pmCell *cell)
    814817{
    815818    // Return a metadata item containing a list of metadata items of region strings
     
    853856psMetadataItem *p_pmConceptFormat_CELL_XBIN(const psMetadataItem *concept,
    854857                                            pmConceptSource source,
    855                                             const psMetadata *cameraFormat,
    856                                             const pmFPA *fpa,
    857                                             const pmChip *chip,
    858                                             const pmCell *cell)
     858                                            const psMetadata *cameraFormat,
     859                                            const pmFPA *fpa,
     860                                            const pmChip *chip,
     861                                            const pmCell *cell)
    859862{
    860863    assert(concept);
     
    865868    psString yKeyword = psMetadataLookupStr(&yBinOK, translation, "CELL.YBIN");
    866869    if (xBinOK && yBinOK && strlen(xKeyword) > 0 && strlen(yKeyword) > 0 &&
    867         strcasecmp(xKeyword, yKeyword) == 0) {
     870        strcasecmp(xKeyword, yKeyword) == 0) {
    868871        psMetadataItem *yBinItem = psMetadataLookup(cell->concepts, "CELL.YBIN"); // Binning factor in y
    869872        psString binString = NULL;
     
    881884psMetadataItem *p_pmConceptFormat_CELL_YBIN(const psMetadataItem *concept,
    882885                                            pmConceptSource source,
    883                                             const psMetadata *cameraFormat,
    884                                             const pmFPA *fpa,
    885                                             const pmChip *chip,
    886                                             const pmCell *cell)
     886                                            const psMetadata *cameraFormat,
     887                                            const pmFPA *fpa,
     888                                            const pmChip *chip,
     889                                            const pmCell *cell)
    887890{
    888891    assert(concept);
     
    893896    psString yKeyword = psMetadataLookupStr(&yBinOK, translation, "CELL.YBIN");
    894897    if (xBinOK && yBinOK && strlen(xKeyword) > 0 && strlen(yKeyword) > 0 &&
    895         strcasecmp(xKeyword, yKeyword) == 0) {
     898        strcasecmp(xKeyword, yKeyword) == 0) {
    896899        // Censor this --- it's already done (though no harm if it's done twice
    897900        return NULL;
     
    904907
    905908psMetadataItem *p_pmConceptFormat_TIMESYS(const psMetadataItem *concept,
    906                                           pmConceptSource source,
    907                                           const psMetadata *cameraFormat,
    908                                           const pmFPA *fpa,
    909                                           const pmChip *chip,
    910                                           const pmCell *cell)
     909                                          pmConceptSource source,
     910                                          const psMetadata *cameraFormat,
     911                                          const pmFPA *fpa,
     912                                          const pmChip *chip,
     913                                          const pmCell *cell)
    911914{
    912915    psString sys = NULL;            // String to store
     
    934937
    935938psMetadataItem *p_pmConceptFormat_TIME(const psMetadataItem *concept,
    936                                        pmConceptSource source,
     939                                       pmConceptSource source,
    937940                                       const psMetadata *cameraFormat,
    938941                                       const pmFPA *fpa,
     
    993996                } else {
    994997                    psWarning("Unrecognised FORMATS option for %s: %s --- "
    995                               "ignored.\n", concept->name, format);
     998                              "ignored.\n", concept->name, format);
    996999                }
    9971000            }
     
    10341037
    10351038        psMetadataItem *dateItem = psMetadataItemAllocStr(concept->name, "The date of observation",
    1036                                                           dateString);
     1039                                                          dateString);
    10371040        psMetadataItem *timeItem = psMetadataItemAllocStr(concept->name, "The time of observation",
    1038                                                           timeString);
     1041                                                          timeString);
    10391042
    10401043        psListRemove(dateTime, PS_LIST_HEAD);
     
    10451048
    10461049        psMetadataItem *item = psMetadataItemAllocPtr(concept->name, PS_DATA_LIST, concept->comment,
    1047                                                       dateTime);
     1050                                                      dateTime);
    10481051        psFree (dateItem);
    10491052        psFree (timeItem);
     
    10701073psMetadataItem *p_pmConceptFormat_Positions(const psMetadataItem *concept,
    10711074                                            pmConceptSource source,
    1072                                             const psMetadata *cameraFormat,
    1073                                             const pmFPA *fpa,
    1074                                             const pmChip *chip,
    1075                                             const pmCell *cell)
     1075                                            const psMetadata *cameraFormat,
     1076                                            const pmFPA *fpa,
     1077                                            const pmChip *chip,
     1078                                            const pmCell *cell)
    10761079{
    10771080    assert(concept);
     
    11031106        psString yKeyword = psMetadataLookupStr(&yFound, translation, companion);
    11041107        if (xFound && yFound && strlen(xKeyword) > 0 && strlen(yKeyword) > 0 &&
    1105             strcasecmp(xKeyword, yKeyword) == 0) {
     1108            strcasecmp(xKeyword, yKeyword) == 0) {
    11061109            psMetadataItem *yItem = psMetadataLookup(cell->concepts, companion); // Corresponding y value
    11071110
     
    11281131        psFree(companion);
    11291132        if (xFound && yFound && strlen(xKeyword) > 0 && strlen(yKeyword) > 0 &&
    1130             strcasecmp(xKeyword, yKeyword) == 0) {
     1133            strcasecmp(xKeyword, yKeyword) == 0) {
    11311134            return NULL;                // We did it with the X; don't do anything.
    11321135        }
Note: See TracChangeset for help on using the changeset viewer.