From 0c945de46270b9b15f1c2c04643cc964db305968 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Fri, 9 Dec 2016 18:40:01 +0100
Subject: [PATCH] old changes; start fthb

---
 pub/CHANGELOG        |  1 +
 pub/ftest/fthb.tab   |  5 +++++
 pub/lib/commands.cpp |  3 ++-
 pub/lib/curve.cpp    |  6 +++++-
 pub/lib/import.cpp   | 25 +++++++++++++++++++------
 5 files changed, 32 insertions(+), 8 deletions(-)
 create mode 100644 pub/ftest/fthb.tab

diff --git a/pub/CHANGELOG b/pub/CHANGELOG
index 0d61598b..bcfeb350 100644
--- a/pub/CHANGELOG
+++ b/pub/CHANGELOG
@@ -1,5 +1,6 @@
 
 - New conversion script i96-to-yda
+- Print info when new fit curve gets constant weighing.
 
 Release 2.3.3f of 3aug16:
 
diff --git a/pub/ftest/fthb.tab b/pub/ftest/fthb.tab
new file mode 100644
index 00000000..3fc25177
--- /dev/null
+++ b/pub/ftest/fthb.tab
@@ -0,0 +1,5 @@
+0 1 2
+3 4 5
+
+6 7 8
+9 10 11
diff --git a/pub/lib/commands.cpp b/pub/lib/commands.cpp
index cd8c8c25..e42246e2 100644
--- a/pub/lib/commands.cpp
+++ b/pub/lib/commands.cpp
@@ -266,11 +266,12 @@ bool frida_command( string cmd )
             "  fx   exchange (copy, then delete source)\n"
             "  fdel delete\n"
             "  fm   make\n"
-            "  ft(h|v|c)[m][s][d]  read tab\n"
+            "  ft(h|v|c)[m|b][s][d]  read tab\n"
             "       h horizontal (only y values, one line per spectrum)\n"
             "       v vertical (one x-y pair per line)\n"
             "       c choose vertical columns\n"
             "       m multi-block (blocks begin with z line)\n"
+            "       b multi-block (without z lines)\n"
             "       s from script\n"
             "       d input includes dy\n"
             ;
diff --git a/pub/lib/curve.cpp b/pub/lib/curve.cpp
index 01fe1c73..a0070bf7 100644
--- a/pub/lib/curve.cpp
+++ b/pub/lib/curve.cpp
@@ -52,7 +52,11 @@ void NCurveFile::create_fitcurve()
         fout->ZCo = fd->ZCo;
         fout->RPar = fd->RPar;
         fout->log_action( "cc " + fc->expr + " # z from " + fd->name );
-        fout->weighing = fd->has_nonzero_dy() ? COlc::_VAR : COlc::_LIN;
+        fout->weighing = COlc::_VAR;
+        if( fd->has_nonzero_dy() ) {
+             fout->weighing = COlc::_LIN;
+             cout << "Constant weight since there are data points with dy=0\n";
+        }
         for (int j=0; j<fd->nJ(); j++) {
             PCurve sout( new CCurve );
             sout->z = fd->VS(j)->z;
diff --git a/pub/lib/import.cpp b/pub/lib/import.cpp
index 261bc83d..2f89b2f1 100644
--- a/pub/lib/import.cpp
+++ b/pub/lib/import.cpp
@@ -26,7 +26,7 @@
 void NImport::read_tab( string qualif )
 { // EMBEDDED_DIALOG
     // ** parse qualif **
-    if( qualif.find_first_not_of("hvcsmd")!=string::npos )
+    if( qualif.find_first_not_of("hvcsbmd")!=string::npos )
         throw S("invalid qualifier");
     char dir = qualif[0];
     if( !( dir=='h' || dir=='v' || dir=='c' ) )
@@ -36,6 +36,9 @@ void NImport::read_tab( string qualif )
     static int iycol=0;
     bool fromscript = qualif.find('s')!=string::npos;
     bool multiblock = qualif.find('m')!=string::npos;
+    bool simpleblock = qualif.find('b')!=string::npos;
+    if (multiblock && simpleblock)
+        throw S("incompatible options bm");
     bool with_d = qualif.find('d')!=string::npos;
     if( horizontal && with_d )
         throw S("incompatible options hd");
@@ -98,6 +101,7 @@ void NImport::read_tab( string qualif )
         double val;
         PSpec s;
         while( triv::freadln(fd, &lin) ) {
+            cout << "DEBUG '" << lin << "'\n";
             ++n_in;
             if( lin.substr(0,4)=="#rpa" ){
                 triv::string_extract_word( lin.substr(4), &s1, &s2 );
@@ -113,22 +117,30 @@ void NImport::read_tab( string qualif )
             if( nline==-1 ) { // start of block
                 if( !horizontal && nblock!=0 && s && s->size()>0 )
                     fout->V.push_back( move(s) );
-                if ( multiblock ) {
+                if( multiblock ) {
                     if( !triv::str2vec(lin, &zdat, 0, false) )
                         throw "invalid header line [" + lin +
                             "] (or legitimate break ?)";
                     if( nblock==0 ){ // first header
                         nzdat = zdat.size();
-                        nz += nzdat;
                         for( int iz=0; iz<nzdat; ++iz )
                             fout->ZCo.push_back( CCoord("z"+S(iz), "") );
                     } else if( zdat.size() != nzdat )
                         throw "line " + S(n_in) +
                             ": header has length " + S(zdat.size()) +
                             " instead of " + S(nzdat);
+                } else if( simpleblock ) {
+                    if( nblock==0 ) // first header
+                        fout->ZCo.push_back( CCoord("#block", "") );
+                    cout << "DEBUG SB " << nblock << "\n";
+                    nzdat = 1;
+                    zdat.resize( 1, (double)nblock );
+                    cout << "DEBUG ZD0 " << zdat[0] << "\n";
                 }
-                if ( nblock==0 && horizontal ) {
-                    nz += 1;
+                if( nblock==0 && horizontal ) {
+                    nz = 1;
+                    if( multiblock || simpleblock )
+                        nz += nzdat;
                     fout->ZCo.push_back( CCoord("line", "") );
                 }
                 if( !horizontal ){
@@ -144,10 +156,11 @@ void NImport::read_tab( string qualif )
             }
 
             if( lin=="" && nline!=-1 ) { // end-of-block
+                cout << "DEBUG EL\n";
                 nline = -1;
-                ++nblock;
                 continue;
             }
+            cout << "DEBUG DL " << nblock << "\n";
 
             // regular data line
             if( !triv::str2vec(lin, &dat, 0, false) )
-- 
GitLab