nickginsberg / noaa-gfs-js

A lightweight library for pulling GFS (Global Forecasting System) weather data from NOAA, without any major 3rd party depencies.
MIT License
7 stars 0 forks source link

Time potentially off by one day #5

Closed deckerego closed 1 month ago

deckerego commented 1 month ago

Issuing: noaa_gfs.get_gfs_data('0p25', '20240731', '12', [38,38], [-85,-85], 3, 'pratesfc', true)

Results in:

https://nomads.ncep.noaa.gov/dods/gfs_0p25/gfs20240731/gfs_0p25_12z.ascii?pratesfc[0:3][512:512][1100:1100]
{
  array_format: [
    { time: '7/30/2024, 12:00:00 PM', lat: 38, lon: -85, value: 0 },
    { time: '7/30/2024, 3:00:00 PM', lat: 38, lon: -85, value: 0 },
    { time: '7/30/2024, 6:00:00 PM', lat: 38, lon: -85, value: 4e-7 },
    { time: '7/30/2024, 9:00:00 PM', lat: 38, lon: -85, value: 0 }
  ],
  obj_format: {
    '7/30/2024, 12:00:00 PM': { '38': [Object] },
    '7/30/2024, 3:00:00 PM': { '38': [Object] },
    '7/30/2024, 6:00:00 PM': { '38': [Object] },
    '7/30/2024, 9:00:00 PM': { '38': [Object] }
  },
  times: [
    '7/30/2024, 12:00:00 PM',
    '7/30/2024, 3:00:00 PM',
    '7/30/2024, 6:00:00 PM',
    '7/30/2024, 9:00:00 PM'
  ],
  lats: [ 38 ],
  lons: [ -85 ],
  levs: [],
  url: 'https://nomads.ncep.noaa.gov/dods/gfs_0p25/gfs20240731/gfs_0p25_12z.ascii?pratesfc[0:3][512:512][1100:1100]'
}

However, if I'm understanding correctly the times should be:

  times: [
    '7/31/2024, 12:00:00 PM',
    '7/31/2024, 3:00:00 PM',
    '7/31/2024, 6:00:00 PM',
    '7/31/2024, 9:00:00 PM'
  ],

It appears NOAA is returning this in days since 0001-01-01 - so we have an off by one.

nickginsberg commented 1 month ago

Thanks for reporting @deckerego ! Did some further testing and it looks like this is indeed the case. Have pushed a fix and added additional test cases to ensure it stays fixed. Update to version 1.0.3 and you'll get the fix. Much appreciated!