IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28375


Ignore:
Timestamp:
Jun 16, 2010, 5:30:27 PM (16 years ago)
Author:
watersc1
Message:

merge of stack association and warp/stack/diff jpegs

Location:
trunk
Files:
36 edited
9 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Ohana

  • trunk/dbconfig/changes.txt

    r28343 r28375  
    16341634ALTER TABLE diffSkyfile ADD COLUMN maskfrac_advisory FLOAT after maskfrac_magic;
    16351635
     1636
    16361637ALTER TABLE chipRun CHANGE maskfrac_npix  maskfrac_npix FLOAT;
    16371638ALTER TABLE camRun CHANGE maskfrac_npix  maskfrac_npix FLOAT;
    … …  
    17301731-- this adds the new tables
    17311732
    1732 
    17331733CREATE TABLE minidvodbRun (
    17341734minidvodb_id BIGINT AUTO_INCREMENT,
    … …  
    17411741       PRIMARY KEY(minidvodb_id), KEY(minidvodb_name), INDEX(minidvodb_id)
    17421742) ENGINE=innodb DEFAULT CHARSET=latin1;
    1743 
    1744 
    17451743
    17461744CREATE TABLE minidvodbProcessed (
    … …  
    17911789    FOREIGN KEY(diff_phot_id) REFERENCES diffPhotRun(diff_phot_id)
    17921790) ENGINE=innodb DEFAULT CHARSET=latin1;
     1791
     1792
     1793-- Version 1.1.69 warp/stack/diff summary and stack associations.
     1794
     1795CREATE TABLE warpSummary (
     1796    warp_id     BIGINT,
     1797    projection_cell VARCHAR(64) NOT NULL,
     1798    path_base   VARCHAR(255) NOT NULL,
     1799    PRIMARY KEY(warp_id),
     1800    KEY(projection_cell),
     1801    FOREIGN KEY(warp_id) REFERENCES warpRun(warp_id)
     1802) ENGINE=innodb DEFAULT CHARSET=latin1;
     1803
     1804CREATE TABLE diffSummary (
     1805    diff_id     BIGINT,
     1806    projection_cell VARCHAR(64) NOT NULL,
     1807    path_base   VARCHAR(255) NOT NULL,
     1808    PRIMARY KEY(diff_id),
     1809    KEY(projection_cell),
     1810    FOREIGN KEY(diff_id) REFERENCES diffRun(diff_id)
     1811) ENGINE=innodb DEFAULT CHARSET=latin1;
     1812
     1813CREATE TABLE stackAssociation (
     1814    sass_id      BIGINT AUTO_INCREMENT,
     1815    data_group   VARCHAR(64) NOT NULL,
     1816    projection_cell VARCHAR(64) NOT NULL,
     1817    tess_id       VARCHAR(64) NOT NULL,
     1818    filter        VARCHAR(64) NOT NULL,
     1819    PRIMARY KEY(sass_id),
     1820    KEY(data_group),
     1821    KEY(projection_cell),
     1822    KEY(tess_id)
     1823) ENGINE=innodb DEFAULT CHARSET=latin1;
     1824
     1825CREATE TABLE stackAssociationMap (
     1826    sass_id      BIGINT,
     1827    stack_id     BIGINT,
     1828    PRIMARY KEY(sass_id, stack_id),
     1829    FOREIGN KEY(sass_id) REFERENCES stackAssociation(sass_id),
     1830    FOREIGN KEY(stack_id) REFERENCES stackRun(stack_id)
     1831) ENGINE=innodb DEFAULT CHARSET=latin1;
     1832
     1833CREATE TABLE stackSummary (
     1834    sass_id     BIGINT,
     1835    projection_cell VARCHAR(64) NOT NULL,
     1836    path_base   VARCHAR(255) NOT NULL,
     1837    PRIMARY KEY(sass_id),
     1838    KEY(projection_cell),
     1839    FOREIGN KEY(sass_id) REFERENCES stackAssociation(sass_id)
     1840) ENGINE=innodb DEFAULT CHARSET=latin1;
  • trunk/dbconfig/diff.md

    r28056 r28375  
    7575    maskfrac_advisory F32   0.0
    7676END
     77
     78diffSummary METADATA
     79    diff_id         S64      0       # Primary Key fkey(diff_id) ref diffRun(diff_id)
     80    projection_cell STR     32      # Primary Key
     81    path_base       STR     255
     82END
  • trunk/dbconfig/stack.md

    r28043 r28375  
    5353    quality            S16    0
    5454END
     55
     56stackSummary METADATA
     57    sass_id        S64      0       # Primary Key fkey(sass_id) ref stackAssociation(sass_id)
     58    projection_cell  STR            32      # Primary Key
     59    path_base      STR      255
     60END
     61
     62stackAssociation METADATA
     63    sass_id        S64      0       # Primary Key AUTO_INCREMENT
     64    data_group     STR      64      # Key
     65    projection_cell  STR      64      # Key
     66    tess_id        STR      64      # Key
     67    filter         STR      64
     68END
     69
     70stackAssociationMap METADATA
     71    sass_id        S64      0       # Primary Key fkey(sass_id) ref stackAssociation(sass_id)
     72    stack_id       S64      0       # Primary Key fkey(stack_id) ref stackRun(stack_id)
     73END
  • trunk/dbconfig/warp.md

    r28056 r28375  
    7979    label       STR         64      # Primary Key
    8080END
     81
     82warpSummary METADATA
     83    warp_id        S64      0       # Primary Key fkey(warp_id) ref warpRun(warp_id)
     84    projection_cell  STR            32      # Primary Key
     85    path_base      STR      255
     86END
  • trunk/ippScripts/Build.PL

    r28360 r28375  
    109109        scripts/bundle_detrends.pl
    110110        scripts/ipp_cluster_load_monitor.pl
     111        scripts/skycell_jpeg.pl
    111112        scripts/diffphot.pl
    112113    )],
  • trunk/ippScripts/MANIFEST

    r27504 r28375  
    4242scripts/bundle_detrends.pl
    4343scripts/ipp_cluster_load_monitor.pl
     44scripts/skycell_jpeg.pl
    4445t/00_distribution.t
  • trunk/ippTasks/diff.pro

    r27920 r28375  
    1111book init diffSkyfile
    1212#book init diffCleanup
     13book init diffPendingSummary
    1314
    1415### Database lists
    … …  
    1617$diffAdvance_DB = 0
    1718$diff_revert_DB = 0
     19$diffSummary_DB = 0
    1820#$diffCleanup_DB = 0
    1921
    … …  
    2729macro diff.reset
    2830  book init diffSkyfile
     31  book init diffPendingSummary
    2932#  book init diffCleanup
    3033end
    … …  
    4447    active false
    4548  end
     49  task diff.summary.load
     50    active true
     51  end
     52  task diff.summary.run
     53    active true
     54  end
    4655end
    4756
    … …  
    5867  end
    5968  task diff.revert
     69    active false
     70  end
     71  task diff.summary.load
     72    active false
     73  end
     74  task diff.summary.run
    6075    active false
    6176  end
    … …  
    193208    # host anyhost
    194209    # $WORKDIR = $WORKDIR_TEMPLATE
    195 
    196210    if (($DIFF_MODE == 1)||("$DIFF_MODE" == "NULL"))
    197211        $DIFF_TAG = ""
    … …  
    477491  end
    478492end
     493
     494### Load tasks for doing the diffs
     495### Tasks are loaded into diffPendingSkyCell.
     496task           diff.summary.load
     497  host         local
     498
     499  periods      -poll $LOADPOLL
     500  periods      -exec $LOADEXEC
     501  periods      -timeout 1200
     502  npending     1
     503
     504  stdout NULL
     505  stderr $LOGDIR/diff.summary.log
     506
     507  task.exec
     508    if ($LABEL:n == 0) break
     509    $run = difftool -tosummary
     510    if ($DB:n == 0)
     511      option DEFAULT
     512    else
     513      # save the DB name for the exit tasks
     514      option $DB:$diffSummary_DB
     515      $run = $run -dbname $DB:$diffSummary_DB
     516      $diffSummary_DB ++
     517      if ($diffSummary_DB >= $DB:n) set diffSummary_DB = 0
     518    end
     519    add_poll_args run
     520    add_poll_labels run
     521    command $run
     522  end
     523
     524  # success
     525  task.exit    0
     526    # convert 'stdout' to book format
     527    # XXX change tess_id to tess_dir when db is updated
     528    ipptool2book stdout diffPendingSummary -key diff_id -uniq -setword dbname $options:0 -setword pantaskState INIT
     529    if ($VERBOSE > 2)
     530      book listbook diffPendingSummary
     531    end
     532
     533    # delete existing entries in the appropriate pantaskStates
     534    process_cleanup diffPendingSummary
     535  end
     536
     537  # locked list
     538  task.exit    default
     539    showcommand failure
     540  end
     541
     542  task.exit    crash
     543    showcommand crash
     544  end
     545
     546  # operation times out?
     547  task.exit    timeout
     548    showcommand timeout
     549  end
     550end
     551
     552### Run tasks for calculating the diff overlaps
     553### Tasks are taken from diffPendingSkyCell.
     554task           diff.summary.run
     555  periods      -poll $RUNPOLL
     556  periods      -exec $RUNEXEC
     557  periods      -timeout 60
     558
     559  task.exec
     560    # if we are unable to run the 'exec', use a long retry time
     561    periods -exec $RUNEXEC
     562
     563    book npages diffPendingSummary -var N
     564    if ($N == 0) break
     565    if ($NETWORK == 0) break
     566   
     567    # look for new images in diffPendingSkyCell (pantaskState == INIT)
     568    book getpage diffPendingSummary 0 -var pageName -key pantaskState INIT
     569    if ("$pageName" == "NULL") break
     570
     571    book setword diffPendingSummary $pageName pantaskState RUN
     572    book getword diffPendingSummary $pageName diff_id -var DIFF_ID
     573    book getword diffPendingSummary $pageName camera -var CAMERA
     574    book getword diffPendingSummary $pageName workdir -var WORKDIR_TEMPLATE
     575    book getword diffPendingSummary $pageName dbname -var DBNAME
     576    book getword diffPendingSummary $pageName tess_id -var TESS_DIR
     577    book getword diffPendingSummary $pageName diff_mode -var DIFF_MODE
     578    book getword diffPendingSummary $pageName state -var RUN_STATE
     579
     580    # set the host and workdir based on the skycell hash
     581    host anyhost
     582    strsub $WORKDIR_TEMPLATE @HOST@.0 $default_host -var WORKDIR
     583#    set.workdir.by.skycell $SKYCELL_ID $WORKDIR_TEMPLATE $default_host WORKDIR
     584
     585#    if ("$PATH_BASE" == "NULL")
     586
     587    if (($DIFF_MODE == 1)||("$DIFF_MODE" == "NULL"))
     588        $DIFF_TAG = ""
     589    end
     590    if ($DIFF_MODE == 2)
     591        $DIFF_TAG = "WS."
     592    end
     593    if ($DIFF_MODE == 3)
     594        $DIFF_TAG = "SW."
     595    end
     596    if ($DIFF_MODE == 4)
     597        $DIFF_TAG = "SS."
     598    end
     599
     600    basename $TESS_DIR -var TESS_ID
     601
     602    ## generate outroot specific to this exposure
     603    sprintf outroot "%s/%s/%s.%sdif.%s.summary" $WORKDIR $TESS_ID $TESS_ID $DIFF_TAG $DIFF_ID
     604
     605
     606    stdout $LOGDIR/diff.summary.log
     607    stderr $LOGDIR/diff.summary.log
     608
     609    $run = skycell_jpeg.pl --stage diff --stage_id $DIFF_ID --camera $CAMERA --outroot $outroot
     610    add_standard_args run
     611
     612    # save the pageName for future reference below
     613    options $pageName
     614
     615    # create the command line
     616    if ($VERBOSE > 1)
     617      echo command $run
     618    end
     619    periods -exec 0.05
     620    command $run
     621  end
     622
     623  # default exit status
     624  task.exit    default
     625    process_exit diffPendingSummary $options:0 $JOB_STATUS
     626  end
     627
     628  # locked list
     629  task.exit    crash
     630    showcommand crash
     631    echo "hostname: $JOB_HOSTNAME"
     632    book setword diffPendingSummary $options:0 pantaskState CRASH
     633  end
     634
     635  # operation timed out?
     636  task.exit    timeout
     637    showcommand timeout
     638    book setword diffPendingSummary $options:0 pantaskState TIMEOUT
     639  end
     640end
  • trunk/ippTasks/stack.pro

    r27929 r28375  
    1010### Initialise the books containing the tasks to do
    1111book init stackSumSkyfile
     12book init stackPendingSummary
    1213#book init stackCleanup
    1314
    … …  
    1617$stack_revert_DB = 0
    1718#$stackCleanup_DB = 0
     19$stackSummary_DB = 0
    1820
    1921### Check status of stacking tasks
    … …  
    2628macro stack.reset
    2729  book init stackSumSkyfile
     30  book init stackPendingSummary
    2831#  book init stackCleanup
    2932end
    … …  
    4043    active false
    4144  end
     45  task stack.summary.load
     46    active true
     47  end
     48  task stack.summary.run
     49    active true
     50  end
    4251end
    4352
    … …  
    5160  end
    5261  task stack.revert
     62    active false
     63  end
     64  task stack.summary.load
     65    active false
     66  end
     67  task stack.summary.run
    5368    active false
    5469  end
    … …  
    349364# end
    350365
     366
     367
     368
    351369task stack.revert
    352370  host         local
    … …  
    400418end
    401419
     420### Load tasks for doing the stack summary
     421### Tasks are loaded into stackPendingSummary
     422task           stack.summary.load
     423  host         local
     424
     425  periods      -poll $LOADPOLL
     426  periods      -exec $LOADEXEC
     427  periods      -timeout 1200
     428  trange       07:00:00 08:00:00 -nmax 1
     429  npending     1
     430
     431  stdout       NULL
     432  stderr       $LOGDIR/stack.summary.load
     433
     434  task.exec
     435    if ($LABEL:n == 0) break
     436    $run = stacktool -tosummary
     437    if ($DB:n == 0)
     438      option DEFAULT
     439    else
     440      # save the DB name for the exit tasks
     441      option $DB:$stackSummary_DB
     442      $run = $run -dbname $DB:$stackSummary_DB
     443      $stackSummary_DB ++
     444      if ($stackSummary_DB >= $DB:n) set stackSummary_DB = 0
     445    end
     446    add_poll_args run
     447    add_poll_labels run
     448    command $run
     449  end
     450
     451  # success
     452  task.exit     0
     453    # convert 'stdout' to book format
     454    ipptool2book stdout stackPendingSummary -key sass_id -uniq -setword dbname $options:0 -setword pantaskState INIT
     455    if ($VERBOSE > 2)
     456      book listbook stackPendingSummary
     457    end
     458
     459    # delete existing entries in the appropriate pantaskStates
     460    process_cleanup stackPendingSummary
     461  end
     462
     463  # locked list
     464  task.exit     default
     465    showcommand failure
     466  end
     467
     468  task.exit     crash
     469    showcommand crash
     470  end
     471
     472  # operation times out?
     473  task.exit     timeout
     474    showcommand timeout
     475  end
     476end
     477
     478### Run tasks for doing the stack summary
     479task           stack.summary.run
     480  periods      -poll $RUNPOLL
     481  periods      -exec $RUNEXEC
     482  periods      -timeout 60
     483
     484  task.exec
     485    # if we are unable to run the 'exec', use a long retry time
     486    periods -exec $RUNEXEC
     487
     488    book npages stackPendingSummary -var N
     489    if ($N == 0) break
     490    if ($NETWORK == 0) break
     491
     492    # look for new images in stackPendingSummary (pantaskState == INIT)
     493    book getpage stackPendingSummary 0 -var pageName -key pantaskState INIT
     494    if ("$pageName" == "NULL") break
     495
     496    book setword stackPendingSummary $pageName pantaskState RUN
     497    book getword stackPendingSummary $pageName sass_id -var SASS_ID
     498    book getword stackPendingSummary $pageName camera -var CAMERA
     499    book getword stackPendingSummary $pageName workdir -var WORKDIR_TEMPLATE
     500    book getword stackPendingSummary $pageName dbname -var DBNAME
     501    book getword stackPendingSummary $pageName tess_id -var TESS_DIR
     502    book getword stackPendingSummary $pageName state -var RUN_STATE
     503    book getword stackPendingSummary $pageName projection_cell -var projection_cell
     504
     505    # set the host and workdir
     506    host anyhost
     507    strsub $WORKDIR_TEMPLATE @HOST@.0 $default_host -var WORKDIR
     508
     509    basename $TESS_DIR -var TESS_ID
     510
     511    ## generate outroot specific to this association
     512    sprintf outroot "%s/%s/%s.stk.%s.summary" $WORKDIR $TESS_ID $TESS_ID $SASS_ID
     513
     514    stdout $LOGDIR/stack.summary.log
     515    stderr $LOGDIR/stack.summary.log
     516
     517    $run = skycell_jpeg.pl --stage stack --stage_id $SASS_ID --camera $CAMERA --outroot $outroot
     518    add_standard_args run
     519
     520    # save the pageName for future reference below
     521    options $pageName
     522
     523    # create the command line
     524    if ($VERBOSE > 1)
     525        echo command $run
     526    end
     527    periods -exec 0.05
     528    command $run
     529  end
     530
     531  # default exit status
     532  task.exit       default
     533    process_exit stackPendingSummary $options:0 $JOB_STATUS
     534  end
     535
     536  # locked list
     537  task.exit       crash
     538    showcommand crash
     539    echo "hostname: $JOB_HOSTNAME"
     540    book setword stackPendingSummary $options:0 pantaskState CRASH
     541  end
     542
     543  # operation timed out?
     544  task.exit       timeout
     545    showcommand timeout
     546    book setword stackPendingSummary $options:0 pantaskState TIMEOUT
     547  end
     548end
     549
  • trunk/ippTasks/warp.pro

    r27926 r28375  
    1313book init warpPendingSkyCell
    1414book init warpPendingCleanup
     15book init warpPendingSummary
    1516
    1617### Database lists
    … …  
    1920$warp_revert_overlap_DB = 0
    2021$warp_revert_warped_DB = 0
     22$warpSummary_DB = 0
    2123
    2224### Check status of warping tasks
    … …  
    3032  book init warpInputExp
    3133  book init warpPendingSkyCell
     34  book init warpPendingSummary
    3235end
    3336
    … …  
    5558    active true
    5659  end
     60  task warp.summary.load
     61    active true
     62  end
     63  task warp.summary.run
     64    active true
     65  end
    5766end
    5867
    … …  
    7887  end
    7988  task warp.revert.warped
     89    active false
     90  end
     91  task warp.summary.load
     92    active false
     93  end
     94  task warp.summary.run
    8095    active false
    8196  end
    … …  
    525540  end
    526541end
     542
     543### Load tasks for doing the warps
     544### Tasks are loaded into warpPendingSkyCell.
     545task           warp.summary.load
     546  host         local
     547
     548  periods      -poll $LOADPOLL
     549  periods      -exec $LOADEXEC
     550  periods      -timeout 1200
     551  npending     1
     552
     553  stdout NULL
     554  stderr $LOGDIR/warp.summary.log
     555
     556  task.exec
     557    if ($LABEL:n == 0) break
     558    $run = warptool -tosummary
     559    if ($DB:n == 0)
     560      option DEFAULT
     561    else
     562      # save the DB name for the exit tasks
     563      option $DB:$warpSummary_DB
     564      $run = $run -dbname $DB:$warpSummary_DB
     565      $warpSummary_DB ++
     566      if ($warpSummary_DB >= $DB:n) set warpSummary_DB = 0
     567    end
     568    add_poll_args run
     569    add_poll_labels run
     570    command $run
     571  end
     572
     573  # success
     574  task.exit    0
     575    # convert 'stdout' to book format
     576    # XXX change tess_id to tess_dir when db is updated
     577    ipptool2book stdout warpPendingSummary -key warp_id -uniq -setword dbname $options:0 -setword pantaskState INIT
     578    if ($VERBOSE > 2)
     579      book listbook warpPendingSummary
     580    end
     581
     582    # delete existing entries in the appropriate pantaskStates
     583    process_cleanup warpPendingSummary
     584  end
     585
     586  # locked list
     587  task.exit    default
     588    showcommand failure
     589  end
     590
     591  task.exit    crash
     592    showcommand crash
     593  end
     594
     595  # operation times out?
     596  task.exit    timeout
     597    showcommand timeout
     598  end
     599end
     600
     601### Run tasks for calculating the warp overlaps
     602### Tasks are taken from warpPendingSkyCell.
     603task           warp.summary.run
     604  periods      -poll $RUNPOLL
     605  periods      -exec $RUNEXEC
     606  periods      -timeout 60
     607
     608  task.exec
     609    # if we are unable to run the 'exec', use a long retry time
     610    periods -exec $RUNEXEC
     611
     612    book npages warpPendingSummary -var N
     613    if ($N == 0) break
     614    if ($NETWORK == 0) break
     615   
     616    # look for new images in warpPendingSkyCell (pantaskState == INIT)
     617    book getpage warpPendingSummary 0 -var pageName -key pantaskState INIT
     618    if ("$pageName" == "NULL") break
     619
     620    book setword warpPendingSummary $pageName pantaskState RUN
     621    book getword warpPendingSummary $pageName warp_id -var WARP_ID
     622    book getword warpPendingSummary $pageName camera -var CAMERA
     623    book getword warpPendingSummary $pageName workdir -var WORKDIR_TEMPLATE
     624    book getword warpPendingSummary $pageName dbname -var DBNAME
     625    book getword warpPendingSummary $pageName tess_id -var TESS_DIR
     626    book getword warpPendingSummary $pageName exp_tag -var EXP_TAG
     627    book getword warpPendingSummary $pageName state -var RUN_STATE
     628
     629    # set the host and workdir based on the skycell hash
     630    host anyhost
     631    strsub $WORKDIR_TEMPLATE @HOST@.0 $default_host -var WORKDIR
     632#    set.workdir.by.skycell $SKYCELL_ID $WORKDIR_TEMPLATE $default_host WORKDIR
     633
     634#    if ("$PATH_BASE" == "NULL")
     635        ## generate outroot specific to this exposure
     636    basename $TESS_DIR -var TESS_ID
     637
     638    sprintf outroot "%s/%s/%s.wrp.%s.%s" $WORKDIR $EXP_TAG $EXP_TAG $WARP_ID $TESS_ID
     639
     640
     641    stdout $LOGDIR/warp.summary.log
     642    stderr $LOGDIR/warp.summary.log
     643
     644    $run = skycell_jpeg.pl --stage warp --stage_id $WARP_ID --camera $CAMERA --outroot $outroot
     645    add_standard_args run
     646
     647    # save the pageName for future reference below
     648    options $pageName
     649
     650    # create the command line
     651    if ($VERBOSE > 1)
     652      echo command $run
     653    end
     654    periods -exec 0.05
     655    command $run
     656  end
     657
     658  # default exit status
     659  task.exit    default
     660    process_exit warpPendingSummary $options:0 $JOB_STATUS
     661  end
     662
     663  # locked list
     664  task.exit    crash
     665    showcommand crash
     666    echo "hostname: $JOB_HOSTNAME"
     667    book setword warpPendingSummary $options:0 pantaskState CRASH
     668  end
     669
     670  # operation timed out?
     671  task.exit    timeout
     672    showcommand timeout
     673    book setword warpPendingSummary $options:0 pantaskState TIMEOUT
     674  end
     675end
  • trunk/ippTools/share/Makefile.am

    r28343 r28375  
    126126     difftool_skyfile.sql \
    127127     difftool_todiffskyfile.sql \
     128     difftool_tosummary.sql \
     129     difftool_addsummary.sql \
    128130     disttool_definebyquery_camera.sql \
    129131     disttool_definebyquery_chip.sql \
    … …  
    278280     regtool_updatebyquery.sql \
    279281     regtool_updatebyqueryimfile.sql \
     282     stacktool_associationdefine_select.sql \
    280283     stacktool_definebyquery_insert.sql \
    281284     stacktool_definebyquery_insert_random_part1.sql \
    … …  
    293296     stacktool_revertsumskyfile_delete.sql \
    294297     stacktool_sumskyfile.sql \
     298     stacktool_sassskyfile.sql \
    295299     stacktool_tosum.sql \
     300     stacktool_tosummary.sql \
     301     stacktool_addsummary.sql \
    296302     staticskytool_definebyquery_select.sql \
    297303     staticskytool_definebyquery_inputs.sql \
    … …  
    326332     warptool_updateskyfile.sql \
    327333     warptool_warped.sql \
     334     warptool_tosummary.sql \
     335     warptool_addsummary.sql \
    328336        diffphottool_definerun.sql \
    329337        diffphottool_input.sql \
  • trunk/ippTools/share/pxadmin_create_tables.sql

    r28348 r28375  
    981981) ENGINE=innodb DEFAULT CHARSET=latin1;
    982982
     983CREATE TABLE warpSummary (
     984       warp_id BIGINT,
     985       projection_cell VARCHAR(64) NOT NULL,
     986       path_base     VARCHAR(255) NOT NULL,
     987       PRIMARY KEY(warp_id),
     988       KEY(projection_cell),
     989       FOREIGN KEY(warp_id) REFERENCES warpRun(warp_id)
     990) ENGINE=innodb DEFAULT CHARSET=latin1;
     991
    983992CREATE TABLE stackRun (
    984993        stack_id BIGINT AUTO_INCREMENT,
    … …  
    10491058        KEY(quality),
    10501059        FOREIGN KEY(stack_id) REFERENCES stackRun(stack_id)
     1060) ENGINE=innodb DEFAULT CHARSET=latin1;
     1061
     1062CREATE TABLE stackAssociation (
     1063    sass_id      BIGINT AUTO_INCREMENT,
     1064    data_group   VARCHAR(64) NOT NULL,
     1065    projection_cell VARCHAR(64) NOT NULL,
     1066    tess_id       VARCHAR(64) NOT NULL,
     1067    filter        VARCHAR(64) NOT NULL,
     1068    PRIMARY KEY(sass_id),
     1069    KEY(data_group),
     1070    KEY(projection_cell),
     1071    KEY(tess_id)
     1072) ENGINE=innodb DEFAULT CHARSET=latin1;
     1073
     1074CREATE TABLE stackAssociationMap (
     1075    sass_id      BIGINT,
     1076    stack_id     BIGINT,
     1077    PRIMARY KEY(sass_id, stack_id),
     1078    FOREIGN KEY(sass_id) REFERENCES stackAssociation(sass_id),
     1079    FOREIGN KEY(stack_id) REFERENCES stackRun(stack_id)
     1080) ENGINE=innodb DEFAULT CHARSET=latin1;
     1081
     1082CREATE TABLE stackSummary (
     1083    sass_id     BIGINT,
     1084    projection_cell VARCHAR(64) NOT NULL,
     1085    path_base   VARCHAR(255) NOT NULL,
     1086    PRIMARY KEY(sass_id),
     1087    KEY(projection_cell),
     1088    FOREIGN KEY(sass_id) REFERENCES stackAssociation(sass_id)
    10511089) ENGINE=innodb DEFAULT CHARSET=latin1;
    10521090
    … …  
    11471185) ENGINE=innodb DEFAULT CHARSET=latin1;
    11481186
     1187CREATE TABLE diffSummary (
     1188    diff_id     BIGINT,
     1189    projection_cell VARCHAR(64) NOT NULL,
     1190    path_base   VARCHAR(255) NOT NULL,
     1191    PRIMARY KEY(diff_id),
     1192    KEY(projection_cell),
     1193    FOREIGN KEY(diff_id) REFERENCES diffRun(diff_id)
     1194) ENGINE=innodb DEFAULT CHARSET=latin1;
     1195
    11491196CREATE TABLE magicRun (
    11501197        magic_id BIGINT AUTO_INCREMENT,
  • trunk/ippTools/share/pxadmin_drop_tables.sql

    r28349 r28375  
    4141DROP TABLE IF EXISTS warpSkyfile;
    4242DROP TABLE IF EXISTS warpMask;
     43DROP TABLE IF EXISTS warpSummary;
    4344DROP TABLE IF EXISTS diffRun;
    4445DROP TABLE IF EXISTS diffInputSkyfile;
    4546DROP TABLE IF EXISTS diffSkyfile;
     47DROP TABLE IF EXISTS diffSummary;
    4648DROP TABLE IF EXISTS stackRun;
    4749DROP TABLE IF EXISTS stackInputSkyfile;
    4850DROP TABLE IF EXISTS stackSumSkyfile;
     51DROP TABLE IF EXISTS stackSummary;
     52DROP TABLE IF EXISTS stackAssociation;
     53DROP TABLE IF EXISTS stackAssociationMap;
    4954DROP TABLE IF EXISTS magicRun;
    5055DROP TABLE IF EXISTS magicInputSkyfile;
  • trunk/ippTools/share/stacktool_associationdefine_select.sql

    r28338 r28375  
    22       sass_id,
    33       data_group,
     4       projection_cell,
    45       tess_id,
    5        filter,
    6        CASE WHEN LOCATE('.',skycell_id,9) > 0 THEN
    7             SUBSTRING_INDEX(skycell_id,'.',2) ELSE
    8             SUBSTRING_INDEX(skycell_id,'.',1) END
    9        AS projection_cell
     6       filter
     7       FROM stackAssociation
     8RIGHT JOIN (
     9      SELECT
     10             data_group,
     11             tess_id,
     12             filter,
     13             CASE WHEN LOCATE('.',skycell_id,9) > 0 THEN
     14                  SUBSTRING_INDEX(skycell_id,'.',2) ELSE
     15                  SUBSTRING_INDEX(skycell_id,'.',1) END
     16             AS projection_cell
    1017       FROM stackRun
    11        LEFT JOIN stackAssociationMap USING (stack_id)
    12        WHERE stackRun.stack_id = @STACK_ID@
     18       WHERE stackRun.stack_id = @STACK_ID@
     19             ) AS RUN USING (data_group,tess_id,filter,projection_cell) LIMIT 1
  • trunk/ippTools/src/difftool.c

    r28056 r28375  
    4444static bool definewarpwarpMode(pxConfig *config);
    4545static bool definestackstackMode(pxConfig *config);
     46static bool tosummaryMode(pxConfig *config);
     47static bool addsummaryMode(pxConfig *config);
    4648static bool pendingcleanuprunMode(pxConfig *config);
    4749static bool pendingcleanupskyfileMode(pxConfig *config);
    … …  
    9395        MODECASE(DIFFTOOL_MODE_DEFINEWARPWARP,        definewarpwarpMode);
    9496        MODECASE(DIFFTOOL_MODE_DEFINESTACKSTACK,      definestackstackMode);
     97        MODECASE(DIFFTOOL_MODE_TOSUMMARY,             tosummaryMode);
     98        MODECASE(DIFFTOOL_MODE_ADDSUMMARY,            addsummaryMode);
    9599        MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPRUN,     pendingcleanuprunMode);
    96100        MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode);
    … …  
    22502254}
    22512255
     2256static bool tosummaryMode(pxConfig *config) {
     2257  PS_ASSERT_PTR_NON_NULL(config, NULL);
     2258 
     2259  psMetadata *where = psMetadataAlloc();
     2260  PXOPT_COPY_S64(config->args, where, "-warp_id",    "diffSkyfile.warp_id", "==");
     2261  PXOPT_COPY_STR(config->args, where, "-tess_id",    "diffSkyfile.tess_id", "==");
     2262  PXOPT_COPY_STR(config->args, where, "-state",      "diffRun.state", "==");
     2263  PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs",  ">=");
     2264  PXOPT_COPY_TIME(config->args, where, "-dateobs_end",   "rawExp.dateobs",  "<=");
     2265  PXOPT_COPY_STR(config->args, where, "-filter",    "rawExp.filter", "LIKE");
     2266  PXOPT_COPY_S64(config->args, where, "-magicked", "diffSkyfile.magicked", "==");
     2267  pxAddLabelSearchArgs (config, where, "-label",   "diffRun.label", "LIKE");
     2268  pxAddLabelSearchArgs (config, where, "-data_group",   "diffRun.data_group", "LIKE");
     2269
     2270  PXOPT_LOOKUP_BOOL(all, config->args, "-all", false);
     2271
     2272  PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     2273  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     2274 
     2275  // find all rawImfiles matching the default query
     2276  psString query = pxDataGet("difftool_tosummary.sql");
     2277  if (!query) {
     2278    psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     2279    return false;
     2280  }
     2281
     2282  // generate where strings for arguments that require extra processing
     2283  // beyond PXOPT_COPY*
     2284  psString where2 = NULL;
     2285  if (!pxmagicAddWhere(config, &where2, "diffSkyfile")) {
     2286    psError(psErrorCodeLast(), false, "pxMagicAddWhere failed");
     2287    return false;
     2288  }
     2289 
     2290  if (psListLength(where->list)) {
     2291    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     2292    psStringAppend(&query, " AND %s", whereClause);
     2293    psFree(whereClause);
     2294  } else if (!all && !where2) {
     2295    psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required");
     2296    return false;
     2297  }
     2298 
     2299  if (where2) {
     2300    if (psListLength(where->list)) {
     2301      psStringAppend(&query, " %s", where2);
     2302    } else {
     2303      psStringAppend(&query, " AND 1 %s", where2);
     2304    }
     2305  }
     2306  psFree(where);
     2307
     2308  // treat limit == 0 as "no limit"
     2309  if (limit) {
     2310    psString limitString = psDBGenerateLimitSQL(limit);
     2311    psStringAppend(&query, " %s", limitString);
     2312    psFree(limitString);
     2313  }
     2314 
     2315  if (!p_psDBRunQuery(config->dbh, query)) {
     2316    psError(PS_ERR_UNKNOWN, false, "database error");
     2317    psFree(query);
     2318    return false;
     2319  }
     2320  psFree(query);
     2321
     2322  psArray *output = p_psDBFetchResult(config->dbh);
     2323  if (!output) {
     2324    psErrorCode err = psErrorCodeLast();
     2325    switch (err) {
     2326    case PS_ERR_DB_CLIENT:
     2327      psError(PXTOOLS_ERR_SYS, false, "database error");
     2328    case PS_ERR_DB_SERVER:
     2329      psError(PXTOOLS_ERR_PROG, false, "database error");
     2330    default:
     2331      psError(PXTOOLS_ERR_PROG, false, "unknown error");
     2332    }
     2333   
     2334    return false;
     2335  }
     2336  if (!psArrayLength(output)) {
     2337    psTrace("difftool", PS_LOG_INFO, "no rows found");
     2338    psFree(output);
     2339    return true;
     2340  }
     2341 
     2342  if (psArrayLength(output)) {
     2343    // negative simple so the default is true
     2344    if (!ippdbPrintMetadatas(stdout, output, "diffRun", !simple)) {
     2345      psError(PS_ERR_UNKNOWN, false, "failed to print array");
     2346      psFree(output);
     2347      return false;
     2348    }
     2349  }
     2350 
     2351  psFree(output);
     2352  return(true);
     2353}
     2354static bool addsummaryMode(pxConfig *config) {
     2355  PS_ASSERT_PTR_NON_NULL(config, NULL);
     2356
     2357  PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false);
     2358  PXOPT_LOOKUP_STR(projection_cell, config->args, "-projection_cell", true, false);
     2359  PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
     2360
     2361  psString query = pxDataGet("difftool_addsummary.sql");
     2362  if (!query) {
     2363    psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     2364    return(false);
     2365  }
     2366  if (!p_psDBRunQueryF(config->dbh, query, diff_id, projection_cell, path_base)) {
     2367    psError(PS_ERR_UNKNOWN, false, "database error");
     2368    psFree(query);
     2369    return(false);
     2370  }
     2371  psS64 numUpdated = psDBAffectedRows(config->dbh);
     2372 
     2373  if (numUpdated != 1) {
     2374    psError(PS_ERR_UNKNOWN, false, "should have affected 1 row");
     2375    psFree(query);
     2376    return false;
     2377  }
     2378 
     2379  psFree(query);
     2380
     2381  // Print anything here?
     2382 
     2383  return(true);
     2384}
     2385
     2386
    22522387static bool pendingcleanuprunMode(pxConfig *config)
    22532388{
  • trunk/ippTools/src/difftool.h

    r27794 r28375  
    3232    DIFFTOOL_MODE_ADDDIFFSKYFILE,
    3333    DIFFTOOL_MODE_ADVANCE,
     34    DIFFTOOL_MODE_TOSUMMARY,
     35    DIFFTOOL_MODE_ADDSUMMARY,
    3436    DIFFTOOL_MODE_DIFFSKYFILE,
    3537    DIFFTOOL_MODE_REVERTDIFFSKYFILE,
  • trunk/ippTools/src/difftoolConfig.c

    r28054 r28375  
    323323    psMetadataAddU64(pendingcleanuprunArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
    324324
     325    // -tosummary
     326    psMetadata *tosummaryArgs = psMetadataAlloc();
     327    psMetadataAddS64(tosummaryArgs, PS_LIST_TAIL,  "-diff_id", 0,           "search by diff ID", 0);
     328    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL,  "-tess_id",  0,          "search by tessellation ID", NULL);
     329    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL, "-state",  0,            "search by state", NULL);
     330    psMetadataAddS64(tosummaryArgs, PS_LIST_TAIL,  "-exp_id",  0,           "search by exposure ID", 0);
     331    psMetadataAddStr(tosummaryArgs , PS_LIST_TAIL, "-exp_name",  0,        "search by exposure name", NULL);
     332    psMetadataAddS64(tosummaryArgs, PS_LIST_TAIL, "-warp_id", 0,         "search by warp ID", 0);
     333   
     334    psMetadataAddTime(tosummaryArgs, PS_LIST_TAIL, "-dateobs_begin", 0,    "search for exposures by time (>=)", NULL);
     335    psMetadataAddTime(tosummaryArgs, PS_LIST_TAIL, "-dateobs_end", 0,      "search for exposures by time (<=)", NULL);
     336    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL,  "-filter", 0,           "search for filter", NULL);
     337    psMetadataAddS64(tosummaryArgs, PS_LIST_TAIL,  "-magicked", 0,         "search by magic id", 0);
     338    psMetadataAddStr(tosummaryArgs,  PS_LIST_TAIL, "-label",  PS_META_DUPLICATE_OK, "search by diffRun label (LIKE comparison)", NULL);
     339    psMetadataAddStr(tosummaryArgs,  PS_LIST_TAIL, "-data_group",  PS_META_DUPLICATE_OK, "search by diffRun data_group (LIKE comparison)", NULL);
     340    psMetadataAddStr(tosummaryArgs,  PS_LIST_TAIL, "-dist_group",  PS_META_DUPLICATE_OK, "search by diffRun dist_group (LIKE comparison)", NULL);
     341    psMetadataAddBool(tosummaryArgs, PS_LIST_TAIL,  "-destreaked", 0, "search for runs that have been destreaked", false);
     342    psMetadataAddBool(tosummaryArgs, PS_LIST_TAIL,  "-not_destreaked", 0, "search for runs that have not been destreaked", false);
     343   
     344    psMetadataAddBool(tosummaryArgs, PS_LIST_TAIL, "-all",  0,             "search without arguments", false);
     345    psMetadataAddU64(tosummaryArgs, PS_LIST_TAIL,  "-limit",  0,            "limit result set to N items", 0);
     346    psMetadataAddBool(tosummaryArgs, PS_LIST_TAIL, "-simple",  0,          "use the simple output format", false);
     347   
     348    // -addsummary
     349    psMetadata *addsummaryArgs = psMetadataAlloc();
     350    psMetadataAddS64(addsummaryArgs, PS_LIST_TAIL,  "-diff_id", 0,           "search by diff ID", 0);
     351    psMetadataAddStr(addsummaryArgs, PS_LIST_TAIL, "-projection_cell", 0, "set projection cell", NULL);
     352    psMetadataAddStr(addsummaryArgs, PS_LIST_TAIL, "-path_base", 0, "set summary path base", NULL);
     353
    325354    // -pendingcleanupskyfile
    326355    psMetadata *pendingcleanupskyfileArgs = psMetadataAlloc();
    … …  
    380409    psMetadata *importrunArgs = psMetadataAlloc();
    381410    psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile",  0,          "import from this file (required)", NULL);
    382 
    383411
    384412
    … …  
    415443    PXOPT_ADD_MODE("-toscrubbedskyfile", "set skyfile as scrubbed", DIFFTOOL_MODE_TOSCRUBBEDSKYFILE, toscrubbedskyfileArgs);
    416444    PXOPT_ADD_MODE("-tofullskyfile", "set skyfile as full", DIFFTOOL_MODE_TOFULLSKYFILE, tofullskyfileArgs);
     445    PXOPT_ADD_MODE("-tosummary",            "show runs that can be summarized", DIFFTOOL_MODE_TOSUMMARY, tosummaryArgs);
     446    PXOPT_ADD_MODE("-addsummary",           "add entry to the summary table", DIFFTOOL_MODE_ADDSUMMARY, addsummaryArgs);
    417447
    418448    if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
  • trunk/ippTools/src/stacktool.c

    r28043 r28375  
    3939static bool addsumskyfileMode(pxConfig *config);
    4040static bool sumskyfileMode(pxConfig *config);
     41static bool sassskyfileMode(pxConfig *config);
    4142static bool revertsumskyfileMode(pxConfig *config);
     43static bool tosummaryMode(pxConfig *config);
     44static bool addsummaryMode(pxConfig *config);
    4245static bool pendingcleanuprunMode(pxConfig *config);
    4346static bool pendingcleanupskyfileMode(pxConfig *config);
    … …  
    7578        MODECASE(STACKTOOL_MODE_ADDSUMSKYFILE,         addsumskyfileMode);
    7679        MODECASE(STACKTOOL_MODE_SUMSKYFILE,            sumskyfileMode);
     80        MODECASE(STACKTOOL_MODE_SASSSKYFILE,            sassskyfileMode);
    7781        MODECASE(STACKTOOL_MODE_REVERTSUMSKYFILE,      revertsumskyfileMode);
     82        MODECASE(STACKTOOL_MODE_TOSUMMARY,             tosummaryMode);
     83        MODECASE(STACKTOOL_MODE_ADDSUMMARY,            addsummaryMode);
    7884        MODECASE(STACKTOOL_MODE_PENDINGCLEANUPRUN,     pendingcleanuprunMode);
    7985        MODECASE(STACKTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode);
    … …  
    102108    exit(exit_status);
    103109}
     110//stackAssociationRow *association = pxStackAssociationDefine(data_group,tess_id,filter,skycell_id);
     111stackAssociationRow *pxStackAssociationDefine(pxConfig *config, psS64 stack_id) {
     112  psString select = pxDataGet("stacktool_associationdefine_select.sql");
     113  if (!select) {
     114    psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     115    return false;
     116  }
     117
     118  psString idString = NULL;
     119  psStringAppend(&idString, "%" PRId64, stack_id);
     120  // Copy string to get around the issue with psStringSubstitute not believing
     121  // that select is a psString.
     122  psString rep = psStringCopy(select);
     123  psFree(select);
     124  select = rep;
     125  psStringSubstitute(&select, idString, "@STACK_ID@");
     126  psFree(idString);
     127
     128  if (!p_psDBRunQuery(config->dbh, select)) {
     129    psError(PS_ERR_UNKNOWN,false, "database error");
     130    psFree(select);
     131    return(NULL);
     132  }
     133  psFree(select);
     134  psArray *output = p_psDBFetchResult(config->dbh);
     135  if (!output) {
     136    psErrorCode err = psErrorCodeLast();
     137    switch (err) {
     138    case PS_ERR_DB_CLIENT:
     139      psError(PXTOOLS_ERR_SYS, false, "database error");
     140    case PS_ERR_DB_SERVER:
     141      psError(PXTOOLS_ERR_PROG, false, "database error");
     142    default:
     143      psError(PXTOOLS_ERR_PROG, false, "unknown error");
     144    }
     145    return(NULL);
     146  }
     147  if (psArrayLength(output) != 1) {
     148    psWarning("stacktool: incorrect number of rows found");
     149    psFree(output);
     150    return(NULL);
     151  }
     152  psMetadata *outrow = psMetadataAlloc();
     153  for (long i = 0; i < output->n; i++) {
     154    psMetadata *row = output->data[i];
     155
     156    printf("%" PRId64 " %s %s %s %s\n",psMetadataLookupS64(NULL,row,"sass_id"),
     157           psMetadataLookupStr(NULL,row,"data_group"),
     158           psMetadataLookupStr(NULL,row,"tess_id"),
     159           psMetadataLookupStr(NULL,row,"filter"),
     160           psMetadataLookupStr(NULL,row,"projection_cell"));
     161
     162    if (psMetadataLookupS64(NULL,row,"sass_id") == PS_MAX_S64) {
     163      psMetadataAddS64(outrow,PS_LIST_TAIL,"sass_id",PS_META_REPLACE,"",0);
     164    }
     165    else {
     166      psMetadataAddS64(outrow,PS_LIST_TAIL,"sass_id",PS_META_REPLACE,"",psMetadataLookupS64(NULL,row,"sass_id"));
     167    }
     168    psMetadataAddStr(outrow,PS_LIST_TAIL,"data_group",PS_META_REPLACE,"",psMetadataLookupStr(NULL,row,"data_group"));
     169    psMetadataAddStr(outrow,PS_LIST_TAIL,"tess_id",PS_META_REPLACE,"",psMetadataLookupStr(NULL,row,"tess_id"));
     170    psMetadataAddStr(outrow,PS_LIST_TAIL,"filter",PS_META_REPLACE,"",psMetadataLookupStr(NULL,row,"filter"));
     171    psMetadataAddStr(outrow,PS_LIST_TAIL,"projection_cell",PS_META_REPLACE,"",
     172                     psMetadataLookupStr(NULL,row,"projection_cell"));
     173  }
     174  printf("%" PRId64 " %s %s %s %s\n",psMetadataLookupS64(NULL,outrow,"sass_id"),
     175         psMetadataLookupStr(NULL,outrow,"data_group"),
     176         psMetadataLookupStr(NULL,outrow,"tess_id"),
     177         psMetadataLookupStr(NULL,outrow,"filter"),
     178         psMetadataLookupStr(NULL,outrow,"projection_cell"));
     179 
     180
     181  psFree(output);
     182  stackAssociationRow *sassRow = stackAssociationObjectFromMetadata(outrow);
     183  psFree(outrow);
     184  return(sassRow);
     185}
     186     
     187     
     188 
     189                                             
    104190
    105191
    … …  
    395481        psFree(run);
    396482
     483        //CZW Add an association entry here.
     484        // Define the requested association, and insert it if it doesn't already exist
     485        stackAssociationRow *association = pxStackAssociationDefine(config,stack_id);
     486        psS64 sass_id;
     487        if (!association->sass_id) {
     488          psTrace("stacktool.association",2,"No required Association found. Adding.");
     489
     490          if (!stackAssociationInsertObject(config->dbh,association)) {
     491            if (!psDBRollback(config->dbh)) {
     492              psError(PS_ERR_UNKNOWN, false, "database error");
     493            }
     494            psError(PS_ERR_UNKNOWN, false, "database error");
     495            psFree(output);
     496            psFree(run);
     497            psFree(insert);
     498            psFree(list);
     499            psFree(association);
     500            if (!psDBRollback(config->dbh)) {
     501              psError(PS_ERR_UNKNOWN, false, "database error");
     502            }
     503            return(false);
     504          }
     505          sass_id = psDBLastInsertID(config->dbh);
     506          association->sass_id = sass_id;
     507        }
     508        // Insert the map entry for this row.
     509        stackAssociationMapRow *maprow = stackAssociationMapRowAlloc(sass_id,stack_id);
     510        if (!stackAssociationMapInsertObject(config->dbh,maprow)) {
     511          if (!psDBRollback(config->dbh)) {
     512            psError(PS_ERR_UNKNOWN, false, "database error");
     513          }
     514          psError(PS_ERR_UNKNOWN, false, "database error");
     515          psFree(output);
     516          psFree(run);
     517          psFree(insert);
     518          psFree(list);
     519          psFree(association);
     520          if (!psDBRollback(config->dbh)) {
     521            psError(PS_ERR_UNKNOWN, false, "database error");
     522          }
     523          return(false);
     524        }
     525       
     526       
    397527        // Create a suitable insertion query for this run
    398528        psString thisInsert = psStringCopy(insert);
    … …  
    552682    run->stack_id = psDBLastInsertID(config->dbh);
    553683
     684    //CZW Add an association entry here.
     685   
    554686    // insert the stackInputSkyfile rows
    555687    psListIterator *iter = psListIteratorAlloc(warp_ids->data.list, 0, false);
    … …  
    603735#endif
    604736    psMetadata *where = psMetadataAlloc();
    605     PXOPT_COPY_S64(config->args, where, "-stack_id",  "stack_id",   "==");
    606     PXOPT_COPY_STR(config->args, where, "-label",     "label",     "==");
    607     PXOPT_COPY_STR(config->args, where, "-state",     "state",     "==");
     737    PXOPT_COPY_S64(config->args, where, "-stack_id",  "stackRun.stack_id",   "==");
     738    PXOPT_COPY_STR(config->args, where, "-label",     "stackRun.label",     "==");
     739    PXOPT_COPY_STR(config->args, where, "-state",     "stackRun.state",     "==");
     740    PXOPT_COPY_STR(config->args, where, "-sass_id",   "stackAssociationMap.sass_id",  "==");
    608741    if (!psListLength(where->list)) {
    609742        psFree(where);
    … …  
    612745    }
    613746
     747    //CZW join against stackAssociationMap
    614748    psString query = psStringCopy("UPDATE stackRun");
    615749
    … …  
    10381172}
    10391173
    1040 
    1041 static bool revertsumskyfileMode(pxConfig *config)
     1174static bool sassskyfileMode(pxConfig *config)
    10421175{
    10431176    PS_ASSERT_PTR_NON_NULL(config, false);
    10441177
    10451178    psMetadata *where = psMetadataAlloc();
    1046     PXOPT_COPY_S64(config->args, where, "-stack_id", "stackSumSkyfile.stack_id", "==");
    1047     pxAddLabelSearchArgs(config, where, "-label", "stackRun.label", "==");
    1048     PXOPT_COPY_S16(config->args, where, "-fault", "stackSumSkyfile.fault", "==");
    1049 
    1050     if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
    1051         psFree(where);
    1052         psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
    1053         return false;
    1054     }
    1055 
    1056     // Delete product
    1057     psString delete = pxDataGet("stacktool_revertsumskyfile_delete.sql");
    1058     if (!delete) {
     1179    PXOPT_COPY_S64(config->args, where, "-sass_id", "stackAssociation.sass_id", "==");
     1180    PXOPT_COPY_STR(config->args, where, "-tess_id", "stackAssociation.tess_id", "==");
     1181    PXOPT_COPY_STR(config->args, where, "-projection_cell", "stackAssociation.projection_cell", "==");
     1182    PXOPT_COPY_STR(config->args, where, "-filter", "stackAssociation.filter", "LIKE");
     1183    PXOPT_COPY_STR(config->args, where, "-data_group", "stackAssociation.data_group", "LIKE");
     1184
     1185//  The following three selectors are incompatible with the sql so omit them
     1186//    PXOPT_COPY_S64(config->args, where, "-warp_id", "warpRun.warp_id", "==");
     1187//     PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "==");
     1188//    PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "==");
     1189
     1190    PXOPT_LOOKUP_BOOL(all, config->args, "-all", false);
     1191
     1192    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1193    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1194
     1195    psString query = pxDataGet("stacktool_sassskyfile.sql");
     1196    if (!query) {
    10591197        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    10601198        return false;
    … …  
    10631201    if (psListLength(where->list)) {
    10641202        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    1065         psStringAppend(&delete, " AND %s", whereClause);
     1203        psStringAppend(&query, " WHERE %s", whereClause);
    10661204        psFree(whereClause);
    1067     }
    1068 
    1069     if (!p_psDBRunQuery(config->dbh, delete)) {
    1070         psError(PS_ERR_UNKNOWN, false, "database error");
    1071         psFree(delete);
    1072         psFree(where);
    1073         return false;
    1074     }
    1075     psFree(delete);
    1076 
    1077     int numRows = psDBAffectedRows(config->dbh); // Number of row affected
    1078     psLogMsg("stacktool", PS_LOG_INFO, "Deleted %d rows", numRows);
    1079 
    1080     psFree(where);
    1081 
    1082     return true;
    1083 }
    1084 
    1085 
    1086 static bool setstackRunState(pxConfig *config, psS64 stack_id, const char *state)
    1087 {
    1088     PS_ASSERT_PTR_NON_NULL(state, false);
    1089 
    1090     // check that state is a valid string value
    1091     if (!pxIsValidState(state)) {
    1092         psError(PS_ERR_UNKNOWN, false, "invalid stackRun state: %s", state);
    1093         return false;
    1094     }
    1095 
    1096     char *query = "UPDATE stackRun SET state = '%s' WHERE stack_id = %"PRId64;
    1097     if (!p_psDBRunQueryF(config->dbh, query, state, stack_id)) {
    1098         psError(PS_ERR_UNKNOWN, false,
    1099                 "failed to change state for stack_id %"PRId64, stack_id);
    1100         return false;
    1101     }
    1102 
    1103     return true;
    1104 }
    1105 
    1106 #ifdef notdef
    1107 static bool setstackRunStateByLabel(pxConfig *config, const char *label, const char *state)
    1108 {
    1109     PS_ASSERT_PTR_NON_NULL(state, false);
    1110 
    1111     // check that state is a valid string value
    1112     if (!pxIsValidState(state)) {
    1113         psError(PS_ERR_UNKNOWN, false, "invalid stackRun state: %s", state);
    1114         return false;
    1115     }
    1116 
    1117     char *query = "UPDATE stackRun SET state = '%s' WHERE label = '%s'";
    1118     if (!p_psDBRunQueryF(config->dbh, query, state, label)) {
    1119         psError(PS_ERR_UNKNOWN, false,
    1120                 "failed to change state for label %s", label);
    1121         return false;
    1122     }
    1123 
    1124     return true;
    1125 }
    1126 #endif
    1127 
    1128 static bool pendingcleanuprunMode(pxConfig *config)
    1129 {
    1130     PS_ASSERT_PTR_NON_NULL(config, NULL);
    1131 
    1132     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    1133     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    1134 
    1135     psMetadata *where = psMetadataAlloc();
    1136     pxAddLabelSearchArgs (config, where, "-label", "stackRun.label", "==");
    1137 
    1138     psString query = pxDataGet("stacktool_pendingcleanuprun.sql");
    1139     if (!query) {
    1140         psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    1141         return false;
    1142     }
    1143 
    1144     if (where && psListLength(where->list)) {
    1145         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    1146         psStringAppend(&query, " AND %s", whereClause);
    1147         psFree(whereClause);
    1148     }
     1205    } else if (!all) {
     1206        psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required");
     1207        return false;
     1208    }
     1209
    11491210    psFree(where);
    11501211
    … …  
    11651226    psArray *output = p_psDBFetchResult(config->dbh);
    11661227    if (!output) {
    1167         psError(PS_ERR_UNKNOWN, false, "database error");
     1228        psErrorCode err = psErrorCodeLast();
     1229        switch (err) {
     1230            case PS_ERR_DB_CLIENT:
     1231                psError(PXTOOLS_ERR_SYS, false, "database error");
     1232            case PS_ERR_DB_SERVER:
     1233                psError(PXTOOLS_ERR_PROG, false, "database error");
     1234            default:
     1235                psError(PXTOOLS_ERR_PROG, false, "unknown error");
     1236        }
     1237
    11681238        return false;
    11691239    }
    … …  
    11741244    }
    11751245
     1246    if (psArrayLength(output)) {
     1247        if (!ippdbPrintMetadatas(stdout, output, "stackSumSkyfile", !simple)) {
     1248            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1249            psFree(output);
     1250            return false;
     1251        }
     1252    }
     1253
     1254    psFree(output);
     1255
     1256    return true;
     1257}
     1258
     1259
     1260static bool revertsumskyfileMode(pxConfig *config)
     1261{
     1262    PS_ASSERT_PTR_NON_NULL(config, false);
     1263
     1264    psMetadata *where = psMetadataAlloc();
     1265    PXOPT_COPY_S64(config->args, where, "-stack_id", "stackSumSkyfile.stack_id", "==");
     1266    pxAddLabelSearchArgs(config, where, "-label", "stackRun.label", "==");
     1267    PXOPT_COPY_S16(config->args, where, "-fault", "stackSumSkyfile.fault", "==");
     1268
     1269    if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
     1270        psFree(where);
     1271        psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
     1272        return false;
     1273    }
     1274
     1275    // Delete product
     1276    psString delete = pxDataGet("stacktool_revertsumskyfile_delete.sql");
     1277    if (!delete) {
     1278        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1279        return false;
     1280    }
     1281
     1282    if (psListLength(where->list)) {
     1283        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1284        psStringAppend(&delete, " AND %s", whereClause);
     1285        psFree(whereClause);
     1286    }
     1287
     1288    if (!p_psDBRunQuery(config->dbh, delete)) {
     1289        psError(PS_ERR_UNKNOWN, false, "database error");
     1290        psFree(delete);
     1291        psFree(where);
     1292        return false;
     1293    }
     1294    psFree(delete);
     1295
     1296    int numRows = psDBAffectedRows(config->dbh); // Number of row affected
     1297    psLogMsg("stacktool", PS_LOG_INFO, "Deleted %d rows", numRows);
     1298
     1299    psFree(where);
     1300
     1301    return true;
     1302}
     1303
     1304
     1305static bool setstackRunState(pxConfig *config, psS64 stack_id, const char *state)
     1306{
     1307    PS_ASSERT_PTR_NON_NULL(state, false);
     1308
     1309    // check that state is a valid string value
     1310    if (!pxIsValidState(state)) {
     1311        psError(PS_ERR_UNKNOWN, false, "invalid stackRun state: %s", state);
     1312        return false;
     1313    }
     1314
     1315    char *query = "UPDATE stackRun SET state = '%s' WHERE stack_id = %"PRId64;
     1316    if (!p_psDBRunQueryF(config->dbh, query, state, stack_id)) {
     1317        psError(PS_ERR_UNKNOWN, false,
     1318                "failed to change state for stack_id %"PRId64, stack_id);
     1319        return false;
     1320    }
     1321
     1322    return true;
     1323}
     1324
     1325#ifdef notdef
     1326static bool setstackRunStateByLabel(pxConfig *config, const char *label, const char *state)
     1327{
     1328    PS_ASSERT_PTR_NON_NULL(state, false);
     1329
     1330    // check that state is a valid string value
     1331    if (!pxIsValidState(state)) {
     1332        psError(PS_ERR_UNKNOWN, false, "invalid stackRun state: %s", state);
     1333        return false;
     1334    }
     1335
     1336    char *query = "UPDATE stackRun SET state = '%s' WHERE label = '%s'";
     1337    if (!p_psDBRunQueryF(config->dbh, query, state, label)) {
     1338        psError(PS_ERR_UNKNOWN, false,
     1339                "failed to change state for label %s", label);
     1340        return false;
     1341    }
     1342
     1343    return true;
     1344}
     1345#endif
     1346static bool tosummaryMode(pxConfig *config) {
     1347  PS_ASSERT_PTR_NON_NULL(config, NULL);
     1348 
     1349  psMetadata *where = psMetadataAlloc();
     1350  PXOPT_COPY_S64(config->args, where, "-stack_id",    "stackSumSkyfile.warp_id", "==");
     1351  PXOPT_COPY_S64(config->args, where, "-sass_id",     "stackAssociationMap.sass_id", "==");
     1352  PXOPT_COPY_STR(config->args, where, "-tess_id",    "stackSumSkyfile.tess_id", "==");
     1353  PXOPT_COPY_STR(config->args, where, "-state",      "stackRun.state", "==");
     1354  PXOPT_COPY_STR(config->args, where, "-filter",    "stackRun.filter", "LIKE");
     1355  pxAddLabelSearchArgs (config, where, "-label",   "stackRun.label", "LIKE");
     1356  pxAddLabelSearchArgs (config, where, "-data_group",   "stackRun.data_group", "LIKE");
     1357 
     1358  PXOPT_LOOKUP_BOOL(all, config->args, "-all", false);
     1359
     1360  PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1361  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1362 
     1363  // find all rawImfiles matching the default query
     1364  psString query = pxDataGet("stacktool_tosummary.sql");
     1365  if (!query) {
     1366    psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1367    return false;
     1368  }
     1369
     1370  // generate where strings for arguments that require extra processing
     1371  // beyond PXOPT_COPY*
     1372  if (psListLength(where->list)) {
     1373    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1374    psStringAppend(&query, " AND %s", whereClause);
     1375    psFree(whereClause);
     1376  } else if (!all) {
     1377    psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required");
     1378    return false;
     1379  }
     1380 
     1381  psFree(where);
     1382
     1383  // treat limit == 0 as "no limit"
     1384  if (limit) {
     1385    psString limitString = psDBGenerateLimitSQL(limit);
     1386    psStringAppend(&query, " %s", limitString);
     1387    psFree(limitString);
     1388  }
     1389
     1390  if (!p_psDBRunQuery(config->dbh, query)) {
     1391    psError(PS_ERR_UNKNOWN, false, "database error");
     1392    psFree(query);
     1393    return false;
     1394  }
     1395  psFree(query);
     1396
     1397  psArray *output = p_psDBFetchResult(config->dbh);
     1398  if (!output) {
     1399    psErrorCode err = psErrorCodeLast();
     1400    switch (err) {
     1401    case PS_ERR_DB_CLIENT:
     1402      psError(PXTOOLS_ERR_SYS, false, "database error");
     1403    case PS_ERR_DB_SERVER:
     1404      psError(PXTOOLS_ERR_PROG, false, "database error");
     1405    default:
     1406      psError(PXTOOLS_ERR_PROG, false, "unknown error");
     1407    }
     1408   
     1409    return false;
     1410  }
     1411  if (!psArrayLength(output)) {
     1412    psTrace("stacktool", PS_LOG_INFO, "no rows found");
     1413    psFree(output);
     1414    return true;
     1415  }
     1416 
     1417  if (psArrayLength(output)) {
    11761418    // negative simple so the default is true
    1177     if (!ippdbPrintMetadatas(stdout, output, "stackPendingCleanupRun", !simple)) {
    1178         psError(PS_ERR_UNKNOWN, false, "failed to print array");
    1179         psFree(output);
    1180         return false;
    1181     }
    1182 
    1183     psFree(output);
    1184 
    1185     return true;
    1186 }
    1187 
    1188 static bool pendingcleanupskyfileMode(pxConfig *config)
     1419    if (!ippdbPrintMetadatas(stdout, output, "stackRun", !simple)) {
     1420      psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1421      psFree(output);
     1422      return false;
     1423    }
     1424  }
     1425 
     1426  psFree(output);
     1427  return(true);
     1428}
     1429static bool addsummaryMode(pxConfig *config) {
     1430  PS_ASSERT_PTR_NON_NULL(config, NULL);
     1431
     1432  PXOPT_LOOKUP_S64(sass_id, config->args, "-sass_id", true, false);
     1433  PXOPT_LOOKUP_STR(projection_cell, config->args, "-projection_cell", true, false);
     1434  PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
     1435
     1436  psString query = pxDataGet("stacktool_addsummary.sql");
     1437  if (!query) {
     1438    psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1439    return(false);
     1440  }
     1441  if (!p_psDBRunQueryF(config->dbh, query, sass_id, projection_cell, path_base)) {
     1442    psError(PS_ERR_UNKNOWN, false, "database error");
     1443    psFree(query);
     1444    return(false);
     1445  }
     1446  psS64 numUpdated = psDBAffectedRows(config->dbh);
     1447 
     1448  if (numUpdated != 1) {
     1449    psError(PS_ERR_UNKNOWN, false, "should have affected 1 row");
     1450    psFree(query);
     1451    return false;
     1452  }
     1453 
     1454  psFree(query);
     1455
     1456  // Print anything here?
     1457 
     1458  return(true);
     1459}
     1460
     1461static bool pendingcleanuprunMode(pxConfig *config)
    11891462{
    11901463    PS_ASSERT_PTR_NON_NULL(config, NULL);
    11911464
    1192     PXOPT_LOOKUP_S64(stack_id, config->args, "-stack_id", false, false);
    11931465    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    11941466    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    11951467
    11961468    psMetadata *where = psMetadataAlloc();
    1197     if (stack_id) {
    1198         PXOPT_COPY_S64(config->args, where, "-stack_id", "stack_id", "==");
    1199     }
     1469    PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "==");
     1470    PXOPT_COPY_S64(config->args, where, "-sass_id", "stackAssociationMap.sass_id", "==");
     1471   
    12001472    pxAddLabelSearchArgs (config, where, "-label", "stackRun.label", "==");
    12011473
    1202     psString query = pxDataGet("stacktool_pendingcleanupskyfile.sql");
     1474    psString query = pxDataGet("stacktool_pendingcleanuprun.sql");
    12031475    if (!query) {
    12041476        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    … …  
    12391511
    12401512    // negative simple so the default is true
    1241     if (!ippdbPrintMetadatas(stdout, output, "stackPendingCleanupSkyfile", !simple)) {
     1513    if (!ippdbPrintMetadatas(stdout, output, "stackPendingCleanupRun", !simple)) {
    12421514        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    12431515        psFree(output);
    … …  
    12501522}
    12511523
    1252 
    1253 static bool donecleanupMode(pxConfig *config)
     1524static bool pendingcleanupskyfileMode(pxConfig *config)
    12541525{
    12551526    PS_ASSERT_PTR_NON_NULL(config, NULL);
    12561527
     1528    PXOPT_LOOKUP_S64(stack_id, config->args, "-stack_id", false, false);
    12571529    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    12581530    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    12591531
    12601532    psMetadata *where = psMetadataAlloc();
    1261     PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
    1262 
    1263     psString query = pxDataGet("stacktool_donecleanup.sql");
     1533    if (stack_id) {
     1534        PXOPT_COPY_S64(config->args, where, "-stack_id", "stack_id", "==");
     1535    }
     1536    pxAddLabelSearchArgs (config, where, "-label", "stackRun.label", "==");
     1537
     1538    psString query = pxDataGet("stacktool_pendingcleanupskyfile.sql");
    12641539    if (!query) {
    12651540        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    … …  
    13001575
    13011576    // negative simple so the default is true
     1577    if (!ippdbPrintMetadatas(stdout, output, "stackPendingCleanupSkyfile", !simple)) {
     1578        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1579        psFree(output);
     1580        return false;
     1581    }
     1582
     1583    psFree(output);
     1584
     1585    return true;
     1586}
     1587
     1588
     1589static bool donecleanupMode(pxConfig *config)
     1590{
     1591    PS_ASSERT_PTR_NON_NULL(config, NULL);
     1592
     1593    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1594    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1595
     1596    psMetadata *where = psMetadataAlloc();
     1597    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     1598    PXOPT_COPY_STR(config->args, where, "-sass_id", "sass_id", "==");
     1599
     1600    psString query = pxDataGet("stacktool_donecleanup.sql");
     1601    if (!query) {
     1602        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1603        return false;
     1604    }
     1605
     1606    if (where && psListLength(where->list)) {
     1607        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1608        psStringAppend(&query, " AND %s", whereClause);
     1609        psFree(whereClause);
     1610    }
     1611    psFree(where);
     1612
     1613    // treat limit == 0 as "no limit"
     1614    if (limit) {
     1615        psString limitString = psDBGenerateLimitSQL(limit);
     1616        psStringAppend(&query, " %s", limitString);
     1617        psFree(limitString);
     1618    }
     1619
     1620    if (!p_psDBRunQuery(config->dbh, query)) {
     1621        psError(PS_ERR_UNKNOWN, false, "database error");
     1622        psFree(query);
     1623        return false;
     1624    }
     1625    psFree(query);
     1626
     1627    psArray *output = p_psDBFetchResult(config->dbh);
     1628    if (!output) {
     1629        psError(PS_ERR_UNKNOWN, false, "database error");
     1630        return false;
     1631    }
     1632    if (!psArrayLength(output)) {
     1633        psTrace("stacktool", PS_LOG_INFO, "no rows found");
     1634        psFree(output);
     1635        return true;
     1636    }
     1637
     1638    // negative simple so the default is true
    13021639    if (!ippdbPrintMetadatas(stdout, output, "stackDoneCleanup", !simple)) {
    13031640        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    … …  
    13291666}
    13301667
     1668//CZW I have not added sass information to the export/import run modes yet.
    13311669bool exportrunMode(pxConfig *config)
    13321670{
  • trunk/ippTools/src/stacktool.h

    r23310 r28375  
    3333    STACKTOOL_MODE_ADDSUMSKYFILE,
    3434    STACKTOOL_MODE_SUMSKYFILE,
     35    STACKTOOL_MODE_SASSSKYFILE,
    3536    STACKTOOL_MODE_REVERTSUMSKYFILE,
     37    STACKTOOL_MODE_TOSUMMARY,
     38    STACKTOOL_MODE_ADDSUMMARY,
    3639    STACKTOOL_MODE_PENDINGCLEANUPRUN,
    3740    STACKTOOL_MODE_PENDINGCLEANUPSKYFILE,
  • trunk/ippTools/src/stacktoolConfig.c

    r28043 r28375  
    197197    psMetadataAddBool(sumskyfileArgs, PS_LIST_TAIL, "-all",  0,            "enable search without arguments", false);
    198198
     199    // -sassskyfile
     200    psMetadata *sassskyfileArgs = psMetadataAlloc();
     201    psMetadataAddS64(sassskyfileArgs, PS_LIST_TAIL, "-sass_id", 0,           "search by stack association ID", 0);
     202    psMetadataAddStr(sassskyfileArgs, PS_LIST_TAIL, "-tess_id", 0,            "search by tess ID", 0);
     203    psMetadataAddStr(sassskyfileArgs, PS_LIST_TAIL, "-projection_cell", 0,         "search by projection cell", 0);
     204
     205    psMetadataAddStr(sassskyfileArgs, PS_LIST_TAIL, "-data_group", 0,        "search by stackAssociation.data_group (LIKE comparison)", NULL);
     206    psMetadataAddStr(sassskyfileArgs, PS_LIST_TAIL, "-filter", 0,            "search by filter (LIKE comparison)", NULL);
     207    psMetadataAddU64(sassskyfileArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
     208    psMetadataAddBool(sassskyfileArgs, PS_LIST_TAIL, "-simple",  0,            "use the simple output format", false);
     209    psMetadataAddBool(sassskyfileArgs, PS_LIST_TAIL, "-all",  0,            "enable search without arguments", false);
     210
    199211    // -revertsumskyfile
    200212    psMetadata *revertsumskyfileArgs= psMetadataAlloc();
    … …  
    204216    psMetadataAddBool(revertsumskyfileArgs, PS_LIST_TAIL, "-all",  0, "allow no search terms", 0);
    205217
     218    // -tosummary
     219    psMetadata *tosummaryArgs = psMetadataAlloc();
     220    psMetadataAddS64(tosummaryArgs, PS_LIST_TAIL, "-stack_id", 0,  "search by stack ID", 0);
     221    psMetadataAddS64(tosummaryArgs, PS_LIST_TAIL, "-sass_id", 0,  "search by stack association ID", 0);
     222    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL, "-tess_id", 0,   "search by tessellation ID", NULL);
     223    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL, "-state", 0,     "search by state", NULL);
     224    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL, "-filter", 0,    "search by filter", NULL);
     225    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by stackRun label (LIKE comparison)", NULL);
     226    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL, "-data_group", PS_META_DUPLICATE_OK, "search by stackRun data_group (LIKE comparison)", NULL);
     227    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL, "-dist_group", PS_META_DUPLICATE_OK, "search by stackRun dist_group (LIKE comparison)", NULL);
     228
     229    psMetadataAddBool(tosummaryArgs, PS_LIST_TAIL, "-all",  0,             "search without arguments", false);
     230    psMetadataAddU64(tosummaryArgs, PS_LIST_TAIL,  "-limit",  0,            "limit result set to N items", 0);
     231    psMetadataAddBool(tosummaryArgs, PS_LIST_TAIL, "-simple",  0,          "use the simple output format", false);
     232
     233    // -addsummary
     234    psMetadata *addsummaryArgs = psMetadataAlloc();
     235    psMetadataAddS64(addsummaryArgs, PS_LIST_TAIL, "-sass_id", 0,      "set stack Association ID", 0);
     236    psMetadataAddStr(addsummaryArgs, PS_LIST_TAIL, "-projection_cell", 0, "set projection cell", NULL);
     237    psMetadataAddStr(addsummaryArgs, PS_LIST_TAIL, "-path_base", 0,     "set summary path base", NULL);             
     238   
    206239    // -pendingcleanuprun
    207240    psMetadata *pendingcleanuprunArgs = psMetadataAlloc();
    … …  
    252285    PXOPT_ADD_MODE("-addsumskyfile",   "", STACKTOOL_MODE_ADDSUMSKYFILE,   addsumskyfileArgs);
    253286    PXOPT_ADD_MODE("-sumskyfile",      "list results of stackRun", STACKTOOL_MODE_SUMSKYFILE,      sumskyfileArgs);
     287    PXOPT_ADD_MODE("-sassskyfile",      "list results of stackAssociation", STACKTOOL_MODE_SASSSKYFILE,      sassskyfileArgs);
    254288    PXOPT_ADD_MODE("-revertsumskyfile","", STACKTOOL_MODE_REVERTSUMSKYFILE,      revertsumskyfileArgs);
    255289    PXOPT_ADD_MODE("-pendingcleanuprun",     "show runs that need to be cleaned up", STACKTOOL_MODE_PENDINGCLEANUPRUN,    pendingcleanuprunArgs);
    … …  
    257291    PXOPT_ADD_MODE("-donecleanup",           "show runs that have been cleaned",     STACKTOOL_MODE_DONECLEANUP,          donecleanupArgs);
    258292    PXOPT_ADD_MODE("-updatesumskyfile",      "update fault code for sumskyfile",     STACKTOOL_MODE_UPDATESUMSKYFILE,          updatesumskyfileArgs);
     293    PXOPT_ADD_MODE("-tosummary",            "show runs that can be summarized", STACKTOOL_MODE_TOSUMMARY, tosummaryArgs);
     294    PXOPT_ADD_MODE("-addsummary",           "add entry to the summary table", STACKTOOL_MODE_ADDSUMMARY, addsummaryArgs);
    259295    PXOPT_ADD_MODE("-exportrun",            "export run for import on other database", STACKTOOL_MODE_EXPORTRUN, exportrunArgs);
    260296    PXOPT_ADD_MODE("-importrun",            "import run from metadata file",           STACKTOOL_MODE_IMPORTRUN, importrunArgs);
  • trunk/ippTools/src/warptool.c

    r28202 r28375  
    4848static bool maskedMode(pxConfig *config);
    4949static bool unblockMode(pxConfig *config);
     50static bool tosummaryMode(pxConfig *config);
     51static bool addsummaryMode(pxConfig *config);
    5052static bool pendingcleanuprunMode(pxConfig *config);
    5153static bool pendingcleanupwarpMode(pxConfig *config);
    … …  
    101103        MODECASE(WARPTOOL_MODE_MASKED,             maskedMode);
    102104        MODECASE(WARPTOOL_MODE_UNBLOCK,            unblockMode);
     105        MODECASE(WARPTOOL_MODE_TOSUMMARY,          tosummaryMode);
     106        MODECASE(WARPTOOL_MODE_ADDSUMMARY,         addsummaryMode);
    103107        MODECASE(WARPTOOL_MODE_PENDINGCLEANUPRUN,  pendingcleanuprunMode);
    104108        MODECASE(WARPTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupwarpMode);
    … …  
    15481552}
    15491553
     1554static bool tosummaryMode(pxConfig *config) {
     1555  PS_ASSERT_PTR_NON_NULL(config, NULL);
     1556 
     1557  psMetadata *where = psMetadataAlloc();
     1558  PXOPT_COPY_S64(config->args, where, "-warp_id",    "warpSkyfile.warp_id", "==");
     1559  PXOPT_COPY_STR(config->args, where, "-tess_id",    "warpSkyfile.tess_id", "==");
     1560  PXOPT_COPY_STR(config->args, where, "-state",      "warpRun.state", "==");
     1561  PXOPT_COPY_S64(config->args, where, "-exp_id",     "rawExp.exp_id", "==");
     1562  PXOPT_COPY_STR(config->args, where, "-exp_name",   "rawExp.exp_name", "==");
     1563  PXOPT_COPY_S64(config->args, where, "-fake_id",    "fakeRun.fake_id", "==");
     1564  PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs",  ">=");
     1565  PXOPT_COPY_TIME(config->args, where, "-dateobs_end",   "rawExp.dateobs",  "<=");
     1566  PXOPT_COPY_STR(config->args, where, "-filter",    "rawExp.filter", "LIKE");
     1567  PXOPT_COPY_S64(config->args, where, "-magicked", "warpSkyfile.magicked", "==");
     1568  pxAddLabelSearchArgs (config, where, "-label",   "warpRun.label", "LIKE");
     1569  pxAddLabelSearchArgs (config, where, "-data_group",   "warpRun.data_group", "LIKE");
     1570
     1571  PXOPT_LOOKUP_BOOL(all, config->args, "-all", false);
     1572
     1573  PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1574  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1575 
     1576  // find all rawImfiles matching the default query
     1577  psString query = pxDataGet("warptool_tosummary.sql");
     1578  if (!query) {
     1579    psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1580    return false;
     1581  }
     1582
     1583  // generate where strings for arguments that require extra processing
     1584  // beyond PXOPT_COPY*
     1585  psString where2 = NULL;
     1586  if (!pxmagicAddWhere(config, &where2, "warpSkyfile")) {
     1587    psError(psErrorCodeLast(), false, "pxMagicAddWhere failed");
     1588    return false;
     1589  }
     1590 
     1591  if (psListLength(where->list)) {
     1592    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1593    psStringAppend(&query, " AND %s", whereClause);
     1594    psFree(whereClause);
     1595  } else if (!all && !where2) {
     1596    psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required");
     1597    return false;
     1598  }
     1599 
     1600  if (where2) {
     1601    psStringAppend(&query, " %s", where2);
     1602  }
     1603  psFree(where);
     1604
     1605  // treat limit == 0 as "no limit"
     1606  if (limit) {
     1607    psString limitString = psDBGenerateLimitSQL(limit);
     1608    psStringAppend(&query, " %s", limitString);
     1609    psFree(limitString);
     1610  }
     1611 
     1612  if (!p_psDBRunQuery(config->dbh, query)) {
     1613    psError(PS_ERR_UNKNOWN, false, "database error");
     1614    psFree(query);
     1615    return false;
     1616  }
     1617  psFree(query);
     1618
     1619  psArray *output = p_psDBFetchResult(config->dbh);
     1620  if (!output) {
     1621    psErrorCode err = psErrorCodeLast();
     1622    switch (err) {
     1623    case PS_ERR_DB_CLIENT:
     1624      psError(PXTOOLS_ERR_SYS, false, "database error");
     1625    case PS_ERR_DB_SERVER:
     1626      psError(PXTOOLS_ERR_PROG, false, "database error");
     1627    default:
     1628      psError(PXTOOLS_ERR_PROG, false, "unknown error");
     1629    }
     1630   
     1631    return false;
     1632  }
     1633  if (!psArrayLength(output)) {
     1634    psTrace("warptool", PS_LOG_INFO, "no rows found");
     1635    psFree(output);
     1636    return true;
     1637  }
     1638 
     1639  if (psArrayLength(output)) {
     1640    // negative simple so the default is true
     1641    if (!ippdbPrintMetadatas(stdout, output, "warpRun", !simple)) {
     1642      psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1643      psFree(output);
     1644      return false;
     1645    }
     1646  }
     1647 
     1648  psFree(output);
     1649  return(true);
     1650}
     1651static bool addsummaryMode(pxConfig *config) {
     1652  PS_ASSERT_PTR_NON_NULL(config, NULL);
     1653
     1654  PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false);
     1655  PXOPT_LOOKUP_STR(projection_cell, config->args, "-projection_cell", true, false);
     1656  PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
     1657
     1658  psString query = pxDataGet("warptool_addsummary.sql");
     1659  if (!query) {
     1660    psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1661    return(false);
     1662  }
     1663  if (!p_psDBRunQueryF(config->dbh, query, warp_id, projection_cell, path_base)) {
     1664    psError(PS_ERR_UNKNOWN, false, "database error");
     1665    psFree(query);
     1666    return(false);
     1667  }
     1668  psS64 numUpdated = psDBAffectedRows(config->dbh);
     1669 
     1670  if (numUpdated != 1) {
     1671    psError(PS_ERR_UNKNOWN, false, "should have affected 1 row");
     1672    psFree(query);
     1673    return false;
     1674  }
     1675 
     1676  psFree(query);
     1677
     1678  // Print anything here?
     1679 
     1680  return(true);
     1681}
     1682
    15501683static bool pendingcleanuprunMode(pxConfig *config)
    15511684{
  • trunk/ippTools/src/warptool.h

    r27737 r28375  
    4444    WARPTOOL_MODE_MASKED,
    4545    WARPTOOL_MODE_UNBLOCK,
     46    WARPTOOL_MODE_TOSUMMARY,
     47    WARPTOOL_MODE_ADDSUMMARY,
    4648    WARPTOOL_MODE_PENDINGCLEANUPRUN,
    4749    WARPTOOL_MODE_PENDINGCLEANUPSKYFILE,
  • trunk/ippTools/src/warptoolConfig.c

    r28054 r28375  
    321321    psMetadataAddStr(unblockArgs, PS_LIST_TAIL, "-label",  0,            "name of a label to unmask (required)", NULL);
    322322
     323    // -tosummary
     324    psMetadata *tosummaryArgs = psMetadataAlloc();
     325    psMetadataAddS64(tosummaryArgs, PS_LIST_TAIL, "-warp_id", 0,         "search by warp ID", 0);
     326    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL,  "-tess_id",  0,          "search by tessellation ID", NULL);
     327    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL, "-state",  0,            "search by state", NULL);
     328    psMetadataAddS64(tosummaryArgs, PS_LIST_TAIL, "-exp_id", 0,            "search by exposure tag", 0);
     329    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL, "-exp_name", 0,          "search by exposure tag", 0);
     330    psMetadataAddS64(tosummaryArgs, PS_LIST_TAIL, "-fake_id", 0,           "search by phase 3 version of exposure tag", 0);
     331    psMetadataAddTime(tosummaryArgs, PS_LIST_TAIL, "-dateobs_begin", 0,    "search for exposures by time (>=)", NULL);
     332    psMetadataAddTime(tosummaryArgs, PS_LIST_TAIL, "-dateobs_end", 0,      "search for exposures by time (<=)", NULL);
     333    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL,  "-filter", 0,           "search for exposures by filter", NULL);
     334    psMetadataAddS64(tosummaryArgs, PS_LIST_TAIL,  "-magicked", 0,         "search by magic id", 0);
     335    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL,  "-label",  PS_META_DUPLICATE_OK, "search by warpRun label", NULL);
     336    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL,  "-data_group",  PS_META_DUPLICATE_OK, "search by warpRun data_group", NULL);
     337    psMetadataAddStr(tosummaryArgs, PS_LIST_TAIL,  "-dist_group",  PS_META_DUPLICATE_OK, "search by warpRun dist_group", NULL);
     338    psMetadataAddBool(tosummaryArgs, PS_LIST_TAIL, "-destreaked", 0, "search for runs that have been destreaked", false);
     339    psMetadataAddBool(tosummaryArgs, PS_LIST_TAIL, "-not_destreaked", 0, "search for runs that have not been destreaked", false);
     340   
     341    psMetadataAddBool(tosummaryArgs, PS_LIST_TAIL, "-all",  0,             "search without arguments", false);
     342    psMetadataAddU64(tosummaryArgs, PS_LIST_TAIL,  "-limit",  0,            "limit result set to N items", 0);
     343    psMetadataAddBool(tosummaryArgs, PS_LIST_TAIL, "-simple",  0,          "use the simple output format", false);
     344
     345    // -addsummary
     346    psMetadata *addsummaryArgs = psMetadataAlloc();
     347    psMetadataAddS64(addsummaryArgs, PS_LIST_TAIL, "-warp_id", 0,         "set warp ID", 0);
     348    psMetadataAddStr(addsummaryArgs, PS_LIST_TAIL, "-projection_cell", 0,   "set projection cell", NULL);
     349    psMetadataAddStr(addsummaryArgs, PS_LIST_TAIL, "-path_base", 0,       "set summary path base", NULL);
     350   
    323351    // -pendingcleanuprun
    324352    psMetadata *pendingcleanuprunArgs = psMetadataAlloc();
    … …  
    430458    PXOPT_ADD_MODE("-updateskyfile", "update fault code for skyfile", WARPTOOL_MODE_UPDATESKYFILE, updateskyfileArgs);
    431459    PXOPT_ADD_MODE("-setskyfiletoupdate", "set cleaned skyfile to be updated", WARPTOOL_MODE_SETSKYFILETOUPDATE, setskyfiletoupdateArgs);
     460    PXOPT_ADD_MODE("-tosummary",            "show runs that can be summarized", WARPTOOL_MODE_TOSUMMARY, tosummaryArgs);
     461    PXOPT_ADD_MODE("-addsummary",           "add entry to the summary table", WARPTOOL_MODE_ADDSUMMARY, addsummaryArgs);
     462
    432463    PXOPT_ADD_MODE("-exportrun",            "export run for import on other database", WARPTOOL_MODE_EXPORTRUN, exportrunArgs);
    433464    PXOPT_ADD_MODE("-importrun",            "import run from metadata file",           WARPTOOL_MODE_IMPORTRUN, importrunArgs);
  • trunk/ippconfig/recipes/filerules-mef.mdc

    r28286 r28375  
    312312PPSKYCELL.JPEG1         OUTPUT {OUTPUT}.{FILE.INDEX}.b1.jpeg     JPEG      NONE       CHIP       TRUE      NONE
    313313PPSKYCELL.JPEG2         OUTPUT {OUTPUT}.{FILE.INDEX}.b2.jpeg     JPEG      NONE       CHIP       TRUE      NONE
     314PPSKYCELL.BIN1          OUTPUT {OUTPUT}.{FILE.INDEX}.b1.fits     IMAGE     NONE       FPA        TRUE      NONE
     315PPSKYCELL.BIN2          OUTPUT {OUTPUT}.{FILE.INDEX}.b2.fits     IMAGE     NONE       FPA        TRUE      NONE
    314316
    315317LOG.IMFILE              OUTPUT {OUTPUT}.{CHIP.NAME}.log          TEXT      NONE       CHIP       TRUE      NONE
  • trunk/ippconfig/recipes/filerules-simple.mdc

    r28361 r28375  
    277277PPSKYCELL.JPEG1              OUTPUT {OUTPUT}.{FILE.INDEX}.b1.jpeg JPEG            NONE       CHIP       TRUE      NONE
    278278PPSKYCELL.JPEG2              OUTPUT {OUTPUT}.{FILE.INDEX}.b2.jpeg JPEG            NONE       CHIP       TRUE      NONE
     279PPSKYCELL.BIN1               OUTPUT {OUTPUT}.{FILE.INDEX}.b1.fits     IMAGE     NONE       FPA        TRUE      NONE
     280PPSKYCELL.BIN2               OUTPUT {OUTPUT}.{FILE.INDEX}.b2.fits     IMAGE     NONE       FPA        TRUE      NONE
    279281
    280282LOG.IMFILE                   OUTPUT {OUTPUT}.imfile.log           TEXT            NONE       FPA        TRUE      NONE
  • trunk/ippconfig/recipes/filerules-split.mdc

    r28286 r28375  
    297297PPSKYCELL.JPEG1              OUTPUT {OUTPUT}.{FILE.INDEX}.b1.jpeg     JPEG            NONE       CHIP       TRUE      NONE
    298298PPSKYCELL.JPEG2              OUTPUT {OUTPUT}.{FILE.INDEX}.b2.jpeg     JPEG            NONE       CHIP       TRUE      NONE
     299PPSKYCELL.BIN1          OUTPUT {OUTPUT}.{FILE.INDEX}.b1.fits     IMAGE     NONE       FPA        TRUE      NONE
     300PPSKYCELL.BIN2          OUTPUT {OUTPUT}.{FILE.INDEX}.b2.fits     IMAGE     NONE       FPA       TRUE      NONE
    299301
    300302LOG.IMFILE                   OUTPUT {OUTPUT}.{CHIP.NAME}.log          TEXT            NONE       CHIP       TRUE      NONE
  • trunk/ippconfig/recipes/ppSkycell.config

    r24010 r28375  
    44BIN1            S32     4               # Binning factor for output 1
    55BIN2            S32     4               # Binning factor for output 2
    6 
     6MAKEFITS        BOOL    T               # Make fits image as well?
  • trunk/ppImage/src/ppImageLoop.c

    r28043 r28375  
    175175            ESCAPE("Unable to measures pixel stats for image");
    176176        }
     177
    177178        if (!ppImageMosaicChip(config, options, view, "PPIMAGE.CHIP", "PPIMAGE.OUTPUT")) {
    178179            ESCAPE("Unable to mosaic chip");
    … …  
    181182
    182183        // we perform photometry on the readouts of this chip in the output
     184
    183185        psTimerStart(TIMER_PHOT);
    184186        if (options->doPhotom) {
  • trunk/ppImage/src/ppImagePhotom.c

    r23688 r28375  
    1111    pmCell *cell;
    1212    pmReadout *readout;
    13 
     13    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    1414    psphotInit();
    15 
     15    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    1616    // find or define a pmFPAfile PSPHOT.INPUT
    1717    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
    … …  
    2020        return false;
    2121    }
    22 
     22    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    2323    // we make a new copy of the output chip to keep psphot from modifying the output image
    2424    pmChip *oldChip = pmFPAviewThisChip (view, input->src);
    2525    pmChip *newChip = pmFPAviewThisChip (view, input->fpa);
    2626    pmChipCopy (newChip, oldChip);
    27 
     27    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    2828    // iterate over the cells and readout for this chip
    2929    while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    … …  
    3434        while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    3535            if (! readout->data_exists) { continue; }
    36 
     36            printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    3737            // run the actual photometry analysis
    3838            if (!psphotReadout (config, view)) {
  • trunk/ppSkycell/src/ppSkycell.h

    r23992 r28375  
    1616    int bin1, bin2;                     // Binning factors
    1717    pmConfig *config;                   // Configuration
     18  bool doFits;                          // hold whether to do fits as well.
    1819} ppSkycellData;
    1920
  • trunk/ppSkycell/src/ppSkycellCamera.c

    r24009 r28375  
    103103        return false;
    104104    }
     105    if (!pmFPAfileDefineOutput(data->config, NULL, "PPSKYCELL.BIN1")) {
     106        psError(psErrorCodeLast(), false, "Unable to define output.");
     107        return false;
     108    }
     109    if (!pmFPAfileDefineOutput(data->config, NULL, "PPSKYCELL.BIN2")) {
     110        psError(psErrorCodeLast(), false, "Unable to define output.");
     111        return false;
     112    }
    105113
    106114    // Now the camera has been determined, we can read the recipe
    … …  
    116124    data->bin2 = psMetadataLookupS32(NULL, recipe, "BIN2");
    117125
     126    data->doFits = psMetadataLookupBool(NULL, recipe, "MAKEFITS");
     127   
    118128    if (data->bin1 <= 0 || data->bin2 <= 0) {
    119129        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find legitimate values for BIN1 and BIN2");
  • trunk/ppSkycell/src/ppSkycellLoop.c

    r24005 r28375  
    284284        pmFPAfileActivate(data->config->files, true, "PPSKYCELL.JPEG1");
    285285        pmFPAfileActivate(data->config->files, true, "PPSKYCELL.JPEG2");
     286        if (data->doFits) {
     287          pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN1");
     288          pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN2");
     289        }
     290       
    286291        pmFPAview *view = filesIterateDown(data->config); // View to readout
    287292
     293       
    288294        pmCell *cell1 = pmFPAfileThisCell(data->config->files, view, "PPSKYCELL.JPEG1"); // Rebinned cell 1
    289295        pmCell *cell2 = pmFPAfileThisCell(data->config->files, view, "PPSKYCELL.JPEG2"); // Rebinned cell 2
    290         psFree(view);
     296
    291297        pmReadout *ro1 = pmReadoutAlloc(cell1), *ro2 = pmReadoutAlloc(cell2); // Binned readouts
    292298
    … …  
    298304        ro1->data_exists = cell1->data_exists = cell1->parent->data_exists = true;
    299305        ro2->data_exists = cell2->data_exists = cell2->parent->data_exists = true;
    300 
     306       
    301307        pmFPAfile *file1 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.JPEG1", 0);
    302308        file1->save = true;
    303         file1->index = i;
     309        file1->fileIndex = i;
    304310        pmFPAfile *file2 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.JPEG2", 0);
    305311        file2->save = true;
    306         file2->index = i;
     312        file2->fileIndex = i;
     313
     314        if (data->doFits) {
     315          pmCell *Fcell1 = pmFPAfileThisCell(data->config->files, view, "PPSKYCELL.BIN1"); // Rebinned cell 1
     316          pmCell *Fcell2 = pmFPAfileThisCell(data->config->files, view, "PPSKYCELL.BIN2"); // Rebinned cell 2
     317
     318          // This is a hack to get a functioning header created so the fits images can be written out.
     319          psMetadataAddS32(Fcell1->concepts,PS_LIST_TAIL,"CELL.XPARITY", PS_META_REPLACE,"",1);
     320          psMetadataAddS32(Fcell1->concepts,PS_LIST_TAIL,"CELL.YPARITY", PS_META_REPLACE,"",1);
     321          psMetadataAddS32(Fcell1->concepts,PS_LIST_TAIL,"CELL.READDIR", PS_META_REPLACE,"",1);
     322          psMetadataAddS32(Fcell2->concepts,PS_LIST_TAIL,"CELL.XPARITY", PS_META_REPLACE,"",1);
     323          psMetadataAddS32(Fcell2->concepts,PS_LIST_TAIL,"CELL.YPARITY", PS_META_REPLACE,"",1);
     324          psMetadataAddS32(Fcell2->concepts,PS_LIST_TAIL,"CELL.READDIR", PS_META_REPLACE,"",1);
     325
     326          psMetadataAddS32(Fcell1->parent->concepts,PS_LIST_TAIL,"CHIP.XPARITY", PS_META_REPLACE,"",1);
     327          psMetadataAddS32(Fcell1->parent->concepts,PS_LIST_TAIL,"CHIP.YPARITY", PS_META_REPLACE,"",1);
     328          psMetadataAddS32(Fcell2->parent->concepts,PS_LIST_TAIL,"CHIP.XPARITY", PS_META_REPLACE,"",1);
     329          psMetadataAddS32(Fcell2->parent->concepts,PS_LIST_TAIL,"CHIP.YPARITY", PS_META_REPLACE,"",1);
     330
     331          pmReadout *Fro1 = pmReadoutAlloc(Fcell1), *Fro2 = pmReadoutAlloc(Fcell2); // Binned readouts
     332         
     333          Fro1->image = image1;
     334          Fro2->image = image2;
     335          Fro1->mask = mask1;
     336          Fro2->mask = mask2;
     337         
     338          Fro1->data_exists = Fcell1->data_exists = Fcell1->parent->data_exists = true;
     339          Fro2->data_exists = Fcell2->data_exists = Fcell2->parent->data_exists = true;
     340         
     341          pmFPAfile *fits1 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.BIN1", 0);
     342          fits1->save = true;
     343          fits1->fileIndex = i;
     344          pmFPAfile *fits2 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.BIN2", 0);
     345          fits2->save = true;
     346          fits2->fileIndex = i;
     347        }
     348
     349        psFree(view);
    307350#if 0
    308351        {
  • trunk/psModules

  • trunk/psconfig/tagsets/ipp-2.9.dist

    r27873 r28375  
    7373  YYYYY  ppTranslate            ipp-2-9          -0
    7474  YYYYY  ppViz                  ipp-2-9          -0
     75  YYYYY  ppSkycell              ipp-2-9          -0
    7576
    7677  YYYYY  extsrc/gpcsw           ipp-2-9          -0
  • trunk/psphot

  • trunk/psphot/src/psphotReadout.c

    r28013 r28375  
    1414    // by the multiple threads, not the total time used by all threads.
    1515    psTimerStart ("psphotReadout");
    16 
     16    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    1717    pmModelClassSetLimits(PM_MODEL_LIMITS_LAX);
    1818
    … …  
    2626    char *breakPt = psMetadataLookupStr (NULL, recipe, "BREAK_POINT");
    2727    psAssert (breakPt, "configuration error: set BREAK_POINT");
    28 
     28    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    2929    // set the photcode for this image
    3030    if (!psphotAddPhotcode (config, view, "PSPHOT.INPUT")) {
    … …  
    3232        return false;
    3333    }
    34 
     34        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    3535    // Generate the mask and weight images, including the user-defined analysis region of interest
    3636    if (!psphotSetMaskAndVariance (config, view, "PSPHOT.INPUT")) {
    … …  
    4040        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    4141    }
    42 
     42        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    4343    // generate a background model (median, smoothed image)
    4444    if (!psphotModelBackground (config, view, "PSPHOT.INPUT")) {
    4545        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    4646    }
     47            printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    4748    if (!psphotSubtractBackground (config, view, "PSPHOT.INPUT")) {
    4849        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    … …  
    5152        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    5253    }
    53 
     54        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    5455    // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are determined and saved on
    5556    // readout->analysis XXX this function currently only works with a single PSPHOT.INPUT
    … …  
    5859        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    5960    }
    60 
     61        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    6162    // find the detections (by peak and/or footprint) in the image.
    6263    if (!psphotFindDetections (config, view, "PSPHOT.INPUT", true)) { // pass 1
    … …  
    6566        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    6667    }
    67 
     68        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    6869    // construct sources and measure basic stats (saved on detections->newSources)
    6970    if (!psphotSourceStats (config, view, "PSPHOT.INPUT", true)) { // pass 1
    … …  
    7475        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    7576    }
    76 
     77        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    7778    // find blended neighbors of very saturated stars (detections->newSources)
    7879    if (!psphotDeblendSatstars (config, view, "PSPHOT.INPUT")) {
    … …  
    8081        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    8182    }
    82 
     83        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    8384    // mark blended peaks PS_SOURCE_BLEND (detections->newSources)
    8485    if (!psphotBasicDeblend (config, view, "PSPHOT.INPUT")) {
    … …  
    8687        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    8788    }
    88 
     89        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    8990    // classify sources based on moments, brightness.  if a PSF model has been loaded, the PSF
    9091    // clump defined for it is used not measured (detections->newSources)
    … …  
    9394        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    9495    }
     96            printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    9597    // if we were not supplied a PSF model, determine the IQ stats here (detections->newSources)
    9698    if (!psphotImageQuality (config, view, "PSPHOT.INPUT")) { // pass 1
    … …  
    101103        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    102104    }
    103 
     105        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    104106    // use bright stellar objects to measure PSF if we were supplied a PSF for any input file,
    105107    // this step is skipped
    … …  
    115117    // XXX fix this in the new multi-input context
    116118    // psphotLoadExtSources (config, view, "PSPHOT.INPUT"); // pass 1
    117 
     119        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    118120    // construct an initial model for each object, set the radius to fitRadius, set circular
    119121    // fit mask (detections->newSources)
    120122    psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 1
    121 
     123        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    122124    // merge the newly selected sources into the existing list
    123125    // NOTE: merge OLD and NEW
    124126    psphotMergeSources (config, view, "PSPHOT.INPUT");
    125 
     127        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    126128    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    127129    psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", false); // pass 1 (detections->allSources)
    128 
     130        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    129131    // identify CRs and extended sources (only unmeasured sources are measured)
    130132    psphotSourceSize (config, view, "PSPHOT.INPUT", true); // pass 1 (detections->allSources)
    … …  
    132134        goto finish;
    133135    }
    134 
     136        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    135137    // non-linear PSF and EXT fit to brighter sources
    136138    // replace model flux, adjust mask as needed, fit, subtract the models (full stamp)
    137139    psphotBlendFit (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    138 
     140        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    139141    // replace all sources
    140142    psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    141 
     143        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    142144    // linear fit to include all sources (subtract again)
    143145    // NOTE : apply to ALL sources (extended + psf)
    144146    psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 2 (detections->allSources)
    145 
     147        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    146148    // if we only do one pass, skip to extended source analysis
    147149    if (!strcasecmp (breakPt, "PASS1")) goto pass1finish;
    148 
     150        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    149151    // NOTE: possibly re-measure background model here with objects subtracted / or masked
    150152
    151153    // add noise for subtracted objects
    152154    psphotAddNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    153 
     155        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    154156    // find fainter sources
    155157    // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections
    156158    psphotFindDetections (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->peaks, detections->footprints)
    157 
     159        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    158160    // remove noise for subtracted objects (ie, return to normal noise level)
    159161    // NOTE: this needs to operate only on the OLD sources
    160162    psphotSubNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    161 
     163        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    162164    // define new sources based on only the new peaks
    163165    // NOTE: new sources are saved on detections->newSources
    164166    psphotSourceStats (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->newSources)
    165 
     167        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    166168    // set source type
    167169    // NOTE: apply only to detections->newSources
    … …  
    170172        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    171173    }
    172 
     174        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    173175    // create full input models, set the radius to fitRadius, set circular fit mask
    174176    // NOTE: apply only to detections->newSources
    175177    psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 2 (detections->newSources)
    176 
     178        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    177179    // replace all sources so fit below applies to all at once
    178180    // NOTE: apply only to OLD sources (which have been subtracted)
    179181    psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 2
    180 
     182        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    181183    // merge the newly selected sources into the existing list
    182184    // NOTE: merge OLD and NEW
    183185    // XXX check on free of sources...
    184186    psphotMergeSources (config, view, "PSPHOT.INPUT"); // (detections->newSources + detections->allSources -> detections->allSources)
    185 
     187        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    186188    // NOTE: apply to ALL sources
    187189    psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 3 (detections->allSources)
    188 
     190        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    189191pass1finish:
    190192
    … …  
    192194    // NOTE: applies only to NEW (unmeasured) sources
    193195    psphotSourceSize (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->allSources)
    194 
     196        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    195197    psphotExtendedSourceAnalysis (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    196198    psphotExtendedSourceFits (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    197 
     199        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    198200finish:
    199201
    200202    // plot positive sources
    201203    // psphotSourcePlots (readout, sources, recipe);
    202 
     204        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    203205    // measure aperture photometry corrections
    204206    if (!psphotApResid (config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources)
    … …  
    206208        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    207209    }
    208 
     210        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    209211    // calculate source magnitudes
    210     psphotMagnitudes(config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    211 
     212    if (!psphotMagnitudes(config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources)
     213      psErrorStackPrint(stderr, "Unable to do magnitudes.");
     214        psErrorClear();
     215    }     
    212216    if (!psphotEfficiency(config, view, "PSPHOT.INPUT")) { // pass 1
    213217        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
    … …  
    219223
    220224    // replace background in residual image
    221     psphotSkyReplace (config, view, "PSPHOT.INPUT"); // pass 1
    222 
     225    if (!psphotSkyReplace (config, view, "PSPHOT.INPUT")) { // pass 1
     226      psErrorStackPrint(stderr, "Unable to replace sky");
     227      psErrorClear();
     228
     229/*       psLogMsg("psphot", 3, "failed on psphotSkyReplace"); */
     230/*       return(psphotReadoutCleanup(config, view, "PSPHOT.INPUT")); */
     231    }
    223232    // drop the references to the image pixels held by each source
    224     psphotSourceFreePixels (config, view, "PSPHOT.INPUT"); // pass 1
    225 
     233    if (!psphotSourceFreePixels (config, view, "PSPHOT.INPUT")) { // pass 1
     234      psErrorStackPrint(stderr, "Unable to free source pixels");
     235      psErrorClear();
     236
     237/*       psLogMsg ("psphot", 3, "failed on psphotSourceFreePixels"); */
     238/*       return(psphotReadoutCleanup(config, view, "PSPHOT.INPUT")); */
     239    }
    226240    // create the exported-metadata and free local data
    227241    return psphotReadoutCleanup(config, view, "PSPHOT.INPUT");
Note: See TracChangeset for help on using the changeset viewer.