Exemplo n.º 1
0
    def test_catchment_by_number(self):
        expected = loaders.from_file('floodestimation/tests/data/17002.CD3')
        self.db_session.add(expected)

        result = CatchmentCollections(
            self.db_session).catchment_by_number(17002)
        self.assertIs(expected, result)
    def test_vector_b_two_donors(self):
        analysis = QmedAnalysis(self.catchment, CatchmentCollections(self.db_session), year=2000)
        donors = analysis.find_donor_catchments()[0:2]  # 17001, 10001

        # [0.352256808, 0.002198921] * 0.1175 = [0.041390175, 0.000258373]
        result = analysis._vec_b(donors)
        assert_almost_equal(result, [0.041390175, 0.000258373])
    def test_matrix_sigma_eta_two_donors(self):
        analysis = QmedAnalysis(self.catchment, CatchmentCollections(self.db_session), year=2000)
        donors = analysis.find_donor_catchments()[0:2]  # 17001, 10001

        result = analysis._matrix_sigma_eta(donors)
        # 0.1175 * 0.001908936 = 0.00022430
        assert_almost_equal(result, [[0.1175, 0.00022430],
                                     [0.00022430, 0.1175]])
Exemplo n.º 4
0
 def test_nearest_catchments(self):
     subject_catchment = loaders.from_file(
         'floodestimation/tests/data/17002.CD3')
     catchments = CatchmentCollections(
         self.db_session).nearest_qmed_catchments(subject_catchment)
     result = [catchment.id for catchment in catchments]
     expected = [17001, 10001, 10002]
     self.assertEqual(expected, result)
 def test_most_similar_catchments(self):
     subject_catchment = loaders.from_file('floodestimation/tests/data/17002.CD3')
     # Dummy similarity distance function
     function = lambda c1, c2: abs(c2.descriptors.altbar - c1.descriptors.altbar)
     catchments = CatchmentCollections(self.db_session).most_similar_catchments(subject_catchment, function)
     result = [c.id for c in catchments]
     expected = [10001, 10002]
     self.assertEqual(expected, result)
 def test_most_similar_catchments_excl_rejected_amax(self):
     subject_catchment = loaders.from_file('floodestimation/tests/data/17002.CD3')
     # Dummy similarity distance function
     function = lambda c1, c2: abs(c2.descriptors.bfihost - c1.descriptors.bfihost)
     catchments = CatchmentCollections(self.db_session).most_similar_catchments(subject_catchment, function,
                                                                                records_limit=36)
     result = [c.id for c in catchments]
     expected = [10002, 10001]
     self.assertEqual(expected, result)
    def test_model_error_corr_between_two_donors(self):
        analysis = QmedAnalysis(self.catchment, CatchmentCollections(self.db_session), year=2000)
        donors = analysis.find_donor_catchments()[0:2]  # 17001, 10001

        dist = donors[0].distance_to(donors[1])
        self.assertAlmostEqual(dist, 188.8487072)  # not verified

        result = analysis._model_error_corr(donors[0], donors[1])
        self.assertAlmostEqual(result, 0.001908936)
    def test_qmed_two_donors(self):
        analysis = QmedAnalysis(self.catchment, CatchmentCollections(self.db_session), year=2000)
        donors = analysis.find_donor_catchments()[0:2]  # 17001, 10001

        result = analysis.qmed(method='descriptors', donor_catchments=donors)

        # exp(ln(0.61732109) + 0.34379622 * 0.55963062 + 0.00102012 * 0.02991561) =
        # exp(ln(0.61732109) + 0.192429411) = 0.748311028
        self.assertAlmostEqual(result, 0.748311028, places=5)
    def test_l_cv_and_skew(self):
        gauged_catchments = CatchmentCollections(self.db_session)
        catchment = from_file('floodestimation/tests/data/37017.CD3')

        analysis = GrowthCurveAnalysis(catchment, gauged_catchments)
        var, skew = analysis._var_and_skew(catchment)

        self.assertAlmostEqual(var, 0.2232, places=4)
        self.assertAlmostEqual(skew, -0.0908, places=4)
