FV3 Bundle
QgRead.py
Go to the documentation of this file.
1 # (C) Copyright 2009-2016 ECMWF.
2 #
3 # This software is licensed under the terms of the Apache Licence Version 2.0
4 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 # In applying this licence, ECMWF does not waive the privileges and immunities
6 # granted to it by virtue of its status as an intergovernmental organisation nor
7 # does it submit to any jurisdiction.
8 
9 import numpy as np
10 
11 class QgRead:
12 
13  def readFields(self,fdbdir,attributes):
14  filename = fdbdir + "/" + \
15  attributes["expver"] + "." + \
16  attributes["type"] + "." + \
17  attributes["referencedate"]
18 
19  if attributes["type"]=="fc": filename += "." + attributes["step"]
20 
21  print 'reading from file ' + filename
22  infile = open(filename,"r")
23 
24  [nx, ny, nl, nf, ns] = [int(i) for i in infile.readline().split()]
25  print "grid dimensions are: nx=",nx," ny=",ny
26 
27  validity_date = infile.readline()
28  print "validity date is: ",validity_date
29 
30  psi = np.fromfile(file=infile,dtype="float64", \
31  count=(2*ny*nx),sep=" ").reshape((2,ny,nx))
32  print "max(psi)=",np.amax(psi)," min(psi)=",np.amin(psi)
33 
34  pv = np.fromfile(file=infile,dtype="float64", \
35  count=(2*ny*nx),sep=" ").reshape((2,ny,nx))
36  print "max(pv)=",np.amax(pv)," min(pv)=",np.amin(pv)
37 
38  u = np.fromfile(file=infile,dtype="float64",\
39  count=(2*ny*nx),sep=" ").reshape((2,ny,nx))
40  print "max(u)=",np.amax(u)," min(u)=",np.amin(u)
41 
42  v = np.fromfile(file=infile,dtype="float64", \
43  count=(2*ny*nx),sep=" ").reshape((2,ny,nx))
44  print "max(v)=",np.amax(v)," min(v)=",np.amin(v)
45 
46  infile.close()
47 
48  return pv, psi
def readFields(self, fdbdir, attributes)
Definition: QgRead.py:13