Welcome, Guest
Username: Password: Remember me

TOPIC: Write Selafin from scratch with python

Write Selafin from scratch with python 10 years 6 months ago #13044

  • caiodalaqua
  • caiodalaqua's Avatar
Greetings,

I am working in a forecast version of Telemac3d for southern Brazil which requires boundary conditions from global models (i.e. HYCOM). However, the data flux between the models has to be very efficient since the dataset is usually very large. This brings me to my problem, it is computationally inefficient to use ascii formatted files in this task.

Does anyone have a good example in how to write selafin files from scratch using those python modules ? I can read the mesh and the boundary conditions file but I couldn't figure out in how to add variables such temperature, salinity and velocities in the file.

Moreover, Is it possible to write a "discontinuous" selafin file, with only the boundary points ?

Any help is appreciated.

Thank you very much

Caio Eadi Stringari
The administrator has disabled public write access.

Write Selafin from scratch with python 10 years 6 months ago #13047

  • c.coulet
  • c.coulet's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3722
  • Thank you received: 1031
Hi

I'm not sure this will be really efficient to write a selafin file if you're intereested only on the boundary nodes as it's impossible to write it "discontinuous". You will be force to write at least 0 on other points.

But rather than a selafin file, you could probably generate a binary file (eventually inspire by the selafin format) just for boundaries. Then you just have to adapt in telemac the reading of this boundary file...

hope this helps
Christophe
The administrator has disabled public write access.

Write Selafin from scratch with python 10 years 6 months ago #13048

  • sebourban
  • sebourban's Avatar
  • OFFLINE
  • Administrator
  • Principal Scientist
  • Posts: 814
  • Thank you received: 219
Hello, Indeed Christophe is right.

As a matter of fact, we have been working on just about all what you need. This will be included in the next release. So "en primeur", here a first python script that automatically read HYCOM results subsampling it for any part of the world to make up a first "structured" 3D SELAFIN file.

File Attachment:

File Name: convertHYCOM.py
File Size: 21 KB


File Attachment:

File Name: convertUTM.py
File Size: 8 KB


I will try to share with you later this month the mapping part from the SELAFIN created to a SELAFIN-like boundary file + the changes to the TELEMAC source code to read that SELAFIN-like boundary file ...

If you have anything you can share with us, we will consider it.

Hope this helps for now.
Sébastien.
Hope this helps
The administrator has disabled public write access.
The following user(s) said Thank You: caiodalaqua

Write Selafin from scratch with python 10 years 6 months ago #13051

  • caiodalaqua
  • caiodalaqua's Avatar
Hi Sébastien,

Thank you very much for your help !

I am using RTOFS (polar.ncep.noaa.gov/global/) instead of the traditional HYCOM, but the idea is the same...

My work is in still in the beginning. I wrote some scripts to download the data I need automatically using the openDAP protocol within python's netCDF4 module. there are 3 scripts so far, one for the volumetic (3D) files, one for the bi-dimensional files and one for GFS wind, pressure and temperature data.

I just finish another script to locate and interpolate the downloaded data Telemac's open boundaries but I got stopped in the step of writing the output files.

I was going with the approach of writing everything in netcdf and reading them in Telemac but I decided to ask first...

I am attaching what I've done so far.


Caio Eadi Stringari
Attachments:
The administrator has disabled public write access.

Write Selafin from scratch with python 10 years 6 months ago #13053

  • sebourban
  • sebourban's Avatar
  • OFFLINE
  • Administrator
  • Principal Scientist
  • Posts: 814
  • Thank you received: 219
... as a follow-up, here attached the python script that takes the SELAFIN converted from HYCOM, your own GEO file and associated CLI file, and create by interpolation a new SELAFIN-like boundary (binary) file only where the CLI says you have an open liquid boundary.

The last part (the Fortran to read this new binary boundary file) is rather complex ... hopefully you can wait a bit.

Sébastien.

File Attachment:

File Name: convertToBND.py
File Size: 4 KB
The administrator has disabled public write access.

Write Selafin from scratch with python 10 years 6 months ago #13081

  • caiodalaqua
  • caiodalaqua's Avatar
Thanks again Sébastien !

I will definitely use this in the future. Because my files are relatively small (only 5 days forecast simulations) and my dead line is approaching, ascii files will do the job for now.

Let me know if I could help in anything else.

Caio
The administrator has disabled public write access.

Write Selafin from scratch with python 10 years 6 months ago #13082

  • lgrignon
  • lgrignon's Avatar
Hi Sebastien,
Would you have something similar to convert from NetCDF to Selafin?
Thanks!
Laure
The administrator has disabled public write access.
Moderators: borisb

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.