0

I have a netCDF file. When I export it as .txt with Panoply, it transfers the date as julian dates. While downloading the data, I downloaded it every hour of every month. I tried many codes, but somehow I could not convert it to the current date correctly. Is there anyone who can help?

So I want to convert the julian date "964249" to "2010-01-01 00:00:00". My starting year 1900-01-01 00:00:00.0

Gzm_93
  • 3
  • 4

1 Answers1

0

Assuming that 964249 is measured in hours and that the one origin is the origin stated in the question which would make the zero origin one hour before that.

as.POSIXct(3600 * (964249 - 1), origin = "1900-01-01", tz = "UTC")
## [1] "2010-01-01 UTC"

as.POSIXct(3600 * (964261 - 1), origin = "1900-01-01", tz = "UTC")
## [1] "2010-01-01 12:00:00 UTC"

Update

Changed assumptions.

G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341
  • Thank you very much :) The code you suggested works up to a point, but when I change the julian date, the current date does not change. For example, when I change "964249" to "964261", the result is as follows. What do you think I'm missing? – Gzm_93 Nov 10 '21 at 13:54
  • > as.POSIXct(3600 * (964261), origin = "1900-01-01", tz = "UTC") [1] "2010-01-01 13:00:00 UTC" – Gzm_93 Nov 10 '21 at 14:00
  • I get "2010-01-01 12:00:00 UTC" which is correct since the two are 12 hours apart. I have added this to the answer. Also note that I updated the answer at one point so be sure you are using the latest. – G. Grothendieck Nov 10 '21 at 14:09
  • I understand your but "964249" should correspond to date 2010-01-01. I can't understand why the "964261" julia date gives the same date again. Thanks for the update too. – Gzm_93 Nov 10 '21 at 19:03
  • See my last comment. – G. Grothendieck Nov 11 '21 at 14:07
  • Hello, thank you very much. Yes, after reading your last comment more carefully, I understood what you mean. – Gzm_93 Nov 12 '21 at 07:17