You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a funky one for the end of the working week! When taking the additive inverse i.e. negative of a field, the additive inverse of the (field) data is correctly taken but it results, as an unintended side effect, in all of the data for the metadata constructs being wiped, somehow (no time to investigate until next week, and I won't speculate quite how this even happens!). Note that an operation of -f shows this bug but -1*f does not, which implies it is likely an issue with the setup/logic of the - operator on a field.
Quick examples:
>>>f=cf.example_fields()
>>>print(f[0].data) # all good
[[0.007, ..., 0.013]] 1>>>print(-f[0].data) # all good
[[-0.007, ..., -0.013]] 1>>>print(-f[0]) # not all good - see the dim coordsField: specific_humidity (ncvar%q)
----------------------------------Data : specific_humidity(latitude(5), longitude(8)) 1Cellmethods : area: meanDimensioncoords: latitude(5) =
: longitude(8) =
: time(1) =>>>print(-1*f[0]) # also all goodField: specific_humidity (ncvar%q)
----------------------------------Data : specific_humidity(latitude(5), longitude(8)) 1Cellmethods : area: meanDimensioncoords: latitude(5) = [-75.0, ..., 75.0] degrees_north
: longitude(8) = [22.5, ..., 337.5] degrees_east
: time(1) = [2019-01-0100:00:00]
>>>>>>print(-f[1]) # note from this result that other constructs are affected tooField: air_temperature (ncvar%ta)
---------------------------------Data : air_temperature(atmosphere_hybrid_height_coordinate(1), grid_latitude(10), grid_longitude(9)) KCellmethods : grid_latitude(10): grid_longitude(9): meanwhereland (interval: 0.1degrees) time(1): maximumFieldancils : air_temperaturestandard_errorDimensioncoords: atmosphere_hybrid_height_coordinate(1) =
: grid_latitude(10) =
: grid_longitude(9) =
: time(1) =Auxiliarycoords: latitude
: longitude
: long_name=GridlatitudenameCellmeasures : measure:areaCoordreferences: grid_mapping_name:rotated_latitude_longitude
: standard_name:atmosphere_hybrid_height_coordinateDomainancils : atmosphere_hybrid_height_coordinate
: ncvar%b
: surface_altitude
I noticed this during working through issues in the cf-plot basic test suite, whereby a call to cfp.vect(u=c, v=-g) was failing with the error AttributeError: DimensionCoordinate has no data due to the underlying issue whereby the - operation is taken for the field input as the v argument. Which indicates it is more than a representational issue (i.e. the data is missing from the printed output), but I am yet to explore further.
sadielbartholomew
changed the title
All construct data wiped when additive inverse - taken of field
Most construct data wiped when additive inverse - taken of field
Jul 19, 2024
Ah, good spot! I should have thought to check for the more general case. I will update the title...
sadielbartholomew
changed the title
Most construct data wiped when additive inverse - taken of field
Most construct data wiped when unary operator taken of field
Jul 22, 2024
Here's a funky one for the end of the working week! When taking the additive inverse i.e. negative of a field, the additive inverse of the (field) data is correctly taken but it results, as an unintended side effect, in all of the data for the metadata constructs being wiped, somehow (no time to investigate until next week, and I won't speculate quite how this even happens!). Note that an operation of
-f
shows this bug but-1*f
does not, which implies it is likely an issue with the setup/logic of the-
operator on a field.Quick examples:
I noticed this during working through issues in the cf-plot basic test suite, whereby a call to
cfp.vect(u=c, v=-g)
was failing with the errorAttributeError: DimensionCoordinate has no data
due to the underlying issue whereby the-
operation is taken for the field input as thev
argument. Which indicates it is more than a representational issue (i.e. the data is missing from the printed output), but I am yet to explore further.Environment
Using the
main
branch:The text was updated successfully, but these errors were encountered: