Welcome, Guest
Username: Password: Remember me

TOPIC: Writing selafin files

Writing selafin files 10 years 4 months ago #13748

  • OGW
  • OGW's Avatar
Hello, I'm using the Telemac python scripts to read and manipulate a results file. I would like to modify some wave directions and then save to a new output.slf, however I am having some difficulties. I use out.fole.update({ 'hook': open(outFile,'wb') }) to create my new file, then after creating the header, I try to add the results data using out.appendCoreVarsSLF(data) but I get the error

f.write(pack('>i',4*self.NPOIN3))
AttributeError: 'dict' object has no attribute 'write'

I am relatively new to python and so do not really understand this error. Could anyone offer some advice?

Thanks, Oliver
The administrator has disabled public write access.

Writing selafin files 10 years 4 months ago #13749

  • sebourban
  • sebourban's Avatar
  • NOW ONLINE
  • Administrator
  • Principal Scientist
  • Posts: 814
  • Thank you received: 219
Hello,

Can you share your entire script so I can have a try at debugging ?

Thank you,
Sébastien.
The administrator has disabled public write access.

Writing selafin files 10 years 4 months ago #13750

  • OGW
  • OGW's Avatar
Hi, yes here you go.

Thanks, Oliver
Attachments:
The administrator has disabled public write access.

Writing selafin files 10 years 4 months ago #13751

  • sebourban
  • sebourban's Avatar
  • NOW ONLINE
  • Administrator
  • Principal Scientist
  • Posts: 814
  • Thank you received: 219
Hello,

here attached with a few modifications and running about 5000 times faster on a small mesh ... main points are:

- not sure what "data" was
- use the slf to read and write instead of creating a new out
- use the power of numpy for array calculations

Hope this helps,
Sébastien.
Attachments:
The administrator has disabled public write access.

Writing selafin files 10 years 4 months ago #13754

  • OGW
  • OGW's Avatar
Hello, thank you for your reply and very useful python tips for numpy array calculations! 'Data' was just a variation on the wave data I was trying to write, not defined as I sent the code whilst making some changes. Appologies for that.

With regards to using slf to read and write instead of creating a new out, I get an error AttributeError: SELAFIN instance has no attribute 'fole' when trying slf.fole.update({ 'hook': open(outFile,'wb') }). I am able to complete the .fole commands when creating a new out but then I get the error AttributeError: 'dict' object has no attribute 'write' when trying to use the .append commands. Am I missing something?

Many thanks

Oliver
The administrator has disabled public write access.

Writing selafin files 10 years 4 months ago #13755

  • sebourban
  • sebourban's Avatar
  • NOW ONLINE
  • Administrator
  • Principal Scientist
  • Posts: 814
  • Thank you received: 219
hummm.

It looks like the TELEMAC python scripts you have do not have the latest developments. These are substantial.

So -- two options:
- Are you a member of the consortium ? (in which case yo can access the branch guppy)
- If not let me know, I may have to do an intermediate release, which I will have to get authorised by the consortium.

Sébastien.
The administrator has disabled public write access.

Writing selafin files 10 years 4 months ago #13756

  • OGW
  • OGW's Avatar
Hello, I'm not a member of the consortium unfortunately. An intermediate release of these updated scripts would be very useful, if it is possible!

Thanks, Oliver
The administrator has disabled public write access.
Moderators: borisb

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