Skip to content

Commit

Permalink
template
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Nov 20, 2017
1 parent 9a8b565 commit 3b23371
Showing 1 changed file with 23 additions and 74 deletions.
97 changes: 23 additions & 74 deletions pyhwm2014/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
from pathlib2 import Path
#
from . import hwm14
import logging
from numpy import append, arange, ceil, floor, meshgrid, ones,reshape
from matplotlib.pyplot import figure,show,subplots,cm
from matplotlib.colors import Normalize
import seaborn
try:
from matplotlib.pyplot import figure,show,subplots,cm
from matplotlib.colors import Normalize
import seaborn
except (ImportError, RuntimeError):
figure=None
#
try:
from mpl_toolkits.basemap import Basemap
except ImportError:
Expand Down Expand Up @@ -89,7 +94,7 @@ def __init__( self, alt=300., altlim=[0., 400.], altstp=25., ap=[-1, 35],
self.glonstp = glonstp
self.stl = stl
else:
print( 'Invalid option!' )
logging.error('Invalid option!')
return

self.iyd = int((year - (2000 if year > 1999 else 1900)) * 1000) + day
Expand Down Expand Up @@ -172,9 +177,6 @@ def LatProfile( self ):
self.Uwind.append( w[ 1 ] )
self.Vwind.append( w[ 0 ] )

#
# End of 'LatProfile'
#####

def GMTProfile( self ):

Expand Down Expand Up @@ -210,9 +212,6 @@ def GMTProfile( self ):
self.Uwind.append( w[ 1 ] )
self.Vwind.append( w[ 0 ] )

#
# End of 'GMTProfile'
#####

def LonProfile( self ):

Expand Down Expand Up @@ -241,9 +240,6 @@ def LonProfile( self ):
self.Uwind.append( w[ 1 ] )
self.Vwind.append( w[ 0 ] )

#
# End of 'LonProfile'
#####

def toMLT(self, ut):

Expand All @@ -253,14 +249,6 @@ def toMLT(self, ut):
mlat, mlon, f1e, f1n, f2e, f2n = hwm14.gd2qd(self.glat, self.glon)
self.mlt = hwm14.mltcalc(mlat, mlon, self.doy, ut)

#
# End of 'toMLT'
#####

#
# End of HWM14
######


class HWM14Plot:

Expand Down Expand Up @@ -302,14 +290,11 @@ def __init__( self, profObj=None ):
else:
print( 'Invalid option!' )
valid = False
if valid:
if valid and figure is not None:
show()
else:
print( 'Wrong inputs!' )

#
# End of '__init__'
#####

def GetHHMMSS(self):
hh = floor(self.ut)
Expand All @@ -318,9 +303,7 @@ def GetHHMMSS(self):
dummy = dummy * 60 - mm
self.second = int(floor(dummy * 60))
self.hour, self.minute = int(hh), int(mm)
#
# End of 'GetHHMMSS'
#####


def GetTitle(self):

Expand Down Expand Up @@ -365,11 +348,10 @@ def GetTitle(self):
elif self.option == 4:
self.title = '{:s} - {:s} - {:s} - {:s} - GEOG. LAT.: {:s}'.format(dateStr, timeStr, apStr, altStr, latStr)

#
# End of 'GetTitle'
#####

def HeiProfPlot( self ):
if figure is None:
return

self.GetTitle()

Expand All @@ -382,11 +364,10 @@ def HeiProfPlot( self ):
ax.set_ylabel( r'(km)')
ax.legend( loc='best' )

#
# End of 'HeiProfPlot'
#####

def LatProfPlot( self ):
if figure is None:
return

self.GetTitle()

Expand All @@ -399,11 +380,10 @@ def LatProfPlot( self ):
ax.set_ylabel( r'Wind speed (m/s)')
ax.legend( loc='best' )

#
# End of 'LatProfPlot'
#####

def GMTProfPlot( self ):
if figure is None:
return

self.GetTitle()

Expand All @@ -416,11 +396,10 @@ def GMTProfPlot( self ):
ax.set_ylabel( r'Wind speed (m/s)')
ax.legend( loc='best' )

#
# End of 'GMTProfPlot'
#####

def LonProfPlot( self ):
if figure is None:
return

self.GetTitle()

Expand All @@ -433,22 +412,13 @@ def LonProfPlot( self ):
ax.set_ylabel( r'Wind speed (m/s)')
ax.legend( loc='best' )

#
# End of 'LonProfPlot'
#####

#
# End of 'HWM14Plot'
#####


class HWM142D:

def __init__( self, alt=300., altlim=[0., 400.], altstp=25., ap=[-1, 35],
day=323, f107=-1, f107a=-1, glat=-11.95, glatlim=[-40., 40.],
glatstp=5., glon=-76.77, glonlim=[-40., 40], glonstp=5., option=1,
stl=-1, utlim=[0., 24.], utstp=1., ut=12., verbose=True, year=1993 ):

"""
"""

Expand Down Expand Up @@ -500,7 +470,7 @@ def __init__( self, alt=300., altlim=[0., 400.], altstp=25., ap=[-1, 35],
self.glonlim = glonlim
self.glonstp = glonstp
else:
print( 'Invalid option!' )
logging.error('Invalid option!')
return

self.iyd = int((year - (2000 if year > 1999 else 1900)) * 10000) + day
Expand All @@ -522,12 +492,8 @@ def __init__( self, alt=300., altlim=[0., 400.], altstp=25., ap=[-1, 35],
elif not 'glon' in self.__dict__.keys(): self.LonVsHeiArray()
else: print( '' )

#
# End of '__init__'
#####

def HeiVsLTArray( self ):

"""
"""

Expand All @@ -547,26 +513,19 @@ def HeiVsLTArray( self ):

self.altbins = hwm14Obj.altbins

#
# End of 'HeiVsLTArray'
#####

def LatVsHeiArray(self):

""" """

self.altbins = arange(self.altlim[0], self.altlim[1] + self.altstp, self.altstp)

for _alt in self.altbins:

if True:

hwm14Obj = HWM14( alt=_alt, ap=self.ap, glatlim=self.glatlim,
glatstp=self.glatstp, glon=self.glon, option=self.option,
verbose=self.verbose, ut=self.ut )

else:

pass

Uwind = reshape( hwm14Obj.Uwind, ( len( hwm14Obj.Uwind ), 1 ) )
Expand All @@ -579,9 +538,6 @@ def LatVsHeiArray(self):
self.Uwind = self.Uwind.T
self.Vwind = self.Vwind.T

#
# End of 'LatVsHeiArray'
#####

def LonVsHeiArray(self):

Expand Down Expand Up @@ -611,9 +567,6 @@ def LonVsHeiArray(self):
self.Uwind = self.Uwind.T
self.Vwind = self.Vwind.T

#
# End of 'LonVsHeiArray'
#####

def LonVsLatArray(self):

Expand All @@ -637,16 +590,10 @@ def LonVsLatArray(self):
self.Uwind = self.Uwind.T
self.Vwind = self.Vwind.T

#
# End of 'LonVsHeiArray'
#####


def LatVsGMTArray(self):
pass
#
# End of 'LatVsGMTArray'
#####


#
# End of 'HWM142D'
Expand Down Expand Up @@ -850,6 +797,8 @@ def XVsY2DMap(self, ax, xVal, yVal, zVal, cmap=None, title=None, xlabel=None,

def XVsY2DPlot( self, ax, xVal, yVal, zVal, cmap=None, title=None,
xlabel=None, xlim=None, ylabel=None, ylim=None, zlabel=None, zMax=None, zMin=None ):
if figure is None:
return

X, Y = meshgrid( xVal, yVal )
X = X.T
Expand Down

0 comments on commit 3b23371

Please sign in to comment.