Skip to content
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

netcdf time axis gets irregular values #646

Closed
felixcremer opened this issue Apr 26, 2024 · 2 comments
Closed

netcdf time axis gets irregular values #646

felixcremer opened this issue Apr 26, 2024 · 2 comments

Comments

@felixcremer
Copy link
Contributor

When I open the data from the xarray tutorial with Rasters I get very irregular time axis values.
I would have expected to get clear hourly DateTime objects every six hours.
The time axis is saved in the netcdf as an integer value hours since 1800-01-01.

It seems to me as if the data is converted to Float and then there is some strange float interaction.

using Rasters, NCDatasets
path = "air_temperature.nc"
# First we download the data locally if needed.
if !isfile(path)
    download("https://github.com/pydata/xarray-data/blob/master/air_temperature.nc", "air_temperature.nc")
end

ds = RasterStack("air_temperature.nc")
dims(ds, Ti) # Rasters opening the data
Ti Sampled{DateTime} ForwardOrdered Irregular DimensionalData.Dimensions.LookupArrays.Points
wrapping: 2920-element Vector{DateTime}:
 2013-01-01T00:04:02.688
 2013-01-01T06:02:18.496
 2013-01-01T12:00:34.304
 2013-01-01T17:58:50.112
 2013-01-01T23:57:05.920
 2013-01-02T06:04:06.016
 2013-01-02T12:02:21.824
 2013-01-02T18:00:37.632
 2013-01-02T23:58:53.440
 2013-01-03T05:57:09.248
 2013-01-03T12:04:09.344
 2013-01-03T18:02:25.152
 2013-01-04T00:00:40.960
 
 2014-12-28T23:56:06.528
 2014-12-29T06:03:06.624
 2014-12-29T12:01:22.432
 2014-12-29T17:59:38.240
 2014-12-29T23:57:54.048
 2014-12-30T05:56:09.856
 2014-12-30T12:03:09.952
 2014-12-30T18:01:25.760
 2014-12-30T23:59:41.568
 2014-12-31T05:57:57.376
 2014-12-31T11:56:13.184
 2014-12-31T18:03:13.280
julia> dims(yax,Ti) # This is what I would have expected.
Ti Sampled{DateTime} ForwardOrdered Irregular DimensionalData.Dimensions.LookupArrays.Points
wrapping: 2920-element Vector{DateTime}:
 2013-01-01T00:00:00
 2013-01-01T06:00:00
 2013-01-01T12:00:00
 2013-01-01T18:00:00
 2013-01-02T00:00:00
 2013-01-02T06:00:00
 2013-01-02T12:00:00
 2013-01-02T18:00:00
 
 2014-12-30T06:00:00
 2014-12-30T12:00:00
 2014-12-30T18:00:00
 2014-12-31T00:00:00
 2014-12-31T06:00:00
 2014-12-31T12:00:00
 2014-12-31T18:00:00
@rafaqz
Copy link
Owner

rafaqz commented Apr 26, 2024

Weird. But I can't actually reproduce it:

julia> lookup(RasterStack(path), Ti)
Sampled{Dates.DateTime} ForwardOrdered Irregular DimensionalData.Dimensions.Lookups.Points
wrapping: 2920-element Vector{Dates.DateTime}:
 2013-01-01T00:00:00
 2013-01-01T06:00:00
 2013-01-01T12:00:00
 2013-01-01T18:00:00
 2013-01-02T00:00:00
 2013-01-02T06:00:00
 2013-01-02T12:00:00
 2013-01-02T18:00:00
 2013-01-03T00:00:00
 2013-01-03T06:00:00
 2013-01-03T12:00:00
 
 2014-12-29T06:00:00
 2014-12-29T12:00:00
 2014-12-29T18:00:00
 2014-12-30T00:00:00
 2014-12-30T06:00:00
 2014-12-30T12:00:00
 2014-12-30T18:00:00
 2014-12-31T00:00:00
 2014-12-31T06:00:00
 2014-12-31T12:00:00
 2014-12-31T18:00:00

Maybe try main?

@felixcremer
Copy link
Contributor Author

It is fixed on main.

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

No branches or pull requests

2 participants