thetisproject / thetis

Finite element flow solver for simulating coastal and estuarine flows.
Other
68 stars 28 forks source link

North Sea 2d model #326

Closed Sijbrandb closed 1 year ago

Sijbrandb commented 1 year ago

Hi, I have a problem with putting in the tidal constituents in the North Sea 2d demo: data_dir = os.path.join(os.environ.get("DATA", "./data"), "tpxo") if not os.path.exists(data_dir): raise IOError(f"Forcing data directory {data_dir} does not exist") forcing_constituents = ["Q1", "O1", "P1", "K1", "N2", "M2", "S2", "K2"] elev_tide_2d = Function(P1_2d, name="Tidal elevation") tbnd = forcing.TPXOTidalBoundaryForcing( elev_tide_2d, start_date, coord_system, data_dir=data_dir, constituents=forcing_constituents, boundary_ids=[100], )

I downloaded and extracted the tpxo files and have them stored in ~/Downloads/DATA as 3 separate files: gridtpxo9v5a.nc, h_tpxo9v5a.nc and u_tpxo9.nc. Could someone help me out in which way I can extract the right data form these files? Thanks in advance!

stephankramer commented 1 year ago

The location it looks for these files is set in this line:

data_dir = os.path.join(os.environ.get("DATA", "./data"), "tpxo")

what that means is that it looks at the directory stored in the environment variable DATA and then expects and looks in the subdirectory of that called txpo. So you could make subdirectory ~/Downloads/DATA/tpxo, put these files in there and then set the environment variable to

export DATA=~/Downloads/DATA

before running the python script. So DATA is just the name of the environment variable, not the directory name itself, and it looks for a subdirectory tpxo/ under it. Of course you can also just change the line in the script to any directory you want.

Finally the './data' means it defaults (if you don't set the DATA environment variable) to a directory data/ under the current directory (where you run the script), and then again a subdirectory tpxo/ under that.