fusion-flap / flap

Fusion Library of Analysis Programs
MIT License
11 stars 5 forks source link

DataObject.coordinate[:].values is None if equidistant #25

Closed thelampire closed 4 years ago

thelampire commented 5 years ago

Whenever I try to get the coordinate values without the use of e.g. data.coordinate('Time') and the coordinate is equidistant, the values cannot be gathered and None is returned.

mvecsei commented 5 years ago

I usually circumvent that by calling dataobject.get_coordinate_object('Coordinate Name').data(dataobject.shape)[0] . That has been working OK so far for me.

mvecsei commented 5 years ago

Although maybe there should be a single parameter returning dataobject.data(dataobject.shape)[0], as that is the only thing I have been using from the dataobject.data() routine

thelampire commented 5 years ago

That is how I do it, as well. It is just annoying that I would expect values to have values.

thelampire commented 5 years ago

This is still an issue. If I don't want to get e.g. a 64x80xn_times matrix for GPI data, I cannot access data.coordinates[0].values for the time because it is equidistant. Getting the 64x80 number of time vectors is time consuming. There should be a way of accessing original coordinates with their names. Like data.coordinates['Time'].values. Of couse this is not possible, because data.coordinates is a list. Thus one needs to find the coordinates for the list by cycling through data.coordinates[coord_index].unit.name and then when the correct coord_index is gotten, then the original coordinates can be read by data.coordinates[correct_coord_index].values (if they are not equidistant, because then there are no values).

Something needs to be done with this. I don't think it's too efficient how it is done now. We could have a Skype meeting sometime and discuss FLAP in general.

sandorzoletnik commented 4 years ago

Gents, The aim of the Coordiate.data() call is to hide the coordinate description. You should never read .values, always use the .data() call. To ease things I have added a 'Change only' keyword (can be abbreviated) to the Coordinate.data() and consequently the Data.Object.coordinate() call. If it is set the coordinate values are returned only in the dimensions where they change. I have added an example in flap_tests.test_coordinates(): t = flap.get_data_object_ref('TESTDATA').coordinate('Time',options={'Chang':True})[0].flatten() Here flap.get_data_object_ref() is also new it returns a reference to the DataObject in the storage. (get_data_object returns a copy). This call returns a time vector. If the Time happened to change in 2 dimensions the ....[0] part would return an N-dim object (N is the dimension of the data) with 1 element in all dimensions except the two where Time changes. As Time changes in the example only along 1D, you can use flatten() to remove the dimensions with 1 element.