Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nans in the load tide #33

Open
TPCollings opened this issue Aug 2, 2024 · 3 comments
Open

Nans in the load tide #33

TPCollings opened this issue Aug 2, 2024 · 3 comments

Comments

@TPCollings
Copy link

Describe the bug
I have downloaded the new FES2022b tidal heights from aviso+ and installed the new pyfes package in a fresh conda environment.

I am testing the data/package using the example code for tide predictions but I only get nan values for the radial/load tide.

I've tried rewriting the yaml file to pass the paths to the handler. The handler is finding the files and reading the data. Is there something obvious I'm missing?

The ocean tide returns a result as expected.

To Reproduce
A short code example that reproduces the problem/missing feature. It should be
self-contained, i.e., possible to run as-is via python myproblem.py

import pyfes
dataset_dir = "/home/tom/coastal/data/tide_models/fes2022b"
os.environ['DATASET_DIR'] = dataset_dir
handlers = pyfes.load_config(dataset_dir + '/fes_slev_test.yml')
lon = -1.3510 #-7.688
lat = 50.8562 #59.195
date = numpy.datetime64('1983-01-01T00:00:00')
dates = numpy.arange(date, date + numpy.timedelta64(1, 'D'),
                     numpy.timedelta64(1, 'h'))

lons = numpy.full(dates.shape, lon)
lats = numpy.full(dates.shape, lat)

load, load_lp, _out_rad = pyfes.evaluate_tide(handlers['radial'],
                                       dates,
                                       lons,
                                       lats,
                                       num_threads=1)

print("load tide = " + str(load))
load tide = [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan
 nan nan nan nan nan nan]

My contents of my yaml file is listed below:

radial:
  cartesian:
    paths:
       2N2: ${DATASET_DIR}/load_tide/2n2_fes2022.nc
       K1: ${DATASET_DIR}/load_tide/k1_fes2022.nc
       K2: ${DATASET_DIR}/load_tide/k2_fes2022.nc
       M2: ${DATASET_DIR}/load_tide/m2_fes2022.nc
       N2: ${DATASET_DIR}/load_tide/n2_fes2022.nc
       O1: ${DATASET_DIR}/load_tide/o1_fes2022.nc
       P1: ${DATASET_DIR}/load_tide/p1_fes2022.nc
       Q1: ${DATASET_DIR}/load_tide/q1_fes2022.nc
       S2: ${DATASET_DIR}/load_tide/s2_fes2022.nc
tide:
  cartesian:
    paths:
      2N2: ${DATASET_DIR}/ocean_tide_extrapolated/2n2_fes2022.nc
      K1: ${DATASET_DIR}/ocean_tide_extrapolated/k1_fes2022.nc
      K2: ${DATASET_DIR}/ocean_tide_extrapolated/k2_fes2022.nc
      M2: ${DATASET_DIR}/ocean_tide_extrapolated/m2_fes2022.nc
      M4: ${DATASET_DIR}/ocean_tide_extrapolated/m4_fes2022.nc
      Mf: ${DATASET_DIR}/ocean_tide_extrapolated/mf_fes2022.nc
      Mm: ${DATASET_DIR}/ocean_tide_extrapolated/mm_fes2022.nc
      Msqm: ${DATASET_DIR}/ocean_tide_extrapolated/msqm_fes2022.nc
      Mtm: ${DATASET_DIR}/ocean_tide_extrapolated/mtm_fes2022.nc
      N2: ${DATASET_DIR}/ocean_tide_extrapolated/n2_fes2022.nc
      O1: ${DATASET_DIR}/ocean_tide_extrapolated/o1_fes2022.nc
      P1: ${DATASET_DIR}/ocean_tide_extrapolated/p1_fes2022.nc
      Q1: ${DATASET_DIR}/ocean_tide_extrapolated/q1_fes2022.nc
      S1: ${DATASET_DIR}/ocean_tide_extrapolated/s1_fes2022.nc
      S2: ${DATASET_DIR}/ocean_tide_extrapolated/s2_fes2022.nc

Expected behavior
I would expect non-nan values in the load tide variable.

pyfes/Numpy/Python version information
Output from

import sys, numpy, pyfes.version
print(pyfes.__version__)
print(numpy.__version__)
print(sys.version)

2024.6.0
1.26.4
3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:23:07) [GCC 12.3.0]

Additional context
On another note, I had to fix the numpy version to <2 when installing otherwise I got an error when loading pyfes. The error occurred when pyfes tried to load the netcdf4 package, and was as follows:
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Could this be related?

@TPCollings
Copy link
Author

I have tried using python 3.10 and 3.11 to no avail. I've also tried different numpy versions and had no luck. Is the version of pyfes the most up-to-date? I noticed on the online documentation the version reference is 2024.6.1, but the version on conda-forge is 2024.6.0.

@TPCollings
Copy link
Author

FYI I solved this. The longitudes need to be given in a range from 0:360, not -180:180. This should be specified somewhere in the documentation and the example should be changed to reflect this.

@phillipjws
Copy link

I was also running into this issue, although shifting my longitude didn't seem to resolve, in the nc files of my ocean_tide, the bounds for the longitude are (0.0, 0.0) which matches the handbook, but I'm not sure why they would be this and not (0, 360). The bounds in the load_tide files are (0, 360), although I'm still failing to get results. Let me know if there was anything else you did to resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants