Correcting timestamp from netCDF
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
George Lavidas
il 18 Lug 2018
Commentato: George Lavidas
il 8 Ago 2018
Hello to matlab the community,
If possible I would be grateful for some help in regards to conversion of timestamps in matlab from netcdf.
I am familiar with netcdf and their structure as well as their conversion, but I think I am missing something.
I have a netcdf with time in the format of
time =[23627;
23627.0069444444;
23627.0138888889;
23627.0208333333];
And I am trying to correct the timestamp both to a human readable form but also to use in plots.
Of course I checked the time offset in the netcdf and it is in
"days since 1950-01-01T00:00:00Z";
Therefore, I have included this offset in my estimates but I cannot see to be getting the correct form. I am using this
time_offset=datenum(1950,01,01);
new_time=(time/24)+time_offset;
timestamp=datestr(new_time);
timestamp=datestr(new_time,'yyyymmddHHMM');
nt=str2num(timestamp);
timestamp=uint64(nt);
timestamp=double(nt);
However the outcome does not give me what I would expect.
The measurements should be in 10 minute increments like so:
01-01-2015 00:00:00
01-01-2015 00:10:00
The variable is new_time is estimated as
7.132084583333334e+05
that corresponds to the variable timestamp:
195209111100
It seems that it does not recognize the offset. Have I done anything wrong?
Thank you all in advance,
0 Commenti
Risposta accettata
Peter Perkins
il 3 Ago 2018
>> time = [23627 23627.0069444444 23627.0138888889 23627.0208333333];
>> dt = datetime(1950,1,1,'Format','dd-MMM-yyyy HH:mm:ss') + days(time)
dt =
1×4 datetime array
09-Sep-2014 00:00:00 09-Sep-2014 00:09:59 09-Sep-2014 00:20:00 09-Sep-2014 00:29:59
I guess netCDF timestamps are UTC? The above will work for that, in general, you'd want to use caldays to account for DST shifts twice a year.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su NetCDF in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!