converting from integer time to datetime in 3-hourly data
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Carrie Merritt
el 1 de Dic. de 2020
Comentada: Carrie Merritt
el 13 de Abr. de 2021
I've tried everything I can think of to convert from integer time to datetime. Anyone have any intuitions or suggestions? Thanks!
time
Size: 13208x1
Dimensions: record
Datatype: double
Attributes:
standard_name = 'time'
long_name = 'Time'
units = 'hours since 1979-12-01 00'
time_calendar = 'gregorian'
start = '1979120100'
step = '3'
With having a time step of '3' I'm not sure how to apply the datetime function.
For reference:
>> time(1)
ans =
176064
6 comentarios
Stephan
el 1 de Dic. de 2020
Editada: Stephan
el 1 de Dic. de 2020
Carries comment moved here:
Please see attached. There isn't anything on the script aside from my numerous failed attempts at trying to make this work. All I'm trying to do is read the time in and convert it from its original netCDF format to a date/time format.
Respuesta aceptada
Stephan
el 2 de Dic. de 2020
Editada: Stephan
el 2 de Dic. de 2020
Heres an approach:
I believe the idea behind this:
is that the integer values start counting by
1979-12-01 00:00 --> 0
1979-12-01 03:00 --> 3
1979-12-01 06:00 --> 6
If this assumption would be correct:
data = ncread('EasterlyOneYear850.nc','time');
time_new = datetime('1979-12-01 00:00') + hours(data);
Should give you the correct time values in your data:
time_new(1:3)
gives then:
ans =
3×1 datetime array
01-Jan-2000 00:00:00
01-Jan-2000 03:00:00
01-Jan-2000 06:00:00
So we end up that your data could have started exactly by millenium and ends here:
>> time_new(end)
ans =
datetime
31-Dec-2000 21:00:00
which is the last possible value in the year 2000, since the next one would be in the year 2001.
Can this be correct?
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre String Parsing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!