diff --git a/stim/envi/binary.h b/stim/envi/binary.h index 6650661..e2eb6b4 100644 --- a/stim/envi/binary.h +++ b/stim/envi/binary.h @@ -3,8 +3,8 @@ #ifndef RTS_BINARY_H #define RTS_BINARY_H -#include "../envi/envi_header.h" -#include "../math/vector.h" +#include +#include #include #include #include @@ -134,73 +134,6 @@ public: } } } - - /*// this function updates the optimizer, given the number of bytes processed in an interval and time spent processing - size_t update(size_t bytes_processed, size_t ms_spent){ - interval_B += bytes_processed; //increment the number of bytes processed - interval_ms += ms_spent; //increment the number of milliseconds spent processing - - //if we have sufficient information to evaluate the optimization function at this point - if(interval_ms >= window_ms){ //if sufficient time has passed to get a reliable Bps measurement - size_t new_Bps = interval_B / interval_ms; //calculate the current Bps - - if(sample_step){ //if this is a sample step, collect the information for Bps = f(n0) - Bps = new_Bps; //set the Bps to the evaluated value - n[1] = n[0] - dn; //reduce the batch size by one delta to take a second sample - if(n[1] == 0){ //if the resulting batch size is zero - n[1] = 2*dn; //we're at the left edge: set the new sample point to 2*dn - } - - interval_B = interval_ms = 0; //start a new interval at the new sample point - sample_step = false; //next step will calculate the new batch size via optimization - return n[1]; //return the new batch size - } - else{ //if we have sufficient information to evaluate the derivative and optimize - double f = (double)new_Bps; //we have evaluated the function at this location - double fprime; - if(n[1] < n[0] ){ //if the new point is less than the previous point (usually the case) - fprime = (double)(Bps - new_Bps) / (double)dn; //calculate the forward difference - } - else{ //if the new point is larger (only happens at the minimum limit) - fprime = (double)(new_Bps - Bps) / (double)dn; //calculate the backward difference - } - size_t bestn = n[1] - (size_t)(f / fprime); //calculate the best value for B using Newton's method - n[0] = round_limit( (size_t)bestn ); //set the new dependent point - sample_step = true; //the next step will be a sample step - } - - } - if(sample_step) return n[0]; - return n[1]; //insufficient information, keep the same batch size - }*/ - - /*size_t update(size_t bytes_processed, size_t ms_spent){ - interval_B += bytes_processed; //increment the number of bytes processed - interval_ms += ms_spent; //increment the number of milliseconds spent processing - - //if( Bps[0] == 0 ){ //if the left boundary hasn't been processed - - - //if we have sufficient information to evaluate the optimization function at this point - if(interval_ms >= window_ms){ - size_t new_Bps = interval_B / interval_ms; //calculate the current Bps - - if(Bps[0] == 0) //if the left interval Bps hasn't been calculated - Bps[0] = interval_B / interval_ms; //that is the interval being processed - else - Bps[1] = interval_B / interval_ms; //otherwise the right interval is being processed - - if(Bps[0] != 0 && Bps[1] != 0){ //if both intervals have been processed - - - } - }*/ - - /*size_t update(size_t bytes_processed, size_t ms_spent, size_t& data_rate, bool VERBOSE){ - size_t time = update(bytes_processed, ms_spent, VERBOSE); - data_rate = Bps[0]; - return time; - }*/ }; /** This class manages the streaming of large multidimensional binary files. @@ -356,6 +289,10 @@ public: return test_file_size(); } + bool is_open() { + return file.is_open(); + } + /// Creates a new binary file for streaming /// @param filename is the name of the binary file to be created diff --git a/stim/envi/bsq.h b/stim/envi/bsq.h index dc6a814..8297e30 100644 --- a/stim/envi/bsq.h +++ b/stim/envi/bsq.h @@ -1,9 +1,9 @@ #ifndef STIM_BSQ_H #define STIM_BSQ_H -#include "../envi/envi_header.h" -#include "../envi/hsi.h" -#include "../envi/bil.h" +#include +#include +#include #include #include #include diff --git a/stim/envi/envi.h b/stim/envi/envi.h index 6ae2416..28e58bd 100644 --- a/stim/envi/envi.h +++ b/stim/envi/envi.h @@ -1,11 +1,11 @@ #ifndef STIM_ENVI_H #define STIM_ENVI_H -#include "../envi/envi_header.h" -#include "../envi/bsq.h" -#include "../envi/bip.h" -#include "../envi/bil.h" -#include "../math/fd_coefficients.h" +#include +#include +#include +#include +#include #include #include #include @@ -71,7 +71,7 @@ public: file = NULL; //set the file pointer to NULL } - envi(std::string filename, std::string headername){ + envi(std::string filename, std::string headername) : envi(){ header.load(headername); fname = filename; //save the filename @@ -80,8 +80,36 @@ public: } //used to test if the current ENVI file is valid operator bool(){ - if(file == NULL) return false; - return true; + if (header.interleave == envi_header::BSQ) { //if the infile is bsq file + if (header.data_type == envi_header::float32) + return ((bsq*)file)->is_open(); + else if (header.data_type == envi_header::float64) + return ((bsq*)file)->is_open(); + else + std::cout << "ERROR: unidentified data type" << std::endl; + } + + else if (header.interleave == envi_header::BIL) { //if the infile is bil file + if (header.data_type == envi_header::float32) + return ((bil*)file)->is_open(); + else if (header.data_type == envi_header::float64) + return ((bil*)file)->is_open(); + else + std::cout << "ERROR: unidentified data type" << std::endl; + } + + else if (header.interleave == envi_header::BIP) { //if the infile is bip file + if (header.data_type == envi_header::float32) + return ((bip*)file)->is_open(); + else if (header.data_type == envi_header::float64) + return ((bip*)file)->is_open(); + else + std::cout << "ERROR: unidentified data type" << std::endl; + } + else { + std::cout << "ERROR: unidentified file type" << std::endl; + exit(1); + } } //test to determine if the specified file is an ENVI file diff --git a/stim/envi/hsi.h b/stim/envi/hsi.h index 127158b..665b749 100644 --- a/stim/envi/hsi.h +++ b/stim/envi/hsi.h @@ -1,8 +1,8 @@ #ifndef STIM_HSI_H #define STIM_HSI_H -#include "../envi/envi_header.h" -#include "../envi/binary.h" +#include +#include #include #include -- libgit2 0.21.4