IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41562


Ignore:
Timestamp:
Apr 29, 2021, 2:17:05 PM (5 years ago)
Author:
eugene
Message:

allow tgroups to be fitted without supplying a tgroup list

Location:
trunk/Ohana/src/relphot/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relphot/src/TGroupOps.c

    r41561 r41562  
    66// tgroupTimes carries the times of the tgroups (initially, just the photometric nights)
    77static     int  NtgroupTimes = 0;
     8static     int  NTGROUPTIMES = 0;
    89static TGTimes **tgroupTimes = NULL;
    910
     
    5960  // given photcode, it is left empty (no images)
    6061
    61   ALLOCATE (tgroupTimes, TGTimes *, NtgroupTimes);
     62  NTGROUPTIMES = NtgroupTimes; // if we have loaded a list of times, use that as the starting alloc number
     63  ALLOCATE (tgroupTimes, TGTimes *, NTGROUPTIMES);
    6264
    6365  // the start of an MJD day is 14:00 HST, so the end time can be the start time + 23h 59m 59s (86399s)
     
    118120
    119121  if (!TGROUP_ZEROPT) return;
    120   myAssert (tgroupTimes, "oops, tgroupTimes not allocated");
    121122
    122123  // index of the new entry
    123124  int Ntgt = NtgroupTimes;
    124 
    125125  NtgroupTimes ++;
    126   REALLOCATE (tgroupTimes, TGTimes *, NtgroupTimes);
     126
     127  if (NtgroupTimes >= NTGROUPTIMES) {
     128    NTGROUPTIMES += 100;
     129    REALLOCATE (tgroupTimes, TGTimes *, NTGROUPTIMES);
     130  }
    127131 
    128132  double mjd = ohana_sec_to_mjd (tzero);
     
    187191   * internal construct that defines a group of related images
    188192   */
     193
     194  if (!tgroupTimes) {
     195    NTGROUPTIMES = 100;
     196    ALLOCATE (tgroupTimes, TGTimes *, NTGROUPTIMES);
     197  }
    189198
    190199  ALLOCATE (ImageToTGroup, TGroup *, Nsubset); // tgroup to which image belongs
     
    362371// assume a 1day range for now
    363372TGroup *findTGroup (unsigned int start, int photcode) {
     373
     374  if (!NtgroupTimes) return NULL; // if none are yet defined, do not even try
    364375
    365376  // find index of matching photcode from our list of active secondary photcodes
  • trunk/Ohana/src/relphot/src/args.c

    r41555 r41562  
    359359    TGROUP_ZEROPT = TRUE;
    360360    remove_argument (N, &argc, argv);
    361     TGROUP_FILENAME = strcreate(argv[N]);
    362     remove_argument (N, &argc, argv);
    363361    // if we fit for TGROUPS, start with the images and mosaics frozen
    364362    TGROUP_ZPT_MODE = TGROUP_ZPT_MODE_ALL;
    365363    IMAGE_ZPT_MODE  = IMAGE_ZPT_MODE_NONE;
    366364    MOSAIC_ZPT_MODE = MOSAIC_ZPT_MODE_NONE;
     365  }
     366  if ((N = get_argument (argc, argv, "-tgroup-list"))) {
     367    if (!TGROUP_ZEROPT) {
     368      fprintf (stderr, "-tgroup-list (filename) requires -tgroup option\n");
     369      exit (2);
     370    }
     371    remove_argument (N, &argc, argv);
     372    TGROUP_FILENAME = strcreate(argv[N]);
     373    remove_argument (N, &argc, argv);
    367374  }
    368375  if ((N = get_argument (argc, argv, "-tgroup")) || (N = get_argument (argc, argv, "-tgroups"))) {
     
    567574  if (argc != 1) relphot_usage ();
    568575
    569   if (TGROUP_ZEROPT) {
     576  // if we supplied a file, we need to load it now
     577  if (TGROUP_FILENAME) {
    570578    loadTGroups (TGROUP_FILENAME);
    571579    free (TGROUP_FILENAME);
Note: See TracChangeset for help on using the changeset viewer.