pietern / goestools

Tools to work with signals and files from GOES satellites
https://pietern.github.io/goestools/
BSD 2-Clause "Simplified" License
374 stars 83 forks source link

Fix NWS image timestamp extraction #137

Closed pietern closed 2 years ago

pietern commented 2 years ago

The pattern that encodes the timestamp for NWS images used to be irregular and required careful parsing. This pattern was changed some time before November 2020 and became regular. The irregular parser produced invalid timestamps when applied to filenames with the new pattern. This commit updates the function that extracts a timestamp from the filename to expect the regular pattern.

This commit also removes the timestamp prefix from the filename if it could be extracted, allowing users to specify their own timestamp pattern.

This means that a handler with the following definition:

filename = "{time:%Y%m%dT%H%M%SZ}_{filename}"

No longer produces filenames:

20220327T110046Z_20220327110046-hiwind_pac_latest.gif

But rather:

20220327T110046Z_hiwind_pac_latest.gif

Fixes #100.

pietern commented 2 years ago

Before:

Writing: ./nws/2022-01-27/20220127T110000Z_20220327110045-pac24_latestBW.gif
Writing: ./nws/2022-01-27/20220127T110000Z_20220327110045-pacsfc72_latestBW.gif
Writing: ./nws/2022-01-27/20220127T110000Z_20220327110046-pac48per_latestBW.gif
Writing: ./nws/2022-01-27/20220127T110000Z_20220327110046-hiwind_pac_latest.gif
Writing: ./nws/2022-01-27/20220127T110000Z_20220327110046-hiwind_atl_latest.gif
Writing: ./nws/2022-01-27/20220127T110000Z_20220327110046-pac48_latestBW.gif

After:

Writing: ./nws/2022-03-27/20220327T110045Z_pac24_latestBW.gif
Writing: ./nws/2022-03-27/20220327T110045Z_pacsfc72_latestBW.gif
Writing: ./nws/2022-03-27/20220327T110046Z_pac48per_latestBW.gif
Writing: ./nws/2022-03-27/20220327T110046Z_hiwind_pac_latest.gif
Writing: ./nws/2022-03-27/20220327T110046Z_hiwind_atl_latest.gif
Writing: ./nws/2022-03-27/20220327T110046Z_pac48_latestBW.gif