예제 #1
0
def readVar(fn, vstr, cl=1):
    xDict = read3dDataFromNetCDF(fn, vstr, cl)
    v = xDict['v']
    x = xDict['x']
    y = xDict['y']
    z = xDict['z']
    xDict = None
    return v, x, y, z
예제 #2
0
varname     = args.varname
writeAscii  = args.writeAscii


#==========================================================#


# Obtain a list of files to include.
fileNos, fileList = filesFromList( fileKey+'*' )

fig = plt.figure(num=1, figsize=(12,10))

for fn in fileNos:
  VNU = varname.upper()
  if('MAG' in VNU or 'U1' in VNU or 'U2' in VNU or 'DIR' in VNU):
    dataDict = read3dDataFromNetCDF( fileList[fn] , 'u', cl )
    u = dataDict['v']
    dataDict = read3dDataFromNetCDF( fileList[fn] , 'v', cl )
    v = dataDict['v']
    
    if('MAG' in VNU ): # vr := Umag
      vr = np.sqrt( u**2 + v**2 ); u = None; v = None
    else:
      um = np.mean( u, axis=(0) ); vm = np.mean( v, axis=(0) )
      a  = np.arctan( vm/(um+1.e-5) ); um = None; vm = None 
      if( 'U1' in VNU ):
        vr = u * np.cos(a) + v * np.sin(a)
      elif('U2' in VNU): # U2
        vr =-u * np.sin(a) + v * np.cos(a)
      else:# direction
        vr = np.arctan( v/(u+1.e-5) ) * (180./np.pi)
예제 #3
0
#==========================================================#
'''
Establish two boolean variables which indicate whether the created variable is an
independent or dependent variable in function createNetcdfVariable().
'''
parameter = True
variable = False

strKey = inputIfNone(strKey, " Enter search string: ")
fileNos, fileList = filesFromList(strKey + "*")

for fn in fileNos:
    # - - - - - - - - - - - - - - - - - - - - - - - - - -  #
    # First fluctuation component
    cl = 1
    ncDict = read3dDataFromNetCDF(fileList[fn], varnames[0], cl)
    v1 = ncDict['v']  # 'v' is a generic name for a variable in ncDict

    # Second fluctuation component
    ncDict = read3dDataFromNetCDF(fileList[fn], varnames[1], cl)
    v2 = ncDict['v']

    # Dims
    nt, nz, ny, nx = np.shape(v1)

    # - - - - - - - - - - - - - - - - - - - - - - - - - -  #
    # Spatial coords and time
    x = ncDict['x']
    y = ncDict['y']
    z = ncDict['z']
    time = ncDict['time']
예제 #4
0
normalize = args.normalize
Nbins = args.nbins
mode = args.mode
cl = abs(args.coarse)
varname = args.varname

#==========================================================#

# Obtain a list of files to include.
fileNos, fileList = filesFromList(fileKey + '*')

first = True
fig = None

for fn in fileNos:
    dataDict = read3dDataFromNetCDF(fileList[fn], varname, cl)
    v = dataDict['v']
    x = dataDict['x']
    y = dataDict['y']
    z = dataDict['z']
    time = dataDict['time']

    if (first):
        infoStr = '''
    Coord. range:
    min(x)={0} ... max(x)={1}, nx = {2}
    min(y)={3} ... max(y)={4}, ny = {5}
    min(z)={6} ... max(z)={7}, nz = {8}
    '''.format(\
          np.min(x), np.max(x), len(x),\
          np.min(y), np.max(y), len(y),\
예제 #5
0
'''
Establish two boolean variables which indicate whether the created variable is an
independent or dependent variable in function createNetcdfVariable().
'''
parameter = True;  variable  = False

# Create a dict that is passed into the function read3dDataFromNetCDF
nameDict = dict()
nameDict['xname'] = args.xname
nameDict['yname'] = args.yname
nameDict['zname'] = args.zname

# First fluctuation component
nameDict['varname'] = varname[0]
cl = 1
ncDict = read3dDataFromNetCDF( filename , nameDict, cl )
v = ncDict['v']   # 'v' is a generic name for a variable in ncDict

# Spatial coords and time
x = ncDict['x']; y = ncDict['y']; z = ncDict['z']
time = ncDict['time']

# Now check whether the given indices make sense 
# Here we set i = 0 and j = 0.
ijk1 = sensibleIds( np.array([0,0,kIds[0]]), x, y, z )
ijk2 = sensibleIds( np.array([0,0,kIds[1]]), x, y, z )
print(' Check (1): i, j, k = {}'.format(ijk1))
print(' Check (2): i, j, k = {}'.format(ijk2))

# = = = = = = = = = = = = =
# Mean and variance
예제 #6
0
if (mode == 'mean'): sfunc = bs_stats.mean
if (mode == 'std'): sfunc = bs_stats.std
if (mode == 'var'): sfunc = bs_stats.var

# Obtain a list of files to include.
fileNos, fileList = filesFromList(fileKey + '*', allfiles)

fig = plt.figure(num=1, figsize=(12, 10))
ax = fig.add_axes([0.1, 0.075, 0.875, 0.81])  #[left, top, width, height]

for fn in fileNos:
    vr = None

    for i in range(len(varnames)):
        if (varnames[i].upper() == 'U1' or varnames[i].upper() == 'U2'):
            dataDict = read3dDataFromNetCDF(fileList[fn], 'u', 1)
            u = dataDict['v']
            dataDict = read3dDataFromNetCDF(fileList[fn], 'v', 1)
            v = dataDict['v']
            um = np.mean(u, axis=(0))
            vm = np.mean(v, axis=(0))
            a = np.arctan(vm / (um + 1.e-5))
            um = None
            vm = None
            # Carry the data within dataDict.
            if (varnames[i].upper() == 'U1'):
                dataDict['v'] = u * np.cos(a) + v * np.sin(a)
            else:
                dataDict['v'] = -u * np.sin(a) + v * np.cos(a)
            # Free memory
            u = None
예제 #7
0
ijk1 = args.ijk1
ijk2 = args.ijk2
axisLim = args.axisLim
nkpoints = args.nkpoints
ustar = args.ustar
holewidth = args.holewidth
weighted = args.weighted
npixels = args.npixels
ofile = args.outputToFile
printOn = args.printOn
#==========================================================#
first = True
fig = None

# First fluctuation component
ncDict = read3dDataFromNetCDF(filename, varnames[0], cl)
v1 = ncDict['v']  # 'v' is a generic name for a variable in ncDict

# Second fluctuation component
ncDict = read3dDataFromNetCDF(filename, varnames[1], cl)
v2 = ncDict['v']

# Spatial coords and time
x = ncDict['x']
y = ncDict['y']
z = ncDict['z']
time = ncDict['time']

# Plot coord. information. This aids the user in the beginning.
infoStr = '''
  Coord. range:
예제 #8
0
complexOn = args.complex 
ofile     = args.outputToFile
saveFig   = args.save
gridOn   = args.gridOn
limsOn   = args.limsOn
#==========================================================# 
'''
Establish two boolean variables which indicate whether the created variable is an
independent or dependent variable in function createNetcdfVariable().
'''
parameter = True;  variable  = False


# Read data from NETCDF file
cl = 1
ncDict = read3dDataFromNetCDF( filename , varname, cl )
v = ncDict['v']   # 'v' is a generic name for a variable in ncDict

# Spatial coords and time
x = ncDict['x']
y = ncDict['y']
z = ncDict['z']
time = ncDict['time']

# Plot coord. information. This aids the user in the beginning.
infoStr = '''
  Coord. range:
  min(x)={0} ... max(x)={1}, nx = {2}
  min(y)={3} ... max(y)={4}, ny = {5}
  min(z)={6} ... max(z)={7}, nz = {8}
'''.format(\