Commit 47aab4c0 authored by CEVAER's avatar CEVAER
Browse files

Automatic conversion to compatible python2/3 code with futurize

parent 8b809944
#!/usr/bin/env python
from __future__ import division
from builtins import str
from builtins import range
from past.utils import old_div
import sys
import os
import datetime
......@@ -19,7 +23,7 @@ def readFile(fname):
#list_var=('owiLon','owiLat','owiHeading','owiEcmwfWindSpeed','owiWindSpeed_IPF', 'owiPreProcessing/estimWindDir200', 'owiPreProcessing/MixWindDir200', 'owiPreProcessing/CoefMixWindDir200', 'owiEcmwfWindDirection','owiWindDirection_mod1','owiWindSpeed_mod1','owiWindDirection_mod2','owiWindSpeed_mod2','owiWindDirection_mod3','owiWindSpeed_mod3','owiPreProcessing/FilterBinary200','owiLandFlag','owiIncidenceAngle')
try:
nc=netCDF4.Dataset(fname)
except Exception, e:
except Exception as e:
logger.warn('skipping unreadable %s : %s' % (fname, str(e)))
return None
......@@ -38,7 +42,7 @@ def readFile(fname):
# data[varname]=var[::]
# read groups
for groupName in [ None ] + nc.groups.keys():
for groupName in [ None ] + list(nc.groups.keys()):
if groupName:
group=nc.groups[groupName]
groupNamePref="%s/" % groupName
......@@ -84,7 +88,7 @@ def readMeta(fname):
#list_var=('owiLon','owiLat','owiHeading','owiEcmwfWindSpeed','owiWindSpeed_IPF', 'owiPreProcessing/estimWindDir200', 'owiPreProcessing/MixWindDir200', 'owiPreProcessing/CoefMixWindDir200', 'owiEcmwfWindDirection','owiWindDirection_mod1','owiWindSpeed_mod1','owiWindDirection_mod2','owiWindSpeed_mod2','owiWindDirection_mod3','owiWindSpeed_mod3','owiPreProcessing/FilterBinary200','owiLandFlag','owiIncidenceAngle')
try:
nc=netCDF4.Dataset(fname)
except Exception, e:
except Exception as e:
logger.warn('skipping unreadable %s : %s' % (fname, str(e)))
return None
......@@ -96,7 +100,7 @@ def readMeta(fname):
refDims=nc.variables['owiLon'].dimensions
# read groups
for groupName in [ None ] + nc.groups.keys():
for groupName in [ None ] + list(nc.groups.keys()):
if groupName:
group=nc.groups[groupName]
groupNamePref="%s/" % groupName
......@@ -155,7 +159,7 @@ def readMeta(fname):
def getAttribute(fname, attr):
try:
nc=netCDF4.Dataset(fname)
except Exception, e:
except Exception as e:
logger.warn('skipping unreadable %s : %s' % (fname, str(e)))
return None
......@@ -166,7 +170,7 @@ def getAttribute(fname, attr):
def getFootprint(fname):
try:
nc=netCDF4.Dataset(fname)
except Exception, e:
except Exception as e:
logger.warn('skipping unreadable %s : %s' % (fname, str(e)))
return None
......@@ -180,7 +184,7 @@ def getDateFromFname(fname):
tmp=os.path.basename(fname).split('-')
startDate=datetime.datetime.strptime(tmp[4],"%Y%m%dt%H%M%S")
stopDate=datetime.datetime.strptime(tmp[5],"%Y%m%dt%H%M%S")
date=startDate+(stopDate-startDate)/2
date=startDate+old_div((stopDate-startDate),2)
return date
def getDataAtCoord(data,lon,lat):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment