def main(): print('begin') print(datetime.datetime.now()) instance_gpm = GPM(init_x=init_x, \ gamma=gamma, h=h, f=f, \ num=num, b=b) (x, fx) = instance_gpm.loop() print(x) print(fx) print(datetime.datetime.now())
def test_login_success(self, inputs, login, db): inputs.side_effect = ['test@test', 'test'] db_mock = mock.Mock() db.return_value = db_mock db_mock.execute.return_value.fetchone.return_value = [ 'test@test', 'test' ] assert GPM().login() is True
def test_gpm_assign_member_failure(self, inputs, login, db): inputs.side_effect = [ 'Dummy', 'Dummy', 22, 'M', 'Dummy', 'Dummy', 560034, 'dummy', 'dummy', 'dummy', 1 ] db_mock = mock.Mock() db.return_value = db_mock db_mock.execute.side_effect = sqlite3.Error assert GPM().gpm_assign_member() is False
def test_gpm_assign_member_success(self, inputs, login, db): inputs.side_effect = [ 'Dummy', 'Dummy', 22, 'M', 'Dummy', 'Dummy', 560034, 'dummy', 'dummy', 'dummy', 1 ] db_mock = mock.Mock() db.return_value = db_mock db_mock.execute.return_value = True assert GPM().gpm_assign_member() is True
def main(): init_x = [1, 1, 1] gamma = 0.2 x1 = Symbol("x1") x2 = Symbol("x2") x3 = Symbol("x3") f = [[x1**3 + x2**2 + x3]] h = [[x1**2 + x2**2 + x3**2], [2 * x1**2 + x2**2 + x3**2], [x1**2 + 4 * x2**2 + x3**2], [x1**3 + x2**2 + 3 * x3**2]] b = [9, 11, 10, 13] num = 3 a = GPM(init_x=init_x, gamma=gamma, f=f, h=h, b=b, num=num) (x_min, f_min) = a.loop() print(x_min, f_min)
def __init__(self): self._client = GPM() super()
def main(args,opts): print args print opts ''' prjName = 'GPM.KuPR' prdLv = 'L2' prdVer = '04' varName = 'NS/SLV/precipRateESurface' ''' prjName = 'GPM.GMI' prdLv = 'L2' prdVer = '03' varName = 'S1/surfacePrecipitation' #BBox = [[20,0],[48,180]] # Radar-AMeDAS domain BBox = [[20,118],[48,150]] # Radar-AMeDAS domain res = 0.1 delT = timedelta(seconds=60*60) # sDTime = datetime( 2014,4,30 ) # eDTime = datetime( 2014,5,3 ) sDTime = datetime( 2014,4,3,22 ) sDTime = datetime( 2014,4,4,0 ) eDTime = datetime( 2014,4,5,0 ) print sDTime, eDTime gpm = GPM(prjName, prdLv, prdVer) JP = gpm(varName, sDTime, eDTime, BBox, #[[30,125],[45,145]], 0.2, ) ''' 0.1, timedelta(seconds=3600*24)) ''' for d in JP.griddata: print d.shape, d.max(), d.min(), np.ma.masked_less_equal(d,0).sum() #sys.exit() H = np.arange(25) for h0,h1 in zip(H[:-1], H[1:]): offset = 0 if h1 !=24 else 1 sdtime = datetime(2014,4,4,h0) edtime = datetime(2014,4,4 + offset,h1%24) gpmJP = gpm(varName, sdtime, edtime, BBox, 0.2 ) if hasattr( gpmJP, 'griddata'): for d in gpmJP.griddata: print d.shape, d.max(), d.min(), np.ma.masked_less_equal(d,0).sum() sys.exit() A = np.ma.masked_less_equal( np.array( JP.griddata ), 0 ) M = Basemap( resolution='c' ,llcrnrlat=BBox[0][0], llcrnrlon=BBox[0][1], urcrnrlat=BBox[1][0], urcrnrlon=BBox[1][1]) pl.figure();M.imshow( A.mean(0) );pl.colorbar() #figure();M.scatter(JP.lon.flatten(), JP.lat.flatten(), 10, JP.data.flatten(), edgecolor='none',vmin=0,vmax=10);colorbar() M.drawcoastlines() pl.show() sys.exit() gpmJP = gpm('NS/SLV/precipRateESurface', sDTime, eDTime, BBox, res, delT ) A = array( gpmJP.griddata ) ''' # for no delT Lon = gpmJP.lon Lat = gpmJP.lat Data = gpmJP.data M.scatter(Lon.flatten(), Lat.flatten(), 10, Data.flatten(), edgecolor='none',vmin=0,vmax=10);colorbar() M.drawcoastlines() ''' # for with delT Lon = gpmJP.lon Lat = gpmJP.lat Data = gpmJP.data for lat, lon, data in zip(Lat, Lon, Data): figure() M.scatter(lon.flatten(), lat.flatten(), 10, data.flatten(), edgecolor='none',vmin=0,vmax=10);colorbar() M.drawcoastlines() show() print A.shape, A.max(), A.min() for a in A: print a.shape, a.max(), a.min() print gpmJP.data.min(), gpmJP.data.max() for a in gpmJP.griddata: print a.shape figure() M.imshow( ma.masked_equal(array(a), -9999.9),vmin=0,vmax=10);colorbar() M.drawcoastlines() figure() M.imshow( ma.masked_equal(A, -9999.9).sum(0),vmin=0,vmax=10);colorbar() M.drawcoastlines() show() ''' Path = gpm.get_path(sDTime, eDTime) for i in range(5): s=time.time() DTime, Lat, Lon = gpm.get_gtrack(Path[i]) print time.time()-s ''' return