Skip to content

Commit

Permalink
pep8 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsebgosselin committed Sep 9, 2017
1 parent 409e50c commit 009c655
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions WHAT/meteo/dwnld_weather_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,17 +845,17 @@ def concatenate(self, fname): # ==========================================
<\tr>
<tr><td colspan="4"><hr><\td><\tr>
''' % (StaName[0], province,
np.min(ALLDATA[:,0]), np.max(ALLDATA[:,0]))
np.min(ALLDATA[:, 0]), np.max(ALLDATA[:, 0]))
for i in range(0, len(FIELDS)):
nonan = sum(np.isnan(ALLDATA[:, i+3]))
LOG += '''
<tr>
<td align="left">%s</td>
<td align="left" width=25></td>
<td align="right">%d</td>
<td align="right">&nbsp;(%d%%)</td>
</tr>
''' % (FIELDS[i], nonan, nonan/ndata*100)
nonan = sum(np.isnan(ALLDATA[:, i+3]))
LOG += '''
<tr>
<td align="left">%s</td>
<td align="left" width=25></td>
<td align="right">%d</td>
<td align="right">&nbsp;(%d%%)</td>
</tr>
''' % (FIELDS[i], nonan, nonan/ndata*100)
LOG += '<tr><td colspan="4"><hr><\td><\tr>'

# ----------------------------------------------- Restructure Data ----
Expand Down Expand Up @@ -939,17 +939,18 @@ def __init__(self, parent=None):

# These values need to be pushed from the parent.

self.dirname = [] # Directory where the downloaded files are saved
self.stationID = [] # Unique identifier for the station used for
# downloading the data from the server
self.climateID = [] # Unique identifier for the station
self.dirname = [] # Directory where the downloaded files are saved
self.stationID = []
# Unique identifier for the station used for downloading the
# data from the server
self.climateID = [] # Unique identifier for the station
self.yr_start = []
self.yr_end = []
self.StaName = [] # Common name given to the station (not unique)
self.StaName = [] # Common name given to the station (not unique)

def run(self):

#----------------------------------------------------------- INIT -----
# ---------------------------------------------------------- INIT -----

staID = self.stationID
yr_start = int(self.yr_start)
Expand All @@ -960,9 +961,9 @@ def run(self):
self.ERRFLAG = np.ones(yr_end - yr_start + 1)

self.ConsoleSignal.emit(
'''<font color=black>Downloading data from </font>
<font color=blue>www.climate.weather.gc.ca</font>
<font color=black> for station %s</font>''' % StaName)
'''<font color=black>Downloading data from </font>
<font color=blue>www.climate.weather.gc.ca</font>
<font color=black> for station %s</font>''' % StaName)
self.ProgBarSignal.emit(0)

StaName = StaName.replace('\\', '_')
Expand All @@ -975,12 +976,14 @@ def run(self):

# Data are downloaded on a yearly basis from yStart to yEnd

fname4merge = [] # list of paths of the yearly raw data files that
# will be pass to contatenate and merge function.
# list of paths of the yearly raw data files that will be pass to
# contatenate and merge function.
fname4merge = []

i = 0
for year in range(yr_start, yr_end+1):

if self.STOP == True : # User stopped the downloading process.
if self.STOP:
# The user stopped the downloading process.
break

# File and URL Paths :
Expand All @@ -995,7 +998,6 @@ def run(self):
# Download Data For That Year :

if path.exists(fname):

# If the file was downloaded in the same year that of the data
# record, data will be downloaded again in case the data series
# was not complete.
Expand All @@ -1019,40 +1021,40 @@ def run(self):

if self.ERRFLAG[i] == 1:
self.ConsoleSignal.emit(
'''<font color=red>There was a problem downloading the data
of station %s for year %d.
</font>''' % (StaName, year))
'''<font color=red>There was a problem downloading the
data of station %s for year %d.
</font>''' % (StaName, year))

elif self.ERRFLAG[i] == 0:

self.ConsoleSignal.emit(
'''<font color=black>Weather data for station %s downloaded
successfully for year %d.</font>''' % (StaName, year))
'''<font color=black>Weather data for station %s
downloaded successfully for year %d.
</font>''' % (StaName, year))
fname4merge.append(fname)

elif self.ERRFLAG[i] == 3:

sleep(0.1)

self.ConsoleSignal.emit(
'''<font color=green>A weather data file already existed for
station %s for year %d. Downloading is skipped.
</font>''' % (StaName, year))
'''<font color=green>A weather data file already existed
for station %s for year %d. Downloading is skipped.
</font>''' % (StaName, year))
fname4merge.append(fname)

i += 1

# ---------------------------------------------------- End of Task ----

if self.STOP == True:

if self.STOP:
self.STOP = False
print("Downloading process for station %s stopped." % StaName)
self.ConsoleSignal.emit('''<font color=red>Downloading process for
station %s stopped.
</font>''' % StaName)
else:
cmt = "All raw data files downloaded sucessfully for "
cmt = "All raw data files downloaded sucessfully for "
cmt += "station %s." % StaName
print(cmt)
self.ConsoleSignal.emit('<font color=black>%s</font>' % cmt)
Expand Down

0 comments on commit 009c655

Please sign in to comment.