Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

PR: Add a year range option to the weather normals viewer #142

Merged
merged 30 commits into from
Jan 15, 2018
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ac72614
:recycle: Renamed WeatherAvgGraph to WeatherViewer
jnsebgosselin Jan 9, 2018
eed2bce
:art: Code style changes
jnsebgosselin Jan 9, 2018
578364f
Added a new RangeSpinBoxes class
jnsebgosselin Jan 9, 2018
5ca22c9
Added a year range widget to the weather viewer
jnsebgosselin Jan 9, 2018
89424e7
:book: Added some docstrings to functions
jnsebgosselin Jan 10, 2018
fd34b4f
:art: Some code style changes
jnsebgosselin Jan 10, 2018
fff15a1
:recycle: Added year range for normals calc
jnsebgosselin Jan 10, 2018
b7914bd
Removed annoying prints
jnsebgosselin Jan 11, 2018
e891eb3
:art: Code style changes
jnsebgosselin Jan 11, 2018
2b3b3df
Improved the RangeSpinBoxes implementation
jnsebgosselin Jan 11, 2018
d7460cb
Update the graph and table when year range change.
jnsebgosselin Jan 11, 2018
dd9141f
:art: More code style changes
jnsebgosselin Jan 11, 2018
cd3cba6
Updated the save normals to file functionality
jnsebgosselin Jan 11, 2018
c29d119
Merge remote-tracking branch 'refs/remotes/origin/master' into add_ye…
jnsebgosselin Jan 11, 2018
3f4994c
:wrench: Clean imports
jnsebgosselin Jan 11, 2018
7f65f89
:art: Some code style changes
jnsebgosselin Jan 11, 2018
ad2fabc
:recycle: Refactoring of how language is handled.
jnsebgosselin Jan 11, 2018
96fb2c4
Added the year range as a label of the x-axis
jnsebgosselin Jan 11, 2018
1907c8a
Tweaked bottom margin and fixed set_lang
jnsebgosselin Jan 11, 2018
2c0cfee
Show buttons by default in the SmartSpinBox
jnsebgosselin Jan 11, 2018
6d73c2a
Added a button in toolbar to expand year range
jnsebgosselin Jan 12, 2018
a17733b
Make table more pretty
jnsebgosselin Jan 12, 2018
e53207c
Updated tooltip and made window non resizable
jnsebgosselin Jan 12, 2018
5fad844
Imports
jnsebgosselin Jan 12, 2018
d78a159
Stretch the columns and rows
jnsebgosselin Jan 12, 2018
baf66c8
Remove the call to resize to contents
jnsebgosselin Jan 12, 2018
f8cd8e1
Make the height of the table not hard coded
jnsebgosselin Jan 12, 2018
ec94d74
:art: Some code style changes
jnsebgosselin Jan 13, 2018
9e8054f
Added 'Period' key to WXDataFrame
jnsebgosselin Jan 13, 2018
08d3da9
:wrench: clean imports
jnsebgosselin Jan 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🎨 Some code style changes
  • Loading branch information
jnsebgosselin committed Jan 13, 2018
commit ec94d74477b19115a9a9c3bef7fbc7c30829f0e2
8 changes: 4 additions & 4 deletions gwhat/meteo/weather_reader.py
Original file line number Diff line number Diff line change
@@ -102,22 +102,22 @@ def __init__(self, filename, *args, **kwargs):
self['Missing Tavg'] = load_weather_log(finfo, 'Mean Temp (deg C)')
self['Missing Ptot'] = load_weather_log(finfo, 'Total Precip (mm)')

# ---- format data

print('Make daily time series continuous.')
# ---- Format Data

time = copy(self['Time'])
date = [copy(self['Year']), copy(self['Month']), copy(self['Day'])]
vbrs = ['Tmax', 'Tavg', 'Tmin', 'Ptot', 'Rain', 'PET']
data = [self[x] for x in vbrs]

# Make daily time series continuous :

time, date, data = make_timeserie_continuous(self['Time'], date, data)
self['Time'] = time
self['Year'], self['Month'], self['Day'] = date[0], date[1], date[2]
for i, vbr in enumerate(vbrs):
self[vbr] = data[i]

print('Fill missing with estimated values.')
# Fill missing with estimated values :

for vbr in ['Tmax', 'Tavg', 'Tmin', 'PET']:
self[vbr] = fill_nan(self['Time'], self[vbr], vbr, 'interp')
11 changes: 6 additions & 5 deletions gwhat/meteo/weather_viewer.py
Original file line number Diff line number Diff line change
@@ -878,7 +878,7 @@ def initUI(self):

def populate_table(self, NORMALS):

# ---- Air Temperature ----
# ---- Air Temperature

for row, key in enumerate(['Tmax', 'Tmin', 'Tavg']):
# Months
@@ -895,7 +895,7 @@ def populate_table(self, NORMALS):
item.setTextAlignment(Qt.AlignCenter)
self.setItem(row, 12, item)

# ---- Rain ----
# ---- Rain

row = 3
# Months
@@ -912,7 +912,7 @@ def populate_table(self, NORMALS):
item.setTextAlignment(Qt.AlignCenter)
self.setItem(row, 12, item)

# ---- Snow ----
# ---- Snow

row = 4
# Months
@@ -930,7 +930,7 @@ def populate_table(self, NORMALS):
item.setTextAlignment(Qt.AlignCenter)
self.setItem(row, 12, item)

# ---- Total Precip ----
# ---- Total Precip

row = 5
# Months
@@ -946,9 +946,10 @@ def populate_table(self, NORMALS):
item.setTextAlignment(Qt.AlignCenter)
self.setItem(row, 12, item)

# ---- ETP ----
# ---- ETP

row = 6
# Months
for col in range(12):
item = QTableWidgetItem('%0.1f' % NORMALS['PET'][col])
item.setFlags(item.flags() & ~Qt.ItemIsEditable)
26 changes: 13 additions & 13 deletions gwhat/projet/reader_projet.py
Original file line number Diff line number Diff line change
@@ -106,10 +106,11 @@ def convert_projet_format(self, filename):
def close_projet(self):
try:
self.db.close()
except:
pass # projet is None or already closed
except AttributeError:
# projet is None or already closed.
pass

# =========================================================================
# ---- Project Properties

@property
def name(self):
@@ -169,7 +170,7 @@ def lon(self):
def lon(self, x):
self.db.attrs['longitude'] = x

# ======================================================== water level ====
# ---- Water Levels Dataset Handlers

@property
def wldsets(self):
@@ -232,7 +233,7 @@ def add_wldset(self, name, df):
self.db.flush()

print('New dataset created sucessfully')
except:
except Exception:
print('Unable to save dataset to project db')
del self.db['wldsets'][name]

@@ -241,7 +242,7 @@ def add_wldset(self, name, df):
def del_wldset(self, name):
del self.db['wldsets/%s' % name]

# =========================================================== weather =====
# ---- Weather Dataset Handlers

@property
def wxdsets(self):
@@ -474,12 +475,11 @@ def get_layout(self):
return layout


# :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


class WXDataFrameHDF5(dict):
# This is a wrapper around the h5py group that is used to mimick the
# structure of WXDataFrame in meteo_utils.
"""
This is a wrapper around the h5py group that is used to mimick the
structure of WXDataFrame in gwhat.meteo.weather_reader.
"""
def __init__(self, dset, *args, **kwargs):
super(WXDataFrameHDF5, self).__init__(*args, **kwargs)
self.dset = dset
@@ -508,6 +508,6 @@ def name(self):


if __name__ == '__main__':
f = 'C:/Users/jnsebgosselin/Desktop/testé/testé.what'
f = 'C:/Users/jsgosselin/OneDrive/WHAT/WHAT/tests/Example.what'
f = ("C:/Users/jsgosselin/GWHAT/"
"gwhat/tests/@ new-prô'jèt!/@ new-prô'jèt!.gwt")
pr = ProjetReader(f)