def test_max_gust(self): # I1004 test ttpl = (1,2) gtpl = (4,8) lat = 38.801857 lon = -122.817551 tm = weather_utils.TimeUtils('201609251734') mg = weather_utils.get_max_gust(lat,lon,tm,ttpl,gtpl,self.mydb) self.assertEqual(mg[0][1][0],'HWKC1') self.assertEqual(mg[1][1][4]/mg[0][1][4],2) # Should be double in tm window
+ srow].value lon = sht_wind[ weather_config.config[program_args.utility]['XL_LONG_COLUMN'] + srow].value logging.debug("time, lat, lon = " + str(zigtime.datetime) + " " + str(lat) + " " + str(lon)) # Get list of max wind data based on time and space windows # Output is m x n list of [station_id,time,distance,maximum gust,count] ttpl = (ttpl, ) if isinstance(ttpl, int) else ttpl gtpl = (gtpl, ) if isinstance(gtpl, int) else gtpl try: max_gusts = weather_utils.get_max_gust(lat, lon, zigtime, ttpl, gtpl, igndb) except: logging.warning("Exiting on error. Saving workbook " + xl_data) wbk.save(xl_data) raise first_wg_cell = int( weather_config.config[program_args.utility]['FREE_CELL']) # Clear wind gust cells nmgcells = len(gtpl) * len(ttpl) * 5 for ic in range(nmgcells): sht_wind.cell(row=jrow, column=first_wg_cell + ic).value = None # Write output to cells
tmlocal = pytz.timezone("America/Los_Angeles").localize(tmpydt) tmutc = tmlocal.astimezone(pytz.utc) tmmid = tmutc - timedelta(hours=ttpl[-1]) zmidtime = weather_utils.TimeUtils(tmmid) lat = sht_wind[weather_config.config[program_args.utility]['XL_LAT_COLUMN'] + srow].value lon = sht_wind[ weather_config.config[program_args.utility]['XL_LONG_COLUMN'] + srow].value # Get list of max wind data based on time and space windows # Output is m x n list of [station_id,time,distance,maximum gust,count] try: max_gusts = weather_utils.get_max_gust(lat, lon, zmidtime, ttpl, gtpl, weatherdb) except: logging.warning("Exiting on error. Saving workbook " + xl_data) wbk.save(xl_data) raise # Write output to cells icell = int(weather_config.config[program_args.utility]['FREE_CELL']) for it in max_gusts: for ig in it: for val in ig: # sht_wind[irow][icell].value = val sht_wind.cell(row=irow, column=icell, value=val) icell += 1