Skip to content

improve astrog outofrange warning message #429

Description

@veenstrajelmer

pre-1900 timesteps were supported in #420 by converting the exception to a warning. However, the warning message is too bloated:

import os
import hatyan
hatyan.close("all")
import kenmerkendewaarden as kw

dir_base = r'p:\11210325-005-kenmerkende-waarden\work'
dir_meas = os.path.join(dir_base,'measurements_wl_18700101_20240101')

nap_correction = False
min_coverage = 0.9
drop_duplicates = True
current_station = "cadzand.2"

# extremes are used for slotgemiddelden, havengetallen, overschrijding
df_ext_12345_all = kw.read_measurements(dir_output=dir_meas, station=current_station, quantity="meas_ext",
                                  nap_correction=nap_correction, drop_duplicates=drop_duplicates)

# convert 12345 to 12 by taking minimum of 345 as 2 (laagste laagwater)
df_ext_all = hatyan.calc_HWLW12345to12(df_ext_12345_all)
df_ext_all = df_ext_all.loc[:"1901"]

df_ext_all = df_ext_all.drop("1879-11-03 17:10:00+01:00", axis=0)

#### TIDAL INDICATORS
dict_HWLW_springneap = kw.calc_HWLW_springneap(df_ext=df_ext_all, min_coverage=min_coverage)

Gives:

WARNING:root:The current definition of the relationship between UTC and TAI dates from 1 January 1972. This first dT value is also applied before that date even though this might not be accurate.
WARNING:hatyan.astrog:Requested time out of range (1900-2091): DatetimeIndex(['1877-01-01 23:54:45.835632597'], dtype='datetime64[ns]', freq=None)
WARNING:root:The current definition of the relationship between UTC and TAI dates from 1 January 1972. This first dT value is also applied before that date even though this might not be accurate.
WARNING:hatyan.astrog:Requested time out of range (1900-2091): DatetimeIndex(['1877-01-02 02:16:25.641176358',
               '1877-01-02 14:41:39.805543761',
               '1877-01-03 03:06:53.969911164',
               '1877-01-03 15:32:08.134278567',
               '1877-01-04 03:57:22.298645970',
               '1877-01-04 16:22:36.463013373',
               '1877-01-05 04:47:50.627380776',
               '1877-01-05 17:13:04.791748179',
               '1877-01-06 05:38:18.956115582',
               '1877-01-06 18:03:33.120482985',
               ...
               '1901-12-28 02:18:51.767226054',
               '1901-12-28 14:44:05.931593457',
               '1901-12-29 03:09:20.095960860',
               '1901-12-29 15:34:34.260328263',
               '1901-12-30 03:59:48.424695666',
               '1901-12-30 16:25:02.589063069',
               '1901-12-31 04:50:16.753430472',
               '1901-12-31 17:15:30.917797875',
               '1902-01-01 05:40:45.082165278',
               '1902-01-01 18:05:59.246532681'],
              dtype='datetime64[ns]', length=17642, freq='44714164367403ns')
WARNING:root:The current definition of the relationship between UTC and TAI dates from 1 January 1972. This first dT value is also applied before that date even though this might not be accurate.
WARNING:hatyan.astrog:Requested time out of range (1900-2091): DatetimeIndex(['1877-01-02 02:16:44.359946214',
               '1877-01-02 14:44:58.025463576',
               '1877-01-03 03:11:53.034325902',
               '1877-01-03 15:37:37.486258527',
               '1877-01-04 04:02:21.789933507',
               '1877-01-04 16:26:17.508528100',
               '1877-01-05 04:49:36.551337556',
               '1877-01-05 17:12:30.640408628',
               '1877-01-06 05:35:10.964288722',
               '1877-01-06 17:57:47.938872039',
               ...
               '1901-12-28 02:23:35.582063014',
               '1901-12-28 14:49:46.387938878',
               '1901-12-29 03:15:03.664228589',
               '1901-12-29 15:39:32.268066188',
               '1901-12-30 04:03:18.171800217',
               '1901-12-30 16:26:27.998386836',
               '1901-12-31 04:49:08.662310556',
               '1901-12-31 17:11:27.104242533',
               '1902-01-01 05:33:30.099409468',
               '1902-01-01 17:55:24.117662575'],
              dtype='datetime64[ns]', length=17642, freq=None)
WARNING:root:The current definition of the relationship between UTC and TAI dates from 1 January 1972. This first dT value is also applied before that date even though this might not be accurate.
WARNING:hatyan.astrog:Requested time out of range (1900-2091): DatetimeIndex(['1877-01-02 02:16:44.397916344',
               '1877-01-02 14:44:58.064411106',
               '1877-01-03 03:11:52.590985393',
               '1877-01-03 15:37:36.516860463',
               '1877-01-04 04:02:20.546493816',
               '1877-01-04 16:26:16.382308567',
               '1877-01-05 04:49:35.939747208',
               '1877-01-05 17:12:30.852093181',
               '1877-01-06 05:35:12.164456814',
               '1877-01-06 17:57:50.130970960',
               ...
               '1901-12-28 02:23:35.292474320',
               '1901-12-28 14:49:45.619562822',
               '1901-12-29 03:15:02.496777231',
               '1901-12-29 15:39:30.952665172',
               '1901-12-30 04:03:17.062921838',
               '1901-12-30 16:26:27.485306415',
               '1901-12-31 04:49:09.109901073',
               '1901-12-31 17:11:28.807884549',
               '1902-01-01 05:33:33.255357413',
               '1902-01-01 17:55:28.808249066'],
              dtype='datetime64[ns]', length=17642, freq=None)
WARNING:root:The current definition of the relationship between UTC and TAI dates from 1 January 1972. This first dT value is also applied before that date even though this might not be accurate.
WARNING:hatyan.astrog:Requested time out of range (1900-2091): DatetimeIndex(['1877-01-02 02:16:44.397916344',
               '1877-01-02 14:44:58.064411106',
               '1877-01-03 03:11:52.590985393',
               '1877-01-03 15:37:36.516860463',
               '1877-01-04 04:02:20.546493816',
               '1877-01-04 16:26:16.382308567',
               '1877-01-05 04:49:35.939747208',
               '1877-01-05 17:12:30.852093181',
               '1877-01-06 05:35:12.164456814',
               '1877-01-06 17:57:50.130970960',
               ...
               '1901-12-28 02:23:35.292474320',
               '1901-12-28 14:49:45.619562822',
               '1901-12-29 03:15:02.496777231',
               '1901-12-29 15:39:30.952665172',
               '1901-12-30 04:03:17.062921838',
               '1901-12-30 16:26:27.485306415',
               '1901-12-31 04:49:09.109901073',
               '1901-12-31 17:11:28.807884549',
               '1902-01-01 05:33:33.255357413',
               '1902-01-01 17:55:28.808249066'],
              dtype='datetime64[ns]', length=17642, freq=None)

Make the warning message more consise

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions