From 4bffd281305f7b91d748be89d46c85f9771c11eb Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 26 Oct 2016 21:43:10 +0200 Subject: [PATCH 01/21] Fixed the scatter part of fan Plotting was not done on an axis, meaning that the plotting crashed --- davitpy/pydarn/plotting/fan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/davitpy/pydarn/plotting/fan.py b/davitpy/pydarn/plotting/fan.py index e8f1dd90..8c1acd84 100644 --- a/davitpy/pydarn/plotting/fan.py +++ b/davitpy/pydarn/plotting/fan.py @@ -342,11 +342,11 @@ def plotFan(sTime, rad, interval=60, fileType='fitex', param='velocity', va='center') xctr = x[0] + .175 * (x[1] - x[0]) if(w < 4): - myFig.scatter(xctr, y[1] * (.98 - w * .025), s=.1 * pts[w], + myFig.gca().scatter(xctr, y[1] * (.98 - w * .025), s=.1 * pts[w], zorder=15, marker='o', linewidths=.5, edgecolor='face', facecolor='k') elif(w == 4): - myFig.scatter(xctr, y[1] * (.98 - w * .025), s=.1 * 35., + myFig.gca().scatter(xctr, y[1] * (.98 - w * .025), s=.1 * 35., zorder=15, marker='o', linewidths=.5, edgecolor='k', facecolor='w') elif(w == 5): From 50f7ded5dea0b025f00a47344b62fd6df8cb70af Mon Sep 17 00:00:00 2001 From: Shirling-VT Date: Thu, 10 Nov 2016 15:31:03 -0500 Subject: [PATCH 02/21] Xueling updated the python_install_mac_port.sh and plotMapGrd.py. --- davitpy/pydarn/plotting/plotMapGrd.py | 9 +++++---- install/python_install_mac_port.sh | 20 ++++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/davitpy/pydarn/plotting/plotMapGrd.py b/davitpy/pydarn/plotting/plotMapGrd.py index 5c9b8726..ce4e3e3d 100644 --- a/davitpy/pydarn/plotting/plotMapGrd.py +++ b/davitpy/pydarn/plotting/plotMapGrd.py @@ -52,7 +52,7 @@ class MapConv(object): the axis handle used mObj : utils.plotUtils.mapObj the map object you want data to be overlayed on. - + Methods -------- @@ -134,7 +134,7 @@ def __init__(self, startTime, mObj, axisHandle, hemi='north', # check if hemi and coords keywords are correct assert(hemi == "north" or hemi == "south"), \ logging.error("hemi should either be 'north' or 'south'") - assert(plotCoords == 'mag' or coords == 'mlt'), \ + assert(plotCoords == 'mag' or plotCoords == 'mlt'), \ logging.error("error, coords must be one of 'mag' or 'mlt'") self.hemi = hemi @@ -496,7 +496,8 @@ def calcCnvPots(self): import datetime import numpy import scipy - + from davitpy.utils import * + import davitpy.models.aacgm as aacgm if self.hemi == 'north': hemisphere = 1 @@ -613,7 +614,7 @@ def calcCnvPots(self): # mlt conversion stuff if self.plotCoords == 'mlt': - epoch = timeUtils.datetimeToEpoch(strtTime) + epoch = timeUtils.datetimeToEpoch(self.mapData.sTime+datetime.timedelta(minutes=1)) mltDef = aacgm.mltFromEpoch(epoch,0.0) * 15. lonShftFit += mltDef gridArr[1,:] = numpy.mod( ( gridArr[1,:] + lonShftFit ) / 15., 24. ) diff --git a/install/python_install_mac_port.sh b/install/python_install_mac_port.sh index b37609f6..35c3301e 100755 --- a/install/python_install_mac_port.sh +++ b/install/python_install_mac_port.sh @@ -7,9 +7,15 @@ ver=27 port -n install python${ver} -port -n install mpich +gcc47 +port -n install mpich +port -n install gcc49 +port -n select gcc mp-gcc49 +hash gfotran port -n install coreutils -easy_install pip +#easy_install pip +sudo port install py${ver}-pip +sudo port install pip_select +sudo port select --set pip pip${ver} pip install --upgrade numpy pip install --upgrade matplotlib port -n install py${ver}-matplotlib-basemap @@ -19,7 +25,7 @@ pip install --upgrade pyzmq tornado pygments pip install --upgrade ipython pip install --upgrade jupyter python -c 'from IPython.external import mathjax; mathjax.install_mathjax()' -pip install --upgrade PIL +pip install --upgrade pillow pip install --upgrade pymongo pip install --upgrade paramiko pip install --upgrade jinja2 @@ -27,9 +33,15 @@ pip install --upgrade jsonschema pip install --upgrade cython pip install --upgrade scikit-image pip install --upgrade pandas +pip install netCDF4 dir=$(pwd) cd /tmp git clone https://github.com/matplotlib/basemap.git -cd basemap +cd basemap/geos-3.3.3 +export GEOS_DIR=/usr/local/geos +./configure --prefix=$GEOS_DIR +make +make install +cd .. python2.7 setup.py install From 14d0b5a7a3c99317bfdac14c9feaac7b5e8b2c0b Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 11 Nov 2016 15:15:19 +0100 Subject: [PATCH 03/21] Exposed the resolution of the latitude --- davitpy/utils/plotUtils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/davitpy/utils/plotUtils.py b/davitpy/utils/plotUtils.py index a7e9d3b5..eb040f19 100644 --- a/davitpy/utils/plotUtils.py +++ b/davitpy/utils/plotUtils.py @@ -78,6 +78,8 @@ class as the attribute "dateTime". This is needed when plotting show/hide parallels and meridians grid (default=True) gridLabels : Optional[bool] label parallels and meridians (default=True) + gridLatRes: Optional[float] + set the latitude resolution of gridlines (default=20.) showCoords : Optional[bool] display coordinate system name in upper right corner (default=True) @@ -133,7 +135,7 @@ def __init__(self, ax=None, datetime=None, coords='geo', projection='stere', boundinglat=None, width=None, height=None, draw=True, fillContinents='.8', fillOceans='None', fillLakes=None, fill_alpha=.5, coastLineWidth=0., coastLineColor=None, - grid=True, gridLabels=True, showCoords=True, **kwargs): + grid=True, gridLabels=True, gridLatRes=20., showCoords=True, **kwargs): """This class wraps arround :class:`mpl_toolkits.basemap.Basemap` () @@ -155,6 +157,7 @@ def __init__(self, ax=None, datetime=None, coords='geo', projection='stere', self._showCoords=showCoords self._grid=grid self._gridLabels=gridLabels + self._gridLatRes=gridLatRes self._coordsDict, self._coords_string = get_coord_dict() if datetime is None and dateTime is None: @@ -218,7 +221,7 @@ def draw(self): # draw parallels and meridians. if self._grid: - parallels = np.arange(-80.,81.,20.) + parallels = np.arange(-80.,81.,self._gridLatRes) out = self.drawparallels(parallels, color='.6', zorder=10) # Set format of meridian labels. if self.coords == "mlt": From 8ff3a0156559924956e8113c7f046c44a488e17e Mon Sep 17 00:00:00 2001 From: ksterne Date: Thu, 8 Dec 2016 14:46:45 -0500 Subject: [PATCH 04/21] Obiligatory version update for new develop --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index d4f58aa5..e27a27a8 100644 --- a/setup.py +++ b/setup.py @@ -114,7 +114,7 @@ def read(fname): # Now execute the setup ############################################################################# setup(name='davitpy', - version="0.6", + version="0.7", description="Space Science Toolkit", author="VT SuperDARN Lab and friends", author_email="ajribeiro86@gmail.com", @@ -132,7 +132,7 @@ def read(fname): py_modules=['davitpy'], install_requires=[], classifiers=[ - "Development Status :: 6 - Beta", + "Development Status :: 7 - Beta", "Topic :: Scientific/Engineering", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU General Public License (GPL)", From 5589cd0e819aa4408af54f1573a680a5555e59bf Mon Sep 17 00:00:00 2001 From: ksterne Date: Thu, 15 Dec 2016 14:03:41 -0500 Subject: [PATCH 05/21] plot_acf input checks --- davitpy/pydarn/plotting/acfPlot.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/davitpy/pydarn/plotting/acfPlot.py b/davitpy/pydarn/plotting/acfPlot.py index 85b6a2f3..1e3c013a 100755 --- a/davitpy/pydarn/plotting/acfPlot.py +++ b/davitpy/pydarn/plotting/acfPlot.py @@ -93,6 +93,36 @@ def plot_acf(myBeam, gate, normalized=True, mark_blanked=True, import numpy as np from davitpy import pydarn + # Input checks + # myBeam check for rawacf file + assert(myBeam.fType == 'rawacf'), logging.error('myBeam must ' + 'be from a rawacf file') + # Check of gate parameter + assert(isinstance(gate, int) and gate >= 0), logging.error( + 'gate must be an integer and zero or positive') + # Check of normalized + assert(isinstance(normalized, bool)), logging.error( + 'normalized must be a boolean') + # Check of mark_blanked + assert(isinstance(mark_blanked, bool)), logging.error( + 'mark_blanked must be a boolean') + # Check of xcf + assert(isinstance(xcf, bool)), logging.error( + 'xcf must be a boolean') + # Check of panel + assert(isinstance(panel, int)), logging.error( + 'panel must be an integer') + # Space for ax check(s) + # Check of show variable type + assert(isinstance(show, bool)), logging.error( + 'show must be a boolean') + # Check of png variable type + assert(isinstance(png, bool)), logging.error( + 'png must be a boolean') + # Check of pdf variable type + assert(isinstance(pdf, bool)), logging.error( + 'pdf must be a boolen') + lags = list(set([x[1] - x[0] for x in myBeam.prm.ltab])) ltab = myBeam.prm.ltab tau = myBeam.prm.mpinc From 2f6e6547a98ed63946a6cf7e52e4b9efcfe58b77 Mon Sep 17 00:00:00 2001 From: ksterne Date: Thu, 15 Dec 2016 14:10:05 -0500 Subject: [PATCH 06/21] plot_rli input checks --- davitpy/pydarn/plotting/acfPlot.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/davitpy/pydarn/plotting/acfPlot.py b/davitpy/pydarn/plotting/acfPlot.py index 1e3c013a..a120eaad 100755 --- a/davitpy/pydarn/plotting/acfPlot.py +++ b/davitpy/pydarn/plotting/acfPlot.py @@ -461,6 +461,26 @@ def plot_rli(myBeam, normalized=True, xcf=False, show=True, png=False, pdf=False import matplotlib.cm as cmx from davitpy import pydarn + # Input checks + # myBeam check for rawacf file + assert(myBeam.fType == 'rawacf'), logging.error('myBeam must ' + 'be from a rawacf file') + # Check of normalized variable type + assert(isinstance(normalized, bool)), logging.error( + 'normalized must be a boolean') + # Check of xcf variable type + assert(isinstance(xcf, bool)), logging.error( + 'xcf must be a boolean') + # Check of show variable type + assert(isinstance(show, bool)), logging.error( + 'show must be a boolean') + # Check of png variable type + assert(isinstance(png, bool)), logging.error( + 'png must be a boolean') + # Check of pdf variable type + assert(isinstance(pdf, bool)), logging.error( + 'pdf must be a boolen') + # Get parameters lags = list(set([x[1] - x[0] for x in myBeam.prm.ltab])) range_gates = np.linspace(0.5, myBeam.prm.nrang + 0.5, From 5d40c2cf5c18352957be2a81b573071519e07db1 Mon Sep 17 00:00:00 2001 From: ksterne Date: Thu, 15 Dec 2016 14:19:22 -0500 Subject: [PATCH 07/21] PEP8 edits --- davitpy/pydarn/plotting/acfPlot.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/davitpy/pydarn/plotting/acfPlot.py b/davitpy/pydarn/plotting/acfPlot.py index a120eaad..bc4c5143 100755 --- a/davitpy/pydarn/plotting/acfPlot.py +++ b/davitpy/pydarn/plotting/acfPlot.py @@ -95,8 +95,8 @@ def plot_acf(myBeam, gate, normalized=True, mark_blanked=True, # Input checks # myBeam check for rawacf file - assert(myBeam.fType == 'rawacf'), logging.error('myBeam must ' - 'be from a rawacf file') + assert(myBeam.fType == 'rawacf'), logging.error( + 'myBeam must be from a rawacf file') # Check of gate parameter assert(isinstance(gate, int) and gate >= 0), logging.error( 'gate must be an integer and zero or positive') @@ -169,7 +169,7 @@ def plot_acf(myBeam, gate, normalized=True, mark_blanked=True, acfFFT = [] acfFFT.extend(temp[len(temp) / 2 + 1:]) acfFFT.extend(temp[0:len(temp) / 2 + 1]) - freq_scale_factor = ((3. * 10 ** 8) / + freq_scale_factor = ((3. * 10 ** 8) / (myBeam.prm.tfreq * 1000. * 2. * lags[-1] * myBeam.prm.mpinc * 10.0 ** -6)) vels = freq_scale_factor * (np.array(range(len(acfFFT))) - @@ -190,7 +190,7 @@ def plot_acf(myBeam, gate, normalized=True, mark_blanked=True, if show: fig = pyplot.figure() else: - if (png == False) and (pdf == False): + if (png is False) and (pdf is False): png = True fig = mpl_fig() ax1 = fig.add_axes([0.1, 0.55, 0.35, 0.35]) @@ -415,7 +415,8 @@ def calc_blanked(ltab, tp, tau, tfr, gate): return txs_in_lag -def plot_rli(myBeam, normalized=True, xcf=False, show=True, png=False, pdf=False): +def plot_rli(myBeam, normalized=True, xcf=False, + show=True, png=False, pdf=False): """This function plots a range-lag-intensity plot of ACF/XCF data for an input beamData object. @@ -463,8 +464,8 @@ def plot_rli(myBeam, normalized=True, xcf=False, show=True, png=False, pdf=False # Input checks # myBeam check for rawacf file - assert(myBeam.fType == 'rawacf'), logging.error('myBeam must ' - 'be from a rawacf file') + assert(myBeam.fType == 'rawacf'), logging.error( + 'myBeam must be from a rawacf file') # Check of normalized variable type assert(isinstance(normalized, bool)), logging.error( 'normalized must be a boolean') @@ -492,7 +493,7 @@ def plot_rli(myBeam, normalized=True, xcf=False, show=True, png=False, pdf=False if show: fig = pyplot.figure() else: - if (png == False) and (pdf == False): + if (png is False) and (pdf is False): png = True fig = mpl_fig() @@ -593,7 +594,7 @@ def plot_rli(myBeam, normalized=True, xcf=False, show=True, png=False, pdf=False 'ACF ' + rad_name + ' Beam: ' + str(myBeam.bmnum) fig.suptitle(title, y=0.94) - #handle the outputs + # handle the outputs if png: if not show: canvas = FigureCanvasAgg(fig) From 74e4141ab9d6015e351343d1cb94683ac624a14c Mon Sep 17 00:00:00 2001 From: Xueling Shi Date: Sat, 14 Jan 2017 18:33:23 -0500 Subject: [PATCH 08/21] Update python_install_mac_port.sh no need sudo inside the script --- install/python_install_mac_port.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/python_install_mac_port.sh b/install/python_install_mac_port.sh index 35c3301e..e1c83f13 100755 --- a/install/python_install_mac_port.sh +++ b/install/python_install_mac_port.sh @@ -13,9 +13,9 @@ port -n select gcc mp-gcc49 hash gfotran port -n install coreutils #easy_install pip -sudo port install py${ver}-pip -sudo port install pip_select -sudo port select --set pip pip${ver} +port install py${ver}-pip +port install pip_select +port select --set pip pip${ver} pip install --upgrade numpy pip install --upgrade matplotlib port -n install py${ver}-matplotlib-basemap From 2a785dad06b0f40dd92ff1a12a63351be36fa605 Mon Sep 17 00:00:00 2001 From: Xueling Shi Date: Sat, 14 Jan 2017 20:08:09 -0500 Subject: [PATCH 09/21] Update python_install_mac_port.sh --- install/python_install_mac_port.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/python_install_mac_port.sh b/install/python_install_mac_port.sh index e1c83f13..897cacf7 100755 --- a/install/python_install_mac_port.sh +++ b/install/python_install_mac_port.sh @@ -44,4 +44,4 @@ export GEOS_DIR=/usr/local/geos make make install cd .. -python2.7 setup.py install +python setup.py install From 9d7b9e817efa075ec11193d630a0f725a4807fb0 Mon Sep 17 00:00:00 2001 From: Xueling Shi Date: Mon, 16 Jan 2017 15:06:43 -0800 Subject: [PATCH 10/21] Update debian_dependencies.sh stable basemap vesion --- install/debian_dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/debian_dependencies.sh b/install/debian_dependencies.sh index 960f9180..9bcc61e9 100755 --- a/install/debian_dependencies.sh +++ b/install/debian_dependencies.sh @@ -56,7 +56,7 @@ pip install -U cryptography #install basemap cd /tmp -git clone https://github.com/matplotlib/basemap.git +git clone --branch v1.0.7rel https://github.com/matplotlib/basemap.git cd basemap/geos-3.3.3 export GEOS_DIR=/usr/local ./configure --prefix=$GEOS_DIR From 6bfb73156f16d6b60ff1bd177390c02fe36d3769 Mon Sep 17 00:00:00 2001 From: Xueling Shi Date: Mon, 16 Jan 2017 15:07:27 -0800 Subject: [PATCH 11/21] Update python_install_mac_port.sh --- install/python_install_mac_port.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/python_install_mac_port.sh b/install/python_install_mac_port.sh index 897cacf7..9511d610 100755 --- a/install/python_install_mac_port.sh +++ b/install/python_install_mac_port.sh @@ -37,7 +37,7 @@ pip install netCDF4 dir=$(pwd) cd /tmp -git clone https://github.com/matplotlib/basemap.git +git clone --branch v1.0.7rel https://github.com/matplotlib/basemap.git cd basemap/geos-3.3.3 export GEOS_DIR=/usr/local/geos ./configure --prefix=$GEOS_DIR From 77c0b3e6b5035ebd93796273fd41ffd570ff7a17 Mon Sep 17 00:00:00 2001 From: Ashton Reimer Date: Mon, 16 Jan 2017 18:25:08 -0800 Subject: [PATCH 12/21] Removed unnecessary plotCoords variable that caused bug. --- davitpy/pydarn/plotting/plotMapGrd.py | 57 +++++++-------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/davitpy/pydarn/plotting/plotMapGrd.py b/davitpy/pydarn/plotting/plotMapGrd.py index ce4e3e3d..0210e722 100644 --- a/davitpy/pydarn/plotting/plotMapGrd.py +++ b/davitpy/pydarn/plotting/plotMapGrd.py @@ -103,7 +103,7 @@ class MapConv(object): def __init__(self, startTime, mObj, axisHandle, hemi='north', - maxVelScale=1000., plotCoords='mag'): + maxVelScale=1000.): import datetime from davitpy.pydarn.sdio import sdDataOpen @@ -134,11 +134,8 @@ def __init__(self, startTime, mObj, axisHandle, hemi='north', # check if hemi and coords keywords are correct assert(hemi == "north" or hemi == "south"), \ logging.error("hemi should either be 'north' or 'south'") - assert(plotCoords == 'mag' or plotCoords == 'mlt'), \ - logging.error("error, coords must be one of 'mag' or 'mlt'") self.hemi = hemi - self.plotCoords = plotCoords # Read the corresponding data record from both map and grid files. # This is the way I'm setting stuff up to avoid confusion of reading @@ -215,18 +212,13 @@ def overlayGridVel(self, pltColBar=True, overlayRadNames=True, # depending on whether we have 'mag' or 'mlt' coords, # calculate endLon - if self.plotCoords == 'mag': - endLon = mlonsPlot[nn] + numpy.degrees(delLon) - elif self.plotCoords == 'mlt': - endLon = (mlonsPlot[nn] + numpy.degrees(delLon)) / 15. - else: - logging.warning('Check the coords') + endLon = mlonsPlot[nn] + numpy.degrees(delLon) # get the start and end vecs xVecStrt, yVecStrt = self.mObj(mlonsPlot[nn], mlatsPlot[nn], - coords=self.plotCoords) + coords='mag') xVecEnd, yVecEnd = self.mObj(endLon, endLat, - coords=self.plotCoords) + coords='mag') # Plot the start point and then append the vector indicating magn. # and azimuth @@ -612,14 +604,7 @@ def calcCnvPots(self): else: logging.warning('LatShift is not zero, need to rewrite code for that, currently continuing assuming it is zero') - # mlt conversion stuff - if self.plotCoords == 'mlt': - epoch = timeUtils.datetimeToEpoch(self.mapData.sTime+datetime.timedelta(minutes=1)) - mltDef = aacgm.mltFromEpoch(epoch,0.0) * 15. - lonShftFit += mltDef - gridArr[1,:] = numpy.mod( ( gridArr[1,:] + lonShftFit ) / 15., 24. ) - else: - gridArr[1,:] = ( gridArr[1,:] + lonShftFit ) + gridArr[1,:] = ( gridArr[1,:] + lonShftFit ) latCntr = gridArr[0,:].reshape( ( 181, 60 ) ) lonCntr = gridArr[1,:].reshape( ( 181, 60 ) ) @@ -651,7 +636,7 @@ def overlayCnvCntrs(self): ( latCntr, lonCntr, potCntr ) = self.calcCnvPots() #plot the contours - xCnt, yCnt = self.mObj( lonCntr, latCntr, coords=self.plotCoords ) + xCnt, yCnt = self.mObj( lonCntr, latCntr, coords='mag') cntrPlt = self.mObj.contour( xCnt, yCnt, potCntr, zorder = 2., vmax=potCntr.max(), vmin=potCntr.min(), @@ -681,7 +666,7 @@ def overlayHMB(self, hmbCol='Gray'): """ xVecHMB, yVecHMB = self.mObj( self.mapData.model.boundarymlon, - self.mapData.model.boundarymlat, coords = self.plotCoords ) + self.mapData.model.boundarymlat, coords='mag' ) grdPltHMB = self.mObj.plot( xVecHMB, yVecHMB, linewidth = 2., linestyle = ':', color = hmbCol, zorder = 4. ) grdPltHMB2 = self.mObj.plot( xVecHMB, yVecHMB, @@ -742,16 +727,10 @@ def overlayMapModelVel(self, pltColBar=False, delLon = ( numpy.arctan2( numpy.sin(numpy.deg2rad( velAzm[nn] ) )*numpy.sin(vecLen)*numpy.cos(numpy.deg2rad( mlatsPlot[nn] ) ), numpy.cos(vecLen) - numpy.sin(numpy.deg2rad( mlatsPlot[nn] ) )*numpy.sin(numpy.deg2rad( endLat ) ) ) ) - if self.plotCoords == 'mag': - endLon = mlonsPlot[nn] + numpy.degrees( delLon ) - elif self.plotCoords == 'mlt': - endLon = ( mlonsPlot[nn] + numpy.degrees( delLon ) )/15. - else: - logging.warning('Check the coords.') - - - xVecStrt, yVecStrt = self.mObj(mlonsPlot[nn], mlatsPlot[nn], coords=self.plotCoords) - xVecEnd, yVecEnd = self.mObj(endLon, endLat, coords = self.plotCoords) + endLon = mlonsPlot[nn] + numpy.degrees( delLon ) + + xVecStrt, yVecStrt = self.mObj(mlonsPlot[nn], mlatsPlot[nn], coords='mag') + xVecEnd, yVecEnd = self.mObj(endLon, endLat, coords='mag') self.mapModelPltStrt = self.mObj.scatter( xVecStrt, yVecStrt, c=velMagn[nn], s=10., vmin=0, vmax=self.maxVelPlot, alpha=0.7, @@ -835,18 +814,10 @@ def overlayMapFitVel(self, pltColBar=True, numpy.cos(vecLen) - numpy.sin(numpy.deg2rad( mlatsPlot[nn] ) ) \ *numpy.sin(numpy.deg2rad( endLat ) ) ) ) - if self.plotCoords == 'mag': - endLon = mlonsPlot[nn] + numpy.degrees( delLon ) - elif self.plotCoords == 'mlt': - endLon = ( mlonsPlot[nn] + numpy.degrees( delLon ) )/15. - else: - logging.warning('Check the coords.') - + endLon = mlonsPlot[nn] + numpy.degrees( delLon ) - xVecStrt, yVecStrt = self.mObj(mlonsPlot[nn], mlatsPlot[nn], - coords=self.plotCoords) - xVecEnd, yVecEnd = self.mObj(endLon, endLat, - coords = self.plotCoords) + xVecStrt, yVecStrt = self.mObj(mlonsPlot[nn], mlatsPlot[nn], coords='mag') + xVecEnd, yVecEnd = self.mObj(endLon, endLat, coords='mag') self.mapFitPltStrt.append(self.mObj.scatter( xVecStrt, yVecStrt, c=velMagn[nn], s=10., From c16574e0985285c5b1c99db37a50f2dfad3b0052 Mon Sep 17 00:00:00 2001 From: ksterne Date: Thu, 9 Feb 2017 15:12:08 -0500 Subject: [PATCH 13/21] Adding force connection attempt and debug messages --- davitpy/pydarn/radar/radInfoIo.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/davitpy/pydarn/radar/radInfoIo.py b/davitpy/pydarn/radar/radInfoIo.py index 16fa6289..171cc4c3 100644 --- a/davitpy/pydarn/radar/radInfoIo.py +++ b/davitpy/pydarn/radar/radInfoIo.py @@ -310,7 +310,10 @@ class : updateRadars self.db_host, self.db_name) # print uri try: + logging.debug('Trying to connect to hdw.dat mongodb') conn = MongoClient(uri) + # Force connection attempt + conn.server_info() dba = conn[self.db_name] except: logging.exception('Could not connect to remote DB: ', @@ -318,6 +321,7 @@ class : updateRadars dba = False if dba: + logging.debug('Connection a success, so proceeding with remote db') try: colSel = lambda colName: dba[colName].find() @@ -332,6 +336,7 @@ class : updateRadars hdw.dat info') return False else: + logging.debug('Reading hdw.dat info from local files') result = self.__readFromFiles() if not result: logging.error('Could not update .radars.sqlite file with \ From 89fbd7aed79eaec738b7e948296caf3a91ad9678 Mon Sep 17 00:00:00 2001 From: ksterne Date: Thu, 9 Feb 2017 15:41:20 -0500 Subject: [PATCH 14/21] Corrected exception message --- davitpy/pydarn/radar/radInfoIo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/davitpy/pydarn/radar/radInfoIo.py b/davitpy/pydarn/radar/radInfoIo.py index 171cc4c3..cdb321cf 100644 --- a/davitpy/pydarn/radar/radInfoIo.py +++ b/davitpy/pydarn/radar/radInfoIo.py @@ -316,8 +316,8 @@ class : updateRadars conn.server_info() dba = conn[self.db_name] except: - logging.exception('Could not connect to remote DB: ', - sys.exc_info()[0]) + logging.warning('Could not connect to remote DB: %s', + str(uri)) dba = False if dba: From 4d8bf8a9ada6e3c5f2b1e2d214c505b149143d33 Mon Sep 17 00:00:00 2001 From: ksterne Date: Thu, 9 Feb 2017 15:47:13 -0500 Subject: [PATCH 15/21] PEP8 edits --- davitpy/pydarn/radar/radInfoIo.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/davitpy/pydarn/radar/radInfoIo.py b/davitpy/pydarn/radar/radInfoIo.py index cdb321cf..5e9d1b04 100644 --- a/davitpy/pydarn/radar/radInfoIo.py +++ b/davitpy/pydarn/radar/radInfoIo.py @@ -30,6 +30,7 @@ """ import logging + def radarRead(path=None): """Reads radar.dat file @@ -71,9 +72,9 @@ def radarRead(path=None): txt = 'You may be getting this error because your computer cannot ' txt = '{:s}contact an appropriate internet server to get '.format(txt) txt = '{:s}the latest radar.dat information. You can '.format(txt) - txt = '{:s}use a local file instead by setting the SD_RADAR'.format(txt) - txt = '{:s} environment variable to the location of a local'.format(txt) - txt = '{:s} copy of radar.dat.\n'.format(txt) + txt = '{:s}use a local file instead by setting the '.format(txt) + txt = '{:s}SD_RADAR environment variable to the location '.format(txt) + txt = '{:s}of a local copy of radar.dat.\n'.format(txt) print txt print 'Example, you might add a similar line to your .bashrc:' @@ -161,10 +162,10 @@ def hdwRead(fname, path=None): txt = 'You may be getting this error because your computer cannot ' txt = '{:s}contact an appropriate internet server to get '.format(txt) - txt = '{:s}the latest hdw.dat information. You can can use'.format(txt) - txt = '{:s} a local file instead by setting the SD_HDWPATH '.format(txt) - txt = '{:s}environment variable to the location of the '.format(txt) - txt = '{:s}local hdw.dat path.'.format(txt) + txt = '{:s}the latest hdw.dat information. You can can '.format(txt) + txt = '{:s}use a local file instead by setting the '.format(txt) + txt = '{:s}SD_HDWPATH environment variable to the location'.format(txt) + txt = '{:s} of the local hdw.dat path.'.format(txt) print txt txt = 'You can get the latest hdw.dat files from ' txt = '{:s}https://github.com/vtsuperdarn/hdw.dat\n'.format(txt) @@ -219,7 +220,7 @@ class updateRadars(object): if the database cannot be reached. Currently, the remote database is housed on the VT servers. - Attributes + Attributes ------- sql_path : str path to sqlite file @@ -317,7 +318,7 @@ class : updateRadars dba = conn[self.db_name] except: logging.warning('Could not connect to remote DB: %s', - str(uri)) + str(uri)) dba = False if dba: @@ -325,7 +326,8 @@ class : updateRadars try: colSel = lambda colName: dba[colName].find() - self.db_select = {'rad': colSel("radars"), 'hdw': colSel("hdw"), + self.db_select = {'rad': colSel("radars"), + 'hdw': colSel("hdw"), 'inf': colSel("metadata")} return True except: From d48c300a85f2ff14d28ee25920f2cd207b1fd18c Mon Sep 17 00:00:00 2001 From: MuhammadVT Date: Tue, 14 Feb 2017 14:18:24 -0500 Subject: [PATCH 16/21] remove an extra line --- davitpy/pydarn/radar/radInfoIo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/davitpy/pydarn/radar/radInfoIo.py b/davitpy/pydarn/radar/radInfoIo.py index 5e9d1b04..510df0f8 100644 --- a/davitpy/pydarn/radar/radInfoIo.py +++ b/davitpy/pydarn/radar/radInfoIo.py @@ -150,7 +150,6 @@ def hdwRead(fname, path=None): if path: pathOpen = os.path.join(path, fname) else: - pathOpen = os.getenv('SD_RADAR') pathOpen = os.path.join(str(os.getenv('SD_HDWPATH')), fname) try: From 1bdfbebb01b650fc60d67e442ca318d653f5535f Mon Sep 17 00:00:00 2001 From: ksterne Date: Mon, 27 Feb 2017 12:05:30 -0500 Subject: [PATCH 17/21] Changing logging message levels to be more helpful --- davitpy/pydarn/radar/radInfoIo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/davitpy/pydarn/radar/radInfoIo.py b/davitpy/pydarn/radar/radInfoIo.py index 510df0f8..a52b2c03 100644 --- a/davitpy/pydarn/radar/radInfoIo.py +++ b/davitpy/pydarn/radar/radInfoIo.py @@ -304,6 +304,7 @@ class : updateRadars """ from pymongo import MongoClient import sys + import os # print self.db_user,self.db_pswd,self.db_host, self.db_name uri = 'mongodb://{0}:{1}@{2}/{3}'.format(self.db_user, self.db_pswd, @@ -316,7 +317,7 @@ class : updateRadars conn.server_info() dba = conn[self.db_name] except: - logging.warning('Could not connect to remote DB: %s', + logging.error('Could not connect to remote DB: %s', str(uri)) dba = False @@ -337,7 +338,8 @@ class : updateRadars hdw.dat info') return False else: - logging.debug('Reading hdw.dat info from local files') + logging.warning('Reading hdw.dat info from local files in %s', + os.getenv('SD_HDWPATH')) result = self.__readFromFiles() if not result: logging.error('Could not update .radars.sqlite file with \ From d6d248dc8dc74fc29b635d982b3f8b30999596a2 Mon Sep 17 00:00:00 2001 From: ksterne Date: Mon, 27 Feb 2017 12:10:50 -0500 Subject: [PATCH 18/21] PEP8 edits --- davitpy/pydarn/radar/radInfoIo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/davitpy/pydarn/radar/radInfoIo.py b/davitpy/pydarn/radar/radInfoIo.py index a52b2c03..2066bfb8 100644 --- a/davitpy/pydarn/radar/radInfoIo.py +++ b/davitpy/pydarn/radar/radInfoIo.py @@ -318,7 +318,7 @@ class : updateRadars dba = conn[self.db_name] except: logging.error('Could not connect to remote DB: %s', - str(uri)) + str(uri)) dba = False if dba: @@ -427,11 +427,11 @@ class : updateRadars cur.execute("CREATE TABLE hdw (%s)" % ', '.join(self.dtype_hdw)) cur.execute("CREATE TABLE inf (%s)" % ', '.join(self.dtype_inf)) - cur.executemany("INSERT INTO rad VALUES(%s)" % ', '.join(['?'] * \ + cur.executemany("INSERT INTO rad VALUES(%s)" % ', '.join(['?'] * len(self.dtype_rad)), arr_rad) - cur.executemany("INSERT INTO hdw VALUES(%s)" % ', '.join(['?'] * \ + cur.executemany("INSERT INTO hdw VALUES(%s)" % ', '.join(['?'] * len(self.dtype_hdw)), arr_hdw) - cur.executemany("INSERT INTO inf VALUES(%s)" % ', '.join(['?'] * \ + cur.executemany("INSERT INTO inf VALUES(%s)" % ', '.join(['?'] * len(self.dtype_inf)), arr_inf) return True From 1b619acdc8bbd5503342ed7dea3d9a4556727069 Mon Sep 17 00:00:00 2001 From: ksterne Date: Wed, 19 Apr 2017 07:27:03 -0400 Subject: [PATCH 19/21] Removing plotCoords documentation --- davitpy/pydarn/plotting/plotMapGrd.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/davitpy/pydarn/plotting/plotMapGrd.py b/davitpy/pydarn/plotting/plotMapGrd.py index 0210e722..2bc35473 100644 --- a/davitpy/pydarn/plotting/plotMapGrd.py +++ b/davitpy/pydarn/plotting/plotMapGrd.py @@ -34,8 +34,6 @@ class MapConv(object): maxVelScale : Optional[float] maximum velocity to be used for plotting, min is zero so scale is [0,1000] - plotCoords : Optional[str] - coordinates of the plot, only use either 'mag' or 'mlt' Attributes ---------- @@ -52,7 +50,7 @@ class MapConv(object): the axis handle used mObj : utils.plotUtils.mapObj the map object you want data to be overlayed on. - + Methods -------- From 72e8080409adf05c57c3cd83ff025402e71f0814 Mon Sep 17 00:00:00 2001 From: ksterne Date: Wed, 19 Apr 2017 07:30:25 -0400 Subject: [PATCH 20/21] Making error message clearer --- davitpy/pydarn/plotting/plotMapGrd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/davitpy/pydarn/plotting/plotMapGrd.py b/davitpy/pydarn/plotting/plotMapGrd.py index 2bc35473..8aea942e 100644 --- a/davitpy/pydarn/plotting/plotMapGrd.py +++ b/davitpy/pydarn/plotting/plotMapGrd.py @@ -122,12 +122,12 @@ def __init__(self, startTime, mObj, axisHandle, hemi='north', # requested if hemi == "north": assert(mObj.boundarylats[0] > 0.), \ - logging.error("Map object is using one hemisphere and data the" - " other") + logging.error("Map and data objects must be from the same" + " hemisphere") else: assert(mObj.boundarylats[0] < 0.), \ - logging.error("Map object is using one hemisphere and data the" - " other") + logging.error("Map and data objects must be from the same" + " hemisphere") # check if hemi and coords keywords are correct assert(hemi == "north" or hemi == "south"), \ From d9b5e7666d9ccd73858c27f66e47a472b58d1769 Mon Sep 17 00:00:00 2001 From: Nathaniel Frissell Date: Mon, 24 Apr 2017 17:26:44 -0400 Subject: [PATCH 21/21] Fix Typo in Geopack The comma should be a decimal point. --- davitpy/utils/geoPack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/davitpy/utils/geoPack.py b/davitpy/utils/geoPack.py index d9f509b4..618aa3e4 100644 --- a/davitpy/utils/geoPack.py +++ b/davitpy/utils/geoPack.py @@ -643,7 +643,7 @@ def greatCircleDist(lat1, lon1, lat2, lon2): lon2 = np.radians(lon2) dlat = (lat2 - lat1) / 2.0 - dlon = (lon2 - lon1) / 2,0 + dlon = (lon2 - lon1) / 2.0 a = np.sin(dlat)**2 + np.cos(lat1) * np.cos(lat2) * np.sin(dlon)**2 radDist = 2.0 * np.arctan2(np.sqrt(a), np.sqrt(1.0 - a))