Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

callable from R for most cases now

  • Loading branch information...
commit 5c3b34babb757bf1451b1967cd0f2fa2b6579f7a 1 parent 4d3fc36
@simonfullernuim authored
View
BIN  Debug/SPCIO
Binary file not shown
View
BIN  Debug/src/Basic_parser.o
Binary file not shown
View
BIN  Debug/src/Super_parser.o
Binary file not shown
View
BIN  Debug/src/TMULTI_TXVALS.o
Binary file not shown
View
BIN  Debug/src/TMULTI_parser.o
Binary file not shown
View
BIN  Debug/src/TXVALS_parser.o
Binary file not shown
View
BIN  Debug/src/main.o
Binary file not shown
View
BIN  Debug/src/rcpp_read_spc.o
Binary file not shown
View
223 src/Super_parser.cpp
@@ -9,7 +9,6 @@
#include "Super_parser.h"
using namespace std;
-
void Super_parser::check_log( std::vector< std::string >* check_log2data ){
if(check_log2data->size()>0){
if( reader_hdr->flogoff == 0 ){
@@ -28,17 +27,13 @@ void Super_parser::check_log( std::vector< std::string >* check_log2data ){
}//esle
}//cnuf
-
void Super_parser::readX( int amt ){
int ctr = 0;
- //short step = tsprec_subval / 8;
short step = 4;
int ipt_bytes = amt * step;
int mod_bytes = ipt_bytes % LINE_MAX;
-
- int idx = 0;
- double tmp;
+ double tmp;//NBNBNB Should this BE float??
//Rcpp::NumericVector::iterator xptr = X->begin();
/*
//ifstr->read( buffer, LINEMAX);
@@ -51,11 +46,10 @@ void Super_parser::readX( int amt ){
}//rof
*/
- while((ctr=ctr+LINE_MAX)<=ipt_bytes){
+ while( (ctr=ctr+LINE_MAX) <= ipt_bytes) {
ifstr->read( buffer, LINE_MAX );
for(short i = 0; i < LINE_MAX / step; ++i){
- memcpy(&tmp, buffer+(i*step), step);
- //X[row][idx++] = (double) tmp * pow((double)2, reader_hdr->fexp - tsprec_subval);
+ memcpy( &tmp, buffer + ( i * step ), step );
*X_ptr = tmp;
++X_ptr;
}//rof
@@ -63,21 +57,16 @@ void Super_parser::readX( int amt ){
ifstr->read( buffer, mod_bytes );
for( short i = 0; i < mod_bytes/step; ++i){
memcpy(&tmp, buffer+(i*step), step);
- //X[row][idx++] = (double) tmp * pow((double)2, reader_hdr->fexp - tsprec_subval);
*X_ptr = tmp;
++X_ptr;
}//rof
-}
-/*
+}//cnuf
+/* NB:
* By default offset is reader_hdr->fnsubs --> for TMULTI_TXYXYS_TXVALS this is set to 1
*/
-
-
void Super_parser::readY( short row, int amt, char fexp, unsigned int _offset ){
unsigned int offset = (_offset == 0) ? reader_hdr->fnsub : _offset;
-
Rcpp::NumericMatrix::iterator rdit = ( Y_ptr + row );
- //unsigned char tfexp = 128;
int ctr = 0;
short step = tsprec_subval / 8;
//short step = 4;
@@ -114,14 +103,14 @@ void Super_parser::readY( short row, int amt, char fexp, unsigned int _offset )
for(short i = 0; i < LINE_MAX/step; ++i){
memcpy(&tmp, buffer+(i*4), step);
*rdit = (double) tmp;
- rdit = rdit + reader_hdr->fnsub;
+ rdit = rdit + offset;
}//rof
}//elihw
ifstr->read( buffer, mod_bytes );
for( short i = 0; i < mod_bytes/step; ++i){
memcpy(&tmp, buffer+(i*step), step);
*rdit = (double) tmp;
- rdit = rdit + reader_hdr->fnsub;
+ rdit = rdit + offset;
}//rof
}//fi
else{
@@ -131,21 +120,17 @@ void Super_parser::readY( short row, int amt, char fexp, unsigned int _offset )
for (short i = 0; i < LINE_MAX / step; ++i){
memcpy(&tmp, buffer+(i*step), step);
*rdit = (double) tmp * pow((double)2, fexp - tsprec_subval);
- rdit = rdit + reader_hdr->fnsub;
+ rdit = rdit + offset;
}//rof
}//elihw
ifstr->read( buffer, mod_bytes );
for( short i = 0; i < mod_bytes/step; ++i){
memcpy(&tmp, buffer+(i*step), step);
*rdit = (double) tmp * pow((double)2, fexp - tsprec_subval);
- rdit = rdit + reader_hdr->fnsub;
+ rdit = rdit + offset;
}//rof
}//esle
-}
-
-
-
-
+}//cnuf
short Super_parser::read_log(){
//seekg(JUMP, ios::cur);
@@ -153,7 +138,6 @@ short Super_parser::read_log(){
return logs_to_collect;
}
ifstr->read( (char*) &logstc, LOGSTCSZ );
-
string str;
string label;
string value;
@@ -184,16 +168,14 @@ short Super_parser::read_log(){
}//fi
}//elihw
return (logs_to_collect - logs_collected); //return the numer of log values not collected
-}
+}//cnuf
//test function - remove
void Super_parser::print_stored_log(){
for( std::map< std::string, std::string >::const_iterator it = labeltovalue.begin(); it != labeltovalue.end(); ++it ){
std::cout << it->first << ":\t" << it->second << std::endl;
- }
-}
-
-
+ }//rof
+}//cnuf
void Super_parser::get_hdr_data(std::vector< std::string >* hdr2data){
set_hdr_map();
@@ -206,7 +188,7 @@ void Super_parser::get_hdr_data(std::vector< std::string >* hdr2data){
}//rof
}//cnuf
-void Super_parser::arrange_data( Rcpp::CharacterVector& extranames, Rcpp::List& extralist ){
+void Super_parser::arrange_data( Rcpp::CharacterVector& extranames, Rcpp::List& extralist, short dimension ){
extranames(0) = "z";
extranames(1) = "z.end";
int c = 2;
@@ -216,12 +198,22 @@ void Super_parser::arrange_data( Rcpp::CharacterVector& extranames, Rcpp::List&
}//rof
extralist.names() = extranames;
- extralist["z"] = extralist["z.end"] = reader_hdr->fztype;
+ Rcpp::CharacterVector tmp( dimension );
+ stringstream ss;
+ string z = convert_to_str( reader_hdr->fztype, ss );
+ for( short i = 0; i < dimension; ++i ){
+ tmp(i) = z;
+ }//rof
+ extralist["z"] = Rcpp::clone(tmp);
+ extralist["z.end"] = Rcpp::clone(tmp);
for( map<string, string>::const_iterator it = labeltovalue.begin(); it != labeltovalue.end(); ++it ){
- extralist[it->first] = it->second;
+ for( short i = 0; i < dimension; ++i){
+ tmp(i) = it->second;
+ }//rof
+ extralist[it->first] = Rcpp::clone(tmp);
}//rof
-}
+}//cnuf
void Super_parser::parse_directory( Rcpp::NumericVector::iterator description_vector_it ){
if(!hasDirectory) return;
@@ -237,88 +229,109 @@ void Super_parser::parse_directory( Rcpp::NumericVector::iterator description_ve
use a simple insertion sort to sort the offsets and stores the index positions
- a quicksort is not much use with small sizes and insertion sort acts well with presorted / partially sorted data
*/
- int j; int tmp; int tmp_idx;
- for(unsigned int i = 1; i < nsub; ++i ){
- if( offsets[i] < offsets[i-1] ){
- tmp = offsets[i];
- tmp_idx = offset_indices[i];
- j = i;
- do{
- offsets[j] = offsets[j-1];
- offset_indices[j] = offset_indices[j-1];
- --j;
- }while(j>0 && tmp < offsets[j-1]);
- offsets[j] = tmp;
- offset_indices[j] = tmp_idx;
- }
+ int j; int tmp; int tmp_idx;
+ for(unsigned int i = 1; i < nsub; ++i ){
+ if( offsets[i] < offsets[i-1] ){
+ tmp = offsets[i];
+ tmp_idx = offset_indices[i];
+ j = i;
+ do{
+ offsets[j] = offsets[j-1];
+ offset_indices[j] = offset_indices[j-1];
+ --j;
+ }while(j>0 && tmp < offsets[j-1]);
+ offsets[j] = tmp;
+ offset_indices[j] = tmp_idx;
}
- for( unsigned int i = 0; i < reader_hdr->fnsub; ++i ){
- *description_vector_it = offset_indices[i];
- ++description_vector_it;
- }
- delete [] offsets;
- delete [] offset_indices;
- }//cnuf
+ }
+ for( unsigned int i = 0; i < reader_hdr->fnsub; ++i ){
+ *description_vector_it = offset_indices[i];
+ ++description_vector_it;
+ }
+ delete [] offsets;
+ delete [] offset_indices;
+}//cnuf
//make the whole map a string map;
//this is a little more time consuming than we want but:
//a) it avoids a lot of trouble trying to handle the struct types..
//b) it is a constant independent of the size of the data
//c) it is quite small
void Super_parser::set_hdr_map(){//nb check char versions..
- hdr_map.insert(std::make_pair("ftflgs", convert_to_str(reader_hdr->ftflgs)));
- hdr_map.insert(std::make_pair("fversn", convert_to_str(reader_hdr->fversn)));
- hdr_map.insert(std::make_pair("fexper", convert_to_str(reader_hdr->fexper)));
- hdr_map.insert(std::make_pair("fexp", convert_to_str(reader_hdr->fexp)));
- hdr_map.insert(std::make_pair("fnpts", convert_to_str((int)reader_hdr->fnpts)));
- hdr_map.insert(std::make_pair("ffirst", convert_to_str(reader_hdr->ffirst)));
- hdr_map.insert(std::make_pair("flast", convert_to_str(reader_hdr->flast)));
- hdr_map.insert(std::make_pair("fnsub", convert_to_str((int)reader_hdr->fnsub)));
- hdr_map.insert(std::make_pair("fxtype", convert_to_str(reader_hdr->fxtype)));
- hdr_map.insert(std::make_pair("fytype", convert_to_str(reader_hdr->fytype)));
- hdr_map.insert(std::make_pair("fztype", convert_to_str(reader_hdr->fztype)));
- hdr_map.insert(std::make_pair("fpost", convert_to_str(reader_hdr->fpost)));
- hdr_map.insert(std::make_pair("fdate", convert_to_str((int)reader_hdr->fdate)));
- string tmp_str(reader_hdr->fres, 8);
- hdr_map.insert(std::make_pair("fres", tmp_str ));// null terminated[]?but is it?
- tmp_str.assign(reader_hdr->fsource, 8);
- hdr_map.insert(std::make_pair("fsource", tmp_str));// null terminated[]?but is it?
- hdr_map.insert(std::make_pair("fpeakpt", convert_to_str(reader_hdr->fpeakpt)));
- string fsp_str = "";
- for(int i = 0; i < 8; ++i){
- fsp_str = fsp_str + convert_to_str(reader_hdr->fspare[i]) + ',';
- }
- hdr_map.insert(std::make_pair("fspare", fsp_str));//float[8]
- tmp_str.assign(reader_hdr->fcmnt,129);
- hdr_map.insert(std::make_pair("fcmnt", reader_hdr->fcmnt));// null terminated[]
- tmp_str = "";
- for(int i = 0; i < 30; ++i){
- tmp_str = tmp_str + "" + (( reader_hdr->fcatxt[i] == '\0' ) ? ',' : reader_hdr->fcatxt[i]);
- }
- hdr_map.insert(std::make_pair("fcatxt", tmp_str));//[] fcatxt has 3 values separated by nulls
- hdr_map.insert(std::make_pair("flogoff", convert_to_str((int)reader_hdr->flogoff)));
- hdr_map.insert(std::make_pair("fmods", convert_to_str((int)reader_hdr->fmods)));
- hdr_map.insert(std::make_pair("fprocs", convert_to_str(reader_hdr->fprocs)));
- hdr_map.insert(std::make_pair("flevel", convert_to_str(reader_hdr->flevel)));
- hdr_map.insert(std::make_pair("fsampin", convert_to_str(reader_hdr->fsampin)));
- hdr_map.insert(std::make_pair("ffactor", convert_to_str(reader_hdr->ffactor)));
- tmp_str.assign(reader_hdr->fmethod, 48);
- hdr_map.insert(std::make_pair("fmethod", tmp_str));//[]
- hdr_map.insert(std::make_pair("fzinc", convert_to_str(reader_hdr->fzinc)));
- hdr_map.insert(std::make_pair("fwplanes", convert_to_str((int)reader_hdr->fwplanes)));
- hdr_map.insert(std::make_pair("fwinc", convert_to_str(reader_hdr->fwinc)));
- hdr_map.insert(std::make_pair("fwtype", convert_to_str(reader_hdr->fwtype)));
- // hdr_map.insert(std::make_pair("freserv", convert_to_str(reader_hdr->freserv)));
+ stringstream ss;
+ hdr_map.insert(std::make_pair("ftflgs", convert_to_str(reader_hdr->ftflgs,ss)));
+ hdr_map.insert(std::make_pair("fversn", convert_to_str(reader_hdr->fversn,ss)));
+ hdr_map.insert(std::make_pair("fexper", get_fexper(reader_hdr->fexper)));
+ hdr_map.insert(std::make_pair("fexp", convert_to_str(reader_hdr->fexp,ss)));
+ hdr_map.insert(std::make_pair("fnpts", convert_to_str((int)reader_hdr->fnpts,ss)));
+ hdr_map.insert(std::make_pair("ffirst", convert_to_str(reader_hdr->ffirst,ss)));
+ hdr_map.insert(std::make_pair("flast", convert_to_str(reader_hdr->flast,ss)));
+ hdr_map.insert(std::make_pair("fnsub", convert_to_str((int)reader_hdr->fnsub,ss)));
+ hdr_map.insert(std::make_pair("fxtype", convert_to_str(reader_hdr->fxtype,ss)));
+ hdr_map.insert(std::make_pair("fytype", convert_to_str(reader_hdr->fytype,ss)));
+ hdr_map.insert(std::make_pair("fztype", convert_to_str(reader_hdr->fztype,ss)));
+ hdr_map.insert(std::make_pair("fpost", convert_to_str(reader_hdr->fpost,ss)));
+ hdr_map.insert(std::make_pair("fdate", convert_to_str((int)reader_hdr->fdate,ss)));
+ string tmp_str(reader_hdr->fres, 8);
+ hdr_map.insert(std::make_pair("fres", tmp_str ));// null terminated[]?but is it?
+ tmp_str.assign(reader_hdr->fsource, 8);
+ hdr_map.insert(std::make_pair("fsource", tmp_str));// null terminated[]?but is it?
+ hdr_map.insert(std::make_pair("fpeakpt", convert_to_str(reader_hdr->fpeakpt,ss)));
+ string fsp_str = "";
+ for(int i = 0; i < 8; ++i){
+ fsp_str = fsp_str + convert_to_str(reader_hdr->fspare[i],ss) + ',';
+ }
+ hdr_map.insert(std::make_pair("fspare", fsp_str));//float[8]
+ tmp_str.assign(reader_hdr->fcmnt,129);
+ hdr_map.insert(std::make_pair("fcmnt", reader_hdr->fcmnt));// null terminated[]
+ tmp_str = "";
+ for(int i = 0; i < 30; ++i){
+ tmp_str = tmp_str + "" + (( reader_hdr->fcatxt[i] == '\0' ) ? ',' : reader_hdr->fcatxt[i]);
+ }
+ hdr_map.insert(std::make_pair("fcatxt", tmp_str));//[] fcatxt has 3 values separated by nulls
+ hdr_map.insert(std::make_pair("flogoff", convert_to_str((int)reader_hdr->flogoff,ss)));
+ hdr_map.insert(std::make_pair("fmods", convert_to_str((int)reader_hdr->fmods,ss)));
+ hdr_map.insert(std::make_pair("fprocs", convert_to_str(reader_hdr->fprocs,ss)));
+ hdr_map.insert(std::make_pair("flevel", convert_to_str(reader_hdr->flevel,ss)));
+ hdr_map.insert(std::make_pair("fsampin", convert_to_str(reader_hdr->fsampin,ss)));
+ hdr_map.insert(std::make_pair("ffactor", convert_to_str(reader_hdr->ffactor,ss)));
+ tmp_str.assign(reader_hdr->fmethod, 48);
+ hdr_map.insert(std::make_pair("fmethod", tmp_str));//[]
+ hdr_map.insert(std::make_pair("fzinc", convert_to_str(reader_hdr->fzinc,ss)));
+ hdr_map.insert(std::make_pair("fwplanes", convert_to_str((int)reader_hdr->fwplanes,ss)));
+ hdr_map.insert(std::make_pair("fwinc", convert_to_str(reader_hdr->fwinc,ss)));
+ hdr_map.insert(std::make_pair("fwtype", convert_to_str(reader_hdr->fwtype,ss)));
+ // hdr_map.insert(std::make_pair("freserv", convert_to_str(reader_hdr->freserv)));
+}
+
+string Super_parser::get_fexper(short fexper){
+ switch(fexper){
+ case SPCGEN : return("General");
+ case SPCGC : return("Gas Chromatogram");
+ case SPCCGM : return("General Chromatogram");
+ case SPCHPLC : return("HPLC Chromatogram");
+ case SPCFTIR : return("NIR Spectrum");
+ case SPCNIR : return("UV-VIS Spectrum");
+ case SPCUV : return("* reserved *");
+ case SPCXRY : return( "X-ray diffraction spectrum");
+ case SPCMS : return("Mass Spectrum");
+ case SPCNMR : return("NMR Spectrum");
+ case SPCRMN : return("Raman Spectrum");
+ case SPCFLR : return("Fluorescence Spectrum");
+ case SPCATM : return("Atomic Spectrum");
+ case SPCDAD : return("Chroatography Diode Array Data");
+ default: return("General");
+ }
}
-string Super_parser::convert_to_str(int number)
-{
- stringstream ss;//create a stringstream
+inline string Super_parser::convert_to_str(int number, stringstream& ss ){
+ ss.clear();
+ ss.str("");
ss << number;//add number to the stream
return ss.str();//return a string with the contents of the stream
}
-string Super_parser::convert_to_str(double number)
-{
- stringstream ss;//create a stringstream
+inline string Super_parser::convert_to_str(double number, stringstream& ss ){
+ ss.clear();
+ ss.str("");
ss << number;//add number to the stream
return ss.str();//return a string with the contents of the stream
}
View
38 src/Super_parser.h
@@ -23,21 +23,14 @@
#include "SPC.h"
-//#include "SPC_reader.h"
-
-//class SPC_reader;
-
class Super_parser{
private:
protected:
Rcpp::NumericVector::iterator X_ptr;
Rcpp::NumericMatrix::iterator Y_ptr;
- //std::map< std::string, bool > hdr2data;
std::map< std::string, bool > log2data;
-
-
+ std::map<std::string, std::string >hdr_map;
public:
- //SPC_reader * holder_reader;
std::ifstream* ifstr;
SPC* reader_hdr;
SUBHDR subhdr;
@@ -50,9 +43,8 @@ class Super_parser{
bool want_log_but_no_log;
short logs_to_collect;
short uncollected;
- //std::map< std::string, std::string > log_labeltovalue; //these involve a slight overhead in copying the hdr strings, but it is minor since amount is small
- std::map< std::string, std::string > labeltovalue;
- std::map<std::string, std::string >hdr_map;
+ std::map< std::string, std::string > labeltovalue; ////these involve a slight overhead in copying the hdr strings, but it is minor since amount is small
+
bool hasDirectory;
@@ -63,8 +55,6 @@ class Super_parser{
prec_shifts = tsprec_subval == 32 ? 5 : 4;
get_hdr_data(ipt_hdr2data);
check_log(ipt_log2data);
-
-
}//rotcurtsnoc
//2nd ctr - used for TXYXYS..
Super_parser( std::ifstream* ipt_ifstr, SPC* ipt_reader_hdr, short ipt_tsprec_subval, std::vector< std::string >* ipt_log2data, std::vector< std::string >* ipt_hdr2data )
@@ -72,7 +62,6 @@ class Super_parser{
prec_shifts = tsprec_subval == 32 ? 5 : 4;
get_hdr_data(ipt_hdr2data);
check_log(ipt_log2data);
-
}
void check_log( std::vector< std::string >* check_log2data );
@@ -89,38 +78,25 @@ class Super_parser{
}
virtual ~Super_parser(){}
virtual void readX( int amt = 0);
-
/*
* By default offset is reader_hdr->fnsubs --> for TMULTI_TXYXYS_TXVALS this is set to 1
*/
void readY(short row, int amt, char fexp, unsigned int _offset = 0);
-
void parse_directory( Rcpp::NumericVector::iterator it );
bool has_directory(){return hasDirectory;}
- /*
- void read_proc_logstc(){
- ifstr->read( (char*) &logstc, LOGSTCSZ );
- }
- */
short read_log();//DO
void print_stored_log();
void read_process_subhdr();
void set_hdr_map();
+ std::string get_fexper(short fexper);
void get_hdr_data(std::vector< std::string>* ipt_hdr2data);
- void arrange_data( Rcpp::CharacterVector& extranames, Rcpp::List& extralist );
+ void arrange_data( Rcpp::CharacterVector& extranames, Rcpp::List& extralist, short dimension );
- //virtual Rcpp::NumericMatrix* getX() = 0;
- //virtual Rcpp::NumericMatrix* getY() = 0;
-
- //virtual void print_Y() = 0;
-
- std::string convert_to_str(int n);
- std::string convert_to_str(double n);
+ std::string convert_to_str(int n, std::stringstream& ss );
+ std::string convert_to_str(double n, std::stringstream& ss);
std::string convert_to_str(std::string str){ return str; }
-
-
};
#endif
View
113 src/rcpp_read_spc.cpp
@@ -123,96 +123,57 @@ RcppExport SEXP rcpp_read_spc( SEXP _file, SEXP _hdr2data, SEXP _log2data,
//switch( spcrdr->hdr.ftflgs ){ //we use polymorphism, but the matrices must be passed in from outside
switch( switch_flg ){
case 0 :{
- cout << "Case: " << (int) spcrdr->hdr.ftflgs << endl;
-
+ //cout << "Case: " << (int) spcrdr->hdr.ftflgs << endl;
Rcpp::NumericMatrix Y(1, spcrdr->hdr.fnpts );
-
-
- //Rcpp::Language hyObj_call("new", "hyperSpec");
- //Rcpp::S4 hyObj( hyObj_call.eval() );
-
spcrdr->parser = new Basic_parser( &spcrdr->ifstr, &spcrdr->hdr, spcrdr->tsprec_subval, X.begin(), Y.begin(), &log2data, &hdr2data );
-
- //Rcpp::DataFrame df = Rcpp::DataFrame::create( Rcpp::Named("spc") = Rcpp::NumericVector(1) );
-
spcrdr->parser->parse_file();
//spcrdr->print_SPCHDR();
-
- //spcrdr->parser->log_labeltovalue.size()
short list_sz = spcrdr->parser->labeltovalue.size() + 2;
Rcpp::List extralist( list_sz );//include hdr values here also!!!
Rcpp::CharacterVector extranames( list_sz ); //include hdr values here also!!!
-
- spcrdr->parser->arrange_data(extranames, extralist);
-
-
- Rprintf("extralist made\n");
-
-
-
-// Rcpp::CharacterVector datanames(spcrdr->parser->log_labeltovalue.size());
-
+ spcrdr->parser->arrange_data( extranames, extralist, 1 );//1 dimension
+ //SORT OUT WARNINGS!!!
if(spcrdr->parser->want_log_but_no_log == 1){
cout << "WARNING: want log but no log" << endl;
}//fi
+ Rcpp::Language licall( "print", extralist );
+ licall.eval();
+ Rcpp::DataFrame data1 = Rcpp::DataFrame::create( extralist );
+ Rcpp::Language dfcall("print",data1);
+ dfcall.eval();
-
-
- /*
- for(Rcpp::List::iterator lit = extralist.begin(); lit != extralist.end(); ++lit){
- cout<<"printing:"<<endl;
- Rcpp::Language list_call("print", *lit);
- list_call.eval();
- }//rof
- */
- Rprintf("extralistsize: %i", extralist.size());
- Rcpp::DataFrame data1 = Rcpp::DataFrame::create(extralist);
- Rcpp::Language data_check("eval", data1);
- Rcpp::Language data_print("print", data_check.eval());
- data_print.eval();
- Rprintf("forming object\n");
Rcpp::Language hyObj_call( "new", "hyperSpec", Rcpp::Named("spc") = Y, Rcpp::Named("wavelength") = X, Rcpp::Named("data") = data1 ); //log = log, label = lab
- //Rcpp::Language hyObj_call( "new", "hyperSpec", Rcpp::Named("spc") = Y, Rcpp::Named("wavelength") = X );
- Rprintf("formed object\n");
- Rprintf("here 1\n");
- //Rcpp::Language printcall("print", hyObj_call.eval()); //<-error here, from object formation no doubt...
- //printcall.eval();
return hyObj_call.eval();
- Rprintf("here 2\n");
- Rcpp::S4 hyObj( hyObj_call.eval());
- Rprintf("formed S4 object\n");
- Rcpp::Language hysum("summary", hyObj);
- Rcpp::Language printsum("print", hysum.eval());
- printsum.eval();
- return hyObj;
break;
}//esac
case TMULTI :{
- cout << "Case: " << spcrdr->hdr.ftflgs << endl;
+ Rprintf("Case: %i\n",spcrdr->hdr.ftflgs);
Rcpp::NumericMatrix Y(spcrdr->hdr.fnsub, spcrdr->hdr.fnpts );
spcrdr->parser = new TMULTI_parser( &spcrdr->ifstr, &spcrdr->hdr, spcrdr->tsprec_subval, X.begin(), Y.begin(), &log2data, &hdr2data );
spcrdr->parser->parse_file();
- spcrdr->print_SPCHDR();
- cout << endl;
- cout << "Y values" << endl;
- for(unsigned int i = 0; i < spcrdr->hdr.fnsub; ++i){
- cout << "row: " << i + 1 << endl;
- for(unsigned int j = 0; j < spcrdr->hdr.fnpts; ++j ){
- cout << j+1 <<": " << setprecision(12) << Y(i,j) << endl;
- }//rof
- }//rof
- cout << endl;
- cout << "X values:" << endl;
- for(unsigned int i = 0; i < spcrdr->hdr.fnpts; ++i ){
- cout << setprecision(12) << X(i) << endl;
- }//rof
+ //spcrdr->print_SPCHDR();
+ /*
cout << "Subexps: " << endl;
for( vector<int>::const_iterator it = spcrdr->parser->subexps.begin(); it != spcrdr->parser->subexps.end(); ++it){
cout << *it << endl;
}//rof
+ */
+ short list_sz = spcrdr->parser->labeltovalue.size() + 2;
+ Rcpp::List extralist( list_sz );//include hdr values here also!!!
+ Rcpp::CharacterVector extranames( list_sz ); //include hdr values here also!!!
+ spcrdr->parser->arrange_data( extranames, extralist, spcrdr->hdr.fnsub );
+ //SORT OUT WARNINGS!!!
+ if(spcrdr->parser->want_log_but_no_log == 1){
+ cout << "WARNING: want log but no log" << endl;
+ }//fi
+
+
+ Rcpp::DataFrame data1 = Rcpp::DataFrame::create(extralist);
+ Rcpp::Language hyObj_call( "new", "hyperSpec", Rcpp::Named("spc") = Y, Rcpp::Named("wavelength") = X, Rcpp::Named("data") = data1 ); //log = log, label = lab
+ return hyObj_call.eval();
break;
}
@@ -221,17 +182,21 @@ RcppExport SEXP rcpp_read_spc( SEXP _file, SEXP _hdr2data, SEXP _log2data,
Rcpp::NumericMatrix Y(1, spcrdr->hdr.fnpts );
spcrdr->parser = new TXVALS_parser( &spcrdr->ifstr, &spcrdr->hdr, spcrdr->tsprec_subval, X.begin(), Y.begin(), &log2data, &hdr2data );
spcrdr->parser->parse_file();
- spcrdr->print_SPCHDR();
- cout << endl;
- cout << "X values:" << endl;
- for(unsigned int i = 0; i < spcrdr->hdr.fnpts; ++i ){
- cout << setprecision(12) << X(i) << endl;
- }//rof
- cout << "Y values:" << endl;
- for(unsigned int i = 0; i < spcrdr->hdr.fnpts; ++i ){
- cout << setprecision(12) << Y(0,i) << endl;
- }//rof
+ //spcrdr->print_SPCHDR();
+ short list_sz = spcrdr->parser->labeltovalue.size() + 2;
+ Rcpp::List extralist( list_sz );//include hdr values here also!!!
+ Rcpp::CharacterVector extranames( list_sz ); //include hdr values here also!!!
+ spcrdr->parser->arrange_data( extranames, extralist, 1 );
+ //SORT OUT WARNINGS!!!
+ if(spcrdr->parser->want_log_but_no_log == 1){
+ cout << "WARNING: want log but no log" << endl;
+ }//fi
+ Rprintf("SUBNPTS: %i\n", spcrdr->parser->subhdr.subnpts);
+
+ Rcpp::DataFrame data1 = Rcpp::DataFrame::create(extralist);
+ Rcpp::Language hyObj_call( "new", "hyperSpec", Rcpp::Named("spc") = Y, Rcpp::Named("wavelength") = X, Rcpp::Named("data") = data1 ); //log = log, label = lab
+ return hyObj_call.eval();
break;
}
Please sign in to comment.
Something went wrong with that request. Please try again.