Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

few small changes

  • Loading branch information...
commit 0f4140ef451d47d91d80d096ea601408dfd08d1d 1 parent 5c3b34b
simonfullernuim authored June 03, 2012
BIN  Debug/SPCIO
Binary file not shown
BIN  Debug/src/Super_parser.o
Binary file not shown
BIN  Debug/src/main.o
Binary file not shown
BIN  Debug/src/rcpp_read_spc.o
Binary file not shown
5  src/Super_parser.cpp
@@ -33,7 +33,7 @@ void Super_parser::readX( int amt ){
33 33
 	short step = 4;
34 34
 	int ipt_bytes = amt * step;
35 35
 	int mod_bytes = ipt_bytes % LINE_MAX;
36  
-	double tmp;//NBNBNB Should this BE float??
  36
+	float tmp;//NBNBNB Should this BE float??
37 37
 	//Rcpp::NumericVector::iterator xptr = X->begin();
38 38
 	/*
39 39
 		//ifstr->read( buffer, LINEMAX);
@@ -44,7 +44,6 @@ void Super_parser::readX( int amt ){
44 44
 			++xptr
45 45
 			//ctr=ctr+1;
46 46
 		}//rof
47  
-
48 47
 	 */
49 48
 	while( (ctr=ctr+LINE_MAX) <= ipt_bytes) {
50 49
 		ifstr->read( buffer, LINE_MAX );
@@ -65,6 +64,7 @@ void Super_parser::readX( int amt ){
65 64
  * By default offset is reader_hdr->fnsubs --> for TMULTI_TXYXYS_TXVALS this is set to 1
66 65
  */
67 66
 void  Super_parser::readY( short row, int amt, char fexp, unsigned int _offset ){
  67
+
68 68
 	unsigned int offset = (_offset == 0) ? reader_hdr->fnsub : _offset;
69 69
 	Rcpp::NumericMatrix::iterator rdit = ( Y_ptr +  row );
70 70
 	int ctr = 0;
@@ -97,6 +97,7 @@ void  Super_parser::readY( short row, int amt, char fexp, unsigned int _offset )
97 97
 	}//esle
98 98
 	*/
99 99
 	if(fexp==(-128)){
  100
+
100 101
 		float tmp;
101 102
 		while((ctr=ctr+LINE_MAX)<=ipt_bytes){
102 103
 			ifstr->read( buffer, LINE_MAX );
2  src/TXYXYS_TXVALS_parser.h
@@ -15,7 +15,7 @@ class TXYXYS_TXVALS_parser : public Super_parser{
15 15
 protected:
16 16
 public:
17 17
 	TXYXYS_TXVALS_parser( std::ifstream* ipt_ifstr, SPC* ipt_reader_hdr,  short ipt_tsprec_subval,
18  
-				Rcpp::NumericVector::iterator ipt_X_ptr, Rcpp::NumericMatrix::iterator ipt_Y_ptr, std::vector< std::string >* ipt_log2data, std::vector< std::string >* ipt_hdr2data, SUBHDR _subhdr )
  18
+				Rcpp::NumericVector::iterator ipt_X_ptr, Rcpp::NumericMatrix::iterator ipt_Y_ptr, std::vector< std::string >* ipt_log2data, std::vector< std::string >* ipt_hdr2data, SUBHDR& _subhdr )
19 19
 				: Super_parser( ipt_ifstr, ipt_reader_hdr, ipt_tsprec_subval, ipt_X_ptr, ipt_Y_ptr,	 ipt_log2data, ipt_hdr2data ) {
20 20
 			memcpy( &subhdr, &_subhdr, SUBHSZ );
21 21
 			int Y_len = reader_hdr->fnpts;
51  src/rcpp_read_spc.cpp
@@ -191,8 +191,8 @@ RcppExport SEXP rcpp_read_spc( SEXP _file, SEXP _hdr2data, SEXP _log2data,
191 191
 			if(spcrdr->parser->want_log_but_no_log == 1){
192 192
 				cout << "WARNING: want log but no log" << endl;
193 193
 			}//fi
194  
-
195  
-			Rprintf("SUBNPTS: %i\n", spcrdr->parser->subhdr.subnpts);
  194
+			//NB: Should I flag an error here when subnpts is set????
  195
+			//Rprintf("SUBNPTS: %i\n", spcrdr->parser->subhdr.subnpts);
196 196
 
197 197
 			Rcpp::DataFrame data1 = Rcpp::DataFrame::create(extralist);
198 198
 			Rcpp::Language hyObj_call( "new", "hyperSpec",  Rcpp::Named("spc") =  Y, Rcpp::Named("wavelength") =  X,  Rcpp::Named("data") = data1 ); //log = log, label = lab
@@ -210,17 +210,18 @@ RcppExport SEXP rcpp_read_spc( SEXP _file, SEXP _hdr2data, SEXP _log2data,
210 210
 			spcrdr->parser = new TMULTI_TXVALS_parser( &spcrdr->ifstr, &spcrdr->hdr, spcrdr->tsprec_subval, X.begin(), Y.begin(), &log2data, &hdr2data );
211 211
 			spcrdr->parser->parse_file();
212 212
 			spcrdr->print_SPCHDR();
213  
-			for( unsigned int i = 0; i < spcrdr->hdr.fnsub; ++i ){
214  
-				for( unsigned int j = 0; j < spcrdr->hdr.fnpts; ++j ){
215  
-					cout <<  setprecision(12) << Y(i,j) << endl;
216  
-				}//rof
217  
-				cout << endl;
218  
-			}
219  
-			cout << endl;
220  
-			cout << "X values:" << endl;
221  
-			for(unsigned int i = 0; i < spcrdr->hdr.fnpts; ++i ){
222  
-				cout <<  setprecision(12) << X(i) << endl;
223  
-			}//rof
  213
+			short list_sz = spcrdr->parser->labeltovalue.size()  + 2;
  214
+			Rcpp::List extralist( list_sz );//include hdr values here also!!!
  215
+			Rcpp::CharacterVector extranames( list_sz );	//include hdr values here also!!!
  216
+			spcrdr->parser->arrange_data( extranames, extralist, spcrdr->hdr.fnsub );
  217
+								//SORT OUT WARNINGS!!!
  218
+			if(spcrdr->parser->want_log_but_no_log == 1){
  219
+				cout << "WARNING: want log but no log" << endl;
  220
+			}//fi
  221
+
  222
+			Rcpp::DataFrame data1 = Rcpp::DataFrame::create(extralist);
  223
+			Rcpp::Language hyObj_call( "new", "hyperSpec",  Rcpp::Named("spc") =  Y, Rcpp::Named("wavelength") =  X,  Rcpp::Named("data") = data1 ); //log = log, label = lab
  224
+			return hyObj_call.eval();
224 225
 			break;
225 226
 		}
226 227
 		//CASE: MULTI X's SEPARATE SPECTRA
@@ -234,16 +235,20 @@ RcppExport SEXP rcpp_read_spc( SEXP _file, SEXP _hdr2data, SEXP _log2data,
234 235
 			spcrdr->parser = new TXYXYS_TXVALS_parser( &spcrdr->ifstr, &spcrdr->hdr, spcrdr->tsprec_subval, X.begin(), Y.begin(), &log2data, &hdr2data, subhdr );
235 236
 
236 237
 			spcrdr->parser->parse_file();
237  
-			spcrdr->print_SPCHDR();
238  
-			cout << endl;
239  
-			cout << "X values:" << endl;
240  
-			for(unsigned int i = 0; i < subhdr.subnpts; ++i ){
241  
-				cout << (i+1) << ": " << setprecision(12) << X(i) << endl;
242  
-			}//rof
243  
-			cout << "Y values:" << endl;
244  
-			for(unsigned int i = 0; i < subhdr.subnpts; ++i ){
245  
-				cout << (i+1) << ": " <<  setprecision(12) << Y(0,i) << endl;
246  
-			}//rof
  238
+			//spcrdr->print_SPCHDR();
  239
+			short list_sz = spcrdr->parser->labeltovalue.size()  + 2;
  240
+			Rcpp::List extralist( list_sz );//include hdr values here also!!!
  241
+			Rcpp::CharacterVector extranames( list_sz );	//include hdr values here also!!!
  242
+			spcrdr->parser->arrange_data( extranames, extralist, spcrdr->hdr.fnsub );
  243
+					//SORT OUT WARNINGS!!!
  244
+			if(spcrdr->parser->want_log_but_no_log == 1){
  245
+				cout << "WARNING: want log but no log" << endl;
  246
+			}//fi
  247
+
  248
+
  249
+			Rcpp::DataFrame data1 = Rcpp::DataFrame::create(extralist);
  250
+			Rcpp::Language hyObj_call( "new", "hyperSpec",  Rcpp::Named("spc") =  Y, Rcpp::Named("wavelength") =  X,  Rcpp::Named("data") = data1 ); //log = log, label = lab
  251
+			return hyObj_call.eval();
247 252
 			break;
248 253
 		}
249 254
 		case (TMULTI | TXYXYS | TXVALS) :{

0 notes on commit 0f4140e

Please sign in to comment.
Something went wrong with that request. Please try again.