Hi Alex,
You are wright in almost everything...
I forgot that the xytodegrees() was not in this file, sorry for this. I have my won "telemac tools" module and this function is declared there. It's a fairly simple function:
def xytodegrees(x,y):
from pyproj import Proj
p = Proj(proj='utm',zone='22S',ellps='WGS84')
# minus 10000000.0 because it is in the southern hemisphere
lons,lats=p(x,y-10000000.0,inverse=True)
return lons,lats
You only have to be careful with which coordinate system you are using.
The timezone in the begging is not needed in the code, unless you want to convert the selafin dates to a particular timezone, in my case, it was São Paulo.
The script is actually far from being complete. In order to have a proper netCDF file you will have to interpolate the vertical planes. My script only does a horizontal interpolation. I assume the easiest way is to interpolate horizontally every plane first and than interpolate the sigma coordinates to a regular Z scheme.
As far as I remember there are more thinks to be done, such as properly define the netCDF objects. As I said before, you can use this as example, I really doubt the script will work as it is today.
Cheers
Caio