00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "pdscalibdata/NDArrIOV1.h"
00019
00020 #include <string>
00021 #include <iostream>
00022
00023
00024
00025 using namespace std;
00026
00027 typedef pdscalibdata::NDArrIOV1<float,3> NDAIO;
00028
00029 int main ()
00030 {
00031
00032 cout << "Test of pdscalibdata::NDArrIOV1\n";
00033
00034 const std::string fname("/reg/neh/home1/dubrovin/LCLS/PSANA-V01/pdscalibdata/test/test.data");
00035 unsigned int shape[] = {3,4,8};
00036 NDAIO *ndaio1 = new NDAIO(fname,shape);
00037
00038 cout << "\nPRINT TESTS:\n";
00039
00040 ndaio1->print();
00041 ndaio1->print_file();
00042 ndaio1->print_ndarray();
00043
00044
00045 const ndarray<const float,3>& nda = ndaio1->get_ndarray();
00046 cout << "\nTest local print:\n" << nda << '\n';
00047
00048
00049 std::string fname_test("/tmp/test_ndarrio_m.txt");
00050 cout << "\nTest save_ndarray:\n" << nda
00051 << "\nin file: " << fname_test << '\n';
00052 std::vector<std::string> v_comments;
00053 v_comments.push_back("TITLE File to load ndarray of calibration parameters");
00054 v_comments.push_back("");
00055 v_comments.push_back("EXPERIMENT amo12345");
00056 v_comments.push_back("DETECTOR Camp.0:pnCCD.1");
00057 v_comments.push_back("CALIB_TYPE pedestals");
00058 NDAIO::save_ndarray(nda, fname_test, v_comments);
00059
00060
00061 cout << "\nTest read ndarray from file: " << fname_test << '\n';
00062 NDAIO *ndaio2 = new NDAIO(fname_test, shape);
00063 ndaio2->print_ndarray();
00064
00065
00066 const std::string fname_bwc("/reg/neh/home1/dubrovin/LCLS/PSANA-V01/pdscalibdata/test/test_bwc.data");
00067 cout << "\nBackward compatability test read ndarray from file: " << fname_bwc << '\n';
00068 unsigned int shape_bwc[] = {2,3,4};
00069 NDAIO *ndaio3 = new NDAIO(fname_bwc, shape_bwc);
00070 ndaio3->print_ndarray();
00071
00072
00073 cout << "\nTest read ndarray from file with unknown shape: " << fname_test << '\n';
00074 NDAIO *ndaio4 = new NDAIO(fname_test);
00075 ndaio4->print_ndarray();
00076
00077 return 0;
00078 }