IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 46


Ignore:
Timestamp:
Feb 14, 2003, 2:03:17 AM (23 years ago)
Author:
eugene
Message:

major upgrade for megacam and flips2

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

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/perl/src/mkdetrend

    r17 r46  
    11#!/usr/bin/perl
     2$MKDETREND = "mkdetrend2";
    23
    34# strip off args related to the elixir config system, set env PTOLEMY
     
    67# interpret command-line arguments
    78if (@ARGV < 1) {
    8   print STDOUT "USAGE: mkdetrend (mode) [arguments]\n";
    9   print STDOUT "mode = help gives a complete list\n";
    10   &escape;
     9    print STDOUT "USAGE: $MKDETREND (mode) [arguments]\n";
     10    print STDOUT "mode = help gives a complete list\n";
     11    &escape;
    1112}
    1213if ($ARGV[0] eq "help") { &usage; }
     
    5758if ($ARGV[0] eq "test")         { &mk_test;       }
    5859
    59 &escape ("invalid mkdetrend command $ARGV[0]");
     60&escape ("invalid $MKDETREND command $ARGV[0]");
    6061
    6162######## top level functions ######################
     63
     64sub mk_test {
     65
     66    print "Content-type: text/plain\n\n";
     67
     68    print "mkdetrend2\n";
     69    exit 0;
     70}
    6271
    6372############# define run ##############
    6473sub mk_create {
    6574    if ($ARGV[1] eq "run") { &mk_createrun; }
    66     if (@ARGV != 5) { &escape ("USAGE: mkdetrend create (camera) (run) (startdate) (stopdate)"); }
     75    if (@ARGV != 5) { &escape ("USAGE: $MKDETREND create (camera) (run) (startdate) (stopdate)"); }
    6776   
    6877    $camera = $ARGV[1];
     
    115124############# define run ##############
    116125sub mk_createrun {
    117     if (@ARGV != 3) { &escape ("USAGE: mkdetrend create run (run)"); }
    118     if ($ARGV[1] ne "run") { &escape ("USAGE: mkdetrend create run (run)"); }
     126    if (@ARGV != 3) { &escape ("USAGE: $MKDETREND create run (run)"); }
     127    if ($ARGV[1] ne "run") { &escape ("USAGE: $MKDETREND create run (run)"); }
    119128   
    120129    $run    = $ARGV[2];
     
    157166############# change current run ##############
    158167sub mk_config {
    159     if (@ARGV != 3) { &escape ("USAGE: mkdetrend config (camera) (run)"); }
     168    if (@ARGV != 3) { &escape ("USAGE: $MKDETREND config (camera) (run)"); }
    160169   
    161170    $camera = $ARGV[1];
     
    177186    my ($start, $stop, $mode);
    178187
    179     if ((@ARGV != 2) && (@ARGV != 3)) { &escape ("USAGE: mkdetrend auto [command]"); }
     188    if ((@ARGV != 2) && (@ARGV != 3)) { &escape ("USAGE: $MKDETREND auto [command]"); }
    180189    $command = $ARGV[1];
    181190
    182191    ($start, $stop, $mode) = load_dates ();
    183192    if ($command eq "set") {
    184         if (@ARGV != 3) { &escape ("USAGE: mkdetrend auto set (mode)"); }
     193        if (@ARGV != 3) { &escape ("USAGE: $MKDETREND auto set (mode)"); }
    185194        &save_dates ($start, $stop, $ARGV[2]);
    186195        &goodbye;
    187196    }
    188197   
    189     if (@ARGV != 2) { &escape ("USAGE: mkdetrend auto [command]"); }
     198    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND auto [command]"); }
    190199    if ($command eq "show") {
    191200        print STDERR "MODE : $mode\n";
     
    195204    if ($command eq "run") {
    196205        if ($mode eq "init") {
    197             system ("mkdetrend reset hard");
    198             system ("mkdetrend init");
    199             system ("mkdetrend run");
     206            system ("$MKDETREND reset hard");
     207            system ("$MKDETREND init");
     208            system ("$MKDETREND run");
    200209            &save_dates ($start, $stop, "init");
    201210            &goodbye;
     
    203212       
    204213        if ($mode eq "update") {
    205             system ("mkdetrend update");
     214            system ("$MKDETREND update");
    206215            &save_dates ($start, $stop, "update");
    207216            &goodbye;
     
    212221        }
    213222    }
    214     &escape ("mkdetrend auto $command : command not found\n");
     223    &escape ("$MKDETREND auto $command : command not found\n");
    215224}
    216225
    217226############# main run ##############
    218227sub mk_run {
    219     if (@ARGV != 1) { &escape ("USAGE: mkdetrend run"); }
    220  
    221   system ("mkdetrend flips");
    222   system ("mkdetrend norm");
    223   system ("mkdetrend merge");
    224  
    225   &goodbye;
     228    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND run"); }
     229   
     230    system ("$MKDETREND flips");
     231    system ("$MKDETREND norm");
     232    system ("$MKDETREND merge");
     233   
     234    &goodbye;
    226235}
    227236
    228237############# main init ##############
    229238sub mk_init {
    230     if (@ARGV != 1) { &escape ("USAGE: mkdetrend init"); }
    231  
    232   system ("mkdetrend list.init");
    233   system ("mkdetrend split");
    234  
    235   &goodbye;
     239    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND init"); }
     240   
     241    system ("$MKDETREND list.init");
     242    system ("$MKDETREND split");
     243   
     244    &goodbye;
    236245}
    237246
    238247############# main update ##############
    239248sub mk_update {
    240     if (@ARGV != 1) { &escape ("USAGE: mkdetrend update"); }
    241  
    242   system ("mkdetrend reset update");
    243   system ("mkdetrend init");
    244   system ("mkdetrend update.list");
    245   system ("mkdetrend update.stats");
    246   system ("mkdetrend run");
    247  
    248   &goodbye;
     249    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND update"); }
     250   
     251    system ("$MKDETREND reset update");
     252    system ("$MKDETREND init");
     253    system ("$MKDETREND update.list");
     254    system ("$MKDETREND update.stats");
     255    system ("$MKDETREND run");
     256   
     257    &goodbye;
    249258}
    250259
    251260############# show current state ##############
    252261sub mk_state {
    253     if (@ARGV != 1) { &escape ("USAGE: mkdetrend state"); }
    254  
     262    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND state"); }
     263   
    255264    $file = mkfiles ("dates");
    256265    if (! -e $file) {
     
    268277   
    269278    @list = &load_config;
    270     if (@list == 0) { &escape ("mkdetrend not configured"); }
     279    if (@list == 0) { &escape ("$MKDETREND not configured"); }
    271280
    272281    for ($i = 0; $i < @list; $i++) {
     
    278287############# show current state ##############
    279288sub mk_list_runs {
    280     if (@ARGV != 1) { &escape ("USAGE: mkdetrend list.runs"); }
    281  
    282   system ("ls $root");
    283   &goodbye;
     289    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND list.runs"); }
     290   
     291    system ("ls $root");
     292    &goodbye;
    284293}
    285294
     
    287296sub mk_dup {
    288297    if (@ARGV != 2) { &escape ("USAGE: detrend dup (config)"); }
    289  
    290   $key = $ARGV[1];
    291   @list = load_config ();
    292  
    293   # look for entry that matches requested config
    294   @match = ();
    295   for ($i = 0; $i < @list; $i++) {
    296     $config = gtconfig ($list[$i], "config");
    297     if ($key eq $config) { @match = (@match, $i); }     
    298   }
    299   if (@match == 0) { &escape ("config $key not found\n"); }
    300  
    301   # create new config version based on version 0
    302   $Nnew = @match;
    303   $old = $list[$match[0]];
    304   $new = stconfig ($old, "version", $Nnew);
    305   @list = (@list, $new);
    306   save_config (@list);
    307  
    308   # now we need to duplicate all of the reference files from the first config
    309   for ($i = 0; $i < $Nccd; $i++) {
    310     $fold = mknames ("master", $old, $ccds[$i]);
    311     $fnew = mknames ("master", $new, $ccds[$i]);
    312     system ("cp $fold $fnew");
    313   }
    314   foreach $name ("stats", "medbin", "tenbin", "imbin") {
    315     $fold = mknames ($name, $old);
    316     $fnew = mknames ($name, $new);
    317     system ("cp $fold $fnew");
    318   }
    319  
    320   &goodbye;
    321  
     298   
     299    $key = $ARGV[1];
     300    @list = load_config ();
     301   
     302    # look for entry that matches requested config
     303    @match = ();
     304    for ($i = 0; $i < @list; $i++) {
     305        $config = gtconfig ($list[$i], "config");
     306        if ($key eq $config) { @match = (@match, $i); }
     307    }
     308    if (@match == 0) { &escape ("config $key not found\n"); }
     309   
     310    # create new config version based on version 0
     311    $Nnew = @match;
     312    $old = $list[$match[0]];
     313    $new = stconfig ($old, "version", $Nnew);
     314    @list = (@list, $new);
     315    save_config (@list);
     316   
     317    # now we need to duplicate all of the reference files from the first config
     318    foreach $ccd (@ccds) {
     319        $fold = mknames ("master", $old, $ccd);
     320        $fnew = mknames ("master", $new, $ccd);
     321        system ("cp $fold $fnew");
     322    }
     323    foreach $name ("stats", "medbin", "tenbin", "imbin") {
     324        $fold = mknames ($name, $old);
     325        $fnew = mknames ($name, $new);
     326        system ("cp $fold $fnew");
     327    }
     328   
     329    &goodbye;
     330   
    322331}
    323332
     
    365374            }
    366375
    367             # delete files names in these files:
     376            # delete files names in these files (not needed with flips2)
    368377            $name = &mknames ("msplit", $confline, $ccd);
    369378            open (FILE, "$name");
     
    398407############## delete config ###############
    399408sub mk_del {
    400     if (@ARGV != 2) { &escape ("USAGE: mkdetrend del (config.ver)"); }
    401  
    402   $key = $ARGV[1];
    403   @list = load_config ();
    404  
    405   # look for entry that matches requested config
    406   $match = -1;
    407   for ($i = 0; $i < @list; $i++) {
    408     $version = gtconfig ($list[$i], "version");
    409     if ($key eq $version) {
    410       $match = $i;
    411       last;
    412     }   
    413   }
    414   if ($match == -1) {
    415     print STDERR "config.ver $key not found\n";
    416     &escape;
    417   }
    418  
    419   # create new list without match:
    420   @newlist = ();
    421   for ($i = 0; $i < @list; $i++) {
    422     if ($i == $match) { next; }
    423     @newlist = (@newlist, $list[$i]);
    424   }
    425  
    426   save_config (@newlist);
    427   &goodbye;
    428  
     409    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND del (config.ver)"); }
     410   
     411    $key = $ARGV[1];
     412    @list = load_config ();
     413   
     414    # look for entry that matches requested config
     415    $match = -1;
     416    for ($i = 0; $i < @list; $i++) {
     417        $version = gtconfig ($list[$i], "version");
     418        if ($key eq $version) {
     419            $match = $i;
     420            last;
     421        }       
     422    }
     423    if ($match == -1) {
     424        print STDERR "config.ver $key not found\n";
     425        &escape;
     426    }
     427   
     428    # create new list without match:
     429    @newlist = ();
     430    for ($i = 0; $i < @list; $i++) {
     431        if ($i == $match) { next; }
     432        @newlist = (@newlist, $list[$i]);
     433    }
     434   
     435    save_config (@newlist);
     436    &goodbye;
     437   
    429438}
    430439
    431440############## reset config ###############
    432441sub mk_reset {
    433   if (@ARGV != 2) {
    434     print STDERR "USAGE: mkdetrend reset (level)\n";
    435     print STDERR "       level = hard || update\n";
    436     &escape;
    437   }
    438 
    439   $level = $ARGV[1];
    440   @list = load_config ();
    441  
    442   # find specific config:
     442    if (@ARGV != 2) {
     443        print STDERR "USAGE: $MKDETREND reset (level)\n";
     444        print STDERR "       level = hard || update\n";
     445        &escape;
     446    }
     447
     448    $level = $ARGV[1];
     449    @list = load_config ();
     450   
     451    # find specific config:
    443452RESET:
    444   foreach $confline (@list) {
    445     $status = gtconfig ($confline, "status");
    446 
    447     if ($level eq "hard" ) {
    448         $confline = stconfig ($confline, "status", "init");
    449     }
    450     if ($level eq "update") {
    451         if (($status eq "done.merge") || ($status eq "modified") || ($status eq "update")) {
    452             $confline = stconfig ($confline, "status", "update");
    453             next RESET;
    454         }
    455         if (($status eq "freeze") || ($status eq "accepted")) {
    456             $confline = stconfig ($confline, "status", "freeze");
    457             next RESET;
    458         }
    459         $confline = stconfig ($confline, "status", "init");
    460     }
    461   }
    462   save_config (@list);
    463   &goodbye;
     453    foreach $confline (@list) {
     454        $status = gtconfig ($confline, "status");
     455
     456        if ($level eq "hard" ) {
     457            $confline = stconfig ($confline, "status", "init");
     458        }
     459        if ($level eq "update") {
     460            if (($status eq "done.merge") || ($status eq "modified") || ($status eq "update")) {
     461                $confline = stconfig ($confline, "status", "update");
     462                next RESET;
     463            }
     464            if (($status eq "freeze") || ($status eq "accepted")) {
     465                $confline = stconfig ($confline, "status", "freeze");
     466                next RESET;
     467            }
     468            $confline = stconfig ($confline, "status", "init");
     469        }
     470    }
     471    save_config (@list);
     472    &goodbye;
    464473}
    465474
    466475############## define config ###############
    467476sub mk_def {
    468     if (@ARGV != 4) { &escape ("USAGE: mkdetrend def (config.ver) (start) (stop)"); }
    469  
    470   $key   = $ARGV[1];
    471   $start = $ARGV[2];
    472   $stop  = $ARGV[3];
    473  
    474   @list = load_config ();
    475  
    476   # find specific config:
    477   $match = -1;
    478   for ($i = 0; $i < @list; $i++) {
    479     $version = gtconfig ($list[$i], "version");
    480     if ($key eq $version) {
    481       $match = $i;
    482     }   
    483   }
    484   if (@match == -1) {
    485     print STDERR "config.ver $key not found\n";
    486     &escape;
    487   }
    488  
    489   $new = $list[$match];
    490   $new = stconfig ($new, "start", $start);
    491   $new = stconfig ($new, "stop", $stop);
    492   $list[$match] = $new;
    493  
    494   save_config (@list);
    495   &goodbye;
    496  
     477    if (@ARGV != 4) { &escape ("USAGE: $MKDETREND def (config.ver) (start) (stop)"); }
     478   
     479    $key   = $ARGV[1];
     480    $start = $ARGV[2];
     481    $stop  = $ARGV[3];
     482   
     483    @list = load_config ();
     484   
     485    # find specific config:
     486    $match = -1;
     487    for ($i = 0; $i < @list; $i++) {
     488        $version = gtconfig ($list[$i], "version");
     489        if ($key eq $version) {
     490            $match = $i;
     491        }       
     492    }
     493    if (@match == -1) {
     494        print STDERR "config.ver $key not found\n";
     495        &escape;
     496    }
     497   
     498    $new = $list[$match];
     499    $new = stconfig ($new, "start", $start);
     500    $new = stconfig ($new, "stop", $stop);
     501    $list[$match] = $new;
     502   
     503    save_config (@list);
     504    &goodbye;
     505   
    497506}
    498507
    499508############## list init ###############
    500509sub mk_list_init {
    501   if (@ARGV != 1) { &escape ("USAGE: mkdetrend list.init"); }
    502  
    503   @list = load_config ();
    504  
    505   # create namelist
    506   $Nrun = 0;
    507   $file = mkfiles ("list");
    508   open (FILE, ">$file");
    509   foreach $confline (@list) {
    510       $status = gtconfig ($confline, "status");
    511       if ($status ne "init") { next; }
    512       $Nrun ++;
    513       $line = gtconfig ($confline, "mosaic");
    514       print FILE "$line\n";
    515       $confline = stconfig ($confline, "status", "running.init");
    516   }
    517   close (FILE);
    518   save_config (@list);
    519 
    520   if ($Nrun == 0) { &goodbye; }
    521  
    522   system ("elixir -D DETREND_DIR $det -D mode mkdetrend -D global.pending imselect.split $file");
    523   system ("mkdetrend meval init");
    524  
    525   &goodbye;
     510    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND list.init"); }
     511   
     512    @list = load_config ();
     513   
     514    # create namelist
     515    $Nrun = 0;
     516    $file = mkfiles ("list");
     517    open (FILE, ">$file");
     518    foreach $confline (@list) {
     519        $status = gtconfig ($confline, "status");
     520        if ($status ne "init") { next; }
     521        $Nrun ++;
     522        $line = gtconfig ($confline, "mosaic");
     523        print FILE "$line\n";
     524        $confline = stconfig ($confline, "status", "running.init");
     525    }
     526    close (FILE);
     527    save_config (@list);
     528
     529    if ($Nrun == 0) { &goodbye; }
     530   
     531    vsystem ("elixir -D DETREND_DIR $det -D mode $MKDETREND -D global.pending imselect.split $file");
     532    system ("$MKDETREND meval init");
     533   
     534    &goodbye;
    526535}
    527536
    528537############## split ###############
    529538sub mk_split {
    530     if (@ARGV != 1) { &escape ("USAGE: mkdetrend split"); }
    531  
    532   @list = load_config ();
    533  
    534   # create namelist
    535   $Nrun = 0;
    536   $file = mkfiles ("list");
    537   open (FILE, ">$file");
    538   foreach $confline (@list) {
    539       $status = gtconfig ($confline, "status");
    540       if (($status ne "done.init") && ($status ne "split")) { next; }
    541       $Nrun ++;
    542       for ($j = 0; $j < $Nccd; $j++) {
    543         $line = gtconfig ($confline, "chiprun", $j);
    544         print FILE "$line\n";
    545       }
    546       $confline = stconfig ($confline, "status", "running.split");
    547   }
    548   close (FILE);
    549   save_config (@list);
    550 
    551   if ($Nrun == 0) { &goodbye; }
    552  
    553   system ("elixir -D DETREND_DIR $det -D mode mkdetrend -D global.pending split.mef $file");
    554   system ("mkdetrend eval split");
    555  
    556   &goodbye;
     539    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND split"); }
     540   
     541    @list = load_config ();
     542   
     543    # create namelist
     544    $Nrun = 0;
     545    $file = mkfiles ("list");
     546    open (FILE, ">$file");
     547    foreach $confline (@list) {
     548        $status = gtconfig ($confline, "status");
     549        if (($status ne "done.init") && ($status ne "split")) { next; }
     550        $Nrun ++;
     551        foreach $ccd (@ccds) {
     552            $line = gtconfig ($confline, "chiprun", $ccd);
     553            print FILE "$line\n";
     554        }
     555        $confline = stconfig ($confline, "status", "running.split");
     556    }
     557    close (FILE);
     558    save_config (@list);
     559
     560    if ($Nrun == 0) { &goodbye; }
     561   
     562    system ("elixir -D DETREND_DIR $det -D mode $MKDETREND -D global.pending merge.lists $file");
     563    system ("$MKDETREND eval split");
     564   
     565    &goodbye;
    557566}
    558567
    559568############## update lists ###############
    560569sub mk_update_list {
    561     if (@ARGV != 1) { &escape ("USAGE: mkdetrend update.list"); }
    562  
    563   @list = load_config ();
    564  
    565   # create namelist
    566   $Nrun = 0;
    567   $file = mkfiles ("list");
    568   open (FILE, ">$file");
    569   foreach $confline (@list) {
    570       $status = gtconfig ($confline, "status");
    571       if ($status ne "update") { next; }
    572       $Nrun ++;
    573       $line = gtconfig ($confline, "mosaic");
    574       print FILE "$line\n";
    575       $confline = stconfig ($confline, "status", "running.update.list");
    576   }
    577   close (FILE);
    578   save_config (@list);
    579  
    580   if ($Nrun == 0) { &goodbye; }
    581  
    582   system ("elixir -D DETREND_DIR $det -D mode mkdetrend -D global.pending update.split $file");
    583   system ("mkdetrend meval update.list");
    584  
    585   &goodbye;
     570    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND update.list"); }
     571   
     572    @list = load_config ();
     573   
     574    # create namelist
     575    $Nrun = 0;
     576    $file = mkfiles ("list");
     577    open (FILE, ">$file");
     578    foreach $confline (@list) {
     579        $status = gtconfig ($confline, "status");
     580        if ($status ne "update") { next; }
     581        $Nrun ++;
     582        $line = gtconfig ($confline, "mosaic");
     583        print FILE "$line\n";
     584        $confline = stconfig ($confline, "status", "running.update.list");
     585    }
     586    close (FILE);
     587    save_config (@list);
     588   
     589    if ($Nrun == 0) { &goodbye; }
     590   
     591    system ("elixir -D DETREND_DIR $det -D mode $MKDETREND -D global.pending update.split $file");
     592    system ("$MKDETREND meval update.list");
     593   
     594    &goodbye;
    586595}
    587596
    588597############## update stats ###############
    589598sub mk_update_stats {
    590     if (@ARGV != 1) { &escape ("USAGE: mkdetrend update.stats"); }
    591  
    592   @list = load_config ();
    593  
    594   # create namelist
    595   $Nrun = 0;
    596   $file = mkfiles ("list");
    597   open (FILE, ">$file");
    598   foreach $confline (@list) {
    599       $status = gtconfig ($confline, "status");
    600       if (($status ne "done.update.list") && ($status ne "update.stats")) { next; }
    601       $Nrun ++;
    602       for ($j = 0; $j < $Nccd; $j++) {
    603           $line = gtconfig ($confline, "chiprun", $j);
    604           print FILE "$line\n";
    605       }
    606       $confline = stconfig ($confline, "status", "running.update.stats");
    607 
    608   }
    609   close (FILE);
    610   save_config (@list);
    611  
    612   if ($Nrun == 0) { &goodbye; }
    613  
    614   system ("elixir -D DETREND_DIR $det -D mode mkdetrend -D global.pending update.msplit $file");
    615   system ("mkdetrend eval update.stats");
    616  
    617   &goodbye;
     599    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND update.stats"); }
     600   
     601    @list = load_config ();
     602   
     603    # create namelist
     604    $Nrun = 0;
     605    $file = mkfiles ("list");
     606    open (FILE, ">$file");
     607    foreach $confline (@list) {
     608        $status = gtconfig ($confline, "status");
     609        if (($status ne "done.update.list") && ($status ne "update.stats")) { next; }
     610        $Nrun ++;
     611        foreach $ccd (@ccds) {
     612            $line = gtconfig ($confline, "chiprun", $ccd);
     613            print FILE "$line\n";
     614        }
     615        $confline = stconfig ($confline, "status", "running.update.stats");
     616
     617    }
     618    close (FILE);
     619    save_config (@list);
     620   
     621    if ($Nrun == 0) { &goodbye; }
     622   
     623    system ("elixir -D DETREND_DIR $det -D mode $MKDETREND -D global.pending update.msplit $file");
     624    system ("$MKDETREND eval update.stats");
     625   
     626    &goodbye;
    618627}
    619628
    620629############## set state ###############
    621630sub mk_set {
    622     if (@ARGV != 3) { &escape ("USAGE: mkdetrend set (config number) (state)"); }
    623  
    624   @list = load_config ();
    625  
    626   $key = $ARGV[1];
    627   $state = $ARGV[2];
    628  
    629   $new = stconfig ($list[$key], "status", "$state");
    630   $list[$key] = $new;
    631   save_config (@list);
    632  
    633   &goodbye;
     631    if (@ARGV != 3) { &escape ("USAGE: $MKDETREND set (config number) (state)"); }
     632   
     633    @list = load_config ();
     634   
     635    $key = $ARGV[1];
     636    $state = $ARGV[2];
     637   
     638    $new = stconfig ($list[$key], "status", "$state");
     639    $list[$key] = $new;
     640    save_config (@list);
     641   
     642    &goodbye;
    634643}
    635644
    636645############## flips run ###############
    637646sub mk_flips {
    638     if (@ARGV != 1) { &escape ("USAGE: mkdetrend flips"); }
     647    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND flips"); }
    639648   
    640649    @list = load_config ();
     
    648657        if (($status ne "done.split") && ($status ne "modified") && ($status ne "flips")) { next; }
    649658        $Nrun ++;
    650         for ($j = 0; $j < $Nccd; $j++) {
    651             $line = gtconfig ($confline, "chiprun", $j);
     659        foreach $ccd (@ccds) {
     660            $line = gtconfig ($confline, "chiprun", $ccd);
    652661            print FILE "$line\n";
    653662        }
     
    659668    if ($Nrun == 0) { &goodbye; }
    660669
    661     system ("elixir -D DETREND_DIR $det -D mode mkdetrend -D global.pending create.subset $file");
    662     system ("mkdetrend eval flips");
     670    system ("elixir -D DETREND_DIR $det -D mode $MKDETREND -D global.pending create.subset $file");
     671    system ("$MKDETREND eval flips");
    663672
    664673    &goodbye;
     
    667676############## norm run ###############
    668677sub mk_norm {
    669     if (@ARGV != 1) { &escape ("USAGE: mkdetrend norm"); }
     678    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND norm"); }
    670679
    671680    @list = load_config ();
     
    679688        if (($status ne "done.flips") && ($status ne "norm")) { next; }
    680689        $Nrun ++;
    681         for ($j = 0; $j < $Nccd; $j++) {
    682             $line = gtconfig ($confline, "chiprun", $j);
     690        foreach $ccd (@ccds) {
     691            $line = gtconfig ($confline, "chiprun", $ccd);
    683692            print FILE "$line\n";
    684693        }
     
    690699    if ($Nrun == 0) { &goodbye; }
    691700
    692     vsystem ("elixir -D DETREND_DIR $det -D mode mkdetrend -D global.pending normal $file");
    693     vsystem ("mkdetrend eval norm");
     701    vsystem ("elixir -D DETREND_DIR $det -D mode $MKDETREND -D global.pending normal $file");
     702    vsystem ("$MKDETREND eval norm");
    694703
    695704    &goodbye;
     
    698707############## merge run ###############
    699708sub mk_merge {
    700     if (@ARGV != 1) { &escape ("USAGE: mkdetrend merge"); }
     709    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND merge"); }
    701710   
    702711    @list = load_config ();
     
    719728    if ($Nrun == 0) { &goodbye; }
    720729   
    721     vsystem ("elixir -D DETREND_DIR $det -D mode mkdetrend -D global.pending stats $file");
    722     vsystem ("mkdetrend meval merge");
     730    vsystem ("elixir -D DETREND_DIR $det -D mode $MKDETREND -D global.pending stats $file");
     731    vsystem ("$MKDETREND meval merge");
    723732   
    724733    &goodbye;
     
    727736############## reg run ###############
    728737sub mk_reg {
    729     if (@ARGV != 1) { &escape ("USAGE: mkdetrend reg"); }
    730    
    731     @list = load_config ();
    732    
     738    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND reg"); }
     739   
     740    @list = load_config ();
     741   
     742    # create directory for fhtool to work in
     743    $links = mkfiles ("links");
     744    if (! -e $links) { mkdir ($links); }
     745
    733746    # create namelist for those with appropriate status
    734747    foreach $confline (@list) {
     
    740753        $success = 1;
    741754        $ID = gtconfig ($confline, "ID");
    742         for ($j = 0; $j < $Nccd; $j++) {
    743             $file = mknames ("norm", $confline, $ccds[$j]);
    744             $line = "detregister $file -label elixir -ID $ID";
    745             $status = system ($line);
    746             if ($status) {
    747                 print STDERR "error registering $file\n";
    748                 $success = 0;
     755
     756        $DBmode = `gconfig DETREND-DB-MODE`; chop $DBmode;
     757        $DBmode = "\U$DBmode\E";
     758
     759        if ($DBmode eq "SPLIT") {
     760            for ($j = 0; $j < $Nccd; $j++) {
     761                $file = mknames ("norm", $confline, $ccds[$j]);
     762                $line = "detregister $file -label elixir -ID $ID";
     763                $status = system ($line);
     764                if ($status) {
     765                    print STDERR "error registering $file\n";
     766                    $success = 0;
     767                }
    749768            }
    750         }
    751         if ($success) {
     769            goto registered;
     770        }
     771
     772        if ($DBmode eq "MEF") {
     773            # make links
     774            foreach $ccd (@ccds) {
     775                $file = mknames ("norm", $confline, $ccd);
     776                $link = mknames ("link", $confline, $ccd);
     777                symlink $file, $link;
     778            }
     779
     780            # mef, register
     781            $mef = mknames ("mef", $confline);
     782            vsystem ("fhtool -P $links $mef");
     783            if ($status) { $success = 0; }
     784            vsystem ("detregister $mef -label elixir -ID $ID");
     785            if ($status) { $success = 0; }
     786
     787            # remove links
     788            foreach $ccd (@ccds) {
     789                $link = mknames ("link", $confline, $ccd);
     790                unlink $link;
     791            }
     792            goto registered;
     793        }
     794        print STDERR "DB mode not defined?\n";
     795        $success = 0;
     796
     797      registered:
     798        if ($success) {
    752799            $confline = stconfig ($confline, "status", "done.reg");
    753800        } else {
     801            print STDERR "error registering $file\n";
    754802            $confline = stconfig ($confline, "status", "fail.reg");
    755803        }
    756804        save_config (@list);
    757     }
    758 
    759     # detregister is sequential anyway, run serial
    760     # system ("elixir -D DETREND_DIR $det -D mode mkdetrend -D global.pending detregister $file");
    761     # system ("mkdetrend eval reg");
     805
     806    }
    762807
    763808    # use recipe file to decide if we apply 'scat' or not!
    764 
    765809    $file = mkfiles ("list");
    766810    # create list of images to apply scattered-light correction:
     
    775819
    776820            open (FILE, ">$file");
    777             for ($j = 0; $j < $Nccd; $j++) {
    778                 $line = mknames ("norm", $confline, $ccds[$j]);
     821            foreach $ccd (@ccds) {
     822                $line = mknames ("norm", $confline, $ccd);
    779823                print FILE "$line\n";
    780824            }
     
    805849############## html modify ###############
    806850sub mk_fixmasters {
    807     if (@ARGV != 1) { &escape ("USAGE: mkdetrend fix.masters"); }
     851    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND fix.masters"); }
    808852   
    809853    @list = load_config ();
     
    853897############## html modify ###############
    854898sub mk_checksplits {
    855     if (@ARGV != 2) { &escape ("USAGE: mkdetrend check.splits (config)"); }
     899    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND check.splits (config)"); }
    856900   
    857901    $Nconfig = $ARGV[1];
     
    860904
    861905    # re-create all masters to match master for chip 00
    862     for ($i = 0; $i < $Nccd; $i++) {
     906    foreach $ccd (@ccds) {
    863907       
    864908        # load existing master file
    865         $master = mknames ("master", $name, $ccds[$i]);
     909        $master = mknames ("master", $name, $ccd);
    866910        open (FILE, $master);
    867911        @master = <FILE>;
     
    882926############## html duplicate ###############
    883927sub mk_htmldup {
    884     if (@ARGV != 2) { &escape ("USAGE: mkdetrend htmldup (config)"); }
    885  
    886   $config = $ARGV[1];
    887   # we are just calling the "mkdetrend dup" function and then calling "mkdetrend html1"
    888  
    889   system ("mkdetrend dup $config");
    890   print STDOUT "<meta http-equiv=refresh content=\"0; url=$CGI/elixir1?&elconf=$elconf\">\n";
    891  
    892   &goodbye;
    893  
     928    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND htmldup (config)"); }
     929   
     930    $config = $ARGV[1];
     931    # we are just calling the "mkdetrend dup" function and then calling "$MKDETREND html1"
     932   
     933    system ("$MKDETREND dup $config");
     934    print STDOUT "<meta http-equiv=refresh content=\"0; url=$CGI/elixir1?&elconf=$elconf\">\n";
     935   
     936    &goodbye;
     937   
    894938}
    895939
    896940############## html delete ###############
    897941sub mk_htmldel {
    898     if (@ARGV != 2) { &escape ("USAGE: mkdetrend htmldel (config.ver)"); }
    899  
    900   $config = $ARGV[1];
    901   # we are just calling the "mkdetrend del" function and then calling "mkdetrend html1"
    902  
    903   system ("mkdetrend del $config");
    904   print STDOUT "<meta http-equiv=refresh content=\"0; url=$CGI/elixir1?&elconf=$elconf\">\n";
    905  
    906   &goodbye;;
    907  
     942    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND htmldel (config.ver)"); }
     943   
     944    $config = $ARGV[1];
     945    # we are just calling the "mkdetrend del" function and then calling "mkdetrend html1"
     946   
     947    system ("$MKDETREND del $config");
     948    print STDOUT "<meta http-equiv=refresh content=\"0; url=$CGI/elixir1?&elconf=$elconf\">\n";
     949   
     950    &goodbye;;
     951   
    908952}
    909953
    910954############## html define ###############
    911955sub mk_htmldef {
    912     if (@ARGV != 2) { &escape ("USAGE: mkdetrend htmldef (config.ver)"); }
    913  
    914   $key = $ARGV[1];
    915  
    916   # find (config.ver) in list:
    917  
    918   @list = load_config ();
    919  
    920   $match = -1;
    921   for ($i = 0; $i < @list; $i++) {
    922     $version = gtconfig ($list[$i], "version");
    923     if ($key eq $version) {
    924       $match = $i;
    925       last;
    926     }
    927   }
    928     if ($match == -1) { &escape ("error: can't find config entry"); }
    929  
    930   # show the complete list for reference
    931   print STDOUT "<HEADER> <TITLE>Elixir Mkdetrend Report</TITLE> </HEADER>\n";
    932   print STDOUT "<BODY BGCOLOR=#fff0e0 TEXT=#000000 LINK=#0000ff VLINK=#6600ff ALINK=#a0a0a0>\n";
    933   print STDOUT "<table border>\n";
    934   for ($i = 0; $i < @list; $i++) {
    935     $config  = gtconfig ($list[$i], "config");
    936     $version = gtconfig ($list[$i], "version");
    937     $status  = gtconfig ($list[$i], "status");
    938     $from    = gtconfig ($list[$i], "from");
    939     $to      = gtconfig ($list[$i], "to");
    940     print STDOUT "<tr><td> $version </td>\n";
    941     print STDOUT "<td> $from </td><td> $to </td>\n";
    942     print STDOUT "<td> <a href=$CGI/elixir2?$version&elconf=$elconf> $status </a></td>\n";
    943     print STDOUT "<td> <a href=$CGI/split?$config&elconf=$elconf>      split </a></td>\n";
    944     print STDOUT "<td> <a href=$CGI/delete?$version&elconf=$elconf>   delete </a></td>\n";
    945     print STDOUT "<td> <a href=$CGI/redef?$version&elconf=$elconf>  redefine </a></td>\n";
    946     print STDOUT "</tr>\n";
    947   }
    948   print STDOUT "</table></body><br><br>\n";
    949  
    950   $version = gtconfig ($list[$match], "version");
    951   $status  = gtconfig ($list[$match], "status");
    952   $from    = gtconfig ($list[$match], "from");
    953   $to      = gtconfig ($list[$match], "to");
    954   print STDOUT "redefining <b> $key: </b> <br>\n";   
    955   print STDOUT "<table border>\n";
    956   print STDOUT "<tr><td> $version </td>\n";
    957   print STDOUT "<td> $from </td><td> $to </td><td> $status </a></td>\n";
    958   print STDOUT "</tr></table>\n";
    959  
    960  
    961   # create a simple form for redefine:
    962   print STDOUT "<form method=post action=$CGI/redefine&elconf=$elconf>\n";
    963   print STDOUT "start: <input type=text value=$from name=start size=40 maxlength=40> <br>\n";
    964   print STDOUT "stop: <input type=text value=$to name=stop size=40 maxlength=40> <br>\n";
    965   print STDOUT "<input type=hidden name=config value=\"$key\">\n";
    966   print STDOUT "<input type=\"submit\" value=\"submit\"><input type=\"reset\" value=\"reset\">\n";
    967   print STDOUT "</form>\n";
    968   print STDOUT "</body>\n";
    969  
    970   &goodbye;;
    971  
    972 }
    973 
    974 ############## html modify ###############
    975 sub mk_htmlmod {
    976     if (@ARGV != 1) { &escape ("USAGE: mkdetrend htmlmod"); }
    977    
    978     $key = $ENV{'WWW_config'};
    979     $Nimage = $ENV{'WWW_Nimage'};
     956    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND htmldef (config.ver)"); }
     957   
     958    $key = $ARGV[1];
     959   
     960    # find (config.ver) in list:
    980961   
    981962    @list = load_config ();
     
    991972    if ($match == -1) { &escape ("error: can't find config entry"); }
    992973   
     974    # show the complete list for reference
     975    print STDOUT "<HEADER> <TITLE>Elixir Mkdetrend Report</TITLE> </HEADER>\n";
     976    print STDOUT "<BODY BGCOLOR=#fff0e0 TEXT=#000000 LINK=#0000ff VLINK=#6600ff ALINK=#a0a0a0>\n";
     977    print STDOUT "<table border>\n";
     978    for ($i = 0; $i < @list; $i++) {
     979        $config  = gtconfig ($list[$i], "config");
     980        $version = gtconfig ($list[$i], "version");
     981        $status  = gtconfig ($list[$i], "status");
     982        $from    = gtconfig ($list[$i], "from");
     983        $to      = gtconfig ($list[$i], "to");
     984        print STDOUT "<tr><td> $version </td>\n";
     985        print STDOUT "<td> $from </td><td> $to </td>\n";
     986        print STDOUT "<td> <a href=$CGI/elixir2?$version&elconf=$elconf> $status </a></td>\n";
     987        print STDOUT "<td> <a href=$CGI/split?$config&elconf=$elconf>      split </a></td>\n";
     988        print STDOUT "<td> <a href=$CGI/delete?$version&elconf=$elconf>   delete </a></td>\n";
     989        print STDOUT "<td> <a href=$CGI/redef?$version&elconf=$elconf>  redefine </a></td>\n";
     990        print STDOUT "</tr>\n";
     991    }
     992    print STDOUT "</table></body><br><br>\n";
     993   
     994    $version = gtconfig ($list[$match], "version");
     995    $status  = gtconfig ($list[$match], "status");
     996    $from    = gtconfig ($list[$match], "from");
     997    $to      = gtconfig ($list[$match], "to");
     998    print STDOUT "redefining <b> $key: </b> <br>\n";   
     999    print STDOUT "<table border>\n";
     1000    print STDOUT "<tr><td> $version </td>\n";
     1001    print STDOUT "<td> $from </td><td> $to </td><td> $status </a></td>\n";
     1002    print STDOUT "</tr></table>\n";
     1003   
     1004   
     1005    # create a simple form for redefine:
     1006    print STDOUT "<form method=post action=$CGI/redefine&elconf=$elconf>\n";
     1007    print STDOUT "start: <input type=text value=$from name=start size=40 maxlength=40> <br>\n";
     1008    print STDOUT "stop: <input type=text value=$to name=stop size=40 maxlength=40> <br>\n";
     1009    print STDOUT "<input type=hidden name=config value=\"$key\">\n";
     1010    print STDOUT "<input type=\"submit\" value=\"submit\"><input type=\"reset\" value=\"reset\">\n";
     1011    print STDOUT "</form>\n";
     1012    print STDOUT "</body>\n";
     1013   
     1014    &goodbye;;
     1015   
     1016}
     1017
     1018############## html modify ###############
     1019sub mk_htmlmod {
     1020    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND htmlmod"); }
     1021   
     1022    $key = $ENV{'WWW_config'};
     1023    $Nimage = $ENV{'WWW_Nimage'};
     1024   
     1025    @list = load_config ();
     1026   
     1027    $match = -1;
     1028    for ($i = 0; $i < @list; $i++) {
     1029        $version = gtconfig ($list[$i], "version");
     1030        if ($key eq $version) {
     1031            $match = $i;
     1032            last;
     1033        }
     1034    }
     1035    if ($match == -1) { &escape ("error: can't find config entry"); }
     1036   
    9931037    # re-create $master to match selections
    9941038    # depends on the format of data in the 'master' file
    995     for ($i = 0; $i < $Nccd; $i++) {
     1039    foreach $ccd (@ccds) {
    9961040
    9971041        # load existing master file
    998         $master = mknames ("master", $list[$match], $ccds[$i]);
     1042        $master = mknames ("master", $list[$match], $ccd);
    9991043        open (FILE, $master);
    10001044        @master = <FILE>;
     
    10021046
    10031047        if ($Nimage != @master) {
    1004             print STDOUT "error: mis-match in image lists ccd $i\n";
     1048            print STDOUT "error: mis-match in image lists ccd $ccd\n";
    10051049            &escape;
    10061050        }
     
    10281072############## html accept ###############
    10291073sub mk_htmlkeep {
    1030     if (@ARGV != 2) { &escape ("USAGE: mkdetrend htmlkeep (config.ver)"); }
    1031  
    1032   $key = $ARGV[1];
    1033   @list = load_config ();
    1034  
    1035   $match = -1;
    1036   for ($i = 0; $i < @list; $i++) {
    1037     $version = gtconfig ($list[$i], "version");
    1038     if ($key eq $version) {
    1039       $match = $i;
    1040       last;
    1041     }
    1042   }
    1043   if ($match == -1) {
    1044     print STDERR "error: can't find config entry\n";
    1045     &escape;
    1046   }
    1047  
    1048   # adjust the config file: convert status to 'accepted'
    1049   $list[$match] = stconfig ($list[$match], "status", "accepted");
    1050   save_config (@list);
    1051  
    1052   print STDOUT "<meta http-equiv=refresh content=\"0; url=$CGI/elixir1?&elconf=$elconf\">";
    1053   &goodbye;
     1074    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND htmlkeep (config.ver)"); }
     1075   
     1076    $key = $ARGV[1];
     1077    @list = load_config ();
     1078   
     1079    $match = -1;
     1080    for ($i = 0; $i < @list; $i++) {
     1081        $version = gtconfig ($list[$i], "version");
     1082        if ($key eq $version) {
     1083            $match = $i;
     1084            last;
     1085        }
     1086    }
     1087    if ($match == -1) {
     1088        print STDERR "error: can't find config entry\n";
     1089        &escape;
     1090    }
     1091   
     1092    # adjust the config file: convert status to 'accepted'
     1093    $list[$match] = stconfig ($list[$match], "status", "accepted");
     1094    save_config (@list);
     1095   
     1096    print STDOUT "<meta http-equiv=refresh content=\"0; url=$CGI/elixir1?&elconf=$elconf\">";
     1097    &goodbye;
    10541098}
    10551099
    10561100############## html config ###############
    10571101sub mk_htmlconfig {
    1058     if (@ARGV != 1) { &escape ("USAGE: mkdetrend htmlconfig"); }
    1059  
    1060   ## html headers
    1061   print STDOUT "<HEADER> <TITLE>Elixir Mkdetrend Report</TITLE> </HEADER>\n";
    1062   print STDOUT "<BODY BGCOLOR=#fff0f0 TEXT=#000000 LINK=#0000ff VLINK=#6600ff ALINK=#a0a0a0>\n";
    1063  
    1064   # create a simple form for redefine:
    1065   print STDOUT "<form method=post action=$CGI/newconfig>\n";
    1066   if ($elconf) {
    1067       print STDOUT "enter new config: <input type=text value=$elconf name=config size=40 maxlength=40> <br>\n";
    1068   } else {
    1069       print STDOUT "enter new config: <input type=text name=config size=40 maxlength=40> <br>\n";
    1070   }
    1071   print STDOUT "<input type=\"submit\" value=\"submit\"><input type=\"reset\" value=\"reset\">\n";
    1072   print STDOUT "</form>\n";
    1073   print STDOUT "</body>\n";
    1074  
    1075   &goodbye;
     1102    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND htmlconfig"); }
     1103   
     1104    ## html headers
     1105    print STDOUT "<HEADER> <TITLE>Elixir Mkdetrend Report</TITLE> </HEADER>\n";
     1106    print STDOUT "<BODY BGCOLOR=#fff0f0 TEXT=#000000 LINK=#0000ff VLINK=#6600ff ALINK=#a0a0a0>\n";
     1107   
     1108    # create a simple form for redefine:
     1109    print STDOUT "<form method=post action=$CGI/newconfig>\n";
     1110    if ($elconf) {
     1111        print STDOUT "enter new config: <input type=text value=$elconf name=config size=40 maxlength=40> <br>\n";
     1112    } else {
     1113        print STDOUT "enter new config: <input type=text name=config size=40 maxlength=40> <br>\n";
     1114    }
     1115    print STDOUT "<input type=\"submit\" value=\"submit\"><input type=\"reset\" value=\"reset\">\n";
     1116    print STDOUT "</form>\n";
     1117    print STDOUT "</body>\n";
     1118   
     1119    &goodbye;
    10761120}
    10771121
    10781122############## html level 1 ###############
    10791123sub mk_html1 {
    1080     if (@ARGV != 1) { &escape ("USAGE: mkdetrend html1"); }
    1081  
    1082   @list = load_config ();
    1083  
    1084   ## html headers
    1085   print STDOUT "<HEADER> <TITLE>Elixir Mkdetrend Report</TITLE> </HEADER>\n";
    1086   print STDOUT "<BODY BGCOLOR=#fff0f0 TEXT=#000000 LINK=#0000ff VLINK=#6600ff ALINK=#a0a0a0>\n";
    1087 
    1088   print STDOUT "<table border>\n";
    1089   for ($i = 0; $i < @list; $i++) {
    1090     $config  = gtconfig ($list[$i], "config");
    1091     $version = gtconfig ($list[$i], "version");
    1092     $from    = gtconfig ($list[$i], "from");
    1093     $to      = gtconfig ($list[$i], "to");
    1094     $status  = gtconfig ($list[$i], "status");
    1095     print STDOUT "<tr><td> $version </td>\n";
    1096     print STDOUT "<td> $from </td><td> $to </td>\n";
    1097     print STDOUT "<td> <a href=$CGI/elixir2?$version&elconf=$elconf> $status </a></td>\n";
    1098     print STDOUT "<td> <a href=$CGI/split?$config&elconf=$elconf> split </a></td>\n";
    1099     print STDOUT "<td> <a href=$CGI/delete?$version&elconf=$elconf> delete </a></td>\n";
    1100     print STDOUT "<td> <a href=$CGI/redef?$version&elconf=$elconf> redefine </a></td>\n";
    1101     print STDOUT "</tr>\n";
    1102   }
    1103  
    1104   print STDOUT "</table><br><br>\n";
    1105   if ($elconf eq "") {
    1106       print STDOUT "Current Config: <b>default</b><br>\n";
    1107   } else {
    1108       print STDOUT "Current Config: <b>$elconf</b><br>\n";
    1109   }
    1110   print STDOUT "<a href=$CGI/config?&elconf=$elconf>Change Config</a></td>\n";
    1111   print STDOUT "</body>\n";
    1112   &goodbye;;
     1124    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND html1"); }
     1125   
     1126    @list = load_config ();
     1127   
     1128    ## html headers
     1129    print STDOUT "<HEADER> <TITLE>Elixir Mkdetrend Report</TITLE> </HEADER>\n";
     1130    print STDOUT "<BODY BGCOLOR=#fff0f0 TEXT=#000000 LINK=#0000ff VLINK=#6600ff ALINK=#a0a0a0>\n";
     1131
     1132    print STDOUT "<table border>\n";
     1133    for ($i = 0; $i < @list; $i++) {
     1134        $config  = gtconfig ($list[$i], "config");
     1135        $version = gtconfig ($list[$i], "version");
     1136        $from    = gtconfig ($list[$i], "from");
     1137        $to      = gtconfig ($list[$i], "to");
     1138        $status  = gtconfig ($list[$i], "status");
     1139        print STDOUT "<tr><td> $version </td>\n";
     1140        print STDOUT "<td> $from </td><td> $to </td>\n";
     1141        print STDOUT "<td> <a href=$CGI/elixir2?$version&elconf=$elconf> $status </a></td>\n";
     1142        print STDOUT "<td> <a href=$CGI/split?$config&elconf=$elconf> split </a></td>\n";
     1143        print STDOUT "<td> <a href=$CGI/delete?$version&elconf=$elconf> delete </a></td>\n";
     1144        print STDOUT "<td> <a href=$CGI/redef?$version&elconf=$elconf> redefine </a></td>\n";
     1145        print STDOUT "</tr>\n";
     1146    }
     1147   
     1148    print STDOUT "</table><br><br>\n";
     1149    if ($elconf eq "") {
     1150        print STDOUT "Current Config: <b>default</b><br>\n";
     1151    } else {
     1152        print STDOUT "Current Config: <b>$elconf</b><br>\n";
     1153    }
     1154    print STDOUT "<a href=$CGI/config?&elconf=$elconf>Change Config</a></td>\n";
     1155    print STDOUT "</body>\n";
     1156    &goodbye;;
    11131157}
    11141158
    11151159############## html level 2 ###############
    11161160sub mk_html2 {
    1117     if (@ARGV != 2) { &escape ("USAGE: mkdetrend html2 (config.ver)"); }
    1118  
    1119   @list = load_config ();
    1120  
    1121   # entry on line will be either config.ver (== key) or config.ver.col for sorting
    1122   # grab just the key portion
    1123   $status = "none";
    1124   ($key) = $ARGV[1] =~ /(\w+.\w+.\w+.\w+)/; # (config.ver)
    1125   $arg = $ARGV[1];
    1126  
    1127   # find appropriate config.ver entry:
    1128   for ($i = 0; $i < @list; $i++) {
    1129     $version = gtconfig ($list[$i], "version");
    1130     if ($key eq $version) {
    1131       $confline = $list[$i];
    1132       $status = gtconfig ($confline, "status");
    1133       last;
    1134     }
    1135   }
    1136  
    1137   $from = gtconfig ($confline, "from");
    1138   $to   = gtconfig ($confline, "to");
    1139   print STDOUT "<HEADER> <TITLE>Elixir Mkdetrend Report</TITLE> </HEADER>\n";
    1140   print STDOUT "<BODY BGCOLOR=#fff0f0 TEXT=#000000 LINK=#0000ff VLINK=#6600ff ALINK=#a0a0a0>\n";
    1141   print STDOUT "<center><table border>\n";
    1142   print STDOUT "<tr><th>config   </th><th> from  </th><th> to </th></tr>\n";
    1143   print STDOUT "<tr><td>$version </td><td> $from </td><td> $to</td></tr>\n";
    1144   print STDOUT "</table></center><hr>\n";
    1145  
    1146   $master = mknames ("master", $confline, $ccds[0]);
    1147  
    1148   if ($status eq "modified")   { flips_report ($arg, $confline, "modified"); }
    1149   if ($status eq "accepted")   { flips_report ($arg, $confline, "accepted"); }
    1150   if ($status eq "done.merge") { flips_report ($arg, $confline, "merged"); }
    1151   # if ($status eq "done.update") { flips_report ($arg, $confline, "updated"); }
    1152   if ($status eq "done.reg")   { flips_report_done ($key, $confline, "registered"); }
    1153   if ($status eq "clean")      { flips_report ($key, $confline, "registered"); }
    1154  
    1155   if ($status eq "none")              { $message = "not found"; }
    1156   if ($status eq "init")              { $message = "initialized, not yet run."; }
    1157   if ($status eq "not.available")     { $message = "has no images available for detrend creation."; }
    1158  
    1159   foreach $step (init, flips, norm, merge) {
    1160     if ($status eq "running.$step") { $message = "running step $step"; }
    1161     if ($status eq "fail.$step")    { $message = "failed step $step"; }
    1162     if ($status eq "done.$step") { $message = "has finished $step"; }
    1163   }     
    1164 
    1165   print STDOUT "config <b> $key </b> $message <br>\n";
    1166  
    1167   print STDOUT "<table border>\n";
    1168   open (FILE, "$master");
    1169   while ($line = <FILE>) {
    1170     chop ($line);
    1171     @entry = split ("/", $line);
    1172     $N = @entry - 1;
    1173     print STDOUT "<tr><td>$entry[$N]</td></tr>\n";
    1174   }
    1175   print STDOUT "</table>\n";
    1176  
    1177   print STDOUT "</body>\n";
    1178   &goodbye;
    1179 }
    1180 
    1181 ############## html level 3 ###############
    1182 sub mk_html3 {
    1183     if (@ARGV != 2) { &escape ("USAGE: mkdetrend html3 (entry.config.ver)"); }
    1184  
    1185   @list = load_config ();
    1186  
    1187   # extract the entry and key values from $ARGV[1]
    1188   ($entry, $key) = $ARGV[1] =~ /(\d+)\Q.\E(.*)/;
    1189  
    1190   $status = "none";
    1191   # find appropriate config.ver entry:
    1192   for ($i = 0; $i < @list; $i++) {
    1193     $version = gtconfig ($list[$i], "version");
    1194     if ($key eq $version) {
    1195       $confline = $list[$i];
    1196       $status = gtconfig ($confline, "status");
    1197       last;
    1198     }
    1199   }
    1200  
    1201   print STDOUT "<HEADER> <TITLE>Elixir Mkdetrend Report</TITLE> </HEADER>\n";
    1202   print STDOUT "<BODY BGCOLOR=#fff0f0 TEXT=#000000 LINK=#0000ff VLINK=#6600ff ALINK=#a0a0a0>\n";
    1203  
    1204   if ($status eq "none")              { print STDOUT "config <b> $key </b> not found\n </body>\n"; &goodbye; }
    1205   if ($status eq "init")              { print STDOUT "config <b> $key </b> initialized, not yet run\n </body>\n"; &goodbye; }
    1206   if ($status eq "not.available")     { print STDOUT "config <b> $key </b> has no images available for detrend creation\n </body>\n"; &goodbye; }
    1207  
    1208   # if ($status eq "done.update") { flips_entry ($key, $entry, $confline); }
    1209   if ($status eq "done.merge") { flips_entry ($key, $entry, $confline); }
    1210   if ($status eq "accepted")   { flips_entry ($key, $entry, $confline); }
    1211   if ($status eq "modified")   { flips_entry ($key, $entry, $confline); }
    1212   if ($status eq "done.reg")   { flips_entry ($key, $entry, $confline); }
    1213  
    1214   foreach $step (init, flips, norm, merge) {
    1215     # print "step: $step, $status: $status\n";
    1216     if ($status eq "running.$step") { print STDOUT "config <b> $key </b> running step $step \n </body>\n"; &goodbye; }
    1217     if ($status eq "fail.$step")    { print STDOUT "config <b> $key </b> failed step $step\n </body>\n"; &goodbye; }
    1218    
    1219     if ($status eq "done.$step") {
    1220       print STDOUT "config <b> $key </b> has finished $step\n";
    1221      
    1222       # load image names from CCD 0 list:
    1223       $master = mknames ("master", $confline, $ccds[0]);
    1224       print STDOUT "<table border>\n";
    1225       open (FILE, "$master");
    1226       while ($line = <FILE>) {
     1161    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND html2 (config.ver)"); }
     1162   
     1163    @list = load_config ();
     1164   
     1165    # entry on line will be either config.ver (== key) or config.ver.col for sorting
     1166    # grab just the key portion
     1167    $status = "none";
     1168    ($key) = $ARGV[1] =~ /(\w+.\w+.\w+.\w+)/; # (config.ver)
     1169    $arg = $ARGV[1];
     1170   
     1171    # find appropriate config.ver entry:
     1172    for ($i = 0; $i < @list; $i++) {
     1173        $version = gtconfig ($list[$i], "version");
     1174        if ($key eq $version) {
     1175            $confline = $list[$i];
     1176            $status = gtconfig ($confline, "status");
     1177            last;
     1178        }
     1179    }
     1180   
     1181    $from = gtconfig ($confline, "from");
     1182    $to   = gtconfig ($confline, "to");
     1183    print STDOUT "<HEADER> <TITLE>Elixir Mkdetrend Report</TITLE> </HEADER>\n";
     1184    print STDOUT "<BODY BGCOLOR=#fff0f0 TEXT=#000000 LINK=#0000ff VLINK=#6600ff ALINK=#a0a0a0>\n";
     1185    print STDOUT "<center><table border>\n";
     1186    print STDOUT "<tr><th>config   </th><th> from  </th><th> to </th></tr>\n";
     1187    print STDOUT "<tr><td>$version </td><td> $from </td><td> $to</td></tr>\n";
     1188    print STDOUT "</table></center><hr>\n";
     1189   
     1190    $master = mknames ("master", $confline, $ccds[0]);
     1191   
     1192    if ($status eq "modified")   { flips_report ($arg, $confline,      "modified"); }
     1193    if ($status eq "accepted")   { flips_report ($arg, $confline,      "accepted"); }
     1194    if ($status eq "done.merge") { flips_report ($arg, $confline,      "merged"); }
     1195    if ($status eq "done.reg")   { flips_report_done ($key, $confline, "registered"); }
     1196    if ($status eq "done")       { flips_report_done ($key, $confline, "registered"); }
     1197    if ($status eq "clean")      { flips_report ($key, $confline,      "registered"); }
     1198   
     1199    if ($status eq "none")              { $message = "not found"; }
     1200    if ($status eq "init")              { $message = "initialized, not yet run."; }
     1201    if ($status eq "not.available")     { $message = "has no images available for detrend creation."; }
     1202   
     1203    foreach $step (init, flips, norm, merge) {
     1204        if ($status eq "running.$step") { $message = "running step $step"; }
     1205        if ($status eq "fail.$step")    { $message = "failed step $step"; }
     1206        if ($status eq "done.$step") { $message = "has finished $step"; }
     1207    }     
     1208
     1209    print STDOUT "config <b> $key </b> $message <br>\n";
     1210   
     1211    print STDOUT "<table border>\n";
     1212    open (FILE, "$master");
     1213    while ($line = <FILE>) {
    12271214        chop ($line);
    12281215        @entry = split ("/", $line);
    12291216        $N = @entry - 1;
    12301217        print STDOUT "<tr><td>$entry[$N]</td></tr>\n";
    1231       }
    1232       print STDOUT "</table>\n";
    1233     }
    1234   }
    1235  
    1236   # print STDOUT "</body>\n";
    1237   &goodbye;
     1218    }
     1219    print STDOUT "</table>\n";
     1220   
     1221    print STDOUT "</body>\n";
     1222    &goodbye;
     1223}
     1224
     1225############## html level 3 ###############
     1226sub mk_html3 {
     1227    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND html3 (entry.config.ver)"); }
     1228   
     1229    @list = load_config ();
     1230   
     1231    # extract the entry and key values from $ARGV[1]
     1232    ($entry, $key) = $ARGV[1] =~ /(\d+)\Q.\E(.*)/;
     1233   
     1234    $status = "none";
     1235    # find appropriate config.ver entry:
     1236    for ($i = 0; $i < @list; $i++) {
     1237        $version = gtconfig ($list[$i], "version");
     1238        if ($key eq $version) {
     1239            $confline = $list[$i];
     1240            $status = gtconfig ($confline, "status");
     1241            last;
     1242        }
     1243    }
     1244   
     1245    print STDOUT "<HEADER> <TITLE>Elixir Mkdetrend Report</TITLE> </HEADER>\n";
     1246    print STDOUT "<BODY BGCOLOR=#fff0f0 TEXT=#000000 LINK=#0000ff VLINK=#6600ff ALINK=#a0a0a0>\n";
     1247   
     1248    if ($status eq "none")              { print STDOUT "config <b> $key </b> not found\n </body>\n"; &goodbye; }
     1249    if ($status eq "init")              { print STDOUT "config <b> $key </b> initialized, not yet run\n </body>\n"; &goodbye; }
     1250    if ($status eq "not.available")     { print STDOUT "config <b> $key </b> has no images available for detrend creation\n </body>\n"; &goodbye; }
     1251   
     1252    # if ($status eq "done.update") { flips_entry ($key, $entry, $confline); }
     1253    if ($status eq "done.merge") { flips_entry ($key, $entry, $confline); }
     1254    if ($status eq "accepted")   { flips_entry ($key, $entry, $confline); }
     1255    if ($status eq "modified")   { flips_entry ($key, $entry, $confline); }
     1256    if ($status eq "done.reg")   { flips_entry ($key, $entry, $confline); }
     1257   
     1258    foreach $step (init, flips, norm, merge) {
     1259        # print "step: $step, $status: $status\n";
     1260        if ($status eq "running.$step") { print STDOUT "config <b> $key </b> running step $step \n </body>\n"; &goodbye; }
     1261        if ($status eq "fail.$step")    { print STDOUT "config <b> $key </b> failed step $step\n </body>\n"; &goodbye; }
     1262       
     1263        if ($status eq "done.$step") {
     1264            print STDOUT "config <b> $key </b> has finished $step\n";
     1265           
     1266            # load image names from CCD 0 list:
     1267            $master = mknames ("master", $confline, $ccds[0]);
     1268            print STDOUT "<table border>\n";
     1269            open (FILE, "$master");
     1270            while ($line = <FILE>) {
     1271                chop ($line);
     1272                @entry = split ("/", $line);
     1273                $N = @entry - 1;
     1274                print STDOUT "<tr><td>$entry[$N]</td></tr>\n";
     1275            }
     1276            print STDOUT "</table>\n";
     1277        }
     1278    }
     1279   
     1280    # print STDOUT "</body>\n";
     1281    &goodbye;
    12381282}
    12391283
     
    12421286############## evaluate chip run ###############
    12431287sub mk_eval {
    1244     if (@ARGV != 2) { &escape ("USAGE: mkdetrend eval (step)"); }
    1245  
    1246   $step = $ARGV[1];
    1247   @list = load_config ();
    1248  
    1249   # load success fifo info:
    1250   $file = `gconfig -D mode mkdetrend global.success`; chop $file;
    1251   open (FILE, "$file");
    1252   @success = <FILE>;
    1253   close (FILE);
    1254  
    1255   # load failure fifo info:
    1256   $file = `gconfig -D mode mkdetrend global.failure`; chop $file;
    1257   open (FILE, "$file");
    1258   @failure = <FILE>;
    1259   close (FILE);
    1260  
    1261   # entry must be in state 'running.$step'
    1262   # possible states:
    1263   #   1 all 12 chips in success          == done.$step
    1264   #   2 any chips in failure             == fail.$step
    1265   #   3 any chips missing                == fail.$step
    1266   #   4 any chips in failure, merge.list == not.available (only for $step eq init)
    1267   # valid steps: init flips norm
    1268  
    1269  CONFIG:
    1270   foreach $confline (@list) {
    1271       $status = gtconfig ($confline, "status");
    1272       if ($status ne "running.$step") { next; }
    1273       $state = 1;
    1274 
    1275     CCD:
    1276       for ($j = 0; $j < $Nccd; $j++) {
    1277         $entry = gtconfig ($confline, "chiprun", $j);
    1278 
    1279         # search for entry in success fifo:
    1280         foreach $value (@success) {
    1281           if ($value =~ /^$entry/) { next CCD; }
    1282         }
    1283        
    1284         # search for entry in failure fifo: note the special ending state for 'init'
    1285         foreach $value (@failure) {
    1286           if ($value =~ /^$entry/) {
    1287             $state = 2;
    1288             if ($step eq "split") {
    1289               ($status) = $value =~ /$entry\s+\S+\s+(\S+)/;
    1290               if ($status eq "merge.lists") {
    1291                 $state = 4;
    1292               }
     1288    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND eval (step)"); }
     1289   
     1290    $step = $ARGV[1];
     1291    @list = load_config ();
     1292   
     1293    # load success fifo info:
     1294    $file = `gconfig -D mode $MKDETREND global.success`; chop $file;
     1295    open (FILE, "$file");
     1296    @success = <FILE>;
     1297    close (FILE);
     1298   
     1299    # load failure fifo info:
     1300    $file = `gconfig -D mode $MKDETREND global.failure`; chop $file;
     1301    open (FILE, "$file");
     1302    @failure = <FILE>;
     1303    close (FILE);
     1304   
     1305    # entry must be in state 'running.$step'
     1306    # possible states:
     1307    #   1 all 12 chips in success          == done.$step
     1308    #   2 any chips in failure             == fail.$step
     1309    #   3 any chips missing                == fail.$step
     1310    #   4 any chips in failure, merge.list == not.available (only for $step eq init)
     1311    # valid steps: init flips norm
     1312   
     1313  CONFIG:
     1314    foreach $confline (@list) {
     1315        $status = gtconfig ($confline, "status");
     1316        if ($status ne "running.$step") { next; }
     1317        $state = 1;
     1318
     1319      CCD:
     1320        foreach $ccd (@ccds) {
     1321            $entry = gtconfig ($confline, "chiprun", $ccd);
     1322
     1323            # search for entry in success fifo:
     1324            foreach $value (@success) {
     1325                if ($value =~ /^$entry/) { next CCD; }
    12931326            }
     1327           
     1328            # search for entry in failure fifo: note the special ending state for 'init'
     1329            foreach $value (@failure) {
     1330                if ($value =~ /^$entry/) {
     1331                    $state = 2;
     1332                    if ($step eq "split") {
     1333                        ($status) = $value =~ /$entry\s+\S+\s+(\S+)/;
     1334                        if ($status eq "merge.lists") {
     1335                            $state = 4;
     1336                        }
     1337                    }
     1338                    last CCD;
     1339                }
     1340            }
     1341           
     1342            # if we make it here, it wasn't in either fifo.success or fifo.failure...
     1343            $state = 3;
    12941344            last CCD;
    1295           }
    1296         }
    1297        
    1298         # if we make it here, it wasn't in either fifo.success or fifo.failure...
    1299         $state = 3;
    1300         last CCD;
    1301       }
    1302      
    1303       if ($state == 1) { $confline = stconfig ($confline, "status", "done.$step"); }
    1304       if ($state == 2) { $confline = stconfig ($confline, "status", "fail.$step"); }
    1305       if ($state == 3) { $confline = stconfig ($confline, "status", "fail.$step"); }
    1306       if ($state == 4) { $confline = stconfig ($confline, "status", "not.available"); }
    1307   }
    1308   save_config (@list);
    1309 
    1310   system ("mkdetrend state");
    1311   &goodbye;
     1345        }
     1346       
     1347        if ($state == 1) { $confline = stconfig ($confline, "status", "done.$step"); }
     1348        if ($state == 2) { $confline = stconfig ($confline, "status", "fail.$step"); }
     1349        if ($state == 3) { $confline = stconfig ($confline, "status", "fail.$step"); }
     1350        if ($state == 4) { $confline = stconfig ($confline, "status", "not.available"); }
     1351    }
     1352    save_config (@list);
     1353
     1354    system ("$MKDETREND state");
     1355    &goodbye;
    13121356}
    13131357
    13141358############## evaluate mosaic run ###############
    13151359sub mk_meval {
    1316     if (@ARGV != 2) { &escape ("USAGE: mkdetrend meval (step)"); }
    1317  
    1318   $step = $ARGV[1];
    1319   @list = load_config ();
    1320  
    1321   # load success fifo info:
    1322   $file = `gconfig -D mode mkdetrend global.success`; chop $file;
    1323   open (FILE, "$file");
    1324   @success = <FILE>;
    1325   close (FILE);
    1326  
    1327   # load failure fifo info:
    1328   $file = `gconfig -D mode mkdetrend global.failure`; chop $file;
    1329   open (FILE, "$file");
    1330   @failure = <FILE>;
    1331   close (FILE);
    1332  
    1333   # entry must be in state 'running.$step'
    1334   # possible states:
    1335   #   1 entry in success          == done.$step
    1336   #   2 entry in failure          == fail.$step
    1337   #   3 entry missing             == fail.$step
    1338   # valid steps: merge
    1339  
    1340   foreach $confline (@list) {
    1341       $status = gtconfig ($confline, "status");
    1342       if ($status ne "running.$step") { next; }
    1343       $state = 3;
    1344       $entry = gtconfig ($confline, "mosaic");
    1345 
    1346     MCHECK:
    1347       {
    1348           foreach $value (@success) {
    1349               if ($value =~ /^$entry/) {
    1350                   $state = 1;
    1351                   last MCHECK;
    1352               }
    1353           }
    1354          
    1355           foreach $value (@failure) {
    1356               if ($value =~ /^$entry/) {
    1357                   $state = 2;
    1358                   next MCHECK;
     1360    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND meval (step)"); }
     1361   
     1362    $step = $ARGV[1];
     1363    @list = load_config ();
     1364   
     1365    # load success fifo info:
     1366    $file = `gconfig -D mode $MKDETREND global.success`; chop $file;
     1367    open (FILE, "$file");
     1368    @success = <FILE>;
     1369    close (FILE);
     1370   
     1371    # load failure fifo info:
     1372    $file = `gconfig -D mode $MKDETREND global.failure`; chop $file;
     1373    open (FILE, "$file");
     1374    @failure = <FILE>;
     1375    close (FILE);
     1376   
     1377    # entry must be in state 'running.$step'
     1378    # possible states:
     1379    #   1 entry in success          == done.$step
     1380    #   2 entry in failure          == fail.$step
     1381    #   3 entry missing             == fail.$step
     1382    # valid steps: merge
     1383   
     1384    foreach $confline (@list) {
     1385        $status = gtconfig ($confline, "status");
     1386        if ($status ne "running.$step") { next; }
     1387        $state = 3;
     1388        $entry = gtconfig ($confline, "mosaic");
     1389
     1390      MCHECK:
     1391        {
     1392            foreach $value (@success) {
     1393                if ($value =~ /^$entry/) {
     1394                    $state = 1;
     1395                    last MCHECK;
     1396                }
    13591397            }
    1360           }
    1361       }
    1362      
    1363       if ($state == 1) { $confline = stconfig ($confline, "status", "done.$step"); }
    1364       if ($state == 2) { $confline = stconfig ($confline, "status", "fail.$step"); }
    1365       if ($state == 3) { $confline = stconfig ($confline, "status", "fail.$step"); }
    1366   }
    1367  
    1368   save_config (@list);
    1369   system ("mkdetrend state");
    1370  
    1371   &goodbye;
     1398           
     1399            foreach $value (@failure) {
     1400                if ($value =~ /^$entry/) {
     1401                    $state = 2;
     1402                    next MCHECK;
     1403                }
     1404            }
     1405        }
     1406       
     1407        if ($state == 1) { $confline = stconfig ($confline, "status", "done.$step"); }
     1408        if ($state == 2) { $confline = stconfig ($confline, "status", "fail.$step"); }
     1409        if ($state == 3) { $confline = stconfig ($confline, "status", "fail.$step"); }
     1410    }
     1411   
     1412    save_config (@list);
     1413    system ("$MKDETREND state");
     1414   
     1415    &goodbye;
    13721416}
    13731417
    13741418############## html for dads ###############
    13751419sub mk_dads {
    1376     if (@ARGV != 2) { &escape ("USAGE: mkdetrend dads (config.ver)"); }
     1420    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND dads (config.ver)"); }
    13771421   
    13781422    # options: mkdetrend dads (config.ver)
     
    14521496############## html for dads ###############
    14531497sub mk_dads_html {
    1454     if (@ARGV != 2) { &escape ("USAGE: mkdetrend dads (config.ver)"); }
     1498    if (@ARGV != 2) { &escape ("USAGE: $MKDETREND dads (config.ver)"); }
    14551499   
    14561500    @list = load_config ();
     
    15111555    print STDOUT "Total Counts: $Ncnt<br> r.m.s. median sigma: $Sigma% <br><br>\n";
    15121556    print STDOUT "</td><td align=right><img src=$imbin></td></tr></table>\n";
    1513        
     1557   
    15141558    print STDOUT "<center><b>Statistics on each available input image.</b></center>
    15151559  Time is in UT, light background means dawn, grey means dusk.\n";
     
    15671611############## dads level 1 ###############
    15681612sub mk_dads_top {
    1569     if (@ARGV != 1) { &escape ("USAGE: mkdetrend dads.top"); }
    1570  
    1571   @list = load_config ();
    1572  
    1573   ## html headers
    1574   print STDOUT "<HEADER> <TITLE>Elixir Mkdetrend Report</TITLE> </HEADER>\n";
    1575   print STDOUT "<BODY BGCOLOR=#fff0f0 TEXT=#000000 LINK=#0000ff VLINK=#6600ff ALINK=#a0a0a0>\n";
    1576 
    1577   print STDOUT "<table border>\n";
    1578   for ($i = 0; $i < @list; $i++) {
    1579     $config  = gtconfig ($list[$i], "config");
    1580     $version = gtconfig ($list[$i], "version");
    1581     $from    = gtconfig ($list[$i], "from");
    1582     $to      = gtconfig ($list[$i], "to");
    1583     $status  = gtconfig ($list[$i], "status");
    1584     print STDOUT "<tr><td> $version </td>\n";
    1585     print STDOUT "<td> $from </td><td> $to </td>\n";
    1586     print STDOUT "<td> <a href=$version.html> $status </a></td>\n";
    1587     print STDOUT "</tr>\n";
    1588   }
    1589  
    1590   print STDOUT "</table></body>\n";
    1591   &goodbye;;
    1592  
     1613    if (@ARGV != 1) { &escape ("USAGE: $MKDETREND dads.top"); }
     1614   
     1615    @list = load_config ();
     1616   
     1617    ## html headers
     1618    print STDOUT "<HEADER> <TITLE>Elixir Mkdetrend Report</TITLE> </HEADER>\n";
     1619    print STDOUT "<BODY BGCOLOR=#fff0f0 TEXT=#000000 LINK=#0000ff VLINK=#6600ff ALINK=#a0a0a0>\n";
     1620
     1621    print STDOUT "<table border>\n";
     1622    for ($i = 0; $i < @list; $i++) {
     1623        $config  = gtconfig ($list[$i], "config");
     1624        $version = gtconfig ($list[$i], "version");
     1625        $from    = gtconfig ($list[$i], "from");
     1626        $to      = gtconfig ($list[$i], "to");
     1627        $status  = gtconfig ($list[$i], "status");
     1628        print STDOUT "<tr><td> $version </td>\n";
     1629        print STDOUT "<td> $from </td><td> $to </td>\n";
     1630        print STDOUT "<td> <a href=$version.html> $status </a></td>\n";
     1631        print STDOUT "</tr>\n";
     1632    }
     1633   
     1634    print STDOUT "</table></body>\n";
     1635    &goodbye;;
     1636   
    15931637}
    15941638
    15951639sub by_col {
    1596   @word = split (" ", $statdata[$a]); $va = $word[$col];
    1597   @word = split (" ", $statdata[$b]); $vb = $word[$col];
    1598   $va <=> $vb;
     1640    @word = split (" ", $statdata[$a]); $va = $word[$col];
     1641    @word = split (" ", $statdata[$b]); $vb = $word[$col];
     1642    $va <=> $vb;
    15991643}
    16001644
    16011645sub flips_report {
    1602  
    1603   $col = 0;
    1604   ($config) = $_[0] =~ /(\w+.\w+.\w+)/;
    1605   ($key)    = $_[0] =~ /(\w+.\w+.\w+.\w+)/; # (config.ver)
    1606 
    1607   # look for optional sort key (config.ver[.key])
    1608   if ($_[0] =~ /$key.(\d+)/) {
    1609       ($col) = $_[0] =~ /$key.(\d+)/;
    1610   } else {
    1611       $col = 0;
    1612   }
    1613 
    1614   $line = $_[1];
    1615   $message = $_[2];
    1616  
    1617   open (FILE, mknames ("stats",  $line));            @statdata = <FILE>; close (FILE);
    1618   open (FILE, mknames ("medbin", $line));            @medndata = <FILE>; close (FILE);
    1619   open (FILE, mknames ("master", $line, $ccds[0]));  @mastdata = <FILE>; close (FILE);
    1620 
    1621   $Nkeep = 0;
    1622   $Ncnt = 0;
    1623   $Sigma = 0;
    1624   $Nimage = @statdata;
    1625   for ($i = 0; $i < $Nimage; $i++) {
    1626     @tmpw = split (" ", $mastdata[$i]);
    1627     @tmps = split (" ", $statdata[$i]);
    1628     if ($tmpw[1]) { $Nkeep++; $Ncnt += $tmps[3]; $Sigma += $tmps[8]*$tmps[8]; }
    1629   }
    1630   if ($Nkeep > 0) {
    1631       $Sigma = sprintf "%5.3f", 100*sqrt ($Sigma/$Nkeep);
    1632   } else {
    1633       $Sigma = 100.0;
    1634   }
    1635 
    1636   $imbin = mknames ("imbin",  $line);
    1637   print STDOUT "<table><tr><td width=300px valign=top>\n";
    1638   print STDOUT "<b>this config has been $message. </b><br>\n";
    1639   print STDOUT "there are $Nimage images, $Nkeep used. <br>\n";
    1640   print STDOUT "Total Counts: $Ncnt<br> r.m.s. median sigma: $Sigma% <br><br>\n";
    1641   print STDOUT "you have the following choices: <br>\n";
    1642   print STDOUT "<a href=$CGI/elixir1?&elconf=$elconf> <b> return to top level </b><br></a>\n";
    1643   print STDOUT "<a href=$CGI/split?$config&elconf=$elconf> <b> split config </b><br></a>\n";
    1644   print STDOUT "<a href=$CGI/accept?$key&elconf=$elconf> <b> accept config </b><br></a>\n";
    1645   print STDOUT "</td><td width=640px align=right><img width=100% src=$imbin></td></tr></table>\n";
    1646  
    1647   print STDOUT "<form method=post action=$CGI/modify?&elconf=$elconf>\n";
    1648 
    1649   print STDOUT "<center><b>Statistics on each available input image.</b></center>
     1646   
     1647    $col = 0;
     1648    ($type)   = $_[0] =~ /\w+.(\w+).\w+/;
     1649    ($config) = $_[0] =~ /(\w+.\w+.\w+)/;
     1650    ($key)    = $_[0] =~ /(\w+.\w+.\w+.\w+)/; # (config.ver)
     1651
     1652    # look for optional sort key (config.ver[.key])
     1653    if ($_[0] =~ /$key.(\d+)/) {
     1654        ($col) = $_[0] =~ /$key.(\d+)/;
     1655    } else {
     1656        $col = 0;
     1657    }
     1658
     1659    $line = $_[1];
     1660    $message = $_[2];
     1661   
     1662    open (FILE, mknames ("stats",  $line));            @statdata = <FILE>; close (FILE);
     1663    open (FILE, mknames ("medbin", $line));            @medndata = <FILE>; close (FILE);
     1664    open (FILE, mknames ("master", $line, $ccds[0]));  @mastdata = <FILE>; close (FILE);
     1665
     1666    $Nkeep = 0;
     1667    $Ncnt = 0;
     1668    $Sigma = 0;
     1669    $Nimage = @statdata;
     1670    for ($i = 0; $i < $Nimage; $i++) {
     1671        @tmpw = split (" ", $mastdata[$i]);
     1672        @tmps = split (" ", $statdata[$i]);
     1673        if ($tmpw[1]) { $Nkeep++; $Ncnt += $tmps[3]; $Sigma += $tmps[8]*$tmps[8]; }
     1674    }
     1675    if ($Nkeep > 0) {
     1676        if ($type eq "flat") {
     1677            $Sigma = sprintf "%5.3f", 100*sqrt ($Sigma/$Nkeep);
     1678            $statline = "Total Counts: $Ncnt<br> r.m.s. median sigma: $Sigma% <br><br>\n";
     1679        } else {
     1680            $Sigma = sprintf "%5.3f", sqrt ($Sigma/$Nkeep);
     1681            $Ncnt  = sprintf "%5.3f", ($Ncnt / $Nkeep);
     1682            $statline = "Mean Counts: $Ncnt<br> r.m.s. median sigma: $Sigma <br><br>\n";
     1683        }
     1684    } else {
     1685        $statline = "";
     1686    }
     1687
     1688    $imbin = mknames ("imbin",  $line);
     1689    print STDOUT "<table><tr><td width=300px valign=top>\n";
     1690    print STDOUT "<b>this config has been $message. </b><br>\n";
     1691    print STDOUT "there are $Nimage images, $Nkeep used. <br>\n";
     1692    print STDOUT "$statline\n";
     1693    print STDOUT "you have the following choices: <br>\n";
     1694    print STDOUT "<a href=$CGI/elixir1?&elconf=$elconf> <b> return to top level </b><br></a>\n";
     1695    print STDOUT "<a href=$CGI/split?$config&elconf=$elconf> <b> split config </b><br></a>\n";
     1696    print STDOUT "<a href=$CGI/accept?$key&elconf=$elconf> <b> accept config </b><br></a>\n";
     1697    print STDOUT "</td><td width=640px align=right><img width=100% src=$imbin></td></tr></table>\n";
     1698   
     1699    print STDOUT "<form method=post action=$CGI/modify?&elconf=$elconf>\n";
     1700
     1701    print STDOUT "<center><b>Statistics on each available input image.</b></center>
    16501702  Time is in UT, light background means dawn, grey means dusk. Click
    16511703  on the column heading to sort by that entry\n";
    16521704
    1653   print STDOUT "<table bgcolor=#fff0e0 border=1 cellspacing=0 cellpadding=3>\n";
    1654   print STDOUT "<tr bgcolor=#00aaaa>\n";
    1655   print STDOUT "<th > <a href=$CGI/elixir2?$key.0&elconf=$elconf> image </a></th>\n";
    1656   print STDOUT "<th > Date </th>\n";
    1657   print STDOUT "<th > Time </th>\n";
    1658   print STDOUT "<th > <a href=$CGI/elixir2?$key.3&elconf=$elconf> Mean </a></th>\n";
    1659   print STDOUT "<th > <a href=$CGI/elixir2?$key.5&elconf=$elconf> Sigma (raw) </a></th>\n";
    1660   print STDOUT "<th > <a href=$CGI/elixir2?$key.6&elconf=$elconf> Sigma (clipped) </a></th>\n";
    1661   print STDOUT "<th > <a href=$CGI/elixir2?$key.8&elconf=$elconf> Sigma (med) </a></th>\n";
    1662   print STDOUT "<th > image </th>\n";
    1663   print STDOUT "<th > used? </th>\n";
    1664   print STDOUT "<th > keep? </th></tr>\n\n";
    1665  
    1666   @order = ();
    1667   for ($i = 0; $i < $Nimage; $i++) { @order = (@order, $i); }
    1668  
    1669   @entry = sort by_col @order;
    1670  
    1671   for ($i = 0; $i < $Nimage; $i++) {
    1672     $N = $entry[$i];
    1673    
    1674     @word = split (" ", $statdata[$N]);
    1675     $used = $word[12];
    1676     $dawn = $word[11];
    1677    
    1678     @tmpw = split (" ", $mastdata[$N]);
    1679     $keep = $tmpw[1];
    1680    
    1681     @tmpw = split ("/", $medndata[$N]);
    1682     $medname = $tmpw[-1];
    1683    
    1684     # $sig1 = sprintf "%5.3f", $word[4];
    1685     # $sig2 = sprintf "%5.3f", $word[5];
    1686     # $sig3 = sprintf "%5.3f", $word[6];
    1687     # $sig4 = sprintf "%5.3f", $word[7];
    1688     # $mean = sprintf "%8.1f", $word[3];
    1689    
    1690     print STDOUT "<tr><td> <a href=$CGI/elixir3?$N.$key&elconf=$elconf> $word[0] </a></td><td> $word[1] </td>\n";
    1691     if ($dawn) { print STDOUT "<td bgcolor=#cccccc> $word[2] </td>\n"; }
    1692     else       { print STDOUT "<td> $word[2] </td>\n"; }
    1693     print STDOUT "<td> $word[3] </td>\n";
    1694     print STDOUT "<td> $word[5] </td><td> $word[6] </td><td> $word[8] </td>\n";
    1695     print STDOUT "<td> <a border=0 href=$CGI/elixir3?$N.$key&elconf=$elconf>\n";
    1696     print STDOUT "<img src=$www/$medname></a></td>\n";
    1697     if ($used) { print STDOUT "<td>yes</td>\n"; }
    1698     else       { print STDOUT "<td>no</td>\n"; }
    1699     if ($keep) { print STDOUT "<td bgcolor=#00c000><input type=checkbox checked name=image.$N value=$N size=1></td></tr>\n\n"; }
    1700     else       { print STDOUT "<td bgcolor=#d00000><input type=checkbox         name=image.$N value=$N size=1></td></tr>\n\n"; }       
    1701    
    1702   }
    1703  
    1704   print STDOUT "</table>\n";
    1705   print STDOUT "<input type=hidden    name=Nimage value=\"$Nimage\">\n";
    1706   print STDOUT "<input type=hidden    name=config value=\"$key\">\n";
    1707   print STDOUT "<input type=submit    value=\"apply changes\">\n";
    1708   print STDOUT "<input type=reset     value=Reset>\n";
    1709   # print STDOUT "<select name=status   size=1> \n";
    1710   print STDOUT "</form></body>\n";
    1711   &goodbye;
    1712  
     1705    print STDOUT "<table bgcolor=#fff0e0 border=1 cellspacing=0 cellpadding=3>\n";
     1706    print STDOUT "<tr bgcolor=#00aaaa>\n";
     1707    print STDOUT "<th > <a href=$CGI/elixir2?$key.0&elconf=$elconf> image </a></th>\n";
     1708    print STDOUT "<th > Date </th>\n";
     1709    print STDOUT "<th > Time </th>\n";
     1710    print STDOUT "<th > <a href=$CGI/elixir2?$key.3&elconf=$elconf> Mean </a></th>\n";
     1711    print STDOUT "<th > <a href=$CGI/elixir2?$key.5&elconf=$elconf> Sigma (raw) </a></th>\n";
     1712    print STDOUT "<th > <a href=$CGI/elixir2?$key.6&elconf=$elconf> Sigma (clipped) </a></th>\n";
     1713    print STDOUT "<th > <a href=$CGI/elixir2?$key.8&elconf=$elconf> Sigma (med) </a></th>\n";
     1714    print STDOUT "<th > image </th>\n";
     1715    print STDOUT "<th > used? </th>\n";
     1716    print STDOUT "<th > keep? </th></tr>\n\n";
     1717   
     1718    @order = ();
     1719    for ($i = 0; $i < $Nimage; $i++) { @order = (@order, $i); }
     1720   
     1721    @entry = sort by_col @order;
     1722   
     1723    for ($i = 0; $i < $Nimage; $i++) {
     1724        $N = $entry[$i];
     1725       
     1726        @word = split (" ", $statdata[$N]);
     1727        $used = $word[12];
     1728        $dawn = $word[11];
     1729       
     1730        @tmpw = split (" ", $mastdata[$N]);
     1731        $keep = $tmpw[1];
     1732       
     1733        @tmpw = split ("/", $medndata[$N]);
     1734        $medname = $tmpw[-1];
     1735       
     1736        print STDOUT "<tr><td> <a href=$CGI/elixir3?$N.$key&elconf=$elconf> $word[0] </a></td><td> $word[1] </td>\n";
     1737        if ($dawn) { print STDOUT "<td bgcolor=#cccccc> $word[2] </td>\n"; }
     1738        else       { print STDOUT "<td> $word[2] </td>\n"; }
     1739        print STDOUT "<td> $word[3] </td>\n"; # mean
     1740        print STDOUT "<td> $word[5] </td>\n"; # Sigma (raw)
     1741        print STDOUT "<td> $word[6] </td>\n"; # Sigma (clip)
     1742        print STDOUT "<td> $word[8] </td>\n"; # Sigma (med)
     1743        print STDOUT "<td> <a border=0 href=$CGI/elixir3?$N.$key&elconf=$elconf>\n";
     1744        print STDOUT "<img src=$www/$medname></a></td>\n";
     1745        if ($used) { print STDOUT "<td>yes</td>\n"; }
     1746        else       { print STDOUT "<td>no</td>\n"; }
     1747        if ($keep) { print STDOUT "<td bgcolor=#00c000><input type=checkbox checked name=image.$N value=$N size=1></td></tr>\n\n"; }
     1748        else       { print STDOUT "<td bgcolor=#d00000><input type=checkbox         name=image.$N value=$N size=1></td></tr>\n\n"; }   
     1749       
     1750    }
     1751   
     1752    print STDOUT "</table>\n";
     1753    print STDOUT "<input type=hidden    name=Nimage value=\"$Nimage\">\n";
     1754    print STDOUT "<input type=hidden    name=config value=\"$key\">\n";
     1755    print STDOUT "<input type=submit    value=\"apply changes\">\n";
     1756    print STDOUT "<input type=reset     value=Reset>\n";
     1757    # print STDOUT "<select name=status   size=1> \n";
     1758    print STDOUT "</form></body>\n";
     1759    &goodbye;
     1760   
     1761}
     1762
     1763sub flips_report_done {
     1764   
     1765    $col = 0;
     1766    ($type)   = $_[0] =~ /\w+.(\w+).\w+/;
     1767    ($config) = $_[0] =~ /(\w+.\w+.\w+)/;
     1768    ($key)    = $_[0] =~ /(\w+.\w+.\w+.\w+)/; # (config.ver)
     1769
     1770    # look for optional sort key (config.ver[.key])
     1771    if ($_[0] =~ /$key.(\d+)/) {
     1772        ($col) = $_[0] =~ /$key.(\d+)/;
     1773    } else {
     1774        $col = 0;
     1775    }
     1776
     1777    $line = $_[1];
     1778    $message = $_[2];
     1779   
     1780    open (FILE, mknames ("stats",  $line));            @statdata = <FILE>; close (FILE);
     1781    open (FILE, mknames ("medbin", $line));            @medndata = <FILE>; close (FILE);
     1782    open (FILE, mknames ("master", $line, $ccds[0]));  @mastdata = <FILE>; close (FILE);
     1783
     1784    $Nkeep = 0;
     1785    $Ncnt = 0;
     1786    $Sigma = 0;
     1787    $Nimage = @statdata;
     1788    for ($i = 0; $i < $Nimage; $i++) {
     1789        @tmpw = split (" ", $mastdata[$i]);
     1790        @tmps = split (" ", $statdata[$i]);
     1791        if ($tmpw[1]) { $Nkeep++; $Ncnt += $tmps[3]; $Sigma += $tmps[8]*$tmps[8]; }
     1792    }
     1793    if ($Nkeep > 0) {
     1794        if ($type eq "flat") {
     1795            $Sigma = sprintf "%5.3f", 100*sqrt ($Sigma/$Nkeep);
     1796            $statline = "Total Counts: $Ncnt<br> r.m.s. median sigma: $Sigma% <br><br>\n";
     1797        } else {
     1798            $Sigma = sprintf "%5.3f", sqrt ($Sigma/$Nkeep);
     1799            $Ncnt  = sprintf "%5.3f", ($Ncnt / $Nkeep);
     1800            $statline = "Mean Counts: $Ncnt<br> r.m.s. median sigma: $Sigma <br><br>\n";
     1801        }
     1802    } else {
     1803        $statline = "";
     1804    }
     1805
     1806    $imbin = mknames ("imbin",  $line);
     1807    print STDOUT "<table><tr><td width=300px valign=top>\n";
     1808    print STDOUT "<b>this config has been $message. </b><br>\n";
     1809    print STDOUT "there are $Nimage images, $Nkeep used. <br>\n";
     1810    print STDOUT "$statline\n";
     1811    print STDOUT "you have the following choices: <br>\n";
     1812    print STDOUT "<a href=$CGI/elixir1?&elconf=$elconf> <b> return to top level </b><br></a>\n";
     1813    print STDOUT "<a href=$CGI/split?$config&elconf=$elconf> <b> split config </b><br></a>\n";
     1814    print STDOUT "<a href=$CGI/accept?$key&elconf=$elconf> <b> accept config </b><br></a>\n";
     1815    print STDOUT "</td><td width=640px align=right><img width=100% src=$imbin></td></tr></table>\n";
     1816   
     1817    print STDOUT "<center><b>Statistics on each available input image.</b></center>
     1818  Time is in UT, light background means dawn, grey means dusk. Click
     1819  on the column heading to sort by that entry\n";
     1820
     1821    print STDOUT "<table bgcolor=#fff0e0 border=1 cellspacing=0 cellpadding=3>\n";
     1822    print STDOUT "<tr bgcolor=#00aaaa>\n";
     1823    print STDOUT "<th > <a href=$CGI/elixir2?$key.0&elconf=$elconf> image </a></th>\n";
     1824    print STDOUT "<th > Date </th>\n";
     1825    print STDOUT "<th > Time </th>\n";
     1826    print STDOUT "<th > <a href=$CGI/elixir2?$key.3&elconf=$elconf> Mean </a></th>\n";
     1827    print STDOUT "<th > <a href=$CGI/elixir2?$key.5&elconf=$elconf> Sigma (raw) </a></th>\n";
     1828    print STDOUT "<th > <a href=$CGI/elixir2?$key.6&elconf=$elconf> Sigma (clipped) </a></th>\n";
     1829    print STDOUT "<th > <a href=$CGI/elixir2?$key.8&elconf=$elconf> Sigma (med) </a></th>\n";
     1830    print STDOUT "<th > image </th>\n";
     1831    print STDOUT "<th > used? </th></tr>\n\n";
     1832   
     1833    @order = ();
     1834    for ($i = 0; $i < $Nimage; $i++) { @order = (@order, $i); }
     1835   
     1836    @entry = sort by_col @order;
     1837   
     1838    for ($i = 0; $i < $Nimage; $i++) {
     1839        $N = $entry[$i];
     1840       
     1841        @word = split (" ", $statdata[$N]);
     1842        $used = $word[12];
     1843        $dawn = $word[11];
     1844       
     1845        @tmpw = split (" ", $mastdata[$N]);
     1846        $keep = $tmpw[1];
     1847       
     1848        @tmpw = split ("/", $medndata[$N]);
     1849        $medname = $tmpw[-1];
     1850       
     1851        print STDOUT "<tr><td> <a href=$CGI/elixir3?$N.$key&elconf=$elconf> $word[0] </a></td><td> $word[1] </td>\n";
     1852        if ($dawn) { print STDOUT "<td bgcolor=#cccccc> $word[2] </td>\n"; }
     1853        else       { print STDOUT "<td> $word[2] </td>\n"; }
     1854        print STDOUT "<td> $word[3] </td>\n"; # mean
     1855        print STDOUT "<td> $word[5] </td>\n"; # Sigma (raw)
     1856        print STDOUT "<td> $word[6] </td>\n"; # Sigma (clip)
     1857        print STDOUT "<td> $word[8] </td>\n"; # Sigma (med)
     1858        print STDOUT "<td> <a border=0 href=$CGI/elixir3?$N.$key&elconf=$elconf>\n";
     1859        print STDOUT "<img src=$www/$medname></a></td>\n";
     1860        if ($used) { print STDOUT "<td>yes</td>\n"; }
     1861        else       { print STDOUT "<td>no</td>\n"; }
     1862        print STDOUT "</tr>\n";
     1863    }
     1864   
     1865    print STDOUT "</table></body>\n";
     1866    &goodbye;
     1867   
    17131868}
    17141869
    17151870#### process report for html2 ##########
    1716 sub flips_report_done {
    1717  
    1718   ($config) = $_[0] =~ /(\w+.\w+.\w+)/;
    1719   ($key)    = $_[0] =~ /(\w+.\w+.\w+.\w+)/; # (config.ver)
    1720   $line = $_[1];
    1721  
    1722   open (STAT, mknames ("stats", $line));
    1723   open (MED,  mknames ("medbin", $line));
    1724   open (MASTER, mknames ("master", $line, $ccds[0]));
    1725  
    1726   print STDOUT "<table border>\n";
    1727   print STDOUT "<tr><th> image </th><th> Date </th><th> Time </th><th> Mean </th>\n";
    1728   print STDOUT "<th> Sigma (raw) </th><th> Sigma (clipped) </th><th> Sigma (med) </th><th> image </th><th> used? </th></tr>\n\n";
    1729  
    1730   for ($i = 0; $line = <STAT>; $i++) {
     1871sub flips_report_done_old {
     1872   
     1873    ($config) = $_[0] =~ /(\w+.\w+.\w+)/;
     1874    ($key)    = $_[0] =~ /(\w+.\w+.\w+.\w+)/; # (config.ver)
     1875    $line = $_[1];
     1876   
     1877    open (STAT, mknames ("stats", $line));
     1878    open (MED,  mknames ("medbin", $line));
     1879    open (MASTER, mknames ("master", $line, $ccds[0]));
     1880   
     1881    print STDOUT "<table border>\n";
     1882    print STDOUT "<tr><th> image </th><th> Date </th><th> Time </th><th> Mean </th>\n";
     1883    print STDOUT "<th> Sigma (raw) </th><th> Sigma (clipped) </th><th> Sigma (med) </th><th> image </th><th> used? </th></tr>\n\n";
     1884   
     1885    for ($i = 0; $line = <STAT>; $i++) {
     1886       
     1887        chop ($line);
     1888        # print STDOUT "$line<br>\n";
     1889        @word = split (" ",$line);
     1890        $used = $word[12];
     1891        $dawn = $word[11];
     1892       
     1893        $line = <MASTER>;
     1894        chop ($line);
     1895        # print STDOUT "$line<br>\n";
     1896        @tmpw = split (" ",$line);
     1897        $keep = $tmpw[1];
     1898       
     1899        # mkdetrend works with files in the user's paths, but the web page needs
     1900        # to work with files visible to the web server
     1901        $line = <MED>;
     1902        chop ($line);
     1903        @tmpw = split ("/", $line);
     1904        $N = @tmpw - 1;
     1905        $medname = $tmpw[$N];
     1906       
     1907        $sig1 = sprintf "%5.3f", $word[4];
     1908        $sig2 = sprintf "%5.3f", $word[5];
     1909        $sig3 = sprintf "%5.3f", $word[6];
     1910        $sig4 = sprintf "%5.3f", $word[7];
     1911        $mean = sprintf "%8.1f", $word[3];
     1912       
     1913        print STDOUT "<tr><td> <a href=$CGI/elixir3?$i.$key&elconf=$elconf> $word[0] </a></td><td> $word[1] </td>\n";
     1914        if ($dawn) { print STDOUT "<td bgcolor=#cccccc> $word[2] </td>\n"; }
     1915        else       { print STDOUT "<td> $word[2] </td>\n"; }
     1916        print STDOUT "<td> $word[3] </td>\n";
     1917        print STDOUT "<td> $word[5] </td><td> $word[6] </td><td> $word[8] </td><td><img src=$www/$medname></td>\n";
     1918        if ($used) { print STDOUT "<td bgcolor=#00c000>yes</td>\n"; }
     1919        else       { print STDOUT "<td bgcolor=#d00000>no</td>\n"; }
     1920    }
     1921    $Nimage = $i;
     1922   
     1923    print STDOUT "</table>\n";
     1924    print STDOUT "</body>\n";
     1925   
     1926    &goodbye;
     1927   
     1928}
     1929
     1930#### process report for html3 ##########
     1931sub flips_entry {
     1932   
     1933    my($version)= $_[0];                # version of desired entry
     1934    my($entry)  = $_[1];                # desired entry in list
     1935    my($line)   = $_[2];                # list of image stats
     1936   
     1937    open (STAT, mknames ("stats", $line));
     1938    open (TEN,  mknames ("tenbin", $line));
     1939   
     1940    for ($i = 0; ($i < $entry + 1) && ($line = <STAT>) && ($tenline = <TEN>); $i++) {}
     1941    if ($i != $entry + 1) { &escape ("</table> selected entry out of range"); }
     1942   
     1943    $first = ($entry == 0);
     1944    $tmp = <STAT>;
     1945    $last = ($tmp == "");
     1946    $next = $entry + 1;
     1947    $prev = $entry - 1;
    17311948   
    17321949    chop ($line);
    1733     # print STDOUT "$line<br>\n";
    17341950    @word = split (" ",$line);
    1735     $used = $word[12];
    1736     $dawn = $word[11];
    1737    
    1738     $line = <MASTER>;
    1739     chop ($line);
    1740     # print STDOUT "$line<br>\n";
    1741     @tmpw = split (" ",$line);
    1742     $keep = $tmpw[1];
     1951    $keep = $word[12];
    17431952   
    17441953    # mkdetrend works with files in the user's paths, but the web page needs
    17451954    # to work with files visible to the web server
    1746     $line = <MED>;
    1747     chop ($line);
    1748     @tmpw = split ("/", $line);
     1955    chop ($tenline);
     1956    @tmpw = split ("/", $tenline);
    17491957    $N = @tmpw - 1;
    1750     $medname = $tmpw[$N];
     1958    $name = $tmpw[$N];
    17511959   
    17521960    $sig1 = sprintf "%5.3f", $word[4];
     
    17561964    $mean = sprintf "%8.1f", $word[3];
    17571965   
    1758     print STDOUT "<tr><td> <a href=$CGI/elixir3?$i.$key&elconf=$elconf> $word[0] </a></td><td> $word[1] </td>\n";
    1759     if ($dawn) { print STDOUT "<td bgcolor=#cccccc> $word[2] </td>\n"; }
    1760     else       { print STDOUT "<td> $word[2] </td>\n"; }
    1761     print STDOUT "<td> $word[3] </td>\n";
    1762     print STDOUT "<td> $word[5] </td><td> $word[6] </td><td> $word[8] </td><td><img src=$www/$medname></td>\n";
    1763     if ($used) { print STDOUT "<td bgcolor=#00c000>yes</td>\n"; }
    1764     else       { print STDOUT "<td bgcolor=#d00000>no</td>\n"; }
    1765   }
    1766   $Nimage = $i;
    1767  
    1768   print STDOUT "</table>\n";
    1769   print STDOUT "</body>\n";
    1770  
    1771   &goodbye;
    1772  
    1773 }
    1774 
    1775 #### process report for html3 ##########
    1776 sub flips_entry {
    1777  
    1778   my($version)= $_[0];          # version of desired entry
    1779   my($entry)  = $_[1];          # desired entry in list
    1780   my($line)   = $_[2];          # list of image stats
    1781  
    1782   open (STAT, mknames ("stats", $line));
    1783   open (TEN,  mknames ("tenbin", $line));
    1784  
    1785   for ($i = 0; ($i < $entry + 1) && ($line = <STAT>) && ($tenline = <TEN>); $i++) {}
    1786   if ($i != $entry + 1) { &escape ("</table> selected entry out of range"); }
    1787  
    1788   $first = ($entry == 0);
    1789   $tmp = <STAT>;
    1790   $last = ($tmp == "");
    1791   $next = $entry + 1;
    1792   $prev = $entry - 1;
    1793  
    1794   chop ($line);
    1795   @word = split (" ",$line);
    1796   $keep = $word[12];
    1797  
    1798   # mkdetrend works with files in the user's paths, but the web page needs
    1799   # to work with files visible to the web server
    1800   chop ($tenline);
    1801   @tmpw = split ("/", $tenline);
    1802   $N = @tmpw - 1;
    1803   $name = $tmpw[$N];
    1804  
    1805   $sig1 = sprintf "%5.3f", $word[4];
    1806   $sig2 = sprintf "%5.3f", $word[5];
    1807   $sig3 = sprintf "%5.3f", $word[6];
    1808   $sig4 = sprintf "%5.3f", $word[7];
    1809   $mean = sprintf "%8.1f", $word[3];
    1810  
    1811   print STDOUT "<img width=100% src=$www/$name>\n";
    1812  
    1813   print STDOUT "<table><tr><td>\n";
    1814   print STDOUT "<table border>\n";
    1815   print STDOUT "<tr><th> image </th><th> Date </th><th> Time </th><th> Mean </th>\n";
    1816   print STDOUT "<th> Sigma (raw) </th><th> Sigma (clipped) </th><th> Sigma (med) </th><th> used? </th></tr>\n\n";
    1817  
    1818   print STDOUT "<tr><td> $word[0] </a></td><td> $word[1] </td><td> $word[2] </td><td> $word[3] </td>\n";
    1819   print STDOUT "<td> $word[5] </td><td> $word[6] </td><td> $word[8] </td>\n";
    1820   if ($keep) {
    1821     print STDOUT "<td>yes</td>\n";
    1822   } else {
    1823     print STDOUT "<td bgcolor=#ff0000>no</td>\n";
    1824   }     
    1825   print STDOUT "</tr>\n\n";
    1826   print STDOUT "</table>\n";
    1827  
    1828   print STDOUT "</td></tr>\n";
    1829 
    1830   print STDOUT "<tr><td> return to <a href=$CGI/elixir1&elconf=$elconf> config list </a></tr></td>\n";
    1831   print STDOUT "<tr><td> return to <a href=$CGI/elixir2?$version&elconf=$elconf> $version </a></tr></td>\n";
    1832   if (!$first) { print STDOUT "<tr><td> goto <a href=$CGI/elixir3?$prev.$version&elconf=$elconf> prev </a> image </td></tr>\n"; }
    1833   if (!$last)  { print STDOUT "<tr><td> goto <a href=$CGI/elixir3?$next.$version&elconf=$elconf> next </a> image </td></tr>\n"; }
    1834   print STDOUT "</table>\n";
    1835  
    1836   print STDOUT "</body>\n";
    1837   &goodbye;
     1966    print STDOUT "<img width=100% src=$www/$name>\n";
     1967   
     1968    print STDOUT "<table><tr><td>\n";
     1969    print STDOUT "<table border>\n";
     1970    print STDOUT "<tr><th> image </th><th> Date </th><th> Time </th><th> Mean </th>\n";
     1971    print STDOUT "<th> Sigma (raw) </th><th> Sigma (clipped) </th><th> Sigma (med) </th><th> used? </th></tr>\n\n";
     1972   
     1973    print STDOUT "<tr><td> $word[0] </a></td><td> $word[1] </td><td> $word[2] </td><td> $word[3] </td>\n";
     1974    print STDOUT "<td> $word[5] </td><td> $word[6] </td><td> $word[8] </td>\n";
     1975    if ($keep) {
     1976        print STDOUT "<td>yes</td>\n";
     1977    } else {
     1978        print STDOUT "<td bgcolor=#ff0000>no</td>\n";
     1979    }   
     1980    print STDOUT "</tr>\n\n";
     1981    print STDOUT "</table>\n";
     1982   
     1983    print STDOUT "</td></tr>\n";
     1984
     1985    print STDOUT "<tr><td> return to <a href=$CGI/elixir1&elconf=$elconf> config list </a></tr></td>\n";
     1986    print STDOUT "<tr><td> return to <a href=$CGI/elixir2?$version&elconf=$elconf> $version </a></tr></td>\n";
     1987    if (!$first) { print STDOUT "<tr><td> goto <a href=$CGI/elixir3?$prev.$version&elconf=$elconf> prev </a> image </td></tr>\n"; }
     1988    if (!$last)  { print STDOUT "<tr><td> goto <a href=$CGI/elixir3?$next.$version&elconf=$elconf> next </a> image </td></tr>\n"; }
     1989    print STDOUT "</table>\n";
     1990   
     1991    print STDOUT "</body>\n";
     1992    &goodbye;
    18381993}
    18391994
     
    19452100    close (FILE);
    19462101}   
    1947  
     2102
    19482103# $root/detrend.config    - current run
    19492104# $det/config.dat         - config info for specific run, 1 line per setup
     
    19942149            last;
    19952150        }
     2151        if ($type eq "links") {
     2152            $value = "$det/flips/links";
     2153            last;
     2154        }
    19962155        if ($type eq "split") {
    19972156            $value = "$det/split";
     
    20752234            last;
    20762235        }
     2236        if ($type eq "link") {
     2237            $dir = mkfiles ("links");
     2238            $ccd = $_[2];
     2239            if ($ccd eq "") { &escape ("missing CCD for mknames fits"); }
     2240            $value = "$dir/$words[0].$words[1].$words[2].$ccd.$words[3].fits";
     2241            last;
     2242        }
     2243        if ($type eq "mef") {
     2244            $dir = mkfiles ("flips");
     2245            $value = "$dir/$words[0].$words[1].$words[2].$words[3].fits";
     2246            last;
     2247        }
    20772248        if ($type eq "proc.medbin") {
    20782249            $dir = mkfiles ("flips");
     
    21062277#**************************
    21072278sub gtconfig {
    2108   my ($value, $type, @words);
    2109   # in: (config line) (type)
    2110   @words = split (" ", $_[0]);
    2111   $type = $_[1];
    2112 
    2113   {
    2114       if ($type eq "elixir") {
    2115           $value = "$words[0] $words[1] $words[2] $words[3]";
    2116           last;
    2117       }
    2118       if ($type eq "mosaic") {
    2119         $ccd = "xx";
    2120           $value = "$words[0] $words[1] $words[2] $ccd $words[3] $words[4] $words[5]";
    2121           last;
    2122       }
    2123       if ($type eq "chiprun") {
    2124           $ccd  = sprintf "%02d", $_[2];
    2125           $value = "$words[0] $words[1] $words[2] $ccd $words[3] $words[4] $words[5]";
    2126           last;
    2127       }
    2128       if ($type eq "config") {
    2129           $value = "$words[0].$words[1].$words[2]";
    2130           last;
    2131       }
    2132       if ($type eq "version") {
    2133           $value = "$words[0].$words[1].$words[2].$words[3]";
    2134           last;
    2135       }
    2136       if ($type eq "ID") {
    2137           $value = "$words[0]";
    2138           last;
    2139       }
    2140       if ($type eq "type") {
    2141           $value = "$words[1]";
    2142           last;
    2143       }
    2144       if ($type eq "filter") {
    2145           $value = "$words[2]";
    2146           last;
    2147       }
    2148       if ($type eq "from") {
    2149           $value = "$words[4]";
    2150           last;
    2151       }
    2152       if ($type eq "to") {
    2153           $value = "$words[5]";
    2154           last;
    2155       }
    2156       if ($type eq "status") {
    2157           $value = "$words[6]";
    2158           last;
    2159       }
    2160       &escape ("unknown type for gtconfig: $type");
    2161   }
    2162  
    2163   return $value;
     2279    my ($value, $type, @words);
     2280    # in: (config line) (type)
     2281    @words = split (" ", $_[0]);
     2282    $type = $_[1];
     2283
     2284    {
     2285        if ($type eq "elixir") {
     2286            $value = "$words[0] $words[1] $words[2] $words[3]";
     2287            last;
     2288        }
     2289        if ($type eq "mosaic") {
     2290            $ccd = "xx";
     2291            $value = "$words[0] $words[1] $words[2] $ccd $words[3] $words[4] $words[5]";
     2292            last;
     2293        }
     2294        if ($type eq "chiprun") {
     2295            $ccd  = $_[2];
     2296            $value = "$words[0] $words[1] $words[2] $ccd $words[3] $words[4] $words[5]";
     2297            last;
     2298        }
     2299        if ($type eq "config") {
     2300            $value = "$words[0].$words[1].$words[2]";
     2301            last;
     2302        }
     2303        if ($type eq "version") {
     2304            $value = "$words[0].$words[1].$words[2].$words[3]";
     2305            last;
     2306        }
     2307        if ($type eq "ID") {
     2308            $value = "$words[0]";
     2309            last;
     2310        }
     2311        if ($type eq "type") {
     2312            $value = "$words[1]";
     2313            last;
     2314        }
     2315        if ($type eq "filter") {
     2316            $value = "$words[2]";
     2317            last;
     2318        }
     2319        if ($type eq "from") {
     2320            $value = "$words[4]";
     2321            last;
     2322        }
     2323        if ($type eq "to") {
     2324            $value = "$words[5]";
     2325            last;
     2326        }
     2327        if ($type eq "status") {
     2328            $value = "$words[6]";
     2329            last;
     2330        }
     2331        &escape ("unknown type for gtconfig: $type");
     2332    }
     2333   
     2334    return $value;
    21642335}
    21652336
     
    22142385    if ($run eq "") {
    22152386        $run = `gconfig RUNID.MKDETREND`; chop $run;
    2216         if ($?) {  &escape ("run is not defined: use 'mkdetrend config' or 'mkrun sys'\n"); }
    2217         if ($run eq "") {  &escape ("run is not defined: use 'mkdetrend config' or 'mkrun sys'\n"); }
     2387        if ($?) {  &escape ("run is not defined: use '$MKDETREND config' or 'mkrun sys'\n"); }
     2388        if ($run eq "") {  &escape ("run is not defined: use '$MKDETREND config' or 'mkrun sys'\n"); }
    22182389        push @opt, "-D RUNID.MKDETREND $run -D RUNID $run";
    22192390    }
     
    22442415    if ($?) { &escape ("error with elixir camera configuration"); }
    22452416
    2246     $answer = `cameraconfig -ccds`;
    2247     @ccds = split (" ", $answer);
     2417    @ccds = split (" ", `cameraconfig -ccdn`);
    22482418    if ($?) { &escape ("error with elixir camera configuration"); }
    22492419
     
    22712441    return (@argv);
    22722442}
    2273  
     2443
    22742444sub vsystem {
    2275   print STDERR "@_\n";
    2276   $status = system ("@_");
    2277   $status;
     2445    print STDERR "@_\n";
     2446    $status = system ("@_");
     2447    $status;
    22782448}
    22792449
     
    22902460
    22912461sub usage {
    2292   if (@ARGV == 1) {
    2293     print STDERR "\n --- user modes ---\n";
    2294     print STDERR "create (run) (startdate) (stopdate)\n";
    2295     print STDERR "config (run)\n";
    2296     print STDERR "init\n";
    2297     print STDERR "run\n";
    2298     print STDERR "list.runs\n";
    2299     print STDERR "set (config.ver) (state)\n";
    2300     print STDERR "reg\n";
    2301     print STDERR "state \n";
    2302     print STDERR "help \n";
    2303     print STDERR "\n --- internal modes --- \n";
    2304     print STDERR "flips\n";
    2305     print STDERR "norm\n";
    2306     print STDERR "update\n";
    2307     print STDERR "merge\n";
    2308     print STDERR "dup (config)\n";
    2309     print STDERR "del (config)\n";
    2310     print STDERR "def (config.ver) (start) (stop)\n";
    2311     print STDERR "eval (step)\n";
    2312     print STDERR "mevel (step)\n";
    2313     print STDERR "htmldup\n";
    2314     print STDERR "htmldel\n";
    2315     print STDERR "htmldef\n";
    2316     print STDERR "htmlmod\n";
    2317     print STDERR "htmlkeep\n";
    2318     print STDERR "html1\n";
    2319     print STDERR "html2 (config.ver)\n";
    2320     print STDERR "html3 (entry.config.ver)\n";
     2462    if (@ARGV == 1) {
     2463        print STDERR "\n --- user modes ---\n";
     2464        print STDERR "create (run) (startdate) (stopdate)\n";
     2465        print STDERR "config (run)\n";
     2466        print STDERR "init\n";
     2467        print STDERR "run\n";
     2468        print STDERR "list.runs\n";
     2469        print STDERR "set (config.ver) (state)\n";
     2470        print STDERR "reg\n";
     2471        print STDERR "state \n";
     2472        print STDERR "help \n";
     2473        print STDERR "\n --- internal modes --- \n";
     2474        print STDERR "flips\n";
     2475        print STDERR "norm\n";
     2476        print STDERR "update\n";
     2477        print STDERR "merge\n";
     2478        print STDERR "dup (config)\n";
     2479        print STDERR "del (config)\n";
     2480        print STDERR "def (config.ver) (start) (stop)\n";
     2481        print STDERR "eval (step)\n";
     2482        print STDERR "mevel (step)\n";
     2483        print STDERR "htmldup\n";
     2484        print STDERR "htmldel\n";
     2485        print STDERR "htmldef\n";
     2486        print STDERR "htmlmod\n";
     2487        print STDERR "htmlkeep\n";
     2488        print STDERR "html1\n";
     2489        print STDERR "html2 (config.ver)\n";
     2490        print STDERR "html3 (entry.config.ver)\n";
     2491        &escape;
     2492    }
     2493   
     2494    if (@ARGV > 2) { print STDERR "USAGE: $MKDETREND (help) [mode]\n"; &escape; }
     2495   
     2496    if ($ARGV[1] eq "config") {
     2497        print STDERR "set up initial configuration\n";
     2498        &escape;
     2499    }
     2500   
     2501    if ($ARGV[1] eq "save") {
     2502        print STDERR "save results from current configuration\n";
     2503        &escape;
     2504    }
     2505   
     2506    print STDERR "help for $ARGV[1] no defined\n";
    23212507    &escape;
    2322   }
    2323  
    2324   if (@ARGV > 2) { print STDERR "USAGE: mkdetrend (help) [mode]\n"; &escape; }
    2325  
    2326   if ($ARGV[1] eq "config") {
    2327     print STDERR "set up initial configuration\n";
    2328     &escape;
    2329   }
    2330  
    2331   if ($ARGV[1] eq "save") {
    2332     print STDERR "save results from current configuration\n";
    2333     &escape;
    2334   }
    2335  
    2336   print STDERR "help for $ARGV[1] no defined\n";
    2337   &escape;
    2338 }
     2508}
  • trunk/Ohana/src/perl/src/mkfringe

    r17 r46  
    11#!/usr/bin/perl
     2$MKFRINGE = mkfringe2;
    23
    34# strip off args related to the elixir config system, set env PTOLEMY
     
    67# interpret command-line arguments
    78if (@ARGV < 1) {
    8     print STDOUT "USAGE: mkfringe (mode) [arguments]\n";
     9    print STDOUT "USAGE: $MKFRINGE (mode) [arguments]\n";
    910    print STDOUT "mode = help gives a complete list\n";
    1011    &escape;
     
    6263   
    6364    if ($ARGV[1] eq "run") { &mk_createrun; }
    64     if (@ARGV != 5) { &escape ("USAGE: mkfringe create (camera) (run) (startdate) (stopdate)"); }
     65    if (@ARGV != 5) { &escape ("USAGE: $MKFRINGE create (camera) (run) (startdate) (stopdate)"); }
    6566   
    6667    # setting $run & $start here overrides default values loaded by set_globals()
     
    109110sub mk_createrun {
    110111   
    111     if (@ARGV != 3) { &escape ("USAGE: mkfringe create run (run)"); }
     112    if (@ARGV != 3) { &escape ("USAGE: $MKFRINGE create run (run)"); }
    112113    if ($ARGV[1] ne "run") { &escape ("USAGE: mkdetrend create run (run)"); }
    113114   
     
    148149sub mk_config {
    149150   
    150     if (@ARGV != 3) { &escape ("USAGE: mkfringe config (camera) (run)"); }   
     151    if (@ARGV != 3) { &escape ("USAGE: $MKFRINGE config (camera) (run)"); }   
    151152
    152153    $camera = $ARGV[1];
     
    167168sub mk_init {
    168169   
    169     if (@ARGV != 1) { &escape ("USAGE: mkfringe run"); }
    170 
    171     system "mkfringe list.init\n";
    172     system "mkfringe detrend\n";
    173     system "mkfringe merge\n";
     170    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE run"); }
     171
     172    system "$MKFRINGE list.init\n";
     173    system "$MKFRINGE detrend\n";
     174    system "$MKFRINGE merge\n";
    174175    &goodbye;
    175176}
     
    178179sub mk_run {
    179180   
    180     if (@ARGV != 1) { &escape ("USAGE: mkfringe run"); }
    181    
    182     system "mkfringe mkrough";
    183     system "mkfringe defringe";
    184     system "mkfringe merge";
     181    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE run"); }
     182   
     183    system "$MKFRINGE mkrough";
     184    system "$MKFRINGE defringe";
     185    system "$MKFRINGE merge";
    185186   
    186187    &goodbye;
     
    190191sub mk_reg {
    191192   
    192     if (@ARGV != 1) { &escape ("USAGE: mkfringe reg"); }
    193    
    194     system "mkfringe mksmooth";
    195     system "mkfringe regimage";
     193    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE reg"); }
     194   
     195    system "$MKFRINGE mksmooth";
     196    system "$MKFRINGE regimage";
    196197   
    197198    &goodbye;
     
    201202sub mk_state {
    202203   
    203     if (@ARGV != 1) { &escape ("USAGE: mkfringe state"); }
     204    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE state"); }
    204205   
    205206    ($start, $stop, $mode) = &load_dates;
     
    212213   
    213214    @list = &load_config;
    214     if (@list == 0) { &escape ("mkfringe not configured"); }
     215    if (@list == 0) { &escape ("$MKFRINGE not configured"); }
    215216
    216217    for ($i = 0; $i < @list; $i++) {
     
    223224sub mk_list_runs {
    224225   
    225     if (@ARGV != 1) { &escape ("USAGE: mkfringe list.runs"); }
     226    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE list.runs"); }
    226227   
    227228    system ("ls $root");
     
    233234   
    234235    # create mkfringe config file from existing date entries
    235     if (@ARGV != 1) { &escape ("USAGE: mkfringe mkconfig"); }
     236    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE mkconfig"); }
    236237   
    237238    # if new run, need to create the new detdir
     
    244245
    245246    ($start, $stop, $mode) = &load_dates;
    246     if (($start eq "") || ($stop eq "")) { &escape ("dates are not defined: use 'mkfringe config'"); }
     247    if (($start eq "") || ($stop eq "")) { &escape ("dates are not defined: use '$MKFRINGE config'"); }
    247248
    248249    # create run-specific config file
     
    259260sub mk_dup {
    260261   
    261     if (@ARGV != 2) { &escape ("USAGE: mkfringe dup (config)"); }
     262    if (@ARGV != 2) { &escape ("USAGE: $MKFRINGE dup (config)"); }
    262263   
    263264    $key = $ARGV[1];
     
    286287sub mk_cleanup {
    287288   
    288     if ((@ARGV != 1) && (@ARGV != 2)) { &escape ("USAGE: mkfringe cleanup [mode]"); }
     289    if ((@ARGV != 1) && (@ARGV != 2)) { &escape ("USAGE: $MKFRINGE cleanup [mode]"); }
    289290
    290291    $DEBUG = 0;
     
    343344sub mk_del {
    344345   
    345     if (@ARGV != 2) { &escape ("USAGE: mkfringe del (config.ver)"); }
     346    if (@ARGV != 2) { &escape ("USAGE: $MKFRINGE del (config.ver)"); }
    346347   
    347348    $key = $ARGV[1];
     
    376377sub mk_def {
    377378   
    378     if (@ARGV != 4) { &escape ("USAGE: mkfringe def (config.ver) (start) (stop)"); }
     379    if (@ARGV != 4) { &escape ("USAGE: $MKFRINGE def (config.ver) (start) (stop)"); }
    379380   
    380381    $key   = $ARGV[1];
     
    408409sub mk_set {
    409410   
    410     if (@ARGV != 3) { &escape ("USAGE: mkfringe set (config number) (state)"); }
     411    if (@ARGV != 3) { &escape ("USAGE: $MKFRINGE set (config number) (state)"); }
    411412   
    412413    @list = load_config ();
     
    429430sub mk_list_init {
    430431   
    431     if (@ARGV != 1) { &escape ("USAGE: mkfringe list.init"); }
     432    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE list.init"); }
    432433   
    433434    # create necessary directories
     
    457458   
    458459    vsystem ("elixir -D DETREND_DIR $det -D mode fringe1 $file");
    459     vsystem ("mkfringe eval $file init");
     460    vsystem ("$MKFRINGE eval $file init");
    460461
    461462    open (FILE, "$file.eval");
     
    484485sub mk_list_reinit {
    485486   
    486     if (@ARGV != 1) { &escape ("USAGE: mkfringe list.init"); }
     487    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE list.init"); }
    487488   
    488489    # create necessary directories
     
    509510   
    510511    vsystem ("elixir -D DETREND_DIR $det -D mode fringe1 -D global.pending master.lists $file");
    511     vsystem ("mkfringe eval $file init");
     512    vsystem ("$MKFRINGE eval $file init");
    512513
    513514    open (FILE, "$file.eval");
     
    536537sub mk_detrend {
    537538   
    538     if (@ARGV != 1) { &escape ("USAGE: mkfringe detrend"); }
     539    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE detrend"); }
    539540
    540541    @list = load_config ();
     
    563564   
    564565    vsystem ("elixir -D DETREND_DIR $det -D mode fringe2 $file");
    565     vsystem ("mkfringe eval $file detrend");
     566    vsystem ("$MKFRINGE eval $file detrend");
    566567
    567568    open (FILE, "$file.eval");
     
    602603sub mk_map {
    603604   
    604     if (@ARGV != 1) { &escape ("USAGE: mkfringe map"); }
     605    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE map"); }
    605606
    606607    @list = load_config ();
     
    635636sub mk_map_reg {
    636637   
    637     if (@ARGV != 1) { &escape ("USAGE: mkfringe map.reg"); }
     638    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE map.reg"); }
    638639   
    639640    @list = load_config ();
     
    666667sub mk_mkrough {
    667668   
    668     if (@ARGV != 1) { &escape ("USAGE: mkfringe mkrough"); }
     669    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE mkrough"); }
    669670   
    670671    @list = load_config ();
     
    689690        $CONFIG  = mknames ("config", $confline);
    690691
     692        # extract the selected subset of detrend images from master & statlist to sublist
    691693        vsystem ("fr.mklists -subset  $CONFIG.master $CONFIG.med.statlist $CONFIG.med.sublist");
    692694        if ($?) { &escape ("failure running fr.mklists -subset"); }
    693695
     696        # extract the selected subset of defringed images from master & statlist to sublist
    694697        vsystem ("fr.mklists -subset  $CONFIG.master $CONFIG.def.statlist $CONFIG.def.sublist");
    695698        if ($?) { &escape ("failure running fr.mklists -subset"); }
    696699
     700        # calculate fit parameters based on subset
    697701        vsystem ("fr.frstats -fitpars $CONFIG.med.sublist $CONFIG.fitpar");
    698702        if ($?) { &escape ("failure running fr.frstats -fitpars"); }
    699703
     704        # calculate optimal per-image fringe statistics based on fit parameters
    700705        vsystem ("fr.frstats -frstats $CONFIG.med.statlist $CONFIG.fitpar $CONFIG.med.imstats");
    701706        if ($?) { &escape ("failure running fr.frstats -frstats"); }
    702707
     708        # calculate per-image residual fringe stats
    703709        vsystem ("fr.frstats -dfstats $CONFIG.def.statlist $CONFIG.fitpar $CONFIG.def.imstats");
    704710        if ($?) { &escape ("failure running fr.frstats -dfstats"); }
    705711
     712        # assemble master fringe statistic file needed by web tools
    706713        vsystem ("fr.mklists -imstats $CONFIG.master $CONFIG.med.imstats $CONFIG.def.imstats $CONFIG.datlist $CONFIG.imstats");
    707714        if ($?) { &escape ("failure running fr.mklists -imstats"); }
     
    714721   
    715722    vsystem ("elixir -D DETREND_DIR $det -D mode fringe4 $file");
    716     vsystem ("mkfringe eval $file mkrough");
     723    vsystem ("$MKFRINGE eval $file mkrough");
    717724
    718725    open (FILE, "$file.eval");
     
    744751sub mk_defringe {
    745752   
    746     if (@ARGV != 1) { &escape ("USAGE: mkfringe defringe"); }
     753    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE defringe"); }
    747754
    748755    @list = load_config ();
     
    770777   
    771778    vsystem ("elixir -D DETREND_DIR $det -D mode fringe3 $file");
    772     vsystem ("mkfringe eval $file defringe");
     779    vsystem ("$MKFRINGE eval $file defringe");
    773780
    774781    open (FILE, "$file.eval");
     
    805812sub mk_merge {
    806813   
    807     if (@ARGV != 1) { &escape ("USAGE: mkfringe merge"); }
     814    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE merge"); }
    808815
    809816    @list = load_config ();
     
    830837
    831838        vsystem ("fr.frstats -plotstats $CONFIG.med.statlist $CONFIG.fitpar $CONFIG.stats.png");
    832         if ($?) { &escape ("failure running fr.frstats -fitpars"); }
     839        if ($?) { &escape ("failure running fr.frstats -plotstats"); }
    833840
    834841        vsystem ("fr.frstats -frstats $CONFIG.med.statlist $CONFIG.fitpar $CONFIG.med.imstats");
     
    887894sub mk_smooth {
    888895   
    889     if (@ARGV != 1) { &escape ("USAGE: mkfringe mksmooth"); }
     896    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE mksmooth"); }
    890897   
    891898    @list = load_config ();
     
    914921   
    915922    vsystem ("elixir -D DETREND_DIR $det -D mode fringe4 -D global.pending mksmooth $file");
    916     vsystem ("mkfringe eval $file smooth");
     923    vsystem ("$MKFRINGE eval $file smooth");
    917924
    918925    open (FILE, "$file.eval");
     
    944951sub mk_regimage {
    945952   
    946     if (@ARGV != 1) { &escape ("USAGE: mkfringe regimage"); }
     953    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE regimage"); }
    947954   
    948955    @list = load_config ();
     
    957964        $success = 1;
    958965        $ID = gtconfig ($confline, "ID");
    959         for ($j = 0; $j < $Nccd; $j++) {
    960             $file = mknames ("smfile", $confline, $ccds[$j]);
    961             $line = "detregister $file -label fringe-2.1 -ID $ID";
    962             $status = system ($line);
    963             if ($status) {
    964                 print STDERR "error registering $file\n";
    965                 $success = 0;
     966
     967        $DBmode = `gconfig DETREND-DB-MODE`; chop $DBmode;
     968        $DBmode = "\U$DBmode\E";
     969
     970        if ($DBmode eq "SPLIT") {
     971            for ($j = 0; $j < $Nccd; $j++) {
     972                $file = mknames ("smfile", $confline, $ccds[$j]);
     973                $line = "detregister $file -label fringe-2.1 -ID $ID";
     974                $status = system ($line);
     975                if ($status) {
     976                    print STDERR "error registering $file\n";
     977                    $success = 0;
     978                }
    966979            }
    967         }
     980            goto registered;
     981        }
     982
     983        if ($DBmode eq "MEF") {
     984            # make links
     985            foreach $ccd (@ccds) {
     986                $file = mknames ("smfile", $confline, $ccd);
     987                $link = mknames ("link", $confline, $ccd);
     988                symlink $file, $link;
     989            }
     990
     991            # mef, register
     992            $mef = mknames ("mef", $confline);
     993            vsystem ("fhtool -P $links $mef");
     994            if ($status) { $success = 0; }
     995            vsystem ("detregister $mef -label fringe-2.1 -ID $ID");
     996            if ($status) { $success = 0; }
     997
     998            # remove links
     999            foreach $ccd (@ccds) {
     1000                $link = mknames ("link", $confline, $ccd);
     1001                unlink $link;
     1002            }
     1003            goto registered;
     1004        }
     1005        print STDERR "DB mode not defined?\n";
     1006        $success = 0;
     1007
     1008      registered:
    9681009        if ($success) {
    9691010            $confline = stconfig ($confline, "status", "done");
    9701011        } else {
     1012            print STDERR "error registering $file\n";
    9711013            $confline = stconfig ($confline, "status", "fail.reg");
    9721014        }
     
    9791021sub mk_eval {
    9801022   
    981     if (@ARGV != 3) { &escape ("USAGE: mkfringe meval (file) (step)"); }
     1023    if (@ARGV != 3) { &escape ("USAGE: $MKFRINGE meval (file) (step)"); }
    9821024   
    9831025    $infile = $ARGV[1];
     
    10491091sub mk_htmldup {
    10501092   
    1051     if (@ARGV != 2) { &escape ("USAGE: mkfringe htmldup (config)"); }
     1093    if (@ARGV != 2) { &escape ("USAGE: $MKFRINGE htmldup (config)"); }
    10521094   
    10531095    $config = $ARGV[1];
    1054     system ("mkfringe dup $config");
     1096    system ("$MKFRINGE dup $config");
    10551097    print STDOUT "<meta http-equiv=refresh content=\"0; url=$CGI/fr.elixir1?&elconf=$elconf\">\n";
    10561098   
     
    10611103sub mk_htmldel {
    10621104   
    1063     if (@ARGV != 2) { &escape ("USAGE: mkfringe htmldel (config.ver)"); }
     1105    if (@ARGV != 2) { &escape ("USAGE: $MKFRINGE htmldel (config.ver)"); }
    10641106   
    10651107    $config = $ARGV[1];
    1066     system ("mkfringe del $config");
     1108    system ("$MKFRINGE del $config");
    10671109    print STDOUT "<meta http-equiv=refresh content=\"0; url=$CGI/fr.elixir1?&elconf=$elconf\">\n";
    10681110   
     
    10731115sub mk_htmldef {
    10741116   
    1075     if (@ARGV != 2) { &escape ("USAGE: mkfringe htmldef (config.ver)"); }
     1117    if (@ARGV != 2) { &escape ("USAGE: $MKFRINGE htmldef (config.ver)"); }
    10761118   
    10771119    $key = $ARGV[1];
     
    11371179sub mk_htmlmod {
    11381180   
    1139     if (@ARGV != 1) { &escape ("USAGE: mkfringe htmlmod"); }
     1181    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE htmlmod"); }
    11401182   
    11411183    # images which are marked for exclusion are included in the
     
    12171259sub mk_htmlmodes {
    12181260   
    1219     if (@ARGV != 1) { &escape ("USAGE: mkfringe htmlmodes"); }
     1261    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE htmlmodes"); }
    12201262   
    12211263    # modes which are marked for exclusion are included in the
     
    12711313sub mk_htmlmaps {
    12721314   
    1273     if (@ARGV != 1) { &escape ("USAGE: mkfringe htmlmaps"); }
     1315    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE htmlmaps"); }
    12741316   
    12751317    # maps which are marked for inclusion are given in the
     
    13211363sub mk_htmlkeep {
    13221364   
    1323     if (@ARGV != 2) { &escape ("USAGE: mkfringe htmlkeep (config.ver)"); }
     1365    if (@ARGV != 2) { &escape ("USAGE: $MKFRINGE htmlkeep (config.ver)"); }
    13241366   
    13251367    $key = $ARGV[1];
     
    13721414   
    13731415
    1374     if (@ARGV != 1) { &escape ("USAGE: mkfringe html1"); }
     1416    if (@ARGV != 1) { &escape ("USAGE: $MKFRINGE html1"); }
    13751417   
    13761418    @list = load_config ();
     
    14141456   
    14151457    if (@ARGV != 2) {
    1416         print STDERR "USAGE: mkfringe html2 (config.ver)\n";
     1458        print STDERR "USAGE: $MKFRINGE html2 (config.ver)\n";
    14171459        &goodbye;
    14181460    }
     
    14891531   
    14901532    if (@ARGV != 3) {
    1491         print STDERR "USAGE: mkfringe html3 (entry.config.ver) (mode)\n";
     1533        print STDERR "USAGE: $MKFRINGE html3 (entry.config.ver) (mode)\n";
    14921534        &goodbye;
    14931535    }
     
    15571599   
    15581600    if (@ARGV != 2) {
    1559         print STDERR "USAGE: mkfringe dads (config.ver)\n";
     1601        print STDERR "USAGE: $MKFRINGE dads (config.ver)\n";
    15601602        &goodbye;
    15611603    }
     
    16801722   
    16811723    if (@ARGV != 1) {
    1682         print STDERR "USAGE: mkfringe dads.top\n";
     1724        print STDERR "USAGE: $MKFRINGE dads.top\n";
    16831725        &goodbye;
    16841726    }
     
    19211963   
    19221964    if (($mode ne "def") && ($mode ne "med")) {
    1923         print STDOUT "error in mkfringe mode\n";
     1965        print STDOUT "error in $MKFRINGE mode\n";
    19241966        &goodbye;
    19251967    }
     
    20692111}
    20702112
    2071 print STDOUT "error: invalid mkfringe command\n";
     2113print STDOUT "error: invalid $MKFRINGE command\n";
    20722114
    20732115# run:    $root/detrend.config    - current run
     
    21232165            last;
    21242166        }
     2167        if ($type eq "links") {
     2168            $value = "$det/flips/links";
     2169            last;
     2170        }
    21252171        if ($type eq "html") {
    21262172            $value = "$det/html";
     
    21722218            $dir = mkfiles ("fringe");
    21732219            $value = sprintf "$dir/$words[0].$words[1].$words[2].$words[3].master";
     2220            last;
     2221        }
     2222        # output link file for fhtool
     2223        if ($type eq "link") {
     2224            $dir = mkfiles ("links");
     2225            if ($ccd eq "") { &escape ("missing CCD for mknames link"); }
     2226            $value = "$dir/$words[0].$words[1].$words[2].$ccd.$words[3].fits";
     2227            last;
     2228        }
     2229        # output mef file name
     2230        if ($type eq "mef") {
     2231            $dir = mkfiles ("fringe");
     2232            $value = "$dir/$words[0].$words[1].$words[2].$words[3].fits";
    21742233            last;
    21752234        }
     
    25382597    if ($?) { &escape ("error with elixir camera configuration"); }
    25392598
    2540     $answer = `cameraconfig -ccds`;
    2541     @ccds = split (" ", $answer);
     2599    @ccds = split (" ", `cameraconfig -ccdn`);
    25422600    if ($?) { &escape ("error with elixir camera configuration"); }
    25432601
     
    25892647    }
    25902648   
    2591     if (@ARGV > 2) { print STDERR "USAGE: mkfringe (help) [mode]\n"; &goodbye; }
     2649    if (@ARGV > 2) { print STDERR "USAGE: $MKFRINGE (help) [mode]\n"; &goodbye; }
    25922650   
    25932651    if ($ARGV[1] eq "config") {
Note: See TracChangeset for help on using the changeset viewer.