Exemplo n.º 10
0
    def test_lnqmed_residuals_two_donors(self):
        analysis = QmedAnalysis(self.catchment, CatchmentCollections(self.db_session), year=2000)
        donors = analysis.find_donor_catchments()[0:2]  # 17001, 10001

        qmed_amax = [QmedAnalysis(d).qmed() for d in donors]
        qmed_descr =[QmedAnalysis(d, year=2000).qmed(method='descriptors') for d in donors]
        assert_almost_equal(qmed_amax, [90.532, 50.18])  # not verified
        assert_almost_equal(qmed_descr, [51.73180402, 48.70106637])  # not verified

        result = [analysis._lnqmed_residual(d) for d in donors]
        assert_almost_equal(result, [0.55963062, 0.02991561])
Exemplo n.º 11
0
 def test_incl_subject_catchment(self):
     # Subject catchment not in db
     subject_catchment = loaders.from_file('floodestimation/tests/data/37017.CD3')
     # Dummy similarity distance function
     function = lambda c1, c2: abs(c2.descriptors.altbar - c1.descriptors.altbar)
     catchments = CatchmentCollections(self.db_session).most_similar_catchments(subject_catchment, function,
                                                                                include_subject_catchment='force')
     result = [c.id for c in catchments]
     expected = [37017, 10002, 10001]
     self.assertEqual(expected, result)
     self.assertEqual(catchments[0].similarity_dist, 0)
    def test_similarity_distance_incomplete_descriptors(self):
        other_catchment = Catchment(location="Burn A", watercourse="Village B")
        other_catchment.id = 999
        other_catchment.is_suitable_for_pooling = True
        self.db_session.add(other_catchment)

        gauged_catchments = CatchmentCollections(self.db_session)
        analysis = GrowthCurveAnalysis(self.catchment, gauged_catchments)
        self.assertEqual(
            float('inf'),
            analysis._similarity_distance(self.catchment, other_catchment))
Exemplo n.º 13
0
 def test_invalid_subj_catchment_option(self):
     subject_catchment = loaders.from_file(
         'floodestimation/tests/data/17002.CD3')
     # Dummy similarity distance function
     function = lambda c1, c2: abs(c2.descriptors.altbar - c1.descriptors.
                                   altbar)
     self.assertRaises(ValueError,
                       CatchmentCollections(
                           self.db_session).most_similar_catchments,
                       subject_catchment,
                       function,
                       include_subject_catchment='invalid')
    def test_find_donors_exclude_urban(self):
        other_catchment = Catchment(location="Burn A", watercourse="Village B")
        other_catchment.id = 999
        other_catchment.is_suitable_for_pooling = True
        other_catchment.descriptors = Descriptors(urbext2000=0.031)
        self.db_session.add(other_catchment)

        gauged_catchments = CatchmentCollections(self.db_session)
        analysis = GrowthCurveAnalysis(self.catchment, gauged_catchments)
        analysis.find_donor_catchments()
        donor_ids = [d.id for d in analysis.donor_catchments]
        self.assertEqual([10002, 10001], donor_ids)
Exemplo n.º 15
0
 def test_incl_subject_catchment_updated(self):
     # Subject catchment in db
     subject_catchment = loaders.from_file('floodestimation/tests/data/201002.CD3')
     subject_catchment.location = "Updated location name"
     # Dummy similarity distance function
     function = lambda c1, c2: abs(c2.descriptors.altbar - c1.descriptors.altbar)
     catchments = CatchmentCollections(self.db_session).most_similar_catchments(subject_catchment, function,
                                                                                include_subject_catchment='force')
     result = [c.id for c in catchments]
     expected = [201002, 10001, 10002]
     self.assertEqual(expected, result)
     self.assertEqual(catchments[0].location, "Updated location name")
Exemplo n.º 16
0
    def test_matrix_sigma_eps_two_donors(self):
        analysis = QmedAnalysis(self.catchment, CatchmentCollections(self.db_session), year=2000)
        donors = analysis.find_donor_catchments()[0:2]  # 17001, 10001

        record0 = [donors[0].amax_records_start(), donors[0].amax_records_end()]
        record1 = [donors[1].amax_records_start(), donors[1].amax_records_end()]
        self.assertEqual(record0, [1969, 2005])  # n=37
        self.assertEqual(record1, [1939, 1984])  # n=46, 16 years overlapping

        result = analysis._matrix_sigma_eps(donors)
        # 4 * 0.16351290**2 / 37 = 0.00289043
        # 4 * 0.16351290 * 0.20423656 * 16 / 37 / 46 * 0.133632774 = 0.00016781
        # 4 * 0.20423656**2 / 46 = 0.00362718
        assert_almost_equal(result, [[0.00289043, 0.00016781],
                                     [0.00016781, 0.00362718]])
