You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature suggestion: control dtype for tide prediction #618
Currently, modelled tides are returned with a float64 dtype:
import pandas as pd
import pyTMD
import timescale
# Define coordinates and time period
x_coords = [150, 155]
y_coords = [-35, -40]
time = pd.date_range("2020-01", "2020-03", periods=2)
# Model tides
ts = timescale.time.Timescale().from_datetime(time)
m = pyTMD.io.model("/gdata1/data/tide_models/").from_database("EOT20")
ds = m.open_dataset(group="z", constituents=["m2"])
X, Y = ds.tmd.coords_as(x_coords, y_coords, type="trajectory", crs=4326)
local = ds.tmd.interp(x=X, y=Y, extrapolate=True)
tide = local.tmd.predict(ts.tide, deltat=ts.tt_ut1, corrections=m.corrections)
tide += local.tmd.infer(ts.tide, deltat=ts.tt_ut1, corrections=m.corrections)
tide.dtype
>>> dtype('float64')
This can use a lot of memory when running a large tidal analysis. Given the precision of the models, it's likely that float64 is overkill - in many cases, float32 would be sufficient and less memory hungry. I can convert my tide output to float32 after the fact easily enough (e.g. tide.astype("float32")) but this doesn't entirely avoid peak memory issues that occur before the conversion.
It would be fantastic if we could specify an output dtype during tide prediction to control the dtype used by the output xarray.DataArray. For example, something like:
changed the title [-]Feature suggestion: control dtype for modelled tides[/-][+]Feature suggestion: control dtype for tide prediction[/+]on Aug 21, 2026
Activity
[-]Feature suggestion: control dtype for modelled tides[/-][+]Feature suggestion: control dtype for tide prediction[/+]