Advice on installing Python package

Issue #3 resolved
Robbi Bishop-Taylor created an issue

I've recently come across this module, which looks exactly like what I've been looking for to combine with continental coastal monitoring work I've recently been involved with. I've attempted to install the software with the guide here, however have had difficulty following the instructions on this repo.

A few questions:

  • What version of Python is the module compatible with? I've been trying to install it on a Conda Python 3.7 installation
  • The guide specifies the requirements are "netcdf" and "cmake", and then states that the easiest installation method is to use "conda install -c fbriol fes". Should I only use the conda command after I install those stand-alone pieces of software, or will the conda command install them for me?

I've attempted to install via conda (without installing "netcdf" and "cmake" first. Everything indicates the installation was successful, however, when I try to load the module in Python I get the following error without much else to go on:

ImportError: DLL load failed: The specified module could not be found.
Any extra advice you can give me on a workflow for installing the FES Python module would be greatly appreciated.

Comments (12)

  1. Kilian Vos

    Hey Robbi,

    Frederic will probably provde better instructions but I can tell you the steps that I followed to install it (after a bit of trial and error of course):

    1. Download the source folder
    2. conda install -c fbriol fes
    3. In the same conda environment install netcdf
    4. Navigate with Anaconda Prompt to the source folder
    5. mkdir build && cd build
    6. download and install CMAKE
    7. set PATH=C:\Program Files\CMake\bin;%PATH% (or wherever you installed CMAKE)
    8. cmake .. -DCMAKE_INSTALL_PREFIX=/opt/local
    9. Test if it works with import pyfes in python
    10. Download ocean tide, ocean_tide_extrapolated and load tide .nc files from Aviso+ [account needed]
    11. Save the .nc files in the source folder, under /data/fes2014
    12. Update the .ini file to include the absolute path to each tidal component (.nc file)

    I hope this helps,

    Kilian

  2. Angel Ruiz Angulo

    Dear Kilian and Robbi,

    great to find those issues since I have been fighting with them too. I am done pass the step 9 on testing python does recognize import pyfes; however it does not recognize import fes. The opposite happens if I use jupyter to import those packages. Is the package fes discontinued?

    Also I was wondering if you could extend between steps 11 and 12. my ini files have the following shape: TIDE_2N2_FILE = ./ocean_tide/2n2.nc

    when you mean a absolute path is something like: /home/angel/tools/fes-2.9.1-Source/data/fes2014/ocean_tide/2n2.nc

    Thanks a lot,

    Angel

  3. Frederic Briol repo owner

    Hello, I'm on vacation with very limited Internet access. I'm back on August 26th. I'll look at these problems when I get back. Sincerely, Frederic.

  4. Kilian Vos

    hey Angel,

    yes that is what I had to do, so you replace the . with the absolute path to that location.

    The ocean_tide_extrapolated.ini file should look like this:

    TIDE_2N2_FILE = C:/Users/z5030440/Documents/fes-2.9.1-Source/data/fes2014/ocean_tide_extrapolated/2n2.nc
    TIDE_2N2_LATITUDE = lat
    TIDE_2N2_LONGITUDE = lon
    TIDE_2N2_AMPLITUDE = amplitude
    TIDE_2N2_PHASE = phase

    TIDE_EPS2_FILE = C:/Users/z5030440/Documents/fes-2.9.1-Source/data/fes2014/ocean_tide_extrapolated/eps2.nc
    TIDE_EPS2_LATITUDE = lat
    TIDE_EPS2_LONGITUDE = lon
    TIDE_EPS2_AMPLITUDE = amplitude
    TIDE_EPS2_PHASE = phase

  5. Frederic Briol repo owner

    You can also use environment variables by using Linux syntax in "ini" files.

    U=${DATA}/.....
    
  6. Angel Ruiz Angulo

    Thanks a lot to all of you, it did work and now it is up and running. I have a naive question for anyone in the forum. From the python tools do you know a straight way to get the tidal components at a given location?

    Thanks a lot

  7. zhongjie chang

    Hey guys,

    I have followed Kilian’s steps but I am unable to get pass Step 9. When i tried to run the example file (tide_gauge.py) in PyCharm, it shows ‘ModuleNotFoundError: No module named 'pyfes'’. I am able to build the toolbox using CMake and i got a bunch of CMake File & VC++ Project files. I am wondering which step did I made a mistake in. When I test the environment using conda install -c fbriol fes again, the anaconda prompt shows 'All requested packages already installed'.

    My objective is just to get the tidal heights near to a few tide gauges along the coast.

  8. Kilian Vos

    No more need to go through all the cmake stuff now that it’s on anaconda…This is what works for me with version 2.9.1:

    1. Download the source folder from here: https://bitbucket.org/fbriol/fes/downloads/ - unzip it and store in any prefered location.
    2. run: conda install -c fbriol fes
    3. Test import pyfes in python
    4. Download ocean tide and load tide .nc files from Aviso+ [account required] these are large netcdf files that contain all the outputs from the global tide model
    5. Save the .nc files in the source folder, under /data/fes2014 - when using fes in python, it will look for these files in the source folder, but the filepaths to each file have to be given manually (see code below)
    6. Update the .ini file to include the absolute path to each tidal component (.nc file)
    7. below is an example of python code for extracting tide water levels for a given lat lon location and a vector of datetime formatted dates.
    import pyfes
    import datetime
    config_ocean = r"H:\Downloads\fes-2.9.1-Source\data\fes2014\ocean_tide.ini"
    ocean_tide = pyfes.Handler("ocean", "io", config_ocean)
    config_load = r"H:\Downloads\fes-2.9.1-Source\data\fes2014\load_tide.ini"
    load_tide = pyfes.Handler("radial", "io", config_load)
    dates_np = np.empty((len(dates),), dtype='datetime64[us]')
    for i,date in enumerate(dates):
        dates_np[i] = datetime(date.year,date.month,date.day,date.hour,date.minute,date.second)
    lons = Tidelatlon[0]*np.ones(len(dates))
    lats = Tidelatlon[1]*np.ones(len(dates))
    # compute heights for ocean tide and loadings
    ocean_short, ocean_long, min_points = ocean_tide.calculate(lons, lats, dates_np)
    load_short, load_long, min_points = load_tide.calculate(lons, lats, dates_np)
    # sum up all components and convert from cm to m
    tide_level = (ocean_short + ocean_long + load_short + load_long)/100
    # tide level contains the predicted tide heights in m
    

  9. zhongjie chang

    Dear Kilian,

    Your response is amazing and thank you so much for your help! I managed to extract tidal heights based on the given lat, lon, and period. However, I faced an issue where the tidal heights are exactly 180˚ opposite in phase (i.e. tide gauge data (from PSMSL) is rising but the tidal height is dropping). Therefore, once I detide the data using original time series minus tidal heights prediction, the detided data increased in height when it is supposed to be within the range of original time series.

    Did I extracted the wrong values? Please kindly have a quick glance on my add-on codes for the variables: dates and Tidelatlon.

    dates = np.arange(datetime(1992,9,1), datetime(2018,1,1), timedelta(days=1)).astype(datetime) #daily dates
    dates_np = np.empty((len(dates),), dtype='datetime64[us]')
    
    for i,date in enumerate(dates):
        dates_np[i] = datetime(date.year,date.month,date.day,date.hour,date.minute,date.second)
    
    Tidelatlon = [102.1067, 6.2264]
    lons = Tidelatlon[0]*np.ones(len(dates))
    lats = Tidelatlon[1]*np.ones(len(dates))
    

    I ought to get something similar as the picture below:

    Thank you so much. 🙂

  10. Nicholas Metherall

    Thank you @Kilian Vos and @Frederic Briol and others for the support on this. I am having some issues with the testing step ‘import pyfes’

    ImportError: libnetcdf.so.15: cannot open shared object file: No such file or directory

    Yet the directory does seem to exist as it has been saved on the python directory and on the desktop and is readable in the same notebook:

    dir ('/common/tidal_models')

    Any advice about how to progress to the next step would be much appreciated.

  11. Log in to comment