Exemplo n.º 17
0
    def test_beta_two_donors(self):
        analysis = QmedAnalysis(self.catchment, CatchmentCollections(self.db_session), year=2000)
        donors = analysis.find_donor_catchments()[0:2]  # 17001, 10001

        result = [analysis._beta(d) for d in donors]
        assert_almost_equal(result, [0.16351290, 0.20423656])
 def test_single_site_gev(self):
     gauged_catchments = CatchmentCollections(self.db_session)
     catchment = from_file('floodestimation/tests/data/37017.CD3')
     analysis = GrowthCurveAnalysis(catchment, gauged_catchments)
     dist_func = analysis.growth_curve(method='single_site', distr='gev')
     self.assertAlmostEqual(dist_func(0.5), 1)
Exemplo n.º 19
0
 def test_catchment_by_number_not_exist(self):
     result = CatchmentCollections(
         self.db_session, load_data='manual').catchment_by_number(99)
     self.assertIsNone(result)
Exemplo n.º 20
0
 def __init__(self):
     self.name = None
     self.catchment = Catchment("River Town", "River Burn")
     self.db_session = db.Session()
     self.gauged_catchments = CatchmentCollections(self.db_session)
     self.qmed = None
Exemplo n.º 21
0
    def test_distance_two_donors(self):
        analysis = QmedAnalysis(self.catchment, CatchmentCollections(self.db_session), year=2000)
        donors = analysis.find_donor_catchments()[0:2]  # 17001, 10001

        result = [d.distance_to(self.catchment) for d in donors]
        assert_almost_equal(result, [5, 183.8515], decimal=4)
Exemplo n.º 22
0
 def test_vector_alpha_two_donors(self):
     analysis = QmedAnalysis(self.catchment, CatchmentCollections(self.db_session), year=2000)
     donors = analysis.find_donor_catchments()[0:2]  # 17001, 10001
     result = analysis._vec_alpha(donors)
     assert_almost_equal(result, [0.34379622, 0.00102012])  # calculated in Excel
Exemplo n.º 23
0
 def test_matrix_omega_two_donors(self):
     analysis = QmedAnalysis(self.catchment, CatchmentCollections(self.db_session), year=2000)
     donors = analysis.find_donor_catchments()[0:2]  # 17001, 10001
     result = analysis._matrix_omega(donors)
     assert_almost_equal(result, [[0.12039043, 0.00039211],
                                  [0.00039211, 0.12112718]])
Exemplo n.º 24
0
    def test_lnqmed_corr(self):
        analysis = QmedAnalysis(self.catchment, CatchmentCollections(self.db_session), year=2000)
        donors = analysis.find_donor_catchments()[0:2]  # 17001, 10001

        results = analysis._lnqmed_corr(donors[0], donors[1])
        self.assertAlmostEqual(results, 0.133632774)
 def test_find_donors(self):
     gauged_catchments = CatchmentCollections(self.db_session)
     analysis = GrowthCurveAnalysis(self.catchment, gauged_catchments)
     analysis.find_donor_catchments()
     donor_ids = [d.id for d in analysis.donor_catchments]
     self.assertEqual([10002, 10001], donor_ids)
def nrfa_qmed_catchments(db_session):
    return db_session.query(Catchment).join(Descriptors).join(Catchment.amax_records). \
        filter(Catchment.is_suitable_for_qmed,
               Descriptors.centroid_ngr != None,
               or_(Descriptors.urbext2000 < 0.03, Descriptors.urbext2000 == None)). \
        group_by(Catchment). \
        having(func.count(AmaxRecord.catchment_id) >= 10). \
        all()


if __name__ == '__main__':
    db_session = db.Session()

    science_report_collections = ScienceReportCollections(db_session)
    feh_catchments_collections = CatchmentCollections(db_session)

    subject_catchments = science_report_collections.all_catchments()
    print("Total number of catchments: {}".format(len(subject_catchments)))

    with open('output.txt', mode='w') as output_file:
        for i, catchment in enumerate(subject_catchments):
            print(i, catchment.id)
            #output = analyse_catchment(catchment, feh_catchments_collections)
            output = analyse_catchment(catchment, science_report_collections)
            output_file.write(
                "{id}, {qmed_amax}, {qmed_descr}, {qmed_descr_idw}, {qmed_descr_first}, {qmed_descr_1999}, {qmed_descr_idw3}\n"
                .format(**output))

    db_session.close()
