Open deborarodriguesp opened 8 months ago
Hello!
I was so happy to finally have someone using Pyfes! I tried to use the past weeks, and it simply does not work for me! Could you help me, please?
I found this error, repeatedly:
usage: fes_compute_tide.py [-h] [--load LOAD] ocean fes_compute_tide.py: error: the following arguments are required: ocean
But I am using a .ini file, as you are also using in fes.ini... I will show the first block:
TIDE_2N2_FILE = D:/DOUTORAMENTO/Tide/FES2014/ocean_tide_extrapolated/2n2.nc TIDE_2N2_LATITUDE = lat TIDE_2N2_LONGITUDE = lon TIDE_2N2_AMPLITUDE = amplitude TIDE_2N2_PHASE = phase
I will past here my code, which I followed your guide, but I don't need the grid interpolation part:
import argparse import numpy as np import pandas as pd import pyfes import os import sys import pickle def usage(): """ Command syntax """ parser = argparse.ArgumentParser( description='Program example using the Python API for FES.') parser.add_argument('ocean', help='Path to the configuration file that contains ' 'the definition of grids to use to compute the ' 'ocean tide', type=str) parser.add_argument('--load', help='Path to the configuration file that contains ' 'the definition of grids to use to compute the ' 'load tide', type=str) return parser.parse_args() def compute_dates(start_date, end_date, step): period = [start_date] date_i = start_date while date_i < end_date: date_i += np.timedelta64(step, 'm') period.append(date_i) return period def main(): # study location location = 'Pará_Centro' lon_study = -47.782969 lat_study = -0.093179 # dates start_date = np.datetime64('2012-11-01 00:00') end_date = np.datetime64('2014-01-01 00:00') step = 60 # expressed in minutes period = compute_dates(start_date, end_date, step) args = usage() visu = False # Create handler short_tide = pyfes.Handler('ocean', 'memory', 'ocean_tide_extrapolation.ini') sys.exit() # Calculate tide tide_results = {} tide_results['tide_from_fes'] = [] tide_results['dates'] = period for date in period: print(date) dates.fill(date) tide, lp, _ = short_tide.calculate(lon_study.ravel(), lat_study.ravel(), dates.ravel()) tide, lp = tide.reshape(shape), lp.reshape(shape) # Convert tide to cm and to a 2d numpy masked array geo_tide = (tide + lp) * 0.01 geo_tide = geo_tide.reshape(grid_lons.shape) geo_tide = np.ma.masked_where(np.isnan(geo_tide), geo_tide) # Extract tide at study location tide_extract, lon_extract, lat_extract = get_fes_wl_at_extraction_point(lons, lats, lon_study, lat_study, geo_tide) # save tide results in dictionnary tide_results['tide_from_fes'].append(tide_extract) if __name__ == '__main__': main()
If you could help me, I would be extremely grateful, thank you!
okay, I understand my problem now, I need to use this in conda: python fes_compute_tide.py D:/DOUTORAMENTO/Tide/Tide-main/ocean_tide_extrapolation.ini --load D:/DOUTORAMENTO/Tide/Tide-main/ocean_tide_extrapolation.ini
Hello, I am happy that you found the solution of your problem. I hope you can do what you want with pyfes. Florent
Hello!
I was so happy to finally have someone using Pyfes! I tried to use the past weeks, and it simply does not work for me! Could you help me, please?
I found this error, repeatedly:
But I am using a .ini file, as you are also using in fes.ini... I will show the first block:
I will past here my code, which I followed your guide, but I don't need the grid interpolation part:
If you could help me, I would be extremely grateful, thank you!