-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Reading FITS table columns embedding variable-length arrays #5099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reading FITS table columns embedding variable-length arrays #5099
Conversation
|
Can one of the admins verify this patch? |
| kRealNumber, // the column contains a scalar | ||
| kRealArray, // the column contains a fixed-length array | ||
| kRealVector // the column contains a variable-length array | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I try to use a nomenclature similar to C++ basic objects: a kRealArray is an array, i.e. an object of fixed length, a kRealVector is a vector, i.e. an object whose length is variable. Hope you approve it, the following checks are based on it.
|
@phsft-bot build! |
|
Starting build on |
|
Build failed on ROOT-fedora30/cxx14. Warnings:
|
|
Build failed on ROOT-fedora27/noimt. Warnings:
|
|
Build failed on ROOT-fedora29/python3. Warnings:
|
|
Build failed on ROOT-ubuntu16/nortcxxmod. Warnings:
|
|
Build failed on ROOT-performance-centos7-multicore/default. Warnings:
Failing tests: |
tutorials/fitsio/FITS_tutorial8.C
Outdated
| TArrayD *arr3 = hdu->GetTabVarLengthVectorCell(rownum, colname3); | ||
| printf("(%f, %f) \n", arr3->At(0), arr3->At(1)); | ||
|
|
||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add a new line at the end of the file :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
|
Build failed on windows10/cxx14. |
|
Build failed on ROOT-ubuntu18.04-i386/cxx14. Warnings:
|
graf2d/fitsio/src/TFITS.cxx
Outdated
|
|
||
| for (long row = 0; row < table_rows; row++) { | ||
| long offset = 0; | ||
| long repeat = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable name (see CI warnings) is already used in prior code. Either reduce the 'lifetime/scope' of the previous variable or rename this one to avoid (future developer reader the code) confusion. thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also done!
|
To 'fix' the Windows CI build, please fork the roottest repository (https://github.com/root-project/roottest) |
|
Hi @pcanal, I have implemented the changes you requested. 74% tests passed, 240 tests failed out of 934I don't know though if the tests that failed did it for the modification introduced by my patch. How am I supposed to interpret and share the test output? Thank you |
|
The Windows CI part requires that your github account has a fork of both the root repository (you already do) but also the roottest repository (you seem to now also do). |
|
@phsft-bot build with flags -DCTEST_TEST_EXCLUDE_NONE=On |
|
Starting build on |
|
Build failed on mac1014/cxx17. Errors:
Failing tests: |
|
The fit tutorials errors is |
|
I am sorry, I forgot to specify the tutorial dir, as at the beginning of the other tutorial scripts TString dir = gROOT->GetTutorialDir();
TFITSHDU* hdu = new TFITSHDU(dir + "/fitsio/rmf_obs5029747.fits", 1);It could execute only from |
|
@phsft-bot build with flags -DCTEST_TEST_EXCLUDE_NONE=On |
|
Starting build on |
|
Build failed on mac1014/cxx17. Errors:
Failing tests: |
|
Build failed on ROOT-fedora30/cxx14. Errors:
Failing tests: |
|
Build failed on ROOT-ubuntu16/nortcxxmod. Failing tests: |
|
The errors are unrelated. |
|
Build failed on windows10/cxx14. Errors:
|
graf2d/fitsio/src/TFITS.cxx
Outdated
| // TODO: add all type cases, for now only short, long, float and double are considered | ||
| // | ||
| if (abstype == 21) { | ||
| short data[size]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version or setup of Microsoft's compiler on Windows, does apparently not support this construct (array which a 'const int' size). You could try std::vector<short> data; data.resize(sizse);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also done,
I replaced the data array with a vector, as per your suggestion, and then passed the vector.data() array to the fits_read_col function requiring it.
|
Build failed on ROOT-ubuntu18.04-i386/cxx14. Errors:
Failing tests: |
|
Hi @pcanal, I changed the arrays with vectors, could you retry now? |
|
Starting build on |
|
@phsft-bot build with flags -DCTEST_TEST_EXCLUDE_NONE=On |
|
Starting build on |
|
Build failed on ROOT-ubuntu18.04-i386/cxx14. Failing tests: |
|
Hi @pcanal, could you wait before merging? I am doing some more tests with a file with larger arrays in columns. |
|
Hello, Therefore I included one of the test files that are shipped with the sherpa X-ray analysis tools. I changed the input file and the tutorial, sorry if you have to run the tests again. |
|
@phsft-bot build with flags -DCTEST_TEST_EXCLUDE_NONE=On |
|
Starting build on |
|
Build failed on ROOT-fedora30/cxx14. Failing tests: |
|
Build failed on ROOT-ubuntu16/nortcxxmod. Failing tests: |
|
Hello @Axel-Naumann, @pcanal, are the failed test related to my patch? |
No, sorry about that - please ignore them.
I'd like @pcanal to have the final say here. |
|
@cosimoNigro thank you for the PR :) |
Dear ROOT developers,
this Pull Request tries to address this issue I have opened in the ROOT forum.
A limitation of the
TFITSHDUclass was its impossibility to read within columns of a FITS table containing a variable-length array. My patch adds such a possibility.I have modified the
ColumnandCellstructs adding objects necessary to read a variable-length arrays embedded in a cell. TheLoadHDUfunction (fundamentally the initialiser of theTFITSHDUclass) was modified accordingly such that this objects could be assigned.I have modified the functions dealing with printing and reading values from a table such that the occurrence of a column with variable-length arrays embedded can be properly signalled.
In order not to interfere with the previous development of data handling I created a function to read within a cell for this specific case: it is called
GetTabVarLengthVectorCell. I believe it does not make sense to read the entire column in this case (returning an array of variable-length arrays). The user is allowed to access the single cell, when attempting to use any other function (e.g.GetTabRealVectorColumn) to read the entire column, a warning is issued pointing him to this specific function.Last I added a tutorial in
tutorials/fitsio/FITS_tutorial8.Cwith a test file illustrating the application of this case.I would kindly ask for a review,
Best
Cosimo