Exemplo n.º 27
0
    def test_model_error_corr_two_donors(self):
        analysis = QmedAnalysis(self.catchment, CatchmentCollections(self.db_session), year=2000)
        donors = analysis.find_donor_catchments()[0:2]  # 17001, 10001

        result = [analysis._model_error_corr(self.catchment, d) for d in donors]
        assert_almost_equal(result, [0.352256808, 0.002198921])
from floodestimation.loaders import load_catchment
from floodestimation import db
from floodestimation.collections import CatchmentCollections
from floodestimation.analysis import QmedAnalysis

db_session = db.Session()

dee_catchment = load_catchment('nith_cds.cd3')
gauged_catchments = CatchmentCollections(db_session)

qmed_analysis = QmedAnalysis(dee_catchment, gauged_catchments)
print(qmed_analysis.qmed())

print(qmed_analysis.methods)

print(qmed_analysis.qmed_all_methods())

print(qmed_analysis.urban_adj_factor())

print(qmed_analysis.find_donor_catchments(5, 200.0))

qmed_analysis.idw_power = 1.5
print(qmed_analysis.idw_power)

donors = qmed_analysis.find_donor_catchments(5, 200.0)

for donor in donors:
    Q = QmedAnalysis(donors[0], gauged_catchments)
    print(donor, qmed_analysis._error_correlation(donor), Q.qmed_all_methods())
db_session.close()
 def _load_data(self):
     self.results['report_date'] = date.today()
     self.results['catchment'] = self.catchment
     self.gauged_catchments = CatchmentCollections(self.db_session,
                                                   load_data='manual')
Exemplo n.º 30
0
    def __init__(self, parent, p):
        wx.Panel.__init__(self, parent)
        self.p = p

        db_session = db.Session()
        self.gauged_catchments = CatchmentCollections(db_session)
        self.qmed_analysis = QmedAnalysis(config.target_catchment,
                                          self.gauged_catchments)
        db_session.close()

        self.qmed_method = 'best'
        self.donor_search_criteria_refreshed = True
        self.suggested_donors = None
        self.adopted_donors = None
        self.keep_rural = False
        config.analysis.catchment.pot_records = None

        self.adoptedQmed = '-'

        self.calc_obs_amax_btn = wx.Button(self, -1, ' AMAX SERIES ')
        self.calc_obs_amax_btn.Bind(wx.EVT_BUTTON, self.amax_area)
        self.calc_obs_pot_btn = wx.Button(self, -1, ' POT SERIES ')
        self.calc_obs_pot_btn.Bind(wx.EVT_BUTTON, self.pot_area)
        self.refresh_calcs_btn = wx.Button(self, -1, ' REFRESH CALCS ')

        self.qmed_notes = wx.TextCtrl(self,
                                      -1,
                                      "Notes on QMED",
                                      size=(350, 150),
                                      style=wx.TE_MULTILINE)

        self.qmed_2008_label = wx.StaticText(self, -1, "QMED CDS 2008")
        self.qmed_1999_label = wx.StaticText(self, -1, "QMED CDS 1999")
        self.qmed_area_label = wx.StaticText(self, -1, "QMED AREA")
        self.qmed_amax_label = wx.StaticText(self, -1, "QMED AMAX")
        self.qmed_pot_label = wx.StaticText(self, -1, "QMED POT")
        self.qmed_width_label = wx.StaticText(self, -1, "QMED Channel width")
        self.user_qmed_label = wx.StaticText(self, -1, "User QMED")
        self.selected_unadj_qmed_label = wx.StaticText(self, -1,
                                                       "Selected rural QMED")
        self.station_search_distance_label = wx.StaticText(
            self, -1, "Station search distance")
        self.station_search_limit_label = wx.StaticText(
            self, -1, "Station search limit")
        self.idw_label = wx.StaticText(self, -1, "IDW")
        self.selected_unadj_qmed = wx.TextCtrl(self,
                                               -1,
                                               "-",
                                               style=wx.TE_READONLY)

        self.qmed_cds2008 = wx.TextCtrl(self, -1, "-", style=wx.TE_READONLY)
        self.qmed_cds1999 = wx.TextCtrl(self, -1, "-", style=wx.TE_READONLY)
        self.qmed_areaOnly = wx.TextCtrl(self, -1, "-", style=wx.TE_READONLY)
        self.qmed_obs_amax = wx.TextCtrl(self, -1, "-", style=wx.TE_READONLY)
        self.qmed_obs_pot = wx.TextCtrl(self, -1, "-", style=wx.TE_READONLY)
        self.qmed_geom = wx.TextCtrl(self, -1, "-", style=wx.TE_READONLY)
        self.qmed_user = wx.TextCtrl(self, -1, "-")

        self.rb1 = wx.RadioButton(self, -1, '', style=wx.RB_GROUP)
        self.rb2 = wx.RadioButton(self, -1, '')
        self.rb3 = wx.RadioButton(self, -1, '')
        self.rb4 = wx.RadioButton(self, -1, '')
        self.rb5 = wx.RadioButton(self, -1, '')
        self.rb6 = wx.RadioButton(self, -1, '')
        self.rb7 = wx.RadioButton(self, -1, '')

        self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb1.GetId())
        self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb2.GetId())
        self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb3.GetId())
        self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb4.GetId())
        self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb5.GetId())
        self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb6.GetId())
        self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb7.GetId())

        self.station_search_distance = wx.TextCtrl(self, -1, "500.0")
        self.station_limit = wx.TextCtrl(self, -1, "5")
        self.idw_weight = wx.TextCtrl(self, -1, "3")

        self.station_search_distance.Bind(wx.EVT_TEXT,
                                          self.UpdateDonorCriteria)
        self.station_limit.Bind(wx.EVT_TEXT, self.UpdateDonorCriteria)

        #self.calcQMeds()

        self.distance_decay_update = wx.RadioButton(self,
                                                    -1,
                                                    "Decaying with distance",
                                                    style=wx.RB_GROUP)
        self.direct_transfer_update = wx.RadioButton(self, -1,
                                                     'Equal weighting')
        self.dont_update = wx.RadioButton(self, -1, "Don't update")

        #self.Bind(wx.EVT_RADIOBUTTON, self.SetUpdate, id=self.dont_update.GetId())
        #self.Bind(wx.EVT_RADIOBUTTON, self.SetUpdate, id=self.distance_decay_update.GetId())
        #self.Bind(wx.EVT_RADIOBUTTON, self.SetUpdate, id=self.direct_transfer_update.GetId())

        self.local_qmed_adjustment_label = wx.StaticText(
            self, -1, "Local QMED adjustment")
        self.locally_adjusted_qmed_label = wx.StaticText(
            self, -1, "Locally adjusted QMED")
        self.locally_adjusted_qmed = wx.TextCtrl(self,
                                                 -1,
                                                 "-",
                                                 style=wx.TE_READONLY)
        self.local_qmed_adjustment = wx.TextCtrl(self,
                                                 -1,
                                                 "-",
                                                 style=wx.TE_READONLY)

        self.update_for_urb_chk = wx.CheckBox(self, -1,
                                              'Update for urbanisation')
        self.update_for_urb_chk.Bind(wx.EVT_CHECKBOX,
                                     self.SetUrbanChk,
                                     id=self.update_for_urb_chk.GetId())

        self.urban_expansion_factor_label = wx.StaticText(
            self, -1, "Urban expansion factor")
        self.adjusted_urbext_label = wx.StaticText(self, -1, "Adjusted URBEXT")
        self.urban_adjustment_factor_label = wx.StaticText(
            self, -1, "Urban adjustment factor")

        self.urban_expansion_factor = wx.TextCtrl(self,
                                                  -1,
                                                  "-",
                                                  style=wx.TE_READONLY)
        self.adjusted_urbext = wx.TextCtrl(self, -1, "-", style=wx.TE_READONLY)
        self.urban_adjustment_factor = wx.TextCtrl(self,
                                                   -1,
                                                   "-",
                                                   style=wx.TE_READONLY)

        self.adopted_qmed_label = wx.StaticText(self, -1, "Adopted QMED")
        self.adopted_qmed = wx.TextCtrl(self, -1, "-", style=wx.TE_READONLY)

        sizer = wx.GridBagSizer(vgap=5, hgap=10)
        sizer.Add(self.calc_obs_amax_btn, pos=(7, 3))
        sizer.Add(self.calc_obs_pot_btn, pos=(7, 4))

        sizer.Add(self.refresh_calcs_btn, pos=(0, 3))
        sizer.Add(self.qmed_notes, pos=(1, 3), span=(5, 3))

        sizer.Add(self.qmed_2008_label, pos=(0, 0))
        sizer.Add(self.qmed_1999_label, pos=(1, 0))
        sizer.Add(self.qmed_area_label, pos=(2, 0))
        sizer.Add(self.qmed_amax_label, pos=(3, 0))
        sizer.Add(self.qmed_pot_label, pos=(4, 0))
        sizer.Add(self.qmed_width_label, pos=(5, 0))
        sizer.Add(self.user_qmed_label, pos=(6, 0))
        sizer.Add(self.selected_unadj_qmed_label, pos=(7, 0))

        sizer.Add(self.qmed_cds2008, pos=(0, 1))
        sizer.Add(self.qmed_cds1999, pos=(1, 1))
        sizer.Add(self.qmed_areaOnly, pos=(2, 1))
        sizer.Add(self.qmed_obs_amax, pos=(3, 1))
        sizer.Add(self.qmed_obs_pot, pos=(4, 1))
        sizer.Add(self.qmed_geom, pos=(5, 1))
        sizer.Add(self.qmed_user, pos=(6, 1))
        sizer.Add(self.selected_unadj_qmed, pos=(7, 1))

        sizer.Add(self.rb1, pos=(0, 2))
        sizer.Add(self.rb2, pos=(1, 2))
        sizer.Add(self.rb3, pos=(2, 2))
        sizer.Add(self.rb4, pos=(3, 2))
        sizer.Add(self.rb5, pos=(4, 2))
        sizer.Add(self.rb6, pos=(5, 2))
        sizer.Add(self.rb7, pos=(6, 2))

        self.table = wx.Panel(self, -1)
        self.list = CheckListCtrl(self.table)
        self.list.InsertColumn(0, 'STATION')
        self.list.InsertColumn(1, 'DISTANCE')
        self.list.InsertColumn(2, 'ADJUSTMENT FACTOR')
        self.list.InsertColumn(3, 'ERROR CORRELATION')
        self.list.InsertColumn(4, 'WEIGHT')
        self.list.SetColumnWidth(0, 250)
        self.list.SetColumnWidth(1, 100)
        self.list.SetColumnWidth(2, 100)
        self.list.SetColumnWidth(3, 100)
        self.list.SetColumnWidth(4, 100)

        sizer.Add(self.table, pos=(9, 0), span=(1, 6), flag=wx.EXPAND)
        sizer.Add(self.station_search_distance_label, pos=(10, 0), span=(1, 1))
        sizer.Add(self.station_search_distance, pos=(10, 1), span=(1, 1))
        sizer.Add(self.station_search_limit_label, pos=(10, 2), span=(1, 1))
        sizer.Add(self.station_limit, pos=(10, 3), span=(1, 1))
        sizer.Add(self.idw_label, pos=(10, 4), span=(1, 1))
        sizer.Add(self.idw_weight, pos=(10, 5), span=(1, 1))
        sizer.Add(self.dont_update, pos=(11, 0), span=(1, 2))
        sizer.Add(self.distance_decay_update, pos=(12, 0), span=(1, 2))
        sizer.Add(self.direct_transfer_update, pos=(13, 0), span=(1, 2))

        sizer.Add(self.local_qmed_adjustment_label, pos=(12, 2), span=(1, 1))
        sizer.Add(self.local_qmed_adjustment, pos=(12, 3), span=(1, 1))
        sizer.Add(self.locally_adjusted_qmed_label, pos=(13, 2), span=(1, 1))
        sizer.Add(self.locally_adjusted_qmed, pos=(13, 3), span=(1, 1))

        sizer.Add(self.update_for_urb_chk, pos=(15, 0), span=(1, 1))
        sizer.Add(self.urban_expansion_factor, pos=(16, 1), span=(1, 1))
        sizer.Add(self.adjusted_urbext, pos=(17, 1), span=(1, 1))
        sizer.Add(self.urban_adjustment_factor, pos=(18, 1), span=(1, 1))
        sizer.Add(self.urban_expansion_factor_label, pos=(16, 0), span=(1, 1))
        sizer.Add(self.adjusted_urbext_label, pos=(17, 0), span=(1, 1))
        sizer.Add(self.urban_adjustment_factor_label, pos=(18, 0), span=(1, 1))

        sizer.Add(self.adopted_qmed_label, pos=(18, 4), span=(1, 1))
        sizer.Add(self.adopted_qmed, pos=(18, 5), span=(1, 1))

        #  Assign actions to buttons
        self.refresh_calcs_btn.Bind(wx.EVT_BUTTON, self.onRefresh)

        border = wx.BoxSizer()
        border.Add(sizer, 0, wx.ALL, 20)
        self.SetSizerAndFit(border)
        self.Fit()