-
Notifications
You must be signed in to change notification settings - Fork 28
Description
While working on setting up sflux ensemble based on HAFS and GEFS I realized that if the sflux "input" files (e.g. what I generate from HAFS or GEFS) then pyschism incorrectly shifts the time vector:
pyschism/pyschism/forcing/nws/nws2/sflux.py
Lines 331 to 338 in 00b1137
| dst['time'].base_date = ( | |
| nc_start_date.year, | |
| nc_start_date.month, | |
| nc_start_date.day, | |
| 0) | |
| dst['time'][:] = [ | |
| (localize_datetime(x) - nc_start_date) / timedelta(days=1) | |
| for x in variable.datetime_array] |
This is because the schism sflux time hour 00 based, but the vector differences for sflux_*.nc file are calculated based on the actual input .nc file's base time. So for example if I have the following time vector in my custom input nc file:
array(['2023-08-14T18:00:00.000000000', '2023-08-15T00:00:00.000000000',
'2023-08-15T06:00:00.000000000', '2023-08-15T12:00:00.000000000',
'2023-08-15T18:00:00.000000000', '2023-08-16T00:00:00.000000000',
'2023-08-16T06:00:00.000000000', '2023-08-16T12:00:00.000000000',
'2023-08-16T18:00:00.000000000', '2023-08-17T00:00:00.000000000',
'2023-08-17T06:00:00.000000000', '2023-08-17T12:00:00.000000000',
'2023-08-17T18:00:00.000000000', '2023-08-18T00:00:00.000000000',
'2023-08-18T06:00:00.000000000', '2023-08-18T12:00:00.000000000',
'2023-08-18T18:00:00.000000000', '2023-08-19T00:00:00.000000000',
'2023-08-19T06:00:00.000000000', '2023-08-19T12:00:00.000000000',
'2023-08-19T18:00:00.000000000', '2023-08-20T00:00:00.000000000',
'2023-08-20T06:00:00.000000000', '2023-08-20T12:00:00.000000000',
'2023-08-20T18:00:00.000000000', '2023-08-21T00:00:00.000000000',
'2023-08-21T06:00:00.000000000', '2023-08-21T12:00:00.000000000',
'2023-08-21T18:00:00.000000000', '2023-08-22T00:00:00.000000000',
'2023-08-22T06:00:00.000000000', '2023-08-22T12:00:00.000000000',
'2023-08-22T18:00:00.000000000', '2023-08-23T00:00:00.000000000',
'2023-08-23T06:00:00.000000000', '2023-08-23T12:00:00.000000000',
'2023-08-23T18:00:00.000000000', '2023-08-24T00:00:00.000000000',
'2023-08-24T06:00:00.000000000'], dtype='datetime64[ns]')
then I get the following time in the final sflux file sflux_air_1.0001.nc written by pyschism:
array(['2023-08-14T00:00:00.000000000', '2023-08-14T06:00:00.000000000',
'2023-08-14T12:00:00.000000000', '2023-08-14T18:00:00.000000000',
'2023-08-15T00:00:00.000000000', '2023-08-15T06:00:00.000000000',
'2023-08-15T12:00:00.000000000', '2023-08-15T18:00:00.000000000',
'2023-08-16T00:00:00.000000000', '2023-08-16T06:00:00.000000000',
'2023-08-16T12:00:00.000000000', '2023-08-16T18:00:00.000000000',
'2023-08-17T00:00:00.000000000', '2023-08-17T06:00:00.000000000',
'2023-08-17T12:00:00.000000000', '2023-08-17T18:00:00.000000000',
'2023-08-18T00:00:00.000000000', '2023-08-18T06:00:00.000000000',
'2023-08-18T12:00:00.000000000', '2023-08-18T18:00:00.000000000',
'2023-08-19T00:00:00.000000000', '2023-08-19T06:00:00.000000000',
'2023-08-19T12:00:00.000000000', '2023-08-19T18:00:00.000000000',
'2023-08-20T00:00:00.000000000', '2023-08-20T06:00:00.000000000',
'2023-08-20T12:00:00.000000000', '2023-08-20T18:00:00.000000000',
'2023-08-21T00:00:00.000000000', '2023-08-21T06:00:00.000000000',
'2023-08-21T12:00:00.000000000', '2023-08-21T18:00:00.000000000',
'2023-08-22T00:00:00.000000000', '2023-08-22T06:00:00.000000000',
'2023-08-22T12:00:00.000000000', '2023-08-22T18:00:00.000000000',
'2023-08-23T00:00:00.000000000', '2023-08-23T06:00:00.000000000',
'2023-08-23T12:00:00.000000000'], dtype='datetime64[ns]')
I know that I'm using custom input .nc file as SfluxDataset, but still I'm not sure if this is intentional (i.e. I need to make sure my input .nc file dates are 00 based) or a bug!
Note that I call this function to read the custom .nc file I generate from HAFS or GEFS:
pyschism/pyschism/forcing/nws/nws2/nws2.py
Lines 35 to 41 in 00b1137
| def read(cls, path, sflux_1_glob="*_1.*", sflux_2_glob="*_2.*"): | |
| path = pathlib.Path(path) | |
| sflux_2 = list(path.glob(sflux_2_glob)) | |
| return cls( | |
| sflux_1=SfluxDataset(list(path.glob(sflux_1_glob))), | |
| sflux_2=SfluxDataset(sflux_2) if len(sflux_2) > 0 else None, | |
| ) |
Is this not meant to be used on a generic .nc file? My .nc file has all the required variables, it just doesn't have hour 00 based time.