Skip to content

Conversation

@cosimoNigro
Copy link
Contributor

Dear ROOT developers,

this Pull Request tries to address this issue I have opened in the ROOT forum.

A limitation of the TFITSHDU class 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 Column and Cell structs adding objects necessary to read a variable-length arrays embedded in a cell. TheLoadHDU function (fundamentally the initialiser of the TFITSHDU class) 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.C with a test file illustrating the application of this case.

I would kindly ask for a review,

Best

Cosimo

@cosimoNigro cosimoNigro requested a review from couet as a code owner March 7, 2020 11:47
@phsft-bot
Copy link

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
};
Copy link
Contributor Author

@cosimoNigro cosimoNigro Mar 7, 2020

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.

@cosimoNigro cosimoNigro changed the title Reading FITS table columns embedding variable-lengths arrays Reading FITS table columns embedding variable-length arrays Mar 7, 2020
@Axel-Naumann Axel-Naumann requested a review from pcanal March 9, 2020 13:37
@Axel-Naumann
Copy link
Member

@phsft-bot build!

@phsft-bot
Copy link

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-fedora30/cxx14, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu18.04-i386/cxx14, mac1014/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-fedora30/cxx14.
See console output.

Warnings:

  • /build/workspace/root-pullrequests-build/root/graf2d/fitsio/src/TFITS.cxx:541:21: warning: declaration of ‘repeat’ shadows a previous local [-Wshadow]

@phsft-bot
Copy link

Build failed on ROOT-fedora27/noimt.
See console output.

Warnings:

  • /mnt/build/workspace/root-pullrequests-build/root/graf2d/fitsio/src/TFITS.cxx:541:21: warning: declaration of ‘repeat’ shadows a previous local [-Wshadow]

@phsft-bot
Copy link

Build failed on ROOT-fedora29/python3.
See console output.

Warnings:

  • /mnt/build/workspace/root-pullrequests-build/root/graf2d/fitsio/src/TFITS.cxx:541:21: warning: declaration of ‘repeat’ shadows a previous local [-Wshadow]

@phsft-bot
Copy link

Build failed on ROOT-ubuntu16/nortcxxmod.
See console output.

Warnings:

  • /mnt/build/workspace/root-pullrequests-build/root/graf2d/fitsio/src/TFITS.cxx:541:21: warning: declaration of ‘repeat’ shadows a previous local [-Wshadow]

@phsft-bot
Copy link

Build failed on ROOT-performance-centos7-multicore/default.
See console output.

Warnings:

  • /data/sftnight/workspace/root-pullrequests-build/root/graf2d/fitsio/src/TFITS.cxx:541:21: warning: declaration of ‘repeat’ shadows a previous local [-Wshadow]
  • /data/sftnight/workspace/root-pullrequests-build/root/graf2d/fitsio/src/TFITS.cxx:385:12: warning: shadowed declaration is here [-Wshadow]

Failing tests:

TArrayD *arr3 = hdu->GetTabVarLengthVectorCell(rownum, colname3);
printf("(%f, %f) \n", arr3->At(0), arr3->At(1));

} No newline at end of file
Copy link
Member

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 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@phsft-bot
Copy link

Build failed on windows10/cxx14.
See console output.

@phsft-bot
Copy link

Build failed on ROOT-ubuntu18.04-i386/cxx14.
See console output.

Warnings:

  • /home/sftnight/build/workspace/root-pullrequests-build/root/graf2d/fitsio/src/TFITS.cxx:541:21: warning: declaration of ‘repeat’ shadows a previous local [-Wshadow]


for (long row = 0; row < table_rows; row++) {
long offset = 0;
long repeat = 0;
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also done!

@pcanal
Copy link
Member

pcanal commented Mar 9, 2020

To 'fix' the Windows CI build, please fork the roottest repository (https://github.com/root-project/roottest)

@cosimoNigro
Copy link
Contributor Author

cosimoNigro commented Mar 10, 2020

Hi @pcanal,

I have implemented the changes you requested.
I did not understand though your instruction on "fix"ing the windows CI.
I downloaded and run the test suit, shall I share the output somehow?
The result is

74% tests passed, 240 tests failed out of 934

I 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

@pcanal
Copy link
Member

pcanal commented Mar 10, 2020

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).

@pcanal
Copy link
Member

pcanal commented Mar 10, 2020

@phsft-bot build with flags -DCTEST_TEST_EXCLUDE_NONE=On

@phsft-bot
Copy link

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-fedora30/cxx14, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu18.04-i386/cxx14, mac1014/cxx17, windows10/cxx14 with flags -DCTEST_TEST_EXCLUDE_NONE=On
How to customize builds

@phsft-bot
Copy link

Build failed on mac1014/cxx17.
See console output.

Errors:

Failing tests:

@pcanal
Copy link
Member

pcanal commented Mar 10, 2020

The fit tutorials errors is

Processing /build/jenkins/workspace/root-pullrequests-build/root/tutorials/fitsio/FITS_tutorial8.C...
Warning in <TFITSHDU::LoadHDU>: error opening FITS file. Details: could not open the named file
libc++abi.dylib: terminating with uncaught exception of type int
CMake Error at /build/jenkins/workspace/root-pullrequests-build/build/RootTestDriver.cmake:238 (message):
  error code: Child aborted

@cosimoNigro
Copy link
Contributor Author

cosimoNigro commented Mar 10, 2020

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 tutorials/fitsio/.
Apologies

@pcanal
Copy link
Member

pcanal commented Mar 10, 2020

@phsft-bot build with flags -DCTEST_TEST_EXCLUDE_NONE=On

@phsft-bot
Copy link

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-fedora30/cxx14, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu18.04-i386/cxx14, mac1014/cxx17, windows10/cxx14 with flags -DCTEST_TEST_EXCLUDE_NONE=On
How to customize builds

@phsft-bot
Copy link

Build failed on mac1014/cxx17.
See console output.

Errors:

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-fedora30/cxx14.
See console output.

Errors:

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-ubuntu16/nortcxxmod.
See console output.

Failing tests:

@pcanal
Copy link
Member

pcanal commented Mar 10, 2020

The errors are unrelated.

@phsft-bot
Copy link

Build failed on windows10/cxx14.
See console output.

Errors:

  • C:\build\workspace\root-pullrequests-build\root\graf2d\fitsio\src\TFITS.cxx(568,30): error C2131: expression did not evaluate to a constant [C:\build\workspace\root-pullrequests-build\build\graf2d\fitsio\FITSIO.vcxproj]
  • C:\build\workspace\root-pullrequests-build\root\graf2d\fitsio\src\TFITS.cxx(573,28): error C2131: expression did not evaluate to a constant [C:\build\workspace\root-pullrequests-build\build\graf2d\fitsio\FITSIO.vcxproj]
  • C:\build\workspace\root-pullrequests-build\root\graf2d\fitsio\src\TFITS.cxx(578,30): error C2131: expression did not evaluate to a constant [C:\build\workspace\root-pullrequests-build\build\graf2d\fitsio\FITSIO.vcxproj]
  • C:\build\workspace\root-pullrequests-build\root\graf2d\fitsio\src\TFITS.cxx(583,31): error C2131: expression did not evaluate to a constant [C:\build\workspace\root-pullrequests-build\build\graf2d\fitsio\FITSIO.vcxproj]

// TODO: add all type cases, for now only short, long, float and double are considered
//
if (abstype == 21) {
short data[size];
Copy link
Member

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);

Copy link
Contributor Author

@cosimoNigro cosimoNigro Mar 11, 2020

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.

@phsft-bot
Copy link

Build failed on ROOT-ubuntu18.04-i386/cxx14.
See console output.

Errors:

Failing tests:

@cosimoNigro
Copy link
Contributor Author

Hi @pcanal, I changed the arrays with vectors, could you retry now?

@phsft-bot
Copy link

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-fedora30/cxx14, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu18.04-i386/cxx14, mac1014/cxx17, windows10/cxx14
How to customize builds

@pcanal
Copy link
Member

pcanal commented Mar 11, 2020

@phsft-bot build with flags -DCTEST_TEST_EXCLUDE_NONE=On

@phsft-bot
Copy link

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-fedora30/cxx14, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu18.04-i386/cxx14, mac1014/cxx17, windows10/cxx14 with flags -DCTEST_TEST_EXCLUDE_NONE=On
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-ubuntu18.04-i386/cxx14.
See console output.

Failing tests:

@cosimoNigro
Copy link
Contributor Author

Hi @pcanal, could you wait before merging? I am doing some more tests with a file with larger arrays in columns.
Thank you

@cosimoNigro
Copy link
Contributor Author

cosimoNigro commented Mar 12, 2020

Hello,
sorry for this last modification.
The .FITS file I initially decided to include was produced by an experiment specifically for an open-source project and I was not sure it could be made available from another repository (see discussion here, if you are interested).

Therefore I included one of the test files that are shipped with the sherpa X-ray analysis tools.
All NASA mission data are released without license or restriction, so it should be fine to include it in ROOT.

I changed the input file and the tutorial, sorry if you have to run the tests again.
It was an important issue to address.

@pcanal
Copy link
Member

pcanal commented Mar 12, 2020

@phsft-bot build with flags -DCTEST_TEST_EXCLUDE_NONE=On

@phsft-bot
Copy link

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-fedora30/cxx14, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu18.04-i386/cxx14, mac1014/cxx17, windows10/cxx14 with flags -DCTEST_TEST_EXCLUDE_NONE=On
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-fedora30/cxx14.
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-ubuntu16/nortcxxmod.
See console output.

Failing tests:

@cosimoNigro
Copy link
Contributor Author

Hello @Axel-Naumann, @pcanal, are the failed test related to my patch?
Is there something else you want me to change, otherwise could you accept it?

@Axel-Naumann
Copy link
Member

are the failed test related to my patch?

No, sorry about that - please ignore them.

Is there something else you want me to change, otherwise could you accept it?

I'd like @pcanal to have the final say here.

@pcanal
Copy link
Member

pcanal commented Mar 16, 2020

@cosimoNigro thank you for the PR :)

@pcanal pcanal merged commit 9134d8b into root-project:master